anasaziHelper.hh

Go to the documentation of this file.
1 
5 #pragma once
6 
7 #define HAVE_CONFIG_H
8 
9 #include "AnasaziOperator.hpp"
10 #include <AnasaziMultiVec.hpp>
11 #include "operator.hh"
12 #include <Teuchos_SerialDenseMatrix.hpp>
13 
14 namespace concepts {
15 
16 template <class ScalarT>
17 class AnasaziOp : public Anasazi::Operator<ScalarT> {
18  public:
20 
21 
23  AnasaziOp(Teuchos::RCP<Operator<ScalarT> > op)
24  : op(op)
25  { }
26 
28  virtual ~AnasaziOp() {};
30 
32 
33 
37  virtual void Apply ( const Anasazi::MultiVec<ScalarT>& x, Anasazi::MultiVec<ScalarT>& y ) const;
38 
40 
42  return *op;
43  }
44 
45  private:
46  Teuchos::RCP<Operator<ScalarT> > op;
47 
48 };
49 
50 template <class ScalarT>
51 class AnasaziMV : public Anasazi::MultiVec<ScalarT> {
52 public:
53  static const bool NO_ALLOCATE = false;
55 
56  AnasaziMV(int dim = 0, int nvecs = 0, bool allocate = true);
57  virtual ~AnasaziMV();
58 
59 private:
62 
63 
64 public:
65 
69  virtual AnasaziMV<ScalarT>* Clone( const int numvecs ) const;
70 
75  virtual AnasaziMV<ScalarT>* CloneCopy() const;
76 
82  virtual AnasaziMV<ScalarT>* CloneCopy ( const std::vector<int>& index ) const;
83 
89  virtual AnasaziMV<ScalarT>* CloneView ( const std::vector<int>& index );
91 
93 
94 
96  int GetVecLength () const { return dim; }
97 
99  virtual int GetNumberVecs () const { return nvecs; }
100 
102 
104 
105 
108  virtual void MvTimesMatAddMv ( ScalarT alpha, const Anasazi::MultiVec<ScalarT>& A,
109  const Teuchos::SerialDenseMatrix<int,ScalarT>& B, ScalarT beta );
110 
113  virtual void MvAddMv ( ScalarT alpha,const Anasazi::MultiVec<ScalarT>& A,
114  ScalarT beta, const Anasazi::MultiVec<ScalarT>& B );
115 
119  virtual void MvTransMv ( ScalarT alpha, const Anasazi::MultiVec<ScalarT>& A,
120  Teuchos::SerialDenseMatrix<int,ScalarT>& B
121 #ifdef HAVE_ANASAZI_EXPERIMENTAL
122  , ConjType conj = Anasazi::CONJ
123 #endif
124  ) const;
125 
129  virtual void MvDot ( const Anasazi::MultiVec<ScalarT>& A, std::vector<ScalarT> & b
130 #ifdef HAVE_ANASAZI_EXPERIMENTAL
131  , ConjType conj = Anasazi::CONJ
132 #endif
133  ) const;
134 
136 
138 
142  virtual void MvNorm (
143  std::vector<typename Teuchos::ScalarTraits<ScalarT>::magnitudeType> & normvec
144  ) const;
145 
147 
149 
150 
155  virtual void SetBlock ( const Anasazi::MultiVec<ScalarT>& A, const std::vector<int>& index );
156 
159  virtual void MvScale ( ScalarT alpha );
160 
163  virtual void MvScale ( const std::vector<ScalarT>& alpha );
164 
167  virtual void MvRandom ();
168 
171  virtual void MvInit ( ScalarT alpha );
172 
174 
176 
178  virtual void MvPrint ( std::ostream& os ) const;
180 
181  VectorT* getVec(int i)
182  {
183  return vecs[i];
184  }
185 
186  const VectorT* getVec(int i) const
187  {
188  return vecs[i];
189  }
190 
191 private:
192  const int dim;
193  int nvecs;
195  bool allocate;
196 };
197 
198 }
virtual AnasaziMV< ScalarT > * CloneView(const std::vector< int > &index)
Creates a new Anasazi::MultiVec that shares the selected contents of *this.
int nvecs
Print *this multivector to the os output stream.
VectorT ** vecs
Print *this multivector to the os output stream.
AnasaziMV(const AnasaziMV< ScalarT > &other)
const VectorT * getVec(int i) const
Print *this multivector to the os output stream.
virtual AnasaziMV< ScalarT > * CloneCopy(const std::vector< int > &index) const
Creates a new Anasazi::MultiVec and copies the selected contents of *this into the new vector (deep c...
virtual void SetBlock(const Anasazi::MultiVec< ScalarT > &A, const std::vector< int > &index)
Copy the vectors in A to a set of vectors in *this.
virtual int GetNumberVecs() const
Obtain the number of vectors in *this.
bool allocate
Print *this multivector to the os output stream.
virtual AnasaziMV< ScalarT > * CloneCopy() const
Creates a new Anasazi::MultiVec and copies contents of *this into the new vector (deep copy).
Teuchos::RCP< Operator< ScalarT > > op
This method takes the Anasazi::MultiVec x and applies the operator to it resulting in the Anasazi::Mu...
VectorT * getVec(int i)
Print *this multivector to the os output stream.
alglib::complex conj(const alglib::complex &z)
virtual void MvScale(const std::vector< ScalarT > &alpha)
Scale each element of the i-th vector in *this with alpha[i].
AnasaziMV(int dim=0, int nvecs=0, bool allocate=true)
virtual void MvScale(ScalarT alpha)
Scale each element of the vectors in *this with alpha.
virtual void MvDot(const Anasazi::MultiVec< ScalarT > &A, std::vector< ScalarT > &b) const
Compute a vector b where the components are the individual dot-products, i.e.
virtual void MvInit(ScalarT alpha)
Replace each element of the vectors in *this with alpha.
virtual void MvTimesMatAddMv(ScalarT alpha, const Anasazi::MultiVec< ScalarT > &A, const Teuchos::SerialDenseMatrix< int, ScalarT > &B, ScalarT beta)
Update *this with alpha * A * B + beta * (*this).
static const bool NO_ALLOCATE
const int dim
Print *this multivector to the os output stream.
Vector< ScalarT > VectorT
int GetVecLength() const
Obtain the vector length of *this.
Abstract class for an operator.
Definition: ARPACK.hh:16
virtual void MvTransMv(ScalarT alpha, const Anasazi::MultiVec< ScalarT > &A, Teuchos::SerialDenseMatrix< int, ScalarT > &B) const
Compute a dense matrix B through the matrix-matrix multiply alpha * A^T * (*this).
AnasaziOp(Teuchos::RCP< Operator< ScalarT > > op)
Give a matrix instance which will be wrapped by this class.
virtual ~AnasaziOp()
Destructor.
virtual void MvPrint(std::ostream &os) const
Print *this multivector to the os output stream.
virtual void MvAddMv(ScalarT alpha, const Anasazi::MultiVec< ScalarT > &A, ScalarT beta, const Anasazi::MultiVec< ScalarT > &B)
Replace *this with alpha * A + beta * B.
double beta(const double a, const double b)
virtual void Apply(const Anasazi::MultiVec< ScalarT > &x, Anasazi::MultiVec< ScalarT > &y) const
This method takes the Anasazi::MultiVec x and applies the operator to it resulting in the Anasazi::Mu...
virtual void MvRandom()
Fill the vectors in *this with random numbers.
virtual void MvNorm(std::vector< typename Teuchos::ScalarTraits< ScalarT >::magnitudeType > &normvec) const
Compute the 2-norm of each individual vector of *this.
virtual AnasaziMV< ScalarT > * Clone(const int numvecs) const
Creates a new empty Anasazi::MultiVec containing numvecs columns.
AnasaziMV< ScalarT > & operator=(const AnasaziMV< ScalarT > other)
const Operator< ScalarT > & getOp()
This method takes the Anasazi::MultiVec x and applies the operator to it resulting in the Anasazi::Mu...
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich