Anasazi  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AnasaziSpecializedEpetraAdapter.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Anasazi: Block Eigensolvers Package
5 // Copyright 2004 Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8 // the U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
46 #ifndef ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
47 #define ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
48 
49 #include "AnasaziConfigDefs.hpp"
50 #include "Anasaziepetra_DLLExportMacro.h"
51 #include "AnasaziTypes.hpp"
52 #include "AnasaziMultiVec.hpp"
53 #include "AnasaziOperator.hpp"
54 #include "AnasaziEpetraAdapter.hpp"
55 
56 #include "Teuchos_Assert.hpp"
58 #include "Teuchos_RCP.hpp"
59 #include "Epetra_MultiVector.h"
60 #include "Epetra_Vector.h"
61 #include "Epetra_Operator.h"
62 #include "Epetra_Map.h"
63 #include "Epetra_LocalMap.h"
64 
65 #if defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
66 # include <Tpetra_ConfigDefs.hpp> // HAVE_TPETRA_EPETRA
67 # if defined(HAVE_TPETRA_EPETRA)
68 # include <Epetra_TsqrAdaptor.hpp>
69 # endif // defined(HAVE_TPETRA_EPETRA)
70 #endif // defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
71 
72 namespace Anasazi {
73 
75 
76 
81  EpetraSpecializedMultiVecFailure(const std::string& what_arg) : AnasaziError(what_arg)
82  {}};
83 
85 
87  //
88  //--------template class AnasaziEpetraOpMultiVec-----------------
89  //
91 
98  class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraOpMultiVec : public MultiVec<double>, public EpetraMultiVecAccessor {
99  public:
101 
102 
104 
110  EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, const int numvecs);
111 
113 
122  EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, double * array, const int numvecs, const int stride=0);
123 
125 
131  EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, Epetra_DataAccess CV, const Epetra_MultiVector& P_vec, const std::vector<int>& index);
132 
134  EpetraOpMultiVec(const EpetraOpMultiVec& P_vec);
135 
137  virtual ~EpetraOpMultiVec() {};
138 
140 
142 
143 
148  MultiVec<double> * Clone ( const int numvecs ) const;
149 
155  MultiVec<double> * CloneCopy () const;
156 
164  MultiVec<double> * CloneCopy ( const std::vector<int>& index ) const;
165 
173  MultiVec<double> * CloneViewNonConst ( const std::vector<int>& index );
174 
182  const MultiVec<double> * CloneView ( const std::vector<int>& index ) const;
183 
185 
187  Teuchos::RCP<Epetra_MultiVector> GetEpetraMultiVector() { return Epetra_MV; }
188 
190 
191 
193  ptrdiff_t GetGlobalLength () const
194  {
195  if ( Epetra_MV->Map().GlobalIndicesLongLong() )
196  return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength64() );
197  else
198  return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength() );
199  }
200 
202  int GetNumberVecs () const { return Epetra_MV->NumVectors(); }
203 
205 
207 
208 
210  void MvTimesMatAddMv ( double alpha, const MultiVec<double>& A,
212  double beta );
213 
216  void MvAddMv ( double alpha, const MultiVec<double>& A,
217  double beta, const MultiVec<double>& B);
218 
221  void MvTransMv ( double alpha, const MultiVec<double>& A, Teuchos::SerialDenseMatrix<int,double>& B
222 #ifdef HAVE_ANASAZI_EXPERIMENTAL
223  , ConjType conj = Anasazi::CONJ
224 #endif
225  ) const;
226 
229  void MvDot ( const MultiVec<double>& A, std::vector<double> &b
230 #ifdef HAVE_ANASAZI_EXPERIMENTAL
231  , ConjType conj = Anasazi::CONJ
232 #endif
233  ) const;
234 
237  void MvScale ( double alpha ) {
238  TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Scale( alpha )!=0, EpetraSpecializedMultiVecFailure,
239  "Anasazi::EpetraOpMultiVec::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
240  }
241 
244  void MvScale ( const std::vector<double>& alpha );
245 
247 
249 
253  void MvNorm ( std::vector<double> & normvec ) const;
254 
256 
258 
259 
264  void SetBlock ( const MultiVec<double>& A, const std::vector<int>& index );
265 
268  void MvRandom() {
270  "Anasazi::EpetraOpMultiVec::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
271  }
272 
275  void MvInit ( double alpha ) {
276  TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->PutScalar( alpha )!=0, EpetraSpecializedMultiVecFailure,
277  "Anasazi::EpetraOpMultiVec::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
278  }
279 
281 
282 
284  Epetra_MultiVector* GetEpetraMultiVec() { return &*Epetra_MV; };
285 
287  const Epetra_MultiVector* GetEpetraMultiVec() const { return &*Epetra_MV; };
288 
290 
292 
294 
296  void MvPrint( std::ostream& os ) const { Epetra_MV->Print( os ); }
297 
299 
300  private:
301 //use pragmas to disable some false-positive warnings for windows
302 // sharedlibs export
303 #ifdef _MSC_VER
304 #pragma warning(push)
305 #pragma warning(disable:4251)
306 #endif
309  Teuchos::RCP<Epetra_MultiVector> Epetra_MV_Temp;
310 #ifdef _MSC_VER
311 #pragma warning(pop)
312 #endif
313  };
314 
315 
316 } // end of Anasazi namespace
317 
318 #endif // end of file ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
EpetraMultiVecAccessor is an interfaceto allow any Anasazi::MultiVec implementation that is based on ...
EpetraSpecializedMultiVecFailure is thrown when a return value from an Epetra call on an Epetra_Multi...
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
ptrdiff_t GetGlobalLength() const
The number of rows in the multivector.
void MvInit(double alpha)
Replace each element of the vectors in *this with alpha.
int GetNumberVecs() const
Obtain the vector length of *this.
An exception class parent to all Anasazi exceptions.
Interface for multivectors used by Anasazi&#39; linear solvers.
ConjType
Enumerated types used to specify conjugation arguments.
void MvScale(double alpha)
Scale each element of the vectors in *this with alpha.
Specialized adapter class for Anasazi::MultiVec that uses Epetra_MultiVector and Epetra_Operator to d...
const Epetra_MultiVector * GetEpetraMultiVec() const
Return the pointer to the Epetra_MultiVector object.
Anasazi header file which uses auto-configuration information to include necessary C++ headers...
void MvPrint(std::ostream &os) const
Print *this EpetraOpMultiVec.
Epetra_MultiVector * GetEpetraMultiVec()
Return the pointer to the Epetra_MultiVector object.
Templated virtual class for creating operators that can interface with the Anasazi::OperatorTraits cl...
Types and exceptions used within Anasazi solvers and interfaces.
void MvRandom()
Fill the vectors in *this with random numbers.
Epetra_DataAccess
Interface for multivectors used by Anasazi&#39;s linear solvers.
Declarations of Anasazi multi-vector and operator classes using Epetra_MultiVector and Epetra_Operato...