Anasazi Version of the Day
AnasaziSpecializedEpetraAdapter.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                 Anasazi: Block Eigensolvers Package
00005 //                 Copyright (2004) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 // @HEADER
00028 
00033 #ifndef ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
00034 #define ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
00035 
00036 #include "AnasaziConfigDefs.hpp"
00037 #include "Anasaziepetra_DLLExportMacro.h"
00038 #include "AnasaziTypes.hpp"
00039 #include "AnasaziMultiVec.hpp"
00040 #include "AnasaziOperator.hpp"
00041 
00042 #include "Teuchos_Assert.hpp"
00043 #include "Teuchos_SerialDenseMatrix.hpp"
00044 #include "Teuchos_RCP.hpp"
00045 #include "Epetra_MultiVector.h"
00046 #include "Epetra_Vector.h"
00047 #include "Epetra_Operator.h"
00048 #include "Epetra_Map.h"
00049 #include "Epetra_LocalMap.h"
00050 
00051 #if defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
00052 #  include <Tpetra_ConfigDefs.hpp> // HAVE_TPETRA_EPETRA 
00053 #  if defined(HAVE_TPETRA_EPETRA)
00054 #    include <Epetra_TsqrAdaptor.hpp>
00055 #  endif // defined(HAVE_TPETRA_EPETRA)
00056 #endif // defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
00057 
00058 namespace Anasazi {
00059 
00061 
00062 
00066   class EpetraSpecializedMultiVecFailure : public AnasaziError {public:
00067     EpetraSpecializedMultiVecFailure(const std::string& what_arg) : AnasaziError(what_arg)
00068     {}};
00069 
00071   
00073   //
00074   //--------template class AnasaziEpetraOpMultiVec-----------------
00075   //
00077   
00084   class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraOpMultiVec : public MultiVec<double> {
00085   public:
00087 
00088 
00090 
00096     EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, const int numvecs);
00097 
00099 
00108     EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, double * array, const int numvecs, const int stride=0);
00109 
00111 
00117     EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, Epetra_DataAccess CV, const Epetra_MultiVector& P_vec, const std::vector<int>& index);
00118 
00120     EpetraOpMultiVec(const EpetraOpMultiVec& P_vec);
00121 
00123     virtual ~EpetraOpMultiVec() {};
00124 
00126 
00128 
00129 
00134     MultiVec<double> * Clone ( const int numvecs ) const;
00135 
00141     MultiVec<double> * CloneCopy () const;
00142 
00150     MultiVec<double> * CloneCopy ( const std::vector<int>& index ) const;
00151     
00159     MultiVec<double> * CloneViewNonConst ( const std::vector<int>& index );
00160 
00168     const MultiVec<double> * CloneView ( const std::vector<int>& index ) const;
00169 
00171 
00173     Teuchos::RCP<Epetra_MultiVector> GetEpetraMultiVector() { return Epetra_MV; }
00174 
00176 
00177 
00179     int GetNumberVecs () const { return Epetra_MV->NumVectors(); }
00180 
00182     int GetVecLength () const { return Epetra_MV->GlobalLength(); }
00183 
00185 
00187 
00188 
00190     void MvTimesMatAddMv ( double alpha, const MultiVec<double>& A, 
00191                            const Teuchos::SerialDenseMatrix<int,double>& B, 
00192                            double beta );
00193 
00196     void MvAddMv ( double alpha, const MultiVec<double>& A, 
00197                    double beta, const MultiVec<double>& B);
00198 
00201     void MvTransMv ( double alpha, const MultiVec<double>& A, Teuchos::SerialDenseMatrix<int,double>& B 
00202 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00203         , ConjType conj = Anasazi::CONJ
00204 #endif
00205         ) const;
00206   
00209     void MvDot ( const MultiVec<double>& A, std::vector<double> &b
00210 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00211         , ConjType conj = Anasazi::CONJ
00212 #endif
00213         ) const;
00214 
00217     void MvScale ( double alpha ) { 
00218       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Scale( alpha )!=0, EpetraSpecializedMultiVecFailure,
00219           "Anasazi::EpetraOpMultiVec::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
00220     }
00221     
00224     void MvScale ( const std::vector<double>& alpha );
00225 
00227 
00228 
00229     
00233     void MvNorm ( std::vector<double> & normvec ) const;
00234     
00236     
00238 
00239 
00244     void SetBlock ( const MultiVec<double>& A, const std::vector<int>& index );
00245 
00248     void MvRandom() { 
00249       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Random()!=0, EpetraSpecializedMultiVecFailure,
00250           "Anasazi::EpetraOpMultiVec::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
00251     }
00252 
00255     void MvInit ( double alpha ) { 
00256       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->PutScalar( alpha )!=0, EpetraSpecializedMultiVecFailure,
00257           "Anasazi::EpetraOpMultiVec::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
00258     } 
00259     
00261 
00262 
00263 
00265     void MvPrint( std::ostream& os ) const { Epetra_MV->Print( os ); }
00267 
00268   private:
00269 //use pragmas to disable some false-positive warnings for windows 
00270 // sharedlibs export
00271 #ifdef _MSC_VER
00272 #pragma warning(push)
00273 #pragma warning(disable:4251)
00274 #endif
00275     Teuchos::RCP<Epetra_Operator> Epetra_OP;
00276     Teuchos::RCP<Epetra_MultiVector> Epetra_MV;
00277     Teuchos::RCP<Epetra_MultiVector> Epetra_MV_Temp;
00278 #ifdef _MSC_VER
00279 #pragma warning(pop)
00280 #endif
00281   };
00282   
00283 } // end of Anasazi namespace 
00284 
00285 #endif 
00286 // end of file  ANASAZI_SPECIALIZED_EPETRA_MULTIVEC_ADAPTER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends