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 
00097 class Epetra_BasicRowMatrix: public Epetra_CompObject, public Epetra_Object, public virtual Epetra_RowMatrix  {
00098       
00099  public:
00100 
00102 
00103 
00104   /* This constructor requires a valid Epetra_Comm object as its only argument.  The constructor will use Comm to build
00105      Epetra_Maps objects: RowMap, ColMap, DomainMap and RangeMap.  However, these will be zero-length (trivial) maps that
00106      \e must be reset by calling one of the two SetMap() methods listed below.
00107      \param Comm (In) An Epetra_Comm containing a valid Comm object.
00108   */
00109   Epetra_BasicRowMatrix(const Epetra_Comm & Comm);
00110 
00112   virtual ~Epetra_BasicRowMatrix();
00114   
00116 
00117 
00118   /* This method takes a row and column map.  On each processor these maps describe the global rows and columns, resp, 
00119      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
00120      on more than one processor.  The RowMap \e must be 1-to-1.
00121      \param RowMap (In) An Epetra_Map containing on each processor a list of GIDs of rows that the processor cares about.
00122      \param ColMap (In) An Epetra_Map containing on each processor a list of GIDs of columns that the processor cares about.
00123 
00124      In this method, the domain and range maps are assumed to be the same as the row map.  Note that this requires that 
00125      the global matrix be square.  If the matrix is not square, or the domain vectors or range vectors do not have the same layout
00126      as the rows, then the second constructor should be called.
00127   */
00128   void SetMaps(const Epetra_Map & RowMap, const Epetra_Map & ColMap);
00129 
00131   /* This constructor takes a row, column, domain and range map.  On each processor these maps describe the global rows, columns, domain
00132      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
00133      maps do not have to be one-to-one.  In other words, a row ID can appear
00134      on more than one processor, as can a column ID.
00135      \param RowMap (In) An Epetra_Map containing on each processor a list of GIDs of rows that the processor cares about.
00136      \param ColMap (In) An Epetra_Map containing on each processor a list of GIDs of columns that the processor cares about.
00137      \param DomainMap (In) An Epetra_Map describing the distribution of domain vectors and multivectors.
00138      \param RangeMap (In) An Epetra_Map describing the distribution of range vectors and multivectors.
00139 
00140   */
00141   void SetMaps(const Epetra_Map & RowMap, const Epetra_Map & ColMap, 
00142          const Epetra_Map & DomainMap, const Epetra_Map & RangeMap);
00143 
00145 
00146   
00148 
00149 
00151 
00160   virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const = 0;
00161 
00163 
00171     virtual int ExtractMyEntryView(int CurEntry, double * & Value, int & RowIndex, int & ColIndex) = 0;
00172 
00174 
00182     virtual int ExtractMyEntryView(int CurEntry, double const * & Value, int & RowIndex, int & ColIndex) const = 0;
00183 
00185 
00192     virtual int NumMyRowEntries(int MyRow, int & NumEntries) const = 0;
00194 
00196 
00197 
00199 
00206     virtual int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00207 
00209 
00218     virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal,
00219                       const Epetra_MultiVector& X,
00220                       Epetra_MultiVector& Y) const
00221     {
00222       (void)Upper;
00223       (void)Trans;
00224       (void)UnitDiagonal;
00225       (void)X;
00226       (void)Y;
00227       return(-1);
00228     }
00229 
00231 
00236     virtual int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00237 
00239 
00248     virtual int InvRowSums(Epetra_Vector& x) const;
00249 
00251 
00257     virtual int LeftScale(const Epetra_Vector& x);
00258 
00260 
00269     virtual int InvColSums(Epetra_Vector& x) const;
00270 
00272 
00278     virtual int RightScale(const Epetra_Vector& x);
00280 
00282 
00283 
00284 
00286     virtual bool Filled() const {return(true);}
00287 
00289     bool LowerTriangular() const {if (!HaveNumericConstants_) ComputeNumericConstants(); return(LowerTriangular_);}
00290 
00292     virtual bool UpperTriangular() const {if (!HaveNumericConstants_) ComputeNumericConstants(); return(UpperTriangular_);}
00293 
00295   
00297 
00298 
00300     /* Returns the quantity \f$ \| A \|_\infty\f$ such that
00301        \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f].
00302 
00303      \warning This method is supported if and only if the Epetra_RowMatrix Object that was used to create this supports this method.
00304 
00305     */ 
00306     virtual double NormInf() const{if (!HaveNumericConstants_) ComputeNumericConstants(); return(NormInf_);}
00307 
00309     /* Returns the quantity \f$ \| A \|_1\f$ such that
00310        \f[\| A \|_1= \max_{1\lej\len} \sum_{i=1}^m |a_{ij}| \f].
00311 
00312      \warning This method is supported if and only if the Epetra_RowMatrix Object that was used to create this supports this method.
00313 
00314     */ 
00315     virtual double NormOne() const{if (!HaveNumericConstants_) ComputeNumericConstants(); return(NormOne_);}
00316 
00318     /* Note that if the data decomposition is defined such that some nonzeros
00319        appear on multiple processors, then those nonzeros will be counted
00320        multiple times.
00321     */
00322     virtual int NumGlobalNonzeros() const{if (!HaveStructureConstants_) ComputeStructureConstants(); return(NumGlobalNonzeros_);}
00323 
00325     virtual int NumGlobalRows() const {return(OperatorRangeMap().NumGlobalPoints());}
00326 
00328     virtual int NumGlobalCols() const {return(OperatorDomainMap().NumGlobalPoints());}
00329 
00331     virtual int NumGlobalDiagonals() const{return(OperatorDomainMap().NumGlobalPoints());}
00332     
00334     virtual int NumMyNonzeros() const{if (!HaveStructureConstants_) ComputeStructureConstants(); return(NumMyNonzeros_);}
00335 
00337     virtual int NumMyRows() const {return(OperatorRangeMap().NumMyPoints());}
00338 
00340     virtual int NumMyCols() const {return(RowMatrixColMap().NumMyPoints());}
00341 
00343     virtual int NumMyDiagonals() const {return(OperatorRangeMap().NumMyPoints());}
00344 
00346     virtual int MaxNumEntries() const{ if (!HaveStructureConstants_) ComputeStructureConstants(); return(MaxNumEntries_);}
00347 
00349     virtual const Epetra_Map & OperatorDomainMap() const {return(OperatorDomainMap_);}
00350 
00352     virtual const Epetra_Map & OperatorRangeMap() const  {return(OperatorRangeMap_);}
00353 
00355     virtual const Epetra_BlockMap& Map() const {return(RowMatrixRowMap());}
00356 
00358     virtual const Epetra_Map & RowMatrixRowMap() const {return(RowMatrixRowMap_);}
00359 
00361     virtual const Epetra_Map & RowMatrixColMap() const {return(RowMatrixColMap_);}
00362 
00364     virtual const Epetra_Import * RowMatrixImporter() const {return(Importer_);}
00365 
00367     virtual const Epetra_Comm & Comm() const {return(*Comm_);}
00369   
00370   
00372 
00373 
00375   virtual void Print(ostream & os) const;
00377 
00379 
00380     
00382 
00390   virtual int SetUseTranspose(bool UseTranspose) {UseTranspose_ = UseTranspose; return(0);}
00391 
00393   virtual const char* Label() const {return(Epetra_Object::Label());}
00394   
00396 
00402   virtual int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const {
00403     return(Multiply(Epetra_BasicRowMatrix::UseTranspose(), X, Y));}
00404 
00406 
00414   virtual int ApplyInverse(const Epetra_MultiVector& X,
00415                            Epetra_MultiVector& Y) const
00416    {
00417      (void)X;
00418      (void)Y;
00419      return(-1);
00420    }
00421 
00423   bool HasNormInf() const {return(true);}
00424   
00426   virtual bool UseTranspose() const {return(UseTranspose_);}
00427 
00429   
00431 
00432 
00434 
00442   virtual const Epetra_Import* Importer() const {return(Importer_);}
00443   
00445 
00454   virtual const Epetra_Export* Exporter() const {return(Exporter_);}
00455 
00457 
00458  protected:
00459 
00461 
00462 
00463   /* Several constants are pre-computed to save excess computations.  However, if the structure of the
00464      problem changes, specifically if the nonzero count in any given row changes, then this function should be called
00465      to update these constants.
00466   */ 
00467   virtual void ComputeStructureConstants() const;
00469   /* Several numeric constants are pre-computed to save excess computations.  However, if the values of the
00470      problem change, then this function should be called to update these constants.
00471   */ 
00472   virtual void ComputeNumericConstants() const;
00474 
00475   void Setup();
00476   void UpdateImportVector(int NumVectors) const;
00477   void UpdateExportVector(int NumVectors) const;
00478   void SetImportExport();
00479   Epetra_Comm * Comm_;
00480   Epetra_Map OperatorDomainMap_;
00481   Epetra_Map OperatorRangeMap_;
00482   Epetra_Map RowMatrixRowMap_;
00483   Epetra_Map RowMatrixColMap_;
00484   
00485   mutable int NumMyNonzeros_;
00486   mutable int NumGlobalNonzeros_;
00487   mutable int MaxNumEntries_;
00488   mutable double NormInf_;
00489   mutable double NormOne_;
00490   int NumMyRows_;
00491   int NumMyCols_;
00492 
00493   bool UseTranspose_;
00494   bool HasNormInf_;
00495   mutable bool LowerTriangular_;
00496   mutable bool UpperTriangular_;
00497   mutable bool HaveStructureConstants_;
00498   mutable bool HaveNumericConstants_;
00499   mutable bool HaveMaps_;
00500     
00501 
00502   mutable Epetra_MultiVector * ImportVector_;
00503   mutable Epetra_MultiVector * ExportVector_;
00504   Epetra_Import * Importer_;
00505   Epetra_Export * Exporter_;
00506 
00507 };
00508 #endif /* EPETRA_BASICROWMATRIX_H */

Generated on Wed May 12 21:41:04 2010 for Epetra Package Browser (Single Doxygen Collection) by  doxygen 1.4.7