예제 #1
0
  void ScaledMatrix::TransMultVectorImpl(Number alpha, const Vector &x,
                                         Number beta, Vector &y) const
  {
    DBG_ASSERT(IsValid(matrix_));

    // 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
    }

    // need some temporary vectors
    SmartPtr<Vector> tmp_x = x.MakeNewCopy();
    SmartPtr<Vector> tmp_y = y.MakeNew();

    if (IsValid(owner_space_->RowScaling())) {
      tmp_x->ElementWiseMultiply(*owner_space_->RowScaling());
    }

    matrix_->TransMultVector(1.0, *tmp_x, 0.0, *tmp_y);

    if (IsValid(owner_space_->ColumnScaling())) {
      tmp_y->ElementWiseMultiply(*owner_space_->ColumnScaling());
    }

    y.Axpy(alpha, *tmp_y);
  }
예제 #2
0
 void Matrix::SinvBlrmZMTdBrImpl(Number alpha, const Vector& S,
                                 const Vector& R, const Vector& Z,
                                 const Vector& D, Vector& X) const
 {
   TransMultVector(alpha, D, 0., X);
   X.ElementWiseMultiply(Z);
   X.Axpy(1., R);
   X.ElementWiseDivide(S);
 }
예제 #3
0
  void ScaledMatrix::SinvBlrmZMTdBrImpl(Number alpha, const Vector& S,
                                        const Vector& R, const Vector& Z,
                                        const Vector& D, Vector& X) const
  {
    DBG_ASSERT(false && "Got the ScaledMatrix::SinvBlrmZMTdBrImpl.  Should implement specialized method!");

    TransMultVector(alpha, D, 0., X);
    X.ElementWiseMultiply(Z);
    X.Axpy(1., R);
    X.ElementWiseDivide(S);
  }
예제 #4
0
  void DiagMatrix::MultVectorImpl(Number alpha, const Vector &x,
                                  Number beta, Vector &y) const
  {
    //  A few sanity checks
    DBG_ASSERT(Dim()==x.Dim());
    DBG_ASSERT(Dim()==y.Dim());
    DBG_ASSERT(IsValid(diag_));

    // 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
    }

    SmartPtr<Vector> tmp_vec = y.MakeNew();
    tmp_vec->Copy(x);
    tmp_vec->ElementWiseMultiply(*diag_);
    y.Axpy(alpha, *tmp_vec);
  }