/** * Creates a new {@link ValuesListView} for this matrix. */ public ValuesListView() { super(); this.rowCount = getNumRows(); this.columnCount = getNumColumns(); this.size = this.rowCount * this.columnCount; }
@Override public boolean isSquare() { return this.getNumRows() == this.getNumColumns(); }
/** * Creates a new {@link ValuesListView} for this matrix. */ public ValuesListView() { super(); this.rowCount = getNumRows(); this.columnCount = getNumColumns(); this.size = this.rowCount * this.columnCount; }
@Override public boolean isSquare() { return this.getNumRows() == this.getNumColumns(); }
@Override public boolean isSquare() { return this.getNumRows() == this.getNumColumns(); }
/** * Creates a new {@link ValuesListView} for this matrix. */ public ValuesListView() { super(); this.rowCount = getNumRows(); this.columnCount = getNumColumns(); this.size = this.rowCount * this.columnCount; }
@Override public boolean checkSameDimensions( Matrix otherMatrix ) { return (this.getNumRows() == otherMatrix.getNumRows()) && (this.getNumColumns() == otherMatrix.getNumColumns()); }
@Override public boolean checkSameDimensions( Matrix otherMatrix ) { return (this.getNumRows() == otherMatrix.getNumRows()) && (this.getNumColumns() == otherMatrix.getNumColumns()); }
@Override public boolean checkSameDimensions( Matrix otherMatrix ) { return (this.getNumRows() == otherMatrix.getNumRows()) && (this.getNumColumns() == otherMatrix.getNumColumns()); }
@Override public Vector sumOfRows() { final RingAccumulator<Vector> accumulator = new RingAccumulator<Vector>(); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; i++) { accumulator.accumulate(this.getRow(i)); } return accumulator.getSum(); }
@Override public Vector sumOfRows() { final RingAccumulator<Vector> accumulator = new RingAccumulator<Vector>(); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; i++) { accumulator.accumulate(this.getRow(i)); } return accumulator.getSum(); }
@Override public Vector sumOfRows() { final RingAccumulator<Vector> accumulator = new RingAccumulator<Vector>(); final int numRows = this.getNumRows(); for (int i = 0; i < numRows; i++) { accumulator.accumulate(this.getRow(i)); } return accumulator.getSum(); }
@Override public void assertSameDimensions( Matrix other ) { if (!this.checkSameDimensions(other)) { throw new DimensionalityMismatchException( "Matrices must have same dimensions: " + "(" + this.getNumRows() + "x" + this.getNumColumns() + ") !=" + "(" + other.getNumRows() + "x" + other.getNumColumns() + ")" ); } }
@Override public void assertSameDimensions( Matrix other ) { if (!this.checkSameDimensions(other)) { throw new DimensionalityMismatchException( "Matrices must have same dimensions: " + "(" + this.getNumRows() + "x" + this.getNumColumns() + ") !=" + "(" + other.getNumRows() + "x" + other.getNumColumns() + ")" ); } }
@Override public void assertSameDimensions( Matrix other ) { if (!this.checkSameDimensions(other)) { throw new DimensionalityMismatchException( "Matrices must have same dimensions: " + "(" + this.getNumRows() + "x" + this.getNumColumns() + ") !=" + "(" + other.getNumRows() + "x" + other.getNumColumns() + ")" ); } }
@Override public void assertMultiplicationDimensions( final Matrix postMultiplicationMatrix) { if (!this.checkMultiplicationDimensions(postMultiplicationMatrix)) { throw new DimensionalityMismatchException( "Matrices must have same internal dimensions: " + + this.getNumRows() + "x" + this.getNumColumns() + " != " + + postMultiplicationMatrix.getNumRows() + "x" + postMultiplicationMatrix.getNumColumns()); } }
@Override public void assertMultiplicationDimensions( final Matrix postMultiplicationMatrix) { if (!this.checkMultiplicationDimensions(postMultiplicationMatrix)) { throw new DimensionalityMismatchException( "Matrices must have same internal dimensions: " + + this.getNumRows() + "x" + this.getNumColumns() + " != " + + postMultiplicationMatrix.getNumRows() + "x" + postMultiplicationMatrix.getNumColumns()); } }
@Override public void assertMultiplicationDimensions( final Matrix postMultiplicationMatrix) { if (!this.checkMultiplicationDimensions(postMultiplicationMatrix)) { throw new DimensionalityMismatchException( "Matrices must have same internal dimensions: " + + this.getNumRows() + "x" + this.getNumColumns() + " != " + + postMultiplicationMatrix.getNumRows() + "x" + postMultiplicationMatrix.getNumColumns()); } }
@Override public Vector times( final Vector vector) { vector.assertDimensionalityEquals(this.getNumColumns()); final Vector result = vector.getVectorFactory().createVector( this.getNumRows()); for (final MatrixEntry entry : this) { result.increment(entry.getRowIndex(), entry.getValue() * vector.get(entry.getColumnIndex())); } return result; }
@Override public Vector times( final Vector vector) { vector.assertDimensionalityEquals(this.getNumColumns()); final Vector result = vector.getVectorFactory().createVector( this.getNumRows()); for (final MatrixEntry entry : this) { result.increment(entry.getRowIndex(), entry.getValue() * vector.get(entry.getColumnIndex())); } return result; }