final SparseMatrix m) this.numCols = m.getNumColumns(); this.numRows = m.getNumRows(); rows = new SparseVector[m.rows.length];
final SparseMatrix m) this.numCols = m.getNumColumns(); this.numRows = m.getNumRows(); rows = new SparseVector[m.rows.length];
clone.numCols = this.getNumColumns(); clone.numRows = this.getNumRows(); clone.rows = new SparseVector[this.rows.length];
clone.numCols = this.getNumColumns(); clone.numRows = this.getNumRows(); clone.rows = new SparseVector[this.rows.length];
clone.numCols = this.getNumColumns(); clone.numRows = this.getNumRows(); clone.rows = new SparseVector[this.rows.length];
/** * {@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; }
SparseMatrix result = new SparseMatrix(getNumRows(), getNumColumns()); result.columnIndices = Arrays.copyOf(columnIndices, columnIndices.length); result.firstIndicesForRows = Arrays.copyOf(firstIndicesForRows,
SparseMatrix result = new SparseMatrix(getNumRows(), getNumColumns()); result.columnIndices = Arrays.copyOf(columnIndices, columnIndices.length); result.firstIndicesForRows = Arrays.copyOf(firstIndicesForRows,
SparseMatrix result = new SparseMatrix(getNumRows(), getNumColumns()); result.columnIndices = Arrays.copyOf(columnIndices, columnIndices.length); result.firstIndicesForRows = Arrays.copyOf(firstIndicesForRows,
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * * @return {@inheritDoc} */ @Override // Not final because this method is overridden by the Parallel implementation public Vector times( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumColumns()); 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] * vector.values[columnIndices[j]]; } } return result; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * * @return {@inheritDoc} */ @Override // Not final because this method is overridden by the Parallel implementation public Vector times( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumColumns()); 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] * vector.values[columnIndices[j]]; } } return result; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * * @return {@inheritDoc} */ @Override // Not final because this method is overridden by the Parallel implementation public Vector times( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumColumns()); 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] * vector.values[columnIndices[j]]; } } return result; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * * @return {@inheritDoc} */ @Override public final Vector preTimes( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumRows()); if (!isCompressed()) { compress(); } DenseVector result = new DenseVector(getNumColumns()); int row = 0; for (int i = 0; i < values.length; ++i) { while (i >= firstIndicesForRows[row + 1]) { ++row; } result.setElement(columnIndices[i], result.get(columnIndices[i]) + vector.get(row) * values[i]); } return result; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * * @return {@inheritDoc} */ @Override public final Vector preTimes( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumRows()); if (!isCompressed()) { compress(); } DenseVector result = new DenseVector(getNumColumns()); int row = 0; for (int i = 0; i < values.length; ++i) { while (i >= firstIndicesForRows[row + 1]) { ++row; } result.setElement(columnIndices[i], result.get(columnIndices[i]) + vector.get(row) * values[i]); } return result; }
/** * {@inheritDoc} * * NOTE: Upon completion this is in the compressed Yale format. * * @return {@inheritDoc} */ @Override public final Vector preTimes( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumRows()); if (!isCompressed()) { compress(); } DenseVector result = new DenseVector(getNumColumns()); int row = 0; for (int i = 0; i < values.length; ++i) { while (i >= firstIndicesForRows[row + 1]) { ++row; } result.setElement(columnIndices[i], result.get(columnIndices[i]) + vector.get(row) * values[i]); } return result; }
SparseVector result = new SparseVector(getNumColumns()); vector.compress(); final int[] otherIndices = vector.getIndices();
SparseVector result = new SparseVector(getNumColumns()); vector.compress(); final int[] otherIndices = vector.getIndices();
SparseVector result = new SparseVector(getNumColumns()); vector.compress(); final int[] otherIndices = vector.getIndices();