Epetra_BasicRowMatrix.h

Go to the documentation of this file.
00001 
00002 //@HEADER
00003 /*
00004 ************************************************************************
00005 
00006               Epetra: Linear Algebra Services Package 
00007                 Copyright (2001) Sandia Corporation
00008 
00009 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00010 license for use of this work by or on behalf of the U.S. Government.
00011 
00012 This library is free software; you can redistribute it and/or modify
00013 it under the terms of the GNU Lesser General Public License as
00014 published by the Free Software Foundation; either version 2.1 of the
00015 License, or (at your option) any later version.
00016  
00017 This library is distributed in the hope that it will be useful, but
00018 WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 Lesser General Public License for more details.
00021  
00022 You should have received a copy of the GNU Lesser General Public
00023 License along with this library; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 USA
00026 Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00027 
00028 ************************************************************************
00029 */
00030 //@HEADER
00031 
00032 #ifndef EPETRA_BASICROWMATRIX_H
00033 #define EPETRA_BASICROWMATRIX_H
00034 
00035 #include "Epetra_RowMatrix.h"
00036 #include "Epetra_Object.h"
00037 #include "Epetra_CompObject.h"
00038 #include "Epetra_Map.h"
00039 #include "Epetra_Comm.h"
00040 #include "Epetra_SerialDenseVector.h"
00041 #include "Epetra_IntSerialDenseVector.h"
00042 #include "Epetra_MultiVector.h"
00043 
00044 class Epetra_Vector;
00045 class Epetra_Import;
00046 class Epetra_Export;
00047 
00049 
00089 class Epetra_BasicRowMatrix: public Epetra_CompObject, public Epetra_Object, public virtual Epetra_RowMatrix  {
00090       
00091  public:
00092 
00094 
00095 
00096   /* This constructor requires a valid Epetra_Comm object as its only argument.  The constructor will use Comm to build
00097      Epetra_Maps objects: RowMap, ColMap, DomainMap and RangeMap.  However, these will be zero-length (trivial) maps that
00098      \e must be reset by calling one of the two SetMap() methods listed below.
00099      \param Comm (In) An Epetra_Comm containing a valid Comm object.
00100   */
00101   Epetra_BasicRowMatrix(const Epetra_Comm & Comm);
00102 
00104   virtual ~Epetra_BasicRowMatrix();
00106   
00108 
00109 
00110   /* This method takes a row and column map.  On each processor these maps describe the global rows and columns, resp, 
00111      that the processor will care about.  Note that the ColMap does not have to be one-to-one.  In other words, a column ID can appear
00112      on more than one processor.  The RowMap \e must be 1-to-1.
00113      \param RowMap (In) An Epetra_Map containing on each processor a list of GIDs of rows that the processor cares about.
00114      \param ColMap (In) An Epetra_Map containing on each processor a list of GIDs of columns that the processor cares about.
00115 
00116      In this method, the domain and range maps are assumed to be the same as the row map.  Note that this requires that 
00117      the global matrix be square.  If the matrix is not square, or the domain vectors or range vectors do not have the same layout
00118      as the rows, then the second constructor should be called.
00119   */
00120   void SetMaps(const Epetra_Map & RowMap, const Epetra_Map & ColMap);
00121 
00123   /* This constructor takes a row, column, domain and range map.  On each processor these maps describe the global rows, columns, domain
00124      and range, resp, that the processor will care about.  The domain and range maps must be one-to-one, but note that the row and column
00125      maps do not have to be one-to-one.  In other words, a row ID can appear
00126      on more than one processor, as can a column ID.
00127      \param RowMap (In) An Epetra_Map containing on each processor a list of GIDs of rows that the processor cares about.
00128      \param ColMap (In) An Epetra_Map containing on each processor a list of GIDs of columns that the processor cares about.
00129      \param DomainMap (In) An Epetra_Map describing the distribution of domain vectors and multivectors.
00130      \param RangeMap (In) An Epetra_Map describing the distribution of range vectors and multivectors.
00131 
00132   */
00133   void SetMaps(const Epetra_Map & RowMap, const Epetra_Map & ColMap, 
00134          const Epetra_Map & DomainMap, const Epetra_Map & RangeMap);
00135 
00137 
00138   
00140 
00141 
00143 
00152   virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const = 0;
00153 
00155 
00163     virtual int ExtractMyEntryView(int CurEntry, double * & Value, int & RowIndex, int & ColIndex) = 0;
00164 
00166 
00174     virtual int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const = 0;
00175 
00177 
00184     virtual int NumMyRowEntries(int MyRow, int & NumEntries) const = 0;
00186 
00188 
00189 
00191 
00198     virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00199 
00201 
00210     virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal,
00211                       const Epetra_MultiVector& X,
00212                       Epetra_MultiVector& Y) const
00213     {
00214       (void)Upper;
00215       (void)Trans;
00216       (void)UnitDiagonal;
00217       (void)X;
00218       (void)Y;
00219       return(-1);
00220     }
00221 
00223 
00228     virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00229 
00231 
00240     virtual int InvRowSums(Epetra_Vector& x) const;
00241 
00243 
00249     virtual int LeftScale(const Epetra_Vector& x);
00250 
00252 
00261     virtual int InvColSums(Epetra_Vector& x) const;
00262 
00264 
00270     virtual int RightScale(const Epetra_Vector& x);
00272 
00274 
00275 
00276 
00278     virtual bool Filled() const {return(true);}
00279 
00281     bool LowerTriangular() const {if (!HaveNumericConstants_) ComputeNumericConstants(); return(LowerTriangular_);}
00282 
00284     virtual bool UpperTriangular() const {if (!HaveNumericConstants_) ComputeNumericConstants(); return(UpperTriangular_);}
00285 
00287   
00289 
00290 
00292     /* Returns the quantity \f$ \| A \|_\infty\f$ such that
00293        \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f].
00294 
00295      \warning This method is supported if and only if the Epetra_RowMatrix Object that was used to create this supports this method.
00296 
00297     */ 
00298     virtual double NormInf() const{if (!HaveNumericConstants_) ComputeNumericConstants(); return(NormInf_);}
00299 
00301     /* Returns the quantity \f$ \| A \|_1\f$ such that
00302        \f[\| A \|_1= \max_{1\lej\len} \sum_{i=1}^m |a_{ij}| \f].
00303 
00304      \warning This method is supported if and only if the Epetra_RowMatrix Object that was used to create this supports this method.
00305 
00306     */ 
00307     virtual double NormOne() const{if (!HaveNumericConstants_) ComputeNumericConstants(); return(NormOne_);}
00308 
00310     /* Note that if the data decomposition is defined such that some nonzeros
00311        appear on multiple processors, then those nonzeros will be counted
00312        multiple times.
00313     */
00314     virtual int NumGlobalNonzeros() const{if (!HaveStructureConstants_) ComputeStructureConstants(); return(NumGlobalNonzeros_);}
00315 
00317     virtual int NumGlobalRows() const {return(OperatorRangeMap().NumGlobalPoints());}
00318 
00320     virtual int NumGlobalCols() const {return(OperatorDomainMap().NumGlobalPoints());}
00321 
00323     virtual int NumGlobalDiagonals() const{return(OperatorDomainMap().NumGlobalPoints());}
00324     
00326     virtual int NumMyNonzeros() const{if (!HaveStructureConstants_) ComputeStructureConstants(); return(NumMyNonzeros_);}
00327 
00329     virtual int NumMyRows() const {return(OperatorRangeMap().NumMyPoints());}
00330 
00332     virtual int NumMyCols() const {return(RowMatrixColMap().NumMyPoints());}
00333 
00335     virtual int NumMyDiagonals() const {return(OperatorRangeMap().NumMyPoints());}
00336 
00338     virtual int MaxNumEntries() const{ if (!HaveStructureConstants_) ComputeStructureConstants(); return(MaxNumEntries_);}
00339 
00341     virtual const Epetra_Map & OperatorDomainMap() const {return(OperatorDomainMap_);}
00342 
00344     virtual const Epetra_Map & OperatorRangeMap() const  {return(OperatorRangeMap_);}
00345 
00347     virtual const Epetra_BlockMap& Map() const {return(RowMatrixRowMap());}
00348 
00350     virtual const Epetra_Map & RowMatrixRowMap() const {return(RowMatrixRowMap_);}
00351 
00353     virtual const Epetra_Map & RowMatrixColMap() const {return(RowMatrixColMap_);}
00354 
00356     virtual const Epetra_Import * RowMatrixImporter() const {return(Importer_);}
00357 
00359     virtual const Epetra_Comm & Comm() const {return(*Comm_);}
00361   
00362   
00364 
00365 
00367   virtual void Print(ostream & os) const;
00369 
00371 
00372     
00374 
00382   virtual int SetUseTranspose(bool UseTranspose) {return(UseTranspose_ = UseTranspose);}
00383 
00385   virtual const char* Label() const {return(Epetra_Object::Label());}
00386   
00388 
00394   virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
00395     return(Multiply(Epetra_BasicRowMatrix::UseTranspose(), X, Y));}
00396 
00398 
00406   virtual int ApplyInverse(const Epetra_MultiVector& X,
00407                            Epetra_MultiVector& Y) const
00408    {
00409      (void)X;
00410      (void)Y;
00411      return(-1);
00412    }
00413 
00415   bool HasNormInf() const {return(true);}
00416   
00418   virtual bool UseTranspose() const {return(UseTranspose_);}
00419 
00421   
00423 
00424 
00426 
00434   virtual const Epetra_Import* Importer() const {return(Importer_);}
00435   
00437 
00446   virtual const Epetra_Export* Exporter() const {return(Exporter_);}
00447 
00449 
00450  protected:
00451 
00453 
00454 
00455   /* Several constants are pre-computed to save excess computations.  However, if the structure of the
00456      problem changes, specifically if the nonzero count in any given row changes, then this function should be called
00457      to update these constants.
00458   */ 
00459   virtual void ComputeStructureConstants() const;
00461   /* Several numeric constants are pre-computed to save excess computations.  However, if the values of the
00462      problem change, then this function should be called to update these constants.
00463   */ 
00464   virtual void ComputeNumericConstants() const;
00466 
00467   void Setup();
00468   void UpdateImportVector(int NumVectors) const;
00469   void UpdateExportVector(int NumVectors) const;
00470   void SetImportExport();
00471   Epetra_Comm * Comm_;
00472   Epetra_Map OperatorDomainMap_;
00473   Epetra_Map OperatorRangeMap_;
00474   Epetra_Map RowMatrixRowMap_;
00475   Epetra_Map RowMatrixColMap_;
00476   
00477   mutable int NumMyNonzeros_;
00478   mutable int NumGlobalNonzeros_;
00479   mutable int MaxNumEntries_;
00480   mutable double NormInf_;
00481   mutable double NormOne_;
00482   int NumMyRows_;
00483   int NumMyCols_;
00484 
00485   bool UseTranspose_;
00486   bool HasNormInf_;
00487   mutable bool LowerTriangular_;
00488   mutable bool UpperTriangular_;
00489   mutable bool HaveStructureConstants_;
00490   mutable bool HaveNumericConstants_;
00491   mutable bool HaveMaps_;
00492     
00493 
00494   mutable Epetra_MultiVector * ImportVector_;
00495   mutable Epetra_MultiVector * ExportVector_;
00496   Epetra_Import * Importer_;
00497   Epetra_Export * Exporter_;
00498 
00499 };
00500 #endif /* EPETRA_BASICROWMATRIX_H */

Generated on Thu Sep 18 12:37:56 2008 for Epetra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1