Anasazi  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
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 GetNumberVecs () const { return Epetra_MV->NumVectors(); }
00181 
00183     int GetVecLength () const { return Epetra_MV->GlobalLength(); }
00184 
00186 
00188 
00189 
00191     void MvTimesMatAddMv ( double alpha, const MultiVec<double>& A, 
00192                            const Teuchos::SerialDenseMatrix<int,double>& B, 
00193                            double beta );
00194 
00197     void MvAddMv ( double alpha, const MultiVec<double>& A, 
00198                    double beta, const MultiVec<double>& B);
00199 
00202     void MvTransMv ( double alpha, const MultiVec<double>& A, Teuchos::SerialDenseMatrix<int,double>& B 
00203 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00204         , ConjType conj = Anasazi::CONJ
00205 #endif
00206         ) const;
00207   
00210     void MvDot ( const MultiVec<double>& A, std::vector<double> &b
00211 #ifdef HAVE_ANASAZI_EXPERIMENTAL
00212         , ConjType conj = Anasazi::CONJ
00213 #endif
00214         ) const;
00215 
00218     void MvScale ( double alpha ) { 
00219       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Scale( alpha )!=0, EpetraSpecializedMultiVecFailure,
00220           "Anasazi::EpetraOpMultiVec::MvScale call to Epetra_MultiVector::Scale() returned a nonzero value.");
00221     }
00222     
00225     void MvScale ( const std::vector<double>& alpha );
00226 
00228 
00229 
00230     
00234     void MvNorm ( std::vector<double> & normvec ) const;
00235     
00237     
00239 
00240 
00245     void SetBlock ( const MultiVec<double>& A, const std::vector<int>& index );
00246 
00249     void MvRandom() { 
00250       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->Random()!=0, EpetraSpecializedMultiVecFailure,
00251           "Anasazi::EpetraOpMultiVec::MvRandom call to Epetra_MultiVector::Random() returned a nonzero value.");
00252     }
00253 
00256     void MvInit ( double alpha ) { 
00257       TEUCHOS_TEST_FOR_EXCEPTION( Epetra_MV->PutScalar( alpha )!=0, EpetraSpecializedMultiVecFailure,
00258           "Anasazi::EpetraOpMultiVec::MvInit call to Epetra_MultiVector::PutScalar() returned a nonzero value.");
00259     } 
00260    
00262 
00263 
00265     Epetra_MultiVector* GetEpetraMultiVec() { return &*Epetra_MV; };
00266 
00268     const Epetra_MultiVector* GetEpetraMultiVec() const { return &*Epetra_MV; };
00269 
00271  
00273 
00274 
00275 
00277     void MvPrint( std::ostream& os ) const { Epetra_MV->Print( os ); }
00278 
00280 
00281   private:
00282 //use pragmas to disable some false-positive warnings for windows 
00283 // sharedlibs export
00284 #ifdef _MSC_VER
00285 #pragma warning(push)
00286 #pragma warning(disable:4251)
00287 #endif
00288     Teuchos::RCP<Epetra_Operator> Epetra_OP;
00289     Teuchos::RCP<Epetra_MultiVector> Epetra_MV;
00290     Teuchos::RCP<Epetra_MultiVector> Epetra_MV_Temp;
00291 #ifdef _MSC_VER
00292 #pragma warning(pop)
00293 #endif
00294   };
00295 
00296  
00297 } // end of Anasazi namespace 
00298 
00299 #endif // end of file ANASAZI_SPECIALIZED_EPETRA_ADAPTER_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends