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 #include "AnasaziEpetraAdapter.hpp"
00042 
00043 #include "Teuchos_Assert.hpp"
00044 #include "Teuchos_SerialDenseMatrix.hpp"
00045 #include "Teuchos_RCP.hpp"
00046 #include "Epetra_MultiVector.h"
00047 #include "Epetra_Vector.h"
00048 #include "Epetra_Operator.h"
00049 #include "Epetra_Map.h"
00050 #include "Epetra_LocalMap.h"
00051 
00052 #if defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
00053 #  include <Tpetra_ConfigDefs.hpp> // HAVE_TPETRA_EPETRA 
00054 #  if defined(HAVE_TPETRA_EPETRA)
00055 #    include <Epetra_TsqrAdaptor.hpp>
00056 #  endif // defined(HAVE_TPETRA_EPETRA)
00057 #endif // defined(HAVE_ANASAZI_TPETRA) && defined(HAVE_ANASAZI_TSQR)
00058 
00059 namespace Anasazi {
00060 
00062 
00063 
00067   class EpetraSpecializedMultiVecFailure : public AnasaziError {public:
00068     EpetraSpecializedMultiVecFailure(const std::string& what_arg) : AnasaziError(what_arg)
00069     {}};
00070 
00072   
00074   //
00075   //--------template class AnasaziEpetraOpMultiVec-----------------
00076   //
00078   
00085   class ANASAZIEPETRA_LIB_DLL_EXPORT EpetraOpMultiVec : public MultiVec<double>, public EpetraMultiVecAccessor {
00086   public:
00088 
00089 
00091 
00097     EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, const int numvecs);
00098 
00100 
00109     EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, const Epetra_BlockMap& Map_in, double * array, const int numvecs, const int stride=0);
00110 
00112 
00118     EpetraOpMultiVec(const Teuchos::RCP<Epetra_Operator> &Op, Epetra_DataAccess CV, const Epetra_MultiVector& P_vec, const std::vector<int>& index);
00119 
00121     EpetraOpMultiVec(const EpetraOpMultiVec& P_vec);
00122 
00124     virtual ~EpetraOpMultiVec() {};
00125 
00127 
00129 
00130 
00135     MultiVec<double> * Clone ( const int numvecs ) const;
00136 
00142     MultiVec<double> * CloneCopy () const;
00143 
00151     MultiVec<double> * CloneCopy ( const std::vector<int>& index ) const;
00152     
00160     MultiVec<double> * CloneViewNonConst ( const std::vector<int>& index );
00161 
00169     const MultiVec<double> * CloneView ( const std::vector<int>& index ) const;
00170 
00172 
00174     Teuchos::RCP<Epetra_MultiVector> GetEpetraMultiVector() { return Epetra_MV; }
00175 
00177 
00178 
00180     int GetVecLength () const { return Epetra_MV->GlobalLength(); }
00181 
00184     ptrdiff_t GetGlobalLength () const 
00185     {
00186        if ( Epetra_MV->Map().GlobalIndicesLongLong() )
00187           return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength64() );       
00188        else
00189           return static_cast<ptrdiff_t>( Epetra_MV->GlobalLength() ); 
00190     }
00191 
00193     int GetNumberVecs () const { return Epetra_MV->NumVectors(); }
00194 
00196 
00198 
00199 
00201     void MvTimesMatAddMv ( double alpha, const MultiVec<double>& A, 
00202                            const Teuchos::SerialDenseMatrix<int,double>& B, 
00203                            double beta );
00204 
00207     void MvAddMv ( double alpha, const MultiVec<double>& A, 
00208                    double beta, const MultiVec<double>& B);
00209 
00212     void MvTransMv ( double alpha, const MultiVec<double>& A, Teuchos::SerialDenseMatrix<int,double>& B 
00213 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00214         , ConjType conj = Anasazi::CONJ
00215 #endif
00216         ) const;
00217   
00220     void MvDot ( const MultiVec<double>& A, std::vector<double> &b
00221 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00222         , ConjType conj = Anasazi::CONJ
00223 #endif
00224         ) const;
00225 
00228     void MvScale ( double alpha ) { 
00229       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Scale( alpha )!=0, EpetraSpecializedMultiVecFailure,
00230           "Anasazi::EpetraOpMultiVec::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
00231     }
00232     
00235     void MvScale ( const std::vector<double>& alpha );
00236 
00238 
00239 
00240     
00244     void MvNorm ( std::vector<double> & normvec ) const;
00245     
00247     
00249 
00250 
00255     void SetBlock ( const MultiVec<double>& A, const std::vector<int>& index );
00256 
00259     void MvRandom() { 
00260       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Random()!=0, EpetraSpecializedMultiVecFailure,
00261           "Anasazi::EpetraOpMultiVec::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
00262     }
00263 
00266     void MvInit ( double alpha ) { 
00267       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->PutScalar( alpha )!=0, EpetraSpecializedMultiVecFailure,
00268           "Anasazi::EpetraOpMultiVec::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
00269     } 
00270    
00272 
00273 
00275     Epetra_MultiVector* GetEpetraMultiVec() { return &*Epetra_MV; };
00276 
00278     const Epetra_MultiVector* GetEpetraMultiVec() const { return &*Epetra_MV; };
00279 
00281  
00283 
00284 
00285 
00287     void MvPrint( std::ostream& os ) const { Epetra_MV->Print( os ); }
00288 
00290 
00291   private:
00292 //use pragmas to disable some false-positive warnings for windows 
00293 // sharedlibs export
00294 #ifdef _MSC_VER
00295 #pragma warning(push)
00296 #pragma warning(disable:4251)
00297 #endif
00298     Teuchos::RCP<Epetra_Operator> Epetra_OP;
00299     Teuchos::RCP<Epetra_MultiVector> Epetra_MV;
00300     Teuchos::RCP<Epetra_MultiVector> Epetra_MV_Temp;
00301 #ifdef _MSC_VER
00302 #pragma warning(pop)
00303 #endif
00304   };
00305 
00306  
00307 } // end of Anasazi namespace 
00308 
00309 #endif // end of file ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends