/** * Creates a deep copy of m into a DenseMatrix and returns it. * * @param m The matrix to copy * @return The DenseMatrix deep copy of m. */ @Override final public DenseMatrix copyMatrix( final Matrix m) { return new DenseMatrix(m); }
/** * Creates a deep copy of m into a DenseMatrix and returns it. * * @param m The matrix to copy * @return The DenseMatrix deep copy of m. */ @Override final public DenseMatrix copyMatrix( final Matrix m) { return new DenseMatrix(m); }
/** * Creates a deep copy of m into a DenseMatrix and returns it. * * @param m The matrix to copy * @return The DenseMatrix deep copy of m. */ @Override final public DenseMatrix copyMatrix( final Matrix m) { return new DenseMatrix(m); }
/** * Creates a new all-zero DenseMatrix of the specified dimensions. * * @param numRows The number of rows desired in the result * @param numColumns The number of columns desired in the result * @return a new all-zero DenseMatrix of the specified dimensions */ @Override final public DenseMatrix createMatrix( final int numRows, final int numColumns) { return new DenseMatrix(numRows, numColumns); }
/** * Creates a new all-zero DenseMatrix of the specified dimensions. * * @param numRows The number of rows desired in the result * @param numColumns The number of columns desired in the result * @return a new all-zero DenseMatrix of the specified dimensions */ @Override final public DenseMatrix createMatrix( final int numRows, final int numColumns) { return new DenseMatrix(numRows, numColumns); }
/** * Creates a new all-zero DenseMatrix of the specified dimensions. * * @param numRows The number of rows desired in the result * @param numColumns The number of columns desired in the result * @return a new all-zero DenseMatrix of the specified dimensions */ @Override final public DenseMatrix createMatrix( final int numRows, final int numColumns) { return new DenseMatrix(numRows, numColumns); }
/** * Initializes Q and R to the correct size (based on A), but leaves them * as zeroes. * * @param A The matrix to be factored into the Q and R stored herein. */ private QR( final DenseMatrix A) { Q = new DenseMatrix(A.getNumRows(), A.getNumRows()); R = new DenseMatrix(A.getNumRows(), A.getNumColumns()); }
/** * Initializes Q and R to the correct size (based on A), but leaves them * as zeroes. * * @param A The matrix to be factored into the Q and R stored herein. */ private QR( final DenseMatrix A) { Q = new DenseMatrix(A.getNumRows(), A.getNumRows()); R = new DenseMatrix(A.getNumRows(), A.getNumColumns()); }
/** * Initializes Q and R to the correct size (based on A), but leaves them * as zeroes. * * @param A The matrix to be factored into the Q and R stored herein. */ private QR( final DenseMatrix A) { Q = new DenseMatrix(A.getNumRows(), A.getNumRows()); R = new DenseMatrix(A.getNumRows(), A.getNumColumns()); }
@Override public final Matrix times( final DenseMatrix other) { this.assertMultiplicationDimensions(other); final DenseVector[] rows = new DenseVector[diagonal.length]; for (int i = 0; i < diagonal.length; ++i) { DenseVector v = other.row(i); rows[i] = (DenseVector) v.scale(diagonal[i]); } return new DenseMatrix(rows); }
@Override public final Matrix times( final DenseMatrix other) { this.assertMultiplicationDimensions(other); final DenseVector[] rows = new DenseVector[diagonal.length]; for (int i = 0; i < diagonal.length; ++i) { DenseVector v = other.row(i); rows[i] = (DenseVector) v.scale(diagonal[i]); } return new DenseMatrix(rows); }
@Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); final int numRows = this.getNumRows(); final DenseVector[] resultRows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { resultRows[i] = (DenseVector) other.preTimes(this.rows[i]); } return new DenseMatrix(resultRows); }
@Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); final int numRows = this.getNumRows(); final DenseVector[] resultRows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { resultRows[i] = (DenseVector) other.preTimes(this.rows[i]); } return new DenseMatrix(resultRows); }
@Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); final int numRows = this.getNumRows(); final DenseVector[] resultRows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { resultRows[i] = (DenseVector) other.preTimes(this.rows[i]); } return new DenseMatrix(resultRows); }
@Override public final Matrix times( final DenseMatrix other) { this.assertMultiplicationDimensions(other); final DenseVector[] rows = new DenseVector[diagonal.length]; for (int i = 0; i < diagonal.length; ++i) { DenseVector v = other.row(i); rows[i] = (DenseVector) v.scale(diagonal[i]); } return new DenseMatrix(rows); }
/** * Creates the U, Sigma, and V matrices to their correct sizes, but * leaves them as zero matrices. * * @param A The matrix that will be decomposed and so it specifies the * sizes for U, Sigma, and V. */ private SVD( final DenseMatrix A) { U = new DenseMatrix(A.getNumRows(), A.getNumRows()); Sigma = new SparseMatrix(A.getNumRows(), A.getNumColumns()); V = new DenseMatrix(A.getNumColumns(), A.getNumColumns()); }
/** * Creates the U, Sigma, and V matrices to their correct sizes, but * leaves them as zero matrices. * * @param A The matrix that will be decomposed and so it specifies the * sizes for U, Sigma, and V. */ private SVD( final DenseMatrix A) { U = new DenseMatrix(A.getNumRows(), A.getNumRows()); Sigma = new SparseMatrix(A.getNumRows(), A.getNumColumns()); V = new DenseMatrix(A.getNumColumns(), A.getNumColumns()); }
/** * Creates the U, Sigma, and V matrices to their correct sizes, but * leaves them as zero matrices. * * @param A The matrix that will be decomposed and so it specifies the * sizes for U, Sigma, and V. */ private SVD( final DenseMatrix A) { U = new DenseMatrix(A.getNumRows(), A.getNumRows()); Sigma = new SparseMatrix(A.getNumRows(), A.getNumColumns()); V = new DenseMatrix(A.getNumColumns(), A.getNumColumns()); }
@Override final public Matrix transpose() { // It's the transpose of me int m = getNumColumns(); int n = getNumRows(); final DenseVector[] resultRows = new DenseVector[m]; for (int i = 0; i < m; ++i) { DenseVector row = new DenseVector(n); for (int j = 0; j < n; ++j) { row.setElement(j, get(j, i)); } resultRows[i] = row; } return new DenseMatrix(resultRows); }
@Override public final Matrix times( final SparseMatrix other) { this.assertMultiplicationDimensions(other); if (!other.isCompressed()) { other.compress(); } final int numRows = this.getNumRows(); final DenseVector[] resultRows = new DenseVector[numRows]; for (int i = 0; i < numRows; ++i) { resultRows[i] = (DenseVector) other.preTimes(this.rows[i]); } return new DenseMatrix(resultRows); }