Epetra Package Browser (Single Doxygen Collection) Development
Epetra_VbrRowMatrix.h
Go to the documentation of this file.
00001 /*
00002 //@HEADER
00003 // ************************************************************************
00004 //
00005 //               Epetra: Linear Algebra Services Package
00006 //                 Copyright 2011 Sandia Corporation
00007 //
00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00009 // the U.S. Government retains certain rights in this software.
00010 //
00011 // Redistribution and use in source and binary forms, with or without
00012 // modification, are permitted provided that the following conditions are
00013 // met:
00014 //
00015 // 1. Redistributions of source code must retain the above copyright
00016 // notice, this list of conditions and the following disclaimer.
00017 //
00018 // 2. Redistributions in binary form must reproduce the above copyright
00019 // notice, this list of conditions and the following disclaimer in the
00020 // documentation and/or other materials provided with the distribution.
00021 //
00022 // 3. Neither the name of the Corporation nor the names of the
00023 // contributors may be used to endorse or promote products derived from
00024 // this software without specific prior written permission.
00025 //
00026 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00027 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00028 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00029 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00030 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00031 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00032 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00033 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00034 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00035 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00036 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00037 //
00038 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00039 //
00040 // ************************************************************************
00041 //@HEADER
00042 */
00043 
00044 #ifndef EPETRA_VBRROWMATRIX_H
00045 #define EPETRA_VBRROWMATRIX_H
00046 
00047 #include "Epetra_BasicRowMatrix.h"
00048 #include "Epetra_VbrMatrix.h"
00049 #include "Epetra_Map.h"
00050 #include "Epetra_Comm.h"
00051 #include "Epetra_Vector.h"
00052 #include "Epetra_MultiVector.h"
00053 
00055 
00068 class Epetra_VbrRowMatrix: public Epetra_BasicRowMatrix {
00069 
00070  public:
00071 
00073 
00074 
00075   /* The constructor for this class requires a pointer to a fully constructed instance of an Epetra_VbrMatrix
00076      object.
00077      \param Matrix (In) Pointer to an existing Epetra_VbrMatrix. The input matrix must be retained by the user
00078      throughout the existance of the dependent Epetra_VbrRowmatrix object.
00079      \pre Matrix must have Matrix->Filled()==true.
00080   */
00081   Epetra_VbrRowMatrix(Epetra_VbrMatrix * Matrix): Epetra_BasicRowMatrix(Matrix->Comm()), matrix_(Matrix) {
00082   if (Matrix==0) throw Matrix->RowMatrixRowMap().ReportError("Input matrix must have called FillComplete()", -1);
00083   SetMaps(Matrix->RowMatrixRowMap(), Matrix->RowMatrixColMap(), Matrix->OperatorDomainMap(), Matrix->OperatorRangeMap());
00084   if (!Matrix->Filled()) throw Matrix->RowMatrixRowMap().ReportError("Input matrix must have called FillComplete()", -1);
00085   SetLabel("Epetra::VbrRowMatrix");
00086 }
00087 
00089     virtual ~Epetra_VbrRowMatrix(){}
00091 
00093 
00094 
00095   /* Updates the matrix that the Epetra_VbrRowMatrix will use to satisfy the Epetra_RowMatrix functionality.
00096      \param Matrix (In) A pointer to an existing, fully constructed Epetra_VbrMatrix.
00097      \pre Matrix must have Matrix->Filled()==true.
00098   */
00099   int UpdateMatrix(Epetra_VbrMatrix * Matrix){
00100     if (Matrix ==0) {
00101       EPETRA_CHK_ERR(-1);
00102     }
00103     else matrix_ = Matrix;
00104     return(0);
00105   }
00107 
00109 
00110 
00112 
00121   int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const {
00122 
00123     EPETRA_CHK_ERR(matrix_->ExtractMyRowCopy(MyRow, Length, NumEntries, Values, Indices));
00124     return(0);
00125   }
00126 
00128 
00136     int ExtractMyEntryView(int CurEntry, double * &Value, int & RowIndex, int & ColIndex) {
00137       return(-1);
00138     }
00139 
00141 
00149     int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const {
00150       return(-1);
00151     }
00152 
00154 
00163     int NumMyRowEntries(int MyRow, int & NumEntries) const {
00164       EPETRA_CHK_ERR(matrix_->NumMyRowEntries(MyRow, NumEntries));
00165       return(0);
00166     }
00167 
00169 
00171 
00172 
00174 
00181     int RightScale(const Epetra_Vector& x){
00182       HaveNumericConstants_ = false;
00183       UpdateFlops(NumGlobalNonzeros());
00184       EPETRA_CHK_ERR(matrix_->RightScale(x));
00185       return(0);
00186     }
00187 
00189 
00196     int LeftScale(const Epetra_Vector& x){
00197       HaveNumericConstants_ = false;
00198       UpdateFlops(NumGlobalNonzeros());
00199       EPETRA_CHK_ERR(matrix_->LeftScale(x));
00200       return(0);
00201     }
00202 
00204 
00214     int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const{
00215       EPETRA_CHK_ERR(matrix_->Multiply(TransA, X, Y));
00216       return(0);
00217     }
00218 
00220 
00234     int Solve(bool Upper, bool Trans, bool UnitDiagonal,
00235               const Epetra_MultiVector& X,
00236               Epetra_MultiVector& Y) const {
00237       EPETRA_CHK_ERR(matrix_->Solve(Upper, Trans, UnitDiagonal, X, Y));
00238       return(0);
00239     }  //@}
00240 
00241 
00242 
00243  private:
00244 
00245     Epetra_VbrMatrix * matrix_;
00246 
00247 };
00248 #endif /* EPETRA_VBRROWMATRIX_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines