/** * Creates a matrix of default val in all cells of the specified dimensions * * @param numRows The number of rows in the matrix * @param numCols The number of columns in the matrix * @param defaultVal The value to set all elements to */ public DenseMatrix( final int numRows, final int numCols, final double defaultVal) { super(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(numCols, defaultVal); } initBlas(); }
/** * Creates a zero matrix of the specified dimensions * * @param numRows The number of rows in the matrix * @param numCols The number of columns in the matrix */ public DenseMatrix( final int numRows, final int numCols) { super(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(numCols); } initBlas(); }
/** * Creates a zero matrix of the specified dimensions * * @param numRows The number of rows in the matrix * @param numCols The number of columns in the matrix */ public DenseMatrix( final int numRows, final int numCols) { super(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(numCols); } initBlas(); }
/** * Creates a zero matrix of the specified dimensions * * @param numRows The number of rows in the matrix * @param numCols The number of columns in the matrix */ public DenseMatrix( final int numRows, final int numCols) { super(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(numCols); } initBlas(); }
/** * Creates a matrix of default val in all cells of the specified dimensions * * @param numRows The number of rows in the matrix * @param numCols The number of columns in the matrix * @param defaultVal The value to set all elements to */ public DenseMatrix( final int numRows, final int numCols, final double defaultVal) { super(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(numCols, defaultVal); } initBlas(); }
/** * Creates a matrix of default val in all cells of the specified dimensions * * @param numRows The number of rows in the matrix * @param numCols The number of columns in the matrix * @param defaultVal The value to set all elements to */ public DenseMatrix( final int numRows, final int numCols, final double defaultVal) { super(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(numCols, defaultVal); } initBlas(); }
/** * Constructor for creating a dense matrix from a 2-d double List. Copies * the values from arr. Input is treated as row-major. While it would be * possible to pass in a different length list for each row, that would be * bad form. The length of the first row is assumed as the number of columns * desired. * * @param values The 2-d double array that specifies the dimensions and values * to be stored in the matrix. */ public DenseMatrix( final List<List<Double>> values) { int numRows = values.size(); int numCols = (numRows == 0) ? 0 : values.get(0).size(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { final DenseVector v = new DenseVector(numCols); final List<Double> list = values.get(i); for (int j = 0; j < numCols; ++j) { v.values[j] = list.get(j); } this.rows[i] = v; } initBlas(); }
/** * Constructor for creating a dense matrix from a 2-d double array. Copies * the values from arr. Input is treated as row-major. While it would be * possible to pass in a different length list for each row, that would be * bad form. The length of the first row is assumed as the number of columns * desired. * * @param values The 2-d double array that specifies the dimensions and values * to be stored in the new matrix. */ public DenseMatrix( final double[][] values) { int numRows = values.length; int numCols = (numRows == 0) ? 0 : values[0].length; this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { final DenseVector v = new DenseVector(numCols); for (int j = 0; j < numCols; ++j) { v.values[j] = values[i][j]; } this.rows[i] = v; } initBlas(); }
/** * Constructor for creating a dense matrix from a 2-d double array. Copies * the values from arr. Input is treated as row-major. While it would be * possible to pass in a different length list for each row, that would be * bad form. The length of the first row is assumed as the number of columns * desired. * * @param values The 2-d double array that specifies the dimensions and values * to be stored in the new matrix. */ public DenseMatrix( final double[][] values) { int numRows = values.length; int numCols = (numRows == 0) ? 0 : values[0].length; this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { final DenseVector v = new DenseVector(numCols); for (int j = 0; j < numCols; ++j) { v.values[j] = values[i][j]; } this.rows[i] = v; } initBlas(); }
/** * Constructor for creating a dense matrix from a 2-d double array. Copies * the values from arr. Input is treated as row-major. While it would be * possible to pass in a different length list for each row, that would be * bad form. The length of the first row is assumed as the number of columns * desired. * * @param values The 2-d double array that specifies the dimensions and values * to be stored in the new matrix. */ public DenseMatrix( final double[][] values) { int numRows = values.length; int numCols = (numRows == 0) ? 0 : values[0].length; this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { final DenseVector v = new DenseVector(numCols); for (int j = 0; j < numCols; ++j) { v.values[j] = values[i][j]; } this.rows[i] = v; } initBlas(); }
/** * Constructor for creating a dense matrix from a 2-d double List. Copies * the values from arr. Input is treated as row-major. While it would be * possible to pass in a different length list for each row, that would be * bad form. The length of the first row is assumed as the number of columns * desired. * * @param values The 2-d double array that specifies the dimensions and values * to be stored in the matrix. */ public DenseMatrix( final List<List<Double>> values) { int numRows = values.size(); int numCols = (numRows == 0) ? 0 : values.get(0).size(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { final DenseVector v = new DenseVector(numCols); final List<Double> list = values.get(i); for (int j = 0; j < numCols; ++j) { v.values[j] = list.get(j); } this.rows[i] = v; } initBlas(); }
/** * Copy constructor that creates a deep copy of the input matrix. Optimized * for copying DenseMatrices. * * @param m The matrix to copy */ public DenseMatrix( final DenseMatrix m) { super(); final int numRows = m.getNumRows(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(m.rows[i]); } initBlas(); }
/** * Copy constructor that creates a deep copy of the input matrix. Optimized * for copying DenseMatrices. * * @param m The matrix to copy */ public DenseMatrix( final DenseMatrix m) { super(); final int numRows = m.getNumRows(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(m.rows[i]); } initBlas(); }
/** * Copy constructor that creates a deep copy of the input matrix. Optimized * for copying DenseMatrices. * * @param m The matrix to copy */ public DenseMatrix( final DenseMatrix m) { super(); final int numRows = m.getNumRows(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; i++) { this.rows[i] = new DenseVector(m.rows[i]); } initBlas(); }
/** * Package private optimized constructor that allows creation of a matrix * from the given rows. * * This is an optimized constructor for within package only. Don't call this * unless you are -super- careful. * * @param rows The array of rows for the matrix. Each row must be the same * length. */ DenseMatrix( final DenseVector[] rows) { super(); final int numRows = rows.length; if (numRows > 0) { final int numColumns = rows[0].getDimensionality(); for (int i = 1; i < numRows; i++) { rows[i].assertDimensionalityEquals(numColumns); } } this.rows = rows; initBlas(); }
/** * Package private optimized constructor that allows creation of a matrix * from the given rows. * * This is an optimized constructor for within package only. Don't call this * unless you are -super- careful. * * @param rows The array of rows for the matrix. Each row must be the same * length. */ DenseMatrix( final DenseVector[] rows) { super(); final int numRows = rows.length; if (numRows > 0) { final int numColumns = rows[0].getDimensionality(); for (int i = 1; i < numRows; i++) { rows[i].assertDimensionalityEquals(numColumns); } } this.rows = rows; initBlas(); }
/** * Package private optimized constructor that allows creation of a matrix * from the given rows. * * This is an optimized constructor for within package only. Don't call this * unless you are -super- careful. * * @param rows The array of rows for the matrix. Each row must be the same * length. */ DenseMatrix( final DenseVector[] rows) { super(); final int numRows = rows.length; if (numRows > 0) { final int numColumns = rows[0].getDimensionality(); for (int i = 1; i < numRows; i++) { rows[i].assertDimensionalityEquals(numColumns); } } this.rows = rows; initBlas(); }
/** * Copy constructor that copies any input Matrix -- creating a deep copy of * the matrix. * * @param m The matrix to copy. */ public DenseMatrix( final Matrix m) { super(); final int numRows = m.getNumRows(); final int numColumns = m.getNumColumns(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { this.rows[i] = new DenseVector(numColumns); for (int j = 0; j < numColumns; ++j) { this.rows[i].values[j] = m.get(i, j); } } initBlas(); }
/** * Copy constructor that copies any input Matrix -- creating a deep copy of * the matrix. * * @param m The matrix to copy. */ public DenseMatrix( final Matrix m) { super(); final int numRows = m.getNumRows(); final int numColumns = m.getNumColumns(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { this.rows[i] = new DenseVector(numColumns); for (int j = 0; j < numColumns; ++j) { this.rows[i].values[j] = m.get(i, j); } } initBlas(); }
/** * Copy constructor that copies any input Matrix -- creating a deep copy of * the matrix. * * @param m The matrix to copy. */ public DenseMatrix( final Matrix m) { super(); final int numRows = m.getNumRows(); final int numColumns = m.getNumColumns(); this.rows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { this.rows[i] = new DenseVector(numColumns); for (int j = 0; j < numColumns; ++j) { this.rows[i].values[j] = m.get(i, j); } } initBlas(); }