43#include "Teuchos_ScalarTraits.hpp"
62 Epetra_MV = Teuchos::rcp(
new Epetra_MultiVector(Map_in, numvecs) );
63 Epetra_MV_Temp = Teuchos::rcp(
new Epetra_MultiVector(Map_in, numvecs) );
67 const Epetra_BlockMap& Map_in,
double * array,
const int numvecs,
const int stride)
70 Epetra_MV = Teuchos::rcp(
new Epetra_MultiVector(Epetra_DataAccess::Copy, Map_in, array, stride, numvecs) );
71 Epetra_MV_Temp = Teuchos::rcp(
new Epetra_MultiVector(Map_in, numvecs) );
75 Epetra_DataAccess CV,
const Epetra_MultiVector& P_vec,
const std::vector<int>& index)
78 Epetra_MV = Teuchos::rcp(
new Epetra_MultiVector(CV, P_vec, &(
const_cast<std::vector<int> &
>(index))[0], index.size()) );
79 Epetra_MV_Temp = Teuchos::rcp(
new Epetra_MultiVector( P_vec.Map(), index.size()) );
83 : Epetra_OP( P_vec.Epetra_OP )
85 Epetra_MV = Teuchos::rcp(
new Epetra_MultiVector( *(P_vec.Epetra_MV) ) );
86 Epetra_MV_Temp = Teuchos::rcp(
new Epetra_MultiVector( *(P_vec.Epetra_MV_Temp) ) );
139 EpetraOpMultiVec temp_vec(Epetra_OP, Epetra_DataAccess::View, *Epetra_MV, index);
141 int numvecs = index.size();
143 std::vector<int> index2( numvecs );
144 for(
int i=0; i<numvecs; i++)
147 TEUCHOS_TEST_FOR_EXCEPTION( tmp_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::SetBlocks() cast of MultiVec<double> to EpetraOpMultiVec failed.");
148 EpetraOpMultiVec A_vec(Epetra_OP, Epetra_DataAccess::View, *(tmp_vec->GetEpetraMultiVector()), index2);
149 temp_vec.
MvAddMv( 1.0, A_vec, 0.0, A_vec );
152 temp_vec.
MvAddMv( 1.0, A, 0.0, A );
163 const Teuchos::SerialDenseMatrix<int,double>& B,
double beta )
165 Epetra_LocalMap LocalMap(B.numRows(), 0, Epetra_MV->Map().Comm());
166 Epetra_MultiVector B_Pvec(Epetra_DataAccess::View, LocalMap, B.values(), B.stride(), B.numCols());
169 TEUCHOS_TEST_FOR_EXCEPTION( A_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::SetBlocks() cast of MultiVec<double> to EpetraOpMultiVec failed.");
171 TEUCHOS_TEST_FOR_EXCEPTION(
172 Epetra_MV->Multiply(
'N',
'N', alpha, *(A_vec->GetEpetraMultiVector()), B_Pvec, beta ) != 0,
186 TEUCHOS_TEST_FOR_EXCEPTION( A_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::MvAddMv() cast of MultiVec<double> to EpetraOpMultiVec failed.");
188 TEUCHOS_TEST_FOR_EXCEPTION( B_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::MvAddMv() cast of MultiVec<double> to EpetraOpMultiVec failed.");
190 TEUCHOS_TEST_FOR_EXCEPTION(
191 Epetra_MV->Update( alpha, *(A_vec->GetEpetraMultiVector()), beta, *(B_vec->GetEpetraMultiVector()), 0.0 ) != 0,
202 Teuchos::SerialDenseMatrix<int,double>& B
203#ifdef HAVE_ANASAZI_EXPERIMENTAL
211 Epetra_LocalMap LocalMap(B.numRows(), 0, Epetra_MV->Map().Comm());
212 Epetra_MultiVector B_Pvec(Epetra_DataAccess::View, LocalMap, B.values(), B.stride(), B.numCols());
214 int info = Epetra_OP->Apply( *Epetra_MV, *Epetra_MV_Temp );
216 "Anasazi::EpetraOpMultiVec::MvTransMv(): Error returned from Epetra_Operator::Apply()" );
218 TEUCHOS_TEST_FOR_EXCEPTION(
219 B_Pvec.Multiply(
'T',
'N', alpha, *(A_vec->GetEpetraMultiVector()), *Epetra_MV_Temp, 0.0 ) != 0,
231#ifdef HAVE_ANASAZI_EXPERIMENTAL
237 TEUCHOS_TEST_FOR_EXCEPTION( A_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::MvDot() cast of MultiVec<double> to EpetraOpMultiVec failed.");
239 int info = Epetra_OP->Apply( *Epetra_MV, *Epetra_MV_Temp );
241 "Anasazi::EpetraOpMultiVec::MvDot(): Error returned from Epetra_Operator::Apply()" );
244 TEUCHOS_TEST_FOR_EXCEPTION(
245 Epetra_MV_Temp->Dot( *(A_vec->GetEpetraMultiVector()), &b[0] ) != 0,
258 int info = Epetra_OP->Apply( *Epetra_MV, *Epetra_MV_Temp );
260 "Anasazi::EpetraOpMultiVec::MvNorm(): Error returned from Epetra_Operator::Apply()" );
262 if (( (
int)normvec.size() >= Epetra_MV->NumVectors() ) ) {
263 TEUCHOS_TEST_FOR_EXCEPTION(
264 Epetra_MV_Temp->Dot( *Epetra_MV, &normvec[0] ) != 0,
268 for (
int i=0; i<Epetra_MV->NumVectors(); ++i)
269 normvec[i] = Teuchos::ScalarTraits<double>::squareroot( normvec[i] );
281 TEUCHOS_TEST_FOR_EXCEPTION( (
int)alpha.size() != numvecs, std::invalid_argument,
282 "Anasazi::EpetraOpMultiVec::MvScale() alpha argument size was inconsistent with number of vectors in mv.");
284 std::vector<int> tmp_index( 1, 0 );
285 for (
int i=0; i<numvecs; i++) {
286 Epetra_MultiVector temp_vec(Epetra_DataAccess::View, *Epetra_MV, &tmp_index[0], 1);
287 TEUCHOS_TEST_FOR_EXCEPTION(
288 temp_vec.Scale( alpha[i] ) != 0,
Declarations of specialized Anasazi multi-vector and operator classes using Epetra_MultiVector and Ep...
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 MvDot(const MultiVec< double > &A, std::vector< double > &b) const
Compute a vector b where the components are the individual dot-products, i.e. where A[i] is the i-th...
MultiVec< double > * Clone(const int numvecs) const
Creates a new empty EpetraOpMultiVec containing numvecs columns.
void MvAddMv(double alpha, const MultiVec< double > &A, double beta, const MultiVec< double > &B)
Replace *this with .
MultiVec< double > * CloneCopy() const
Creates a new EpetraOpMultiVec and copies contents of *this into the new vector (deep copy).
const MultiVec< double > * CloneView(const std::vector< int > &index) const
Creates a new EpetraOpMultiVec that shares the selected contents of *this.
EpetraOpMultiVec(const Teuchos::RCP< Epetra_Operator > &Op, const Epetra_BlockMap &Map_in, const int numvecs)
Basic EpetraOpMultiVec constructor.
void MvTransMv(double alpha, const MultiVec< double > &A, Teuchos::SerialDenseMatrix< int, double > &B) const
Compute a dense matrix B through the matrix-matrix multiply .
void MvTimesMatAddMv(double alpha, const MultiVec< double > &A, const Teuchos::SerialDenseMatrix< int, double > &B, double beta)
Update *this with .
void SetBlock(const MultiVec< double > &A, const std::vector< int > &index)
Copy the vectors in A to a set of vectors in *this.
int GetNumberVecs() const
Obtain the vector length of *this.
void MvNorm(std::vector< double > &normvec) const
Compute the 2-norm of each individual vector of *this. Upon return, normvec[i] holds the 2-norm of ...
MultiVec< double > * CloneViewNonConst(const std::vector< int > &index)
Creates a new EpetraOpMultiVec that shares the selected contents of *this.
EpetraSpecializedMultiVecFailure is thrown when a return value from an Epetra call on an Epetra_Multi...
Interface for multivectors used by Anasazi's linear solvers.
virtual int GetNumberVecs() const =0
The number of vectors (i.e., columns) in the multivector.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.
ConjType
Enumerated types used to specify conjugation arguments.