void MultiVectorMatrix::MultVectorImpl(Number alpha, const Vector &x, Number beta, Vector &y) const { // A few sanity checks DBG_ASSERT(NCols()==x.Dim()); DBG_ASSERT(NRows()==y.Dim()); // Take care of the y part of the addition if ( beta!=0.0 ) { y.Scal(beta); } else { y.Set(0.0); // In case y hasn't been initialized yet } // See if we can understand the data const DenseVector* dense_x = static_cast<const DenseVector*>(&x); DBG_ASSERT(dynamic_cast<const DenseVector*>(&x)); // We simply add all the Vectors one after the other if (dense_x->IsHomogeneous()) { Number val = dense_x->Scalar(); for (Index i=0; i<NCols(); i++) { y.AddOneVector(alpha*val, *ConstVec(i), 1.); } } else { const Number* values = dense_x->Values(); for (Index i=0; i<NCols(); i++) { y.AddOneVector(alpha*values[i], *ConstVec(i), 1.); } } }
void MultiVectorMatrix::LRMultVector(Number alpha, const Vector &x, Number beta, Vector &y) const { DBG_START_METH("MultiVectorMatrix::LRMultVector(", dbg_verbosity); DBG_ASSERT(NRows()==x.Dim()); DBG_ASSERT(NRows()==y.Dim()); DBG_PRINT((1, "alpha = %e beta = %e\n", alpha, beta)); DBG_PRINT_VECTOR(2, "x", x); if ( beta!=0.0 ) { y.Scal(beta); } else { y.Set(0.0); } DBG_PRINT_VECTOR(2, "beta*y", y); for (Index i=0; i<NCols(); i++) { DBG_PRINT_VECTOR(2, "ConstVec(i)", *ConstVec(i)); y.AddOneVector(alpha*ConstVec(i)->Dot(x), *ConstVec(i), 1.); DBG_PRINT_VECTOR(2, "y mid", y); } }