16#ifndef ANASAZI_SADDLE_OPERATOR_HPP 
   17#define ANASAZI_SADDLE_OPERATOR_HPP 
   23#include "Teuchos_SerialDenseSolver.hpp" 
   27enum PrecType {NO_PREC, NONSYM, BD_PREC, HSS_PREC};
 
   32template <
class ScalarType, 
class MV, 
class OP>
 
   33class SaddleOperator : 
public TraceMinOp<ScalarType,SaddleContainer<ScalarType,MV>,OP>
 
   36  typedef Teuchos::SerialDenseMatrix<int,ScalarType>   SerialDenseMatrix;
 
   40  SaddleOperator( ) { };
 
   41  SaddleOperator( 
const Teuchos::RCP<OP> A, 
const Teuchos::RCP<const MV> B, PrecType pt=NO_PREC, 
const ScalarType alpha=1. );
 
   44  void Apply(
const SaddleContainer<ScalarType,MV>& X, SaddleContainer<ScalarType,MV>& Y) 
const;
 
   46  void removeIndices(
const std::vector<int>& indicesToRemove) { A_->removeIndices(indicesToRemove); };
 
   51  Teuchos::RCP<const MV> B_;
 
   52  Teuchos::RCP<SerialDenseMatrix> Schur_;
 
   60template <
class ScalarType, 
class MV, 
class OP>
 
   61SaddleOperator<ScalarType, MV, OP>::SaddleOperator( 
const Teuchos::RCP<OP> A, 
const Teuchos::RCP<const MV> B, PrecType pt, 
const ScalarType alpha )
 
   72    int nvecs = MVT::GetNumberVecs(*B);
 
   73    Teuchos::RCP<MV> AinvB = MVT::Clone(*B,nvecs);
 
   74    Schur_ = rcp(
new SerialDenseMatrix(nvecs,nvecs));
 
   76    A_->Apply(*B_,*AinvB);
 
   78    MVT::MvTransMv(1., *B_, *AinvB, *Schur_);
 
   83template <
class ScalarType, 
class MV, 
class OP>
 
   84void SaddleOperator<ScalarType, MV, OP>::Apply(
const SaddleContainer<ScalarType,MV>& X, SaddleContainer<ScalarType,MV>& Y)
 const 
   86  RCP<SerialDenseMatrix> Xlower = X.getLower();
 
   87  RCP<SerialDenseMatrix> Ylower = Y.getLower();
 
   93    MVT::MvTransMv(1., *B_, *(X.upper_), *Ylower);
 
   96    A_->Apply(*(X.upper_), *(Y.upper_));
 
   97    MVT::MvTimesMatAddMv(1., *B_, *Xlower, 1., *(Y.upper_));
 
   99  else if(pt_ == NONSYM)
 
  102  MVT::MvTransMv(-1., *B_, *(X.upper_), *Ylower);
 
  105    A_->Apply(*(X.upper_), *(Y.upper_));
 
  106    MVT::MvTimesMatAddMv(1., *B_, *Xlower, 1., *(Y.upper_));
 
  108  else if(pt_ == BD_PREC)
 
  110    Teuchos::SerialDenseSolver<int,ScalarType> MySolver;
 
  113    A_->Apply(*(X.upper_),*(Y.upper_));
 
  116    Teuchos::RCP<SerialDenseMatrix> localSchur = Teuchos::rcp(
new SerialDenseMatrix(*Schur_));
 
  119    MySolver.setMatrix(localSchur);
 
  120    MySolver.setVectors(Ylower, Xlower);
 
  126  else if(pt_ == HSS_PREC)
 
  133    A_->Apply(*(X.upper_),*(Y.upper_));
 
  136    Ylower->scale(1./alpha_);
 
  144    Teuchos::RCP<SerialDenseMatrix> Y1_lower = Teuchos::rcp(
new SerialDenseMatrix(*Ylower));
 
  145    MVT::MvTransMv(1,*B_,*(Y.upper_),*Ylower);
 
  147    Y1_lower->scale(alpha_);
 
  149    *Ylower += *Y1_lower;
 
  151    Ylower->scale(1/(1+alpha_*alpha_));
 
  153    MVT::MvTimesMatAddMv(-1/alpha_,*B_,*Ylower,1/alpha_,*(Y.upper_));
 
  161    std::cout << 
"Not a valid preconditioner type\n";
 
  172template<
class ScalarType, 
class MV, 
class OP>
 
  173class OperatorTraits<ScalarType, 
Experimental::SaddleContainer<ScalarType,MV>, Experimental::SaddleOperator<ScalarType,MV,OP> >
 
  176  static void Apply( 
const Experimental::SaddleOperator<ScalarType,MV,OP>& Op, 
 
  177                     const Experimental::SaddleContainer<ScalarType,MV>& x, 
 
  178                     Experimental::SaddleContainer<ScalarType,MV>& y)
 
  179    { Op.Apply( x, y); };
 
  184#ifdef HAVE_ANASAZI_BELOS 
  187template<
class ScalarType, 
class MV, 
class OP>
 
  188class OperatorTraits<ScalarType, 
Anasazi::Experimental::SaddleContainer<ScalarType,MV>, Anasazi::Experimental::SaddleOperator<ScalarType,MV,OP> >
 
  191  static void Apply( 
const Anasazi::Experimental::SaddleOperator<ScalarType,MV,OP>& Op, 
 
  192                     const Anasazi::Experimental::SaddleContainer<ScalarType,MV>& x, 
 
  193                     Anasazi::Experimental::SaddleContainer<ScalarType,MV>& y)
 
  194    { Op.Apply( x, y); };
 
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
 
Stores a set of vectors of the form [V; L] where V is a distributed multivector and L is a serialdens...
 
Traits class which defines basic operations on multivectors.
 
static void Apply(const OP &Op, const MV &x, MV &y)
Application method which performs operation y = Op*x. An OperatorError exception is thrown if there i...
 
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.