@Override public int getEntryCount() { return this.getNumRows() * this.getNumColumns(); }
@Override public int getEntryCount() { return this.getNumRows() * this.getNumColumns(); }
@Override public int getEntryCount() { return this.getNumRows() * this.getNumColumns(); }
@Override public final void scaleEquals( final double scaleFactor) { final int numRows = this.getNumRows(); final int numColumns = this.getNumColumns(); for (int i = 0; i < numRows; ++i) { for (int j = 0; j < numColumns; ++j) { this.rows[i].values[j] *= scaleFactor; } } }
@Override public final void scaleEquals( final double scaleFactor) { final int numRows = this.getNumRows(); final int numColumns = this.getNumColumns(); for (int i = 0; i < numRows; ++i) { for (int j = 0; j < numColumns; ++j) { this.rows[i].values[j] *= scaleFactor; } } }
/** * Returns the percentage of this that is non-zero elements * * @return the percentage of this that is non-zero elements */ final public double getNonZeroPercent() { return ((double) getNonZeroCount()) / ((double) (getNumRows() * getNumColumns())); }
/** * Returns the percentage of this that is non-zero elements * * @return the percentage of this that is non-zero elements */ final public double getNonZeroPercent() { return ((double) getNonZeroCount()) / ((double) (getNumRows() * getNumColumns())); }
/** * Returns the percentage of this that is non-zero elements * * @return the percentage of this that is non-zero elements */ final public double getNonZeroPercent() { return ((double) getNonZeroCount()) / ((double) (getNumRows() * getNumColumns())); }
@Override final public Vector getRow( final int rowIndex) { if (rowIndex < 0 || rowIndex >= getNumRows()) { throw new ArrayIndexOutOfBoundsException("Input row index (" + rowIndex + ") is not within this " + getNumRows() + "x" + getNumColumns() + " matrix"); } return new DenseVector(rows[rowIndex]); }
@Override public final void plusEquals( final DenseMatrix other) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); final int numColumns = this.getNumColumns(); for (int i = 0; i < numRows; ++i) { for (int j = 0; j < numColumns; ++j) { this.rows[i].values[j] += other.rows[i].values[j]; } } }
@Override public final void plusEquals( final DenseMatrix other) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); final int numColumns = this.getNumColumns(); for (int i = 0; i < numRows; ++i) { for (int j = 0; j < numColumns; ++j) { this.rows[i].values[j] += other.rows[i].values[j]; } } }
/** * 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 Vector getRow( final int rowIndex) { if (rowIndex < 0 || rowIndex >= getNumRows()) { throw new ArrayIndexOutOfBoundsException("Input row index (" + rowIndex + ") is not within this " + getNumRows() + "x" + getNumColumns() + " matrix"); } return new DenseVector(rows[rowIndex]); }
@Override final public Vector getRow( final int rowIndex) { if (rowIndex < 0 || rowIndex >= getNumRows()) { throw new ArrayIndexOutOfBoundsException("Input row index (" + rowIndex + ") is not within this " + getNumRows() + "x" + getNumColumns() + " matrix"); } return new DenseVector(rows[rowIndex]); }
/** * 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 final public Vector solve( final Vector b) { checkSolveDimensions(b); if (!isSquare()) { throw new IllegalStateException("Solve only works on square " + "matrices (this is " + getNumRows() + " x " + getNumColumns()); } QR qr = qrDecompose(); return upperTriangularSolve(qr.R, qr.Q.transpose().times(b)); }
@Override final public Vector solve( final Vector b) { checkSolveDimensions(b); if (!isSquare()) { throw new IllegalStateException("Solve only works on square " + "matrices (this is " + getNumRows() + " x " + getNumColumns()); } QR qr = qrDecompose(); return upperTriangularSolve(qr.R, qr.Q.transpose().times(b)); }
@Override final public Vector solve( final Vector b) { checkSolveDimensions(b); if (!isSquare()) { throw new IllegalStateException("Solve only works on square " + "matrices (this is " + getNumRows() + " x " + getNumColumns()); } QR qr = qrDecompose(); return upperTriangularSolve(qr.R, qr.Q.transpose().times(b)); }