/** * Returns a new matrix that has the same elements as this matrix, but is in * a dense form. This method creates a new object (not a view), so changes * in the returned matrix are NOT reflected in this matrix. * * @return this matrix in a dense form */ public DenseDoubleMatrix2D getDense() { final DenseDoubleMatrix2D dense = new DenseDoubleMatrix2D(rows, columns); forEachNonZero(new cern.colt.function.tdouble.IntIntDoubleFunction() { public double apply(int i, int j, double value) { dense.setQuick(i, j, getQuick(i, j)); return value; } }); return dense; }
/** * Returns a new matrix that has the same elements as this matrix, but is in * a dense form. This method creates a new object (not a view), so changes * in the returned matrix are NOT reflected in this matrix. * * @return this matrix in a dense form */ public DenseDoubleMatrix2D getDense() { final DenseDoubleMatrix2D dense = new DenseDoubleMatrix2D(rows, columns); forEachNonZero(new cern.colt.function.tdouble.IntIntDoubleFunction() { public double apply(int i, int j, double value) { dense.setQuick(i, j, getQuick(i, j)); return value; } }); return dense; }
public DoubleMatrix2D assign(final cern.colt.function.tdouble.DoubleFunction function) { if (function instanceof cern.jet.math.tdouble.DoubleMult) { // x[i] = mult*x[i] final double alpha = ((cern.jet.math.tdouble.DoubleMult) function).multiplicator; if (alpha == 1) return this; if (alpha == 0) return assign(0); if (alpha != alpha) return assign(alpha); // the funny definition of isNaN(). This should better not happen. final double[] valuesE = dcs.x; int nz = cardinality(); for (int j = 0; j < nz; j++) { valuesE[j] *= alpha; } } else { forEachNonZero(new cern.colt.function.tdouble.IntIntDoubleFunction() { public double apply(int i, int j, double value) { return function.apply(value); } }); } return this; }
public DoubleMatrix2D assign(final cern.colt.function.tdouble.DoubleFunction function) { if (function instanceof cern.jet.math.tdouble.DoubleMult) { // x[i] = mult*x[i] final double alpha = ((cern.jet.math.tdouble.DoubleMult) function).multiplicator; if (alpha == 1) return this; if (alpha == 0) return assign(0); if (alpha != alpha) return assign(alpha); // the funny definition of isNaN(). This should better not happen. final double[] valuesE = dcs.x; int nz = cardinality(); for (int j = 0; j < nz; j++) { valuesE[j] *= alpha; } } else { forEachNonZero(new cern.colt.function.tdouble.IntIntDoubleFunction() { public double apply(int i, int j, double value) { return function.apply(value); } }); } return this; }