/** * Linear algebraic matrix-vector multiplication; <tt>z = A * y</tt>. * <tt>z[i] = alpha*Sum(A[i,j] * y[j]) + beta*z[i], i=0..A.rows()-1, j=0..y.size()-1</tt>. * Where <tt>A == this</tt>. * @param y the source vector. * @param z the vector where results are to be stored. * * @throws IllegalArgumentException if <tt>A.columns() != y.size() || A.rows() > z.size())</tt>. */ protected void zMult(final DoubleMatrix1D y, final DoubleMatrix1D z, cern.colt.list.IntArrayList nonZeroIndexes, DoubleMatrix1D[] allRows, final double alpha, final double beta) { if (columns != y.size() || rows > z.size()) throw new IllegalArgumentException("Incompatible args: "+toStringShort()+", "+y.toStringShort()+", "+z.toStringShort()); z.assign(cern.jet.math.Functions.mult(beta/alpha)); for (int i = indexes.length; --i >= 0; ) { if (indexes[i] != null) { for (int k = indexes[i].size(); --k >= 0; ) { int j = indexes[i].getQuick(k); double value = values[i].getQuick(k); z.setQuick(i,z.getQuick(i) + value * y.getQuick(j)); } } } z.assign(cern.jet.math.Functions.mult(alpha)); } }
/** * Linear algebraic matrix-vector multiplication; <tt>z = A * y</tt>. * <tt>z[i] = alpha*Sum(A[i,j] * y[j]) + beta*z[i], i=0..A.rows()-1, j=0..y.size()-1</tt>. * Where <tt>A == this</tt>. * @param y the source vector. * @param z the vector where results are to be stored. * * @throws IllegalArgumentException if <tt>A.columns() != y.size() || A.rows() > z.size())</tt>. */ protected void zMult(final DoubleMatrix1D y, final DoubleMatrix1D z, cern.colt.list.IntArrayList nonZeroIndexes, DoubleMatrix1D[] allRows, final double alpha, final double beta) { if (columns != y.size() || rows > z.size()) throw new IllegalArgumentException("Incompatible args: "+toStringShort()+", "+y.toStringShort()+", "+z.toStringShort()); z.assign(cern.jet.math.Functions.mult(beta/alpha)); for (int i = indexes.length; --i >= 0; ) { if (indexes[i] != null) { for (int k = indexes[i].size(); --k >= 0; ) { int j = indexes[i].getQuick(k); double value = values[i].getQuick(k); z.setQuick(i,z.getQuick(i) + value * y.getQuick(j)); } } } z.assign(cern.jet.math.Functions.mult(alpha)); } }