InverseLinearOperator.cpp 1.2 KB
Newer Older
Jan Zapletal's avatar
Jan Zapletal committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
/*!
 * @file    InverseLinearOperator.cpp
 * @author  Jan Zapletal
 * @date    April 26, 2016
 * 
 */


#ifdef INVERSELINEAROPERATOR_H

namespace bem4i {

template< class LO, class SC >
void InverseLinearOperator< LO, SC >::apply(
    Vector< LO, SC > const & x,
    Vector< LO, SC > & y,
    bool transA,
    SC alpha,
    SC beta
    ) {

  Vector< LO, SC > z( this->dimRange, true );
  //z.setAll( 1.0 );

  switch ( this->params->solver ) {
    case( SolverParameters< LO, SC >::CG ):
      this->op->CGSolve( x, z, this->params->precision, this->params->maxIter, 
      this->precond, this->params->msg );
      break;
    case( SolverParameters< LO, SC >::GMRES ):
      this->op->GMRESSolve( x, z, this->params->precision,
          this->params->maxIter, this->params->maxIter, this->precond,
          this->params->msg );
      break;
    case( SolverParameters< LO, SC >::DGMRES ):
      std::cout << "Not implemented" << std::endl;
      break;
    case( SolverParameters< LO, SC >::FGMRES ):
      this->FGMRESSolve( x, z, this->params->precision,
          this->params->maxIter, this->params->maxIter, this->precond,
          this->params->msg );
      break;
  }

  y.scale( beta );
  y.add( z, alpha );
}

}
#endif