@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 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 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; } }
@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; } }
@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 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 getSubMatrix( final int minRow, final int maxRow, final int minColumn, final int maxColumn) { checkSubmatrixRange(minRow, maxRow, minColumn, maxColumn); SparseMatrix result = new SparseMatrix(maxRow - minRow + 1, maxColumn - minColumn + 1); // You only need worry about the diagonal, so one of the extents will do for (int i = minRow; i <= maxRow; ++i) { // Check to make sure that this element of the diagonal is also in // the other extents if (i >= minColumn && i <= maxColumn) { // If it is, add it at the right place in the output result.setElement(i - minRow, i - minColumn, get(i, i)); } } return result; }
@Override final public Matrix getSubMatrix( final int minRow, final int maxRow, final int minColumn, final int maxColumn) { checkSubmatrixRange(minRow, maxRow, minColumn, maxColumn); SparseMatrix result = new SparseMatrix(maxRow - minRow + 1, maxColumn - minColumn + 1); // You only need worry about the diagonal, so one of the extents will do for (int i = minRow; i <= maxRow; ++i) { // Check to make sure that this element of the diagonal is also in // the other extents if (i >= minColumn && i <= maxColumn) { // If it is, add it at the right place in the output result.setElement(i - minRow, i - minColumn, get(i, i)); } } return result; }
@Override final public Matrix getSubMatrix( final int minRow, final int maxRow, final int minColumn, final int maxColumn) { checkSubmatrixRange(minRow, maxRow, minColumn, maxColumn); SparseMatrix result = new SparseMatrix(maxRow - minRow + 1, maxColumn - minColumn + 1); // You only need worry about the diagonal, so one of the extents will do for (int i = minRow; i <= maxRow; ++i) { // Check to make sure that this element of the diagonal is also in // the other extents if (i >= minColumn && i <= maxColumn) { // If it is, add it at the right place in the output result.setElement(i - minRow, i - minColumn, get(i, i)); } } return result; }
/** * {@inheritDoc} * * NOTE: Calling this method is a really bad idea because you end up storing * a diagonal matrix in a dense representation. */ @Override public final void dotTimesEquals( final DiagonalMatrix 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) { if (i == j) { this.rows[i].values[i] *= other.get(i, i); } else { this.rows[i].values[j] = 0; } } } }
/** * {@inheritDoc} * * NOTE: Calling this method is a really bad idea because you end up storing * a diagonal matrix in a dense representation. */ @Override public final void dotTimesEquals( final DiagonalMatrix 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) { if (i == j) { this.rows[i].values[i] *= other.get(i, i); } else { this.rows[i].values[j] = 0; } } } }
/** * {@inheritDoc} * * NOTE: Calling this method is a really bad idea because you end up storing * a diagonal matrix in a dense representation. */ @Override public final void dotTimesEquals( final DiagonalMatrix 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) { if (i == j) { this.rows[i].values[i] *= other.get(i, i); } else { this.rows[i].values[j] = 0; } } } }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * @return {@inheritDoc} */ @Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); if (!isCompressed()) { compress(); } SparseMatrix result = new SparseMatrix(getNumRows(), getNumColumns()); result.columnIndices = Arrays.copyOf(columnIndices, columnIndices.length); result.firstIndicesForRows = Arrays.copyOf(firstIndicesForRows, firstIndicesForRows.length); result.values = new double[values.length]; for (int i = 0; i < values.length; ++i) { result.values[i] = values[i] * other.get(columnIndices[i], columnIndices[i]); } return result; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * @return {@inheritDoc} */ @Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); if (!isCompressed()) { compress(); } SparseMatrix result = new SparseMatrix(getNumRows(), getNumColumns()); result.columnIndices = Arrays.copyOf(columnIndices, columnIndices.length); result.firstIndicesForRows = Arrays.copyOf(firstIndicesForRows, firstIndicesForRows.length); result.values = new double[values.length]; for (int i = 0; i < values.length; ++i) { result.values[i] = values[i] * other.get(columnIndices[i], columnIndices[i]); } return result; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * @return {@inheritDoc} */ @Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); if (!isCompressed()) { compress(); } SparseMatrix result = new SparseMatrix(getNumRows(), getNumColumns()); result.columnIndices = Arrays.copyOf(columnIndices, columnIndices.length); result.firstIndicesForRows = Arrays.copyOf(firstIndicesForRows, firstIndicesForRows.length); result.values = new double[values.length]; for (int i = 0; i < values.length; ++i) { result.values[i] = values[i] * other.get(columnIndices[i], columnIndices[i]); } return result; }
result.values[i] = values[i] * other.get(curRow, curRow);
result.values[i] = values[i] * other.get(curRow, curRow);