/** * Package private optimized constructor that allows creation of a matrix * from the given rows. * * This is an optimized constructor for within package only. Don't call this * unless you are -super- careful. * * @param rows The array of rows for the matrix. Each row must be the same * length. */ DenseMatrix( final DenseVector[] rows) { super(); final int numRows = rows.length; if (numRows > 0) { final int numColumns = rows[0].getDimensionality(); for (int i = 1; i < numRows; i++) { rows[i].assertDimensionalityEquals(numColumns); } } this.rows = rows; initBlas(); }
/** * Package private optimized constructor that allows creation of a matrix * from the given rows. * * This is an optimized constructor for within package only. Don't call this * unless you are -super- careful. * * @param rows The array of rows for the matrix. Each row must be the same * length. */ DenseMatrix( final DenseVector[] rows) { super(); final int numRows = rows.length; if (numRows > 0) { final int numColumns = rows[0].getDimensionality(); for (int i = 1; i < numRows; i++) { rows[i].assertDimensionalityEquals(numColumns); } } this.rows = rows; initBlas(); }
/** * Package private optimized constructor that allows creation of a matrix * from the given rows. * * This is an optimized constructor for within package only. Don't call this * unless you are -super- careful. * * @param rows The array of rows for the matrix. Each row must be the same * length. */ DenseMatrix( final DenseVector[] rows) { super(); final int numRows = rows.length; if (numRows > 0) { final int numColumns = rows[0].getDimensionality(); for (int i = 1; i < numRows; i++) { rows[i].assertDimensionalityEquals(numColumns); } } this.rows = rows; initBlas(); }
@Override public final Vector times( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumColumns()); DenseVector result = new DenseVector(diagonal.length); for (int i = 0; i < diagonal.length; ++i) { result.setElement(i, vector.get(i) * diagonal[i]); } return result; }
@Override public final Vector times( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumColumns()); DenseVector result = new DenseVector(diagonal.length); for (int i = 0; i < diagonal.length; ++i) { result.setElement(i, vector.get(i) * diagonal[i]); } return result; }
@Override public final Vector times( final DenseVector vector) { vector.assertDimensionalityEquals(this.getNumColumns()); DenseVector result = new DenseVector(diagonal.length); for (int i = 0; i < diagonal.length; ++i) { result.setElement(i, vector.get(i) * diagonal[i]); } 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 // 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; }
@Override public final Vector preTimes( final DenseVector vector) { final int numRows = this.getNumRows(); final int numColumns = this.getNumColumns(); vector.assertDimensionalityEquals(numRows); DenseVector result = new DenseVector(numColumns); for (int i = 0; i < numColumns; ++i) { double entry = 0; for (int j = 0; j < numRows; ++j) { entry += vector.get(j) * rows[j].get(i); } result.setElement(i, entry); } return result; }
@Override public final Vector preTimes( final DenseVector vector) { final int numRows = this.getNumRows(); final int numColumns = this.getNumColumns(); vector.assertDimensionalityEquals(numRows); DenseVector result = new DenseVector(numColumns); for (int i = 0; i < numColumns; ++i) { double entry = 0; for (int j = 0; j < numRows; ++j) { entry += vector.get(j) * rows[j].get(i); } result.setElement(i, entry); } return result; }
@Override public final Vector preTimes( final DenseVector vector) { final int numRows = this.getNumRows(); final int numColumns = this.getNumColumns(); vector.assertDimensionalityEquals(numRows); DenseVector result = new DenseVector(numColumns); for (int i = 0; i < numColumns; ++i) { double entry = 0; for (int j = 0; j < numRows; ++j) { entry += vector.get(j) * rows[j].get(i); } result.setElement(i, entry); } 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; }