Epetra Package Browser (Single Doxygen Collection) Development
Epetra_JadMatrix.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_JADMATRIX_H
00045 #define EPETRA_JADMATRIX_H
00046 
00047 #include "Epetra_BasicRowMatrix.h"
00048 #include "Epetra_Map.h"
00049 #include "Epetra_Comm.h"
00050 #include "Epetra_SerialDenseVector.h"
00051 #include "Epetra_IntSerialDenseVector.h"
00052 
00053 
00054 class Epetra_Vector;
00055 class Epetra_MultiVector;
00056 class Epetra_Import;
00057 class Epetra_Export;
00058 
00060 
00068 class EPETRA_LIB_DLL_EXPORT Epetra_JadMatrix: public Epetra_BasicRowMatrix {
00069       
00070  public:
00071 
00073 
00074 
00075   /* The constructor for this class requires a fully constructed instance of an Epetra_RowMatrix
00076      object.
00077      \param Matrix (In) An existing Epetra_RowMatrix.
00078      \pre Matrix must have Matrix.Filled()==true.
00079   */
00080   Epetra_JadMatrix(const Epetra_RowMatrix & Matrix);
00081 
00083   virtual ~Epetra_JadMatrix();
00085   
00087 
00088 
00089   /* Updates the values only using a matrix that has exactly the same structure as
00090      the matrix used to construct this Epetra_JadMatrix object.  Once the constructor
00091      is called, the Matrix argument is no longer needed.
00092      \param Matrix (In) An existing Epetra_RowMatrix with \e identical structure to 
00093             the matrix used to create this Epetra_JadMatrix.
00094      \param CheckStructure (In) Optional argument, by default is false.  If set to true, 
00095             the method will check to see if the structure of Matrix is compatible with
00096       the structure of matrix used to create this Epetra_JadMatrix.  Performing
00097       this check has signficant overhead, so it should only be turned on for debugging.
00098      \pre Matrix must have Matrix.Filled()==true.
00099   */ 
00100   int UpdateValues(const Epetra_RowMatrix & Matrix, bool CheckStructure = false);
00102   
00104 
00105 
00107 
00116     int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
00117 
00119 
00127     int ExtractMyEntryView(int CurEntry, double * &Value, int & RowIndex, int & ColIndex) { 
00128       if (CurEntry>=NumMyNonzeros_) EPETRA_CHK_ERR(-1); 
00129       Value = &Values_[CurEntry];
00130       ColIndex = Indices_[CurEntry];
00131       for (int j=0; j<NumJaggedDiagonals_; j++) if (CurEntry<IndexOffset_[j+1]) {RowIndex = RowPerm_[CurEntry-IndexOffset_[j]]; break;}
00132       return(0);
00133     }
00134 
00136 
00144     int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const { 
00145       if (CurEntry>=NumMyNonzeros_) EPETRA_CHK_ERR(-1); 
00146       Value = &Values_[CurEntry];
00147       ColIndex = Indices_[CurEntry];
00148       for (int j=0; j<NumJaggedDiagonals_; j++) if (CurEntry<IndexOffset_[j+1]) {RowIndex = RowPerm_[CurEntry-IndexOffset_[j]]; break;}
00149       return(0);
00150     }
00151 
00153 
00162     int NumMyRowEntries(int MyRow, int & NumEntries) const;
00163 
00165 
00167 
00168 
00170 
00180     int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00181 
00183 
00197     int Solve(bool Upper, bool Trans, bool UnitDiagonal,
00198               const Epetra_MultiVector& X,
00199               Epetra_MultiVector& Y) const
00200     {
00201       (void)Upper;
00202       (void)Trans;
00203       (void)UnitDiagonal;
00204       (void)X;
00205       (void)Y;
00206       return(-1);
00207     }
00209 
00210 
00211 
00212  protected:
00213 
00214   void GeneralMV(bool TransA, double * x, double * y) const;
00215   void GeneralMM(bool TransA, double ** X, int LDX, double ** Y, int LDY, int NumVectors) const;
00216   void GeneralMM3RHS(bool TransA, double ** X, int LDX, double ** Y, int LDY, int NumVectors) const;
00217   void GeneralMM2RHS(bool TransA, double * x, int ldx, double * y, int ldy) const;
00218   void Allocate(const Epetra_RowMatrix & Matrix);
00219 
00220   Epetra_SerialDenseVector Values_;
00221   Epetra_IntSerialDenseVector Indices_;
00222   Epetra_IntSerialDenseVector IndexOffset_;
00223   Epetra_IntSerialDenseVector Profile_;
00224   Epetra_IntSerialDenseVector RowPerm_;
00225   Epetra_IntSerialDenseVector InvRowPerm_;
00226   int NumJaggedDiagonals_;
00227 
00228 };
00229 #endif /* EPETRA_JADMATRIX_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines