30 #include "Teuchos_ScalarTraits.hpp" 49 Epetra_MV = Teuchos::rcp(
new Epetra_MultiVector(Map_in, numvecs) );
50 Epetra_MV_Temp = Teuchos::rcp(
new Epetra_MultiVector(Map_in, numvecs) );
54 const Epetra_BlockMap& Map_in,
double * array,
const int numvecs,
const int stride)
57 Epetra_MV = Teuchos::rcp(
new Epetra_MultiVector(Copy, Map_in, array, stride, numvecs) );
58 Epetra_MV_Temp = Teuchos::rcp(
new Epetra_MultiVector(Map_in, numvecs) );
62 Epetra_DataAccess CV,
const Epetra_MultiVector& P_vec,
const std::vector<int>& index)
65 Epetra_MV = Teuchos::rcp(
new Epetra_MultiVector(CV, P_vec, &(
const_cast<std::vector<int> &
>(index))[0], index.size()) );
66 Epetra_MV_Temp = Teuchos::rcp(
new Epetra_MultiVector( P_vec.Map(), index.size()) );
70 : Epetra_OP( P_vec.Epetra_OP )
72 Epetra_MV = Teuchos::rcp(
new Epetra_MultiVector( *(P_vec.Epetra_MV) ) );
73 Epetra_MV_Temp = Teuchos::rcp(
new Epetra_MultiVector( *(P_vec.Epetra_MV_Temp) ) );
128 int numvecs = index.size();
130 std::vector<int> index2( numvecs );
131 for(
int i=0; i<numvecs; i++)
134 TEUCHOS_TEST_FOR_EXCEPTION( tmp_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::SetBlocks() cast of MultiVec<double> to EpetraOpMultiVec failed.");
135 EpetraOpMultiVec A_vec(Epetra_OP, View, *(tmp_vec->GetEpetraMultiVector()), index2);
136 temp_vec.
MvAddMv( 1.0, A_vec, 0.0, A_vec );
139 temp_vec.
MvAddMv( 1.0, A, 0.0, A );
150 const Teuchos::SerialDenseMatrix<int,double>& B,
double beta )
152 Epetra_LocalMap LocalMap(B.numRows(), 0, Epetra_MV->Map().Comm());
153 Epetra_MultiVector B_Pvec(View, LocalMap, B.values(), B.stride(), B.numCols());
156 TEUCHOS_TEST_FOR_EXCEPTION( A_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::SetBlocks() cast of MultiVec<double> to EpetraOpMultiVec failed.");
158 TEUCHOS_TEST_FOR_EXCEPTION(
159 Epetra_MV->Multiply(
'N',
'N', alpha, *(A_vec->GetEpetraMultiVector()), B_Pvec, beta ) != 0,
173 TEUCHOS_TEST_FOR_EXCEPTION( A_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::MvAddMv() cast of MultiVec<double> to EpetraOpMultiVec failed.");
175 TEUCHOS_TEST_FOR_EXCEPTION( B_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::MvAddMv() cast of MultiVec<double> to EpetraOpMultiVec failed.");
177 TEUCHOS_TEST_FOR_EXCEPTION(
178 Epetra_MV->Update( alpha, *(A_vec->GetEpetraMultiVector()), beta, *(B_vec->GetEpetraMultiVector()), 0.0 ) != 0,
189 Teuchos::SerialDenseMatrix<int,double>& B
190 #ifdef HAVE_ANASAZI_EXPERIMENTAL
198 Epetra_LocalMap LocalMap(B.numRows(), 0, Epetra_MV->Map().Comm());
199 Epetra_MultiVector B_Pvec(View, LocalMap, B.values(), B.stride(), B.numCols());
201 int info = Epetra_OP->Apply( *Epetra_MV, *Epetra_MV_Temp );
203 "Anasazi::EpetraOpMultiVec::MvTransMv(): Error returned from Epetra_Operator::Apply()" );
205 TEUCHOS_TEST_FOR_EXCEPTION(
206 B_Pvec.Multiply(
'T',
'N', alpha, *(A_vec->GetEpetraMultiVector()), *Epetra_MV_Temp, 0.0 ) != 0,
218 #ifdef HAVE_ANASAZI_EXPERIMENTAL
224 TEUCHOS_TEST_FOR_EXCEPTION( A_vec==NULL, std::invalid_argument,
"Anasazi::EpetraOpMultiVec::MvDot() cast of MultiVec<double> to EpetraOpMultiVec failed.");
226 int info = Epetra_OP->Apply( *Epetra_MV, *Epetra_MV_Temp );
228 "Anasazi::EpetraOpMultiVec::MvDot(): Error returned from Epetra_Operator::Apply()" );
231 TEUCHOS_TEST_FOR_EXCEPTION(
232 Epetra_MV_Temp->Dot( *(A_vec->GetEpetraMultiVector()), &b[0] ) != 0,
245 int info = Epetra_OP->Apply( *Epetra_MV, *Epetra_MV_Temp );
247 "Anasazi::EpetraOpMultiVec::MvNorm(): Error returned from Epetra_Operator::Apply()" );
249 if (( (
int)normvec.size() >= Epetra_MV->NumVectors() ) ) {
250 TEUCHOS_TEST_FOR_EXCEPTION(
251 Epetra_MV_Temp->Dot( *Epetra_MV, &normvec[0] ) != 0,
255 for (
int i=0; i<Epetra_MV->NumVectors(); ++i)
256 normvec[i] = Teuchos::ScalarTraits<double>::squareroot( normvec[i] );
268 TEUCHOS_TEST_FOR_EXCEPTION( (
int)alpha.size() != numvecs, std::invalid_argument,
269 "Anasazi::EpetraOpMultiVec::MvScale() alpha argument size was inconsistent with number of vectors in mv.");
271 std::vector<int> tmp_index( 1, 0 );
272 for (
int i=0; i<numvecs; i++) {
273 Epetra_MultiVector temp_vec(View, *Epetra_MV, &tmp_index[0], 1);
274 TEUCHOS_TEST_FOR_EXCEPTION(
275 temp_vec.Scale( alpha[i] ) != 0,
Declarations of specialized Anasazi multi-vector and operator classes using Epetra_MultiVector and Ep...
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 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...
const MultiVec< double > * CloneView(const std::vector< int > &index) const
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...
int GetNumberVecs() const
Obtain the vector length of *this.
EpetraOpMultiVec(const Teuchos::RCP< Epetra_Operator > &Op, const Epetra_BlockMap &Map_in, const int numvecs)
Basic EpetraOpMultiVec constructor.
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package...
ConjType
Enumerated types used to specify conjugation arguments.
virtual int GetNumberVecs() const =0
The number of vectors (i.e., columns) in the multivector.
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...
MultiVec< double > * CloneViewNonConst(const std::vector< int > &index)
Creates a new EpetraOpMultiVec that shares the selected contents of *this.
MultiVec< double > * CloneCopy() const
Creates a new EpetraOpMultiVec and copies contents of *this into the new vector (deep copy)...
MultiVec< double > * Clone(const int numvecs) const
Creates a new empty EpetraOpMultiVec containing numvecs columns.
void SetBlock(const MultiVec< double > &A, const std::vector< int > &index)
Copy the vectors in A to a set of vectors in *this.
void MvTimesMatAddMv(double alpha, const MultiVec< double > &A, const Teuchos::SerialDenseMatrix< int, double > &B, double beta)
Update *this with .
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 th...
void MvAddMv(double alpha, const MultiVec< double > &A, double beta, const MultiVec< double > &B)
Replace *this with .