Anasazi Version of the Day
Loading...
Searching...
No Matches
AnasaziSpecializedEpetraAdapter.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Anasazi: Block Eigensolvers Package
4//
5// Copyright 2004 NTESS and the Anasazi contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
14#ifndef ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
15#define ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
16
17#include "AnasaziConfigDefs.hpp"
18#include "Anasaziepetra_DLLExportMacro.h"
19#include "AnasaziTypes.hpp"
20#include "AnasaziMultiVec.hpp"
21#include "AnasaziOperator.hpp"
23
24#include "Teuchos_Assert.hpp"
25#include "Teuchos_SerialDenseMatrix.hpp"
26#include "Teuchos_RCP.hpp"
27#include "Epetra_MultiVector.h"
28#include "Epetra_Vector.h"
29#include "Epetra_Operator.h"
30#include "Epetra_Map.h"
31#include "Epetra_LocalMap.h"
32
33#if defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
34# include <Tpetra_ConfigDefs.hpp> // HAVE_TPETRA_EPETRA
35# if defined(HAVE_TPETRA_EPETRA)
36# include <Epetra_TsqrAdaptor.hpp>
37# endif // defined(HAVE_TPETRA_EPETRA)
38#endif // defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
39
40namespace Anasazi {
41
43
44
49 EpetraSpecializedMultiVecFailure(const std::string& what_arg) : AnasaziError(what_arg)
50 {}};
51
53
55 //
56 //--------template class AnasaziEpetraOpMultiVec-----------------
57 //
59
66 class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraOpMultiVec : public MultiVec<double>, public EpetraMultiVecAccessor {
67 public:
69
70
72
78 EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, const int numvecs);
79
81
90 EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, double * array, const int numvecs, const int stride=0);
91
93
99 EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, Epetra_DataAccess CV, const Epetra_MultiVector& P_vec, const std::vector<int>& index);
100
103
105 virtual ~EpetraOpMultiVec() {};
106
108
110
111
116 MultiVec<double> * Clone ( const int numvecs ) const;
117
123 MultiVec<double> * CloneCopy () const;
124
132 MultiVec<double> * CloneCopy ( const std::vector<int>& index ) const;
133
141 MultiVec<double> * CloneViewNonConst ( const std::vector<int>& index );
142
150 const MultiVec<double> * CloneView ( const std::vector<int>& index ) const;
151
153
155 Teuchos::RCP<Epetra_MultiVector> GetEpetraMultiVector() { return Epetra_MV; }
156
158
159
161 ptrdiff_t GetGlobalLength () const
162 {
163 if ( Epetra_MV->Map().GlobalIndicesLongLong() )
164 return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength64() );
165 else
166 return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength() );
167 }
168
170 int GetNumberVecs () const { return Epetra_MV->NumVectors(); }
171
173
175
176
178 void MvTimesMatAddMv ( double alpha, const MultiVec<double>& A,
179 const Teuchos::SerialDenseMatrix<int,double>& B,
180 double beta );
181
184 void MvAddMv ( double alpha, const MultiVec<double>& A,
185 double beta, const MultiVec<double>& B);
186
189 void MvTransMv ( double alpha, const MultiVec<double>& A, Teuchos::SerialDenseMatrix<int,double>& B
190#ifdef HAVE_ANASAZI_EXPERIMENTAL
191 , ConjType conj = Anasazi::CONJ
192#endif
193 ) const;
194
197 void MvDot ( const MultiVec<double>& A, std::vector<double> &b
198#ifdef HAVE_ANASAZI_EXPERIMENTAL
199 , ConjType conj = Anasazi::CONJ
200#endif
201 ) const;
202
205 void MvScale ( double alpha ) {
206 TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Scale( alpha )!=0, EpetraSpecializedMultiVecFailure,
207 "Anasazi::EpetraOpMultiVec::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
208 }
209
212 void MvScale ( const std::vector<double>& alpha );
213
215
217
221 void MvNorm ( std::vector<double> & normvec ) const;
222
224
226
227
232 void SetBlock ( const MultiVec<double>& A, const std::vector<int>& index );
233
236 void MvRandom() {
237 TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Random()!=0, EpetraSpecializedMultiVecFailure,
238 "Anasazi::EpetraOpMultiVec::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
239 }
240
243 void MvInit ( double alpha ) {
244 TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->PutScalar( alpha )!=0, EpetraSpecializedMultiVecFailure,
245 "Anasazi::EpetraOpMultiVec::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
246 }
247
249
250
252 Epetra_MultiVector* GetEpetraMultiVec() { return &*Epetra_MV; };
253
255 const Epetra_MultiVector* GetEpetraMultiVec() const { return &*Epetra_MV; };
256
258
260
262
264 void MvPrint( std::ostream& os ) const { Epetra_MV->Print( os ); }
265
267
268 private:
269//use pragmas to disable some false-positive warnings for windows
270// sharedlibs export
271#ifdef _MSC_VER
272#pragma warning(push)
273#pragma warning(disable:4251)
274#endif
275 Teuchos::RCP<Epetra_Operator> Epetra_OP;
276 Teuchos::RCP<Epetra_MultiVector> Epetra_MV;
277 Teuchos::RCP<Epetra_MultiVector> Epetra_MV_Temp;
278#ifdef _MSC_VER
279#pragma warning(pop)
280#endif
281 };
282
283
284} // end of Anasazi namespace
285
286#endif // end of file ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
Declarations of Anasazi multi-vector and operator classes using Epetra_MultiVector and Epetra_Operato...
Interface for multivectors used by Anasazi' linear solvers.
Templated virtual class for creating operators that can interface with the Anasazi::OperatorTraits cl...
Types and exceptions used within Anasazi solvers and interfaces.
An exception class parent to all Anasazi exceptions.
EpetraMultiVecAccessor is an interfaceto allow any Anasazi::MultiVec implementation that is based on ...
Specialized adapter class for Anasazi::MultiVec that uses Epetra_MultiVector and Epetra_Operator to d...
void MvScale(double alpha)
Scale each element of the vectors in *this with alpha.
void MvPrint(std::ostream &os) const
Print *this EpetraOpMultiVec.
ptrdiff_t GetGlobalLength() const
The number of rows in the multivector.
const Epetra_MultiVector * GetEpetraMultiVec() const
Return the pointer to the Epetra_MultiVector object.
void MvInit(double alpha)
Replace each element of the vectors in *this with alpha.
void MvRandom()
Fill the vectors in *this with random numbers.
int GetNumberVecs() const
Obtain the vector length of *this.
Epetra_MultiVector * GetEpetraMultiVec()
Return the pointer to the Epetra_MultiVector object.
EpetraSpecializedMultiVecFailure is thrown when a return value from an Epetra call on an Epetra_Multi...
Interface for multivectors used by Anasazi's linear solvers.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.
ConjType
Enumerated types used to specify conjugation arguments.