@Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); 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); }
@Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); 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); }
@Override public final Matrix times( final DiagonalMatrix other) { this.assertMultiplicationDimensions(other); 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); }
@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); }
@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); }
@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); }
@Override public final Matrix times( final DenseMatrix other) { this.assertMultiplicationDimensions(other); // TODO: Make sure this BLAS is truly faster than slow version if (canUseBlasForMult(getNumRows(), getNumColumns(), other.getNumRows(), other.getNumColumns())) { double[] output = new double[getNumRows() * other.getNumColumns()]; BLAS.getInstance().dgemm("N", "N", getNumRows(), other.getNumColumns(), getNumColumns(), 1.0, this.toBlas(), getNumRows(), other.toBlas(), other.getNumRows(), 0.0, output, getNumRows()); return createFromBlas(output, getNumRows(), other.getNumColumns()); } else { return slowMult(other); } }
@Override public final Matrix times( final DenseMatrix other) { this.assertMultiplicationDimensions(other); // TODO: Make sure this BLAS is truly faster than slow version if (canUseBlasForMult(getNumRows(), getNumColumns(), other.getNumRows(), other.getNumColumns())) { double[] output = new double[getNumRows() * other.getNumColumns()]; BLAS.getInstance().dgemm("N", "N", getNumRows(), other.getNumColumns(), getNumColumns(), 1.0, this.toBlas(), getNumRows(), other.toBlas(), other.getNumRows(), 0.0, output, getNumRows()); return createFromBlas(output, getNumRows(), other.getNumColumns()); } else { return slowMult(other); } }
@Override public final Matrix times( final DenseMatrix other) { this.assertMultiplicationDimensions(other); // TODO: Make sure this BLAS is truly faster than slow version if (canUseBlasForMult(getNumRows(), getNumColumns(), other.getNumRows(), other.getNumColumns())) { double[] output = new double[getNumRows() * other.getNumColumns()]; BLAS.getInstance().dgemm("N", "N", getNumRows(), other.getNumColumns(), getNumColumns(), 1.0, this.toBlas(), getNumRows(), other.toBlas(), other.getNumRows(), 0.0, output, getNumRows()); return createFromBlas(output, getNumRows(), other.getNumColumns()); } else { return slowMult(other); } }