@Override public int getEntryCount() { if (!this.isCompressed()) { this.compress(); } return this.values.length; }
@Override public int getEntryCount() { if (!this.isCompressed()) { this.compress(); } return this.values.length; }
@Override public int getEntryCount() { if (!this.isCompressed()) { this.compress(); } return this.values.length; }
/** * Package-private method that returns the compressed Yale-format values. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format values */ final double[] getValues() { if (!isCompressed()) { compress(); } return values; }
/** * Package-private method that returns the compressed Yale-format values. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format values */ final double[] getValues() { if (!isCompressed()) { compress(); } return values; }
/** * Package-private method that returns the compressed Yale-format values. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format values */ final double[] getValues() { if (!isCompressed()) { compress(); } return values; }
/** * Package-private method that returns the compressed Yale-format column * indices. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format column indices */ final int[] getColumnIndices() { if (!isCompressed()) { compress(); } return columnIndices; }
/** * Package-private method that returns the compressed Yale-format first * indices for each row. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format first indices for each row */ final int[] getFirstInRows() { if (!isCompressed()) { compress(); } return firstIndicesForRows; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * @param scaleFactor {@inheritDoc} */ @Override final public void scaleEquals( final double scaleFactor) { if (!isCompressed()) { compress(); } for (int i = 0; i < values.length; ++i) { values[i] *= scaleFactor; } }
/** * Package-private method that returns the compressed Yale-format first * indices for each row. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format first indices for each row */ final int[] getFirstInRows() { if (!isCompressed()) { compress(); } return firstIndicesForRows; }
/** * Package-private method that returns the compressed Yale-format column * indices. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format column indices */ final int[] getColumnIndices() { if (!isCompressed()) { compress(); } return columnIndices; }
/** * Package-private method that returns the compressed Yale-format first * indices for each row. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format first indices for each row */ final int[] getFirstInRows() { if (!isCompressed()) { compress(); } return firstIndicesForRows; }
/** * Package-private method that returns the compressed Yale-format column * indices. * * NOTE: Upon completion this is in the compressed Yale format. * * @return the compressed Yale-format column indices */ final int[] getColumnIndices() { if (!isCompressed()) { compress(); } return columnIndices; }
@Override public Iterator<MatrixEntry> iterator() { if (!isCompressed()) { compress(); } return new NonZeroEntryIterator(); }
@Override public Iterator<MatrixEntry> iterator() { if (!isCompressed()) { compress(); } return new NonZeroEntryIterator(); }
@Override public Iterator<MatrixEntry> iterator() { if (!isCompressed()) { compress(); } return new NonZeroEntryIterator(); }
@Override public Vector sumOfColumns() { if (!isCompressed()) { compress(); } DenseVector result = new DenseVector(numRows); for (int i = 0; i < numRows; ++i) { result.values[i] = 0; for (int j = firstIndicesForRows[i]; j < firstIndicesForRows[i + 1]; ++j) { result.values[i] += values[j]; } } return result; }
@Override public Vector sumOfRows() { if (!isCompressed()) { compress(); } DenseVector result = new DenseVector(numCols); for (int i = 0; i < numRows; ++i) { for (int j = firstIndicesForRows[i]; j < firstIndicesForRows[i + 1]; ++j) { result.values[columnIndices[j]] += values[j]; } } return result; }
@Override public Vector sumOfRows() { if (!isCompressed()) { compress(); } DenseVector result = new DenseVector(numCols); for (int i = 0; i < numRows; ++i) { for (int j = firstIndicesForRows[i]; j < firstIndicesForRows[i + 1]; ++j) { result.values[columnIndices[j]] += values[j]; } } return result; }
@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); }