@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]); }
@Override public int getEntryCount() { return this.getNumRows() * this.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 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 int getEntryCount() { return this.getNumRows() * this.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 void scaledPlusEquals( final DiagonalMatrix other, final double scaleFactor) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; ++i) { this.rows[i].values[i] += other.get(i, i) * scaleFactor; } }
@Override public final void plusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; ++i) { this.rows[i].values[i] += other.get(i, i); } }
/** * 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 public final void plusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; ++i) { this.rows[i].values[i] += other.get(i, i); } }
@Override public final void minusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; ++i) { this.rows[i].values[i] -= other.get(i, i); } }
@Override public void scaledPlusEquals( final DiagonalMatrix other, final double scaleFactor) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; ++i) { this.rows[i].values[i] += other.get(i, i) * 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())); }
@Override public final void minusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; ++i) { this.rows[i].values[i] -= other.get(i, i); } }
/** * 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 public final void minusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; ++i) { this.rows[i].values[i] -= other.get(i, i); } }
@Override public final void plusEquals( final DiagonalMatrix other) { this.assertSameDimensions(other); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; ++i) { this.rows[i].values[i] += other.get(i, i); } }
@Override final public Matrix inverse() { if (!isSquare()) { throw new IllegalStateException("Unable to compute inverse of non-" + "square matrix."); } Matrix I = new DiagonalMatrix(getNumRows()); I.identity(); return solve(I); }
@Override final public Matrix inverse() { if (!isSquare()) { throw new IllegalStateException("Unable to compute inverse of non-" + "square matrix."); } Matrix I = new DiagonalMatrix(getNumRows()); I.identity(); return solve(I); }