/** * Constructs a matrix with a copy of the given values. <tt>values</tt> is * required to have the form <tt>values[row][column]</tt> and have exactly * the same number of columns in every row. Only the values on the main * diagonal, i.e. values[i][i] are used. * <p> * The values are copied. So subsequent changes in <tt>values</tt> are not * reflected in the matrix, and vice-versa. * * @param values * The values to be filled into the new matrix. * @param dindex * index of the diagonal. * @throws IllegalArgumentException * if * * <tt>for any 1 <= row < values.length: values[row].length != values[row-1].length || index < -rows+1 || index > columns - 1</tt> * . */ public DiagonalDoubleMatrix2D(double[][] values, int dindex) { this(values.length, values.length == 0 ? 0 : values[0].length, dindex); assign(values); }
/** * Constructs a matrix with a copy of the given values. <tt>values</tt> is * required to have the form <tt>values[row][column]</tt> and have exactly * the same number of columns in every row. Only the values on the main * diagonal, i.e. values[i][i] are used. * <p> * The values are copied. So subsequent changes in <tt>values</tt> are not * reflected in the matrix, and vice-versa. * * @param values * The values to be filled into the new matrix. * @param dindex * index of the diagonal. * @throws IllegalArgumentException * if * * <tt>for any 1 <= row < values.length: values[row].length != values[row-1].length || index < -rows+1 || index > columns - 1</tt> * . */ public DiagonalDoubleMatrix2D(double[][] values, int dindex) { this(values.length, values.length == 0 ? 0 : values[0].length, dindex); assign(values); }
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. for (int j = dlength; --j >= 0;) { elements[j] *= alpha; } } else { for (int j = dlength; --j >= 0;) { elements[j] = function.apply(elements[j]); } } 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. for (int j = dlength; --j >= 0;) { elements[j] *= alpha; } } else { for (int j = dlength; --j >= 0;) { elements[j] = function.apply(elements[j]); } } return this; }