Epetra Package Browser (Single Doxygen Collection) Development
Epetra_VbrMatrix.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_VBRMATRIX_H
00045 #define EPETRA_VBRMATRIX_H
00046 
00047 // FIXME long long : whole file
00048 
00049 #include <Epetra_ConfigDefs.h>
00050 #include <Epetra_DistObject.h> 
00051 #include <Epetra_CompObject.h> 
00052 #include <Epetra_BLAS.h>
00053 #include <Epetra_RowMatrix.h>
00054 #include <Epetra_Operator.h>
00055 #include <Epetra_CrsGraph.h>
00056 #include <Epetra_SerialDenseMatrix.h>
00057 class Epetra_BlockMap;
00058 class Epetra_Map;
00059 class Epetra_Import;
00060 class Epetra_Export;
00061 class Epetra_Vector;
00062 class Epetra_MultiVector;
00063 
00065 
00172 class EPETRA_LIB_DLL_EXPORT Epetra_VbrMatrix : public Epetra_DistObject,
00173           public Epetra_CompObject,
00174           public Epetra_BLAS,
00175           public virtual Epetra_RowMatrix {
00176  public:
00177 
00179 
00180 
00181 
00191   Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, int *NumBlockEntriesPerRow);
00192   
00194 
00205   Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, int NumBlockEntriesPerRow);
00206 
00208 
00220   Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, const Epetra_BlockMap& ColMap, int *NumBlockEntriesPerRow);
00221   
00223 
00236   Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, const Epetra_BlockMap& ColMap, int NumBlockEntriesPerRow);
00237 
00239 
00248   Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_CrsGraph & Graph);
00249 
00251   Epetra_VbrMatrix(const Epetra_VbrMatrix & Matrix);
00252 
00254   virtual ~Epetra_VbrMatrix();
00256   
00258 
00259 
00260   Epetra_VbrMatrix& operator=(const Epetra_VbrMatrix& src);
00261 
00263 
00269     int PutScalar(double ScalarConstant);
00270 
00272 
00278     int Scale(double ScalarConstant);
00279 
00281 
00286     int DirectSubmitBlockEntry(int GlobalBlockRow, int GlobalBlockCol,
00287                                const double *values, int LDA,
00288                                int NumRows, int NumCols, bool sum_into);
00289 
00291 
00301     int BeginInsertGlobalValues(int BlockRow,
00302         int NumBlockEntries,
00303         int * BlockIndices);
00304 
00306 
00316     int BeginInsertMyValues(int BlockRow, int NumBlockEntries, int * BlockIndices);
00317 
00319 
00329     int BeginReplaceGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
00330 
00332 
00342     int BeginReplaceMyValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
00343 
00345 
00355     int BeginSumIntoGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
00356 
00358 
00368     int BeginSumIntoMyValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
00369 
00371     /* Submit a block entry that will recorded in the block row that was initiated by one of the
00372        Begin routines listed above.  Once a one of the following routines: BeginInsertGlobalValues(),
00373        BeginInsertMyValues(), BeginReplaceGlobalValues(), BeginReplaceMyValues(), BeginSumIntoGlobalValues(),
00374        BeginSumIntoMyValues(), you \e must call SubmitBlockEntry() NumBlockEntries times to register the values 
00375        corresponding to the block indices passed in to the Begin routine.  If the Epetra_VbrMatrix constuctor
00376        was called in Copy mode, the values will be copied.  However, no copying will be done until the EndSubmitEntries()
00377        function is call to complete submission of the current block row.  If the constructor was called in View mode, all
00378        block entries passed via SubmitBlockEntry() will not be copied, but a pointer will be set to point to the argument Values
00379        that was passed in by the user.
00380 
00381        For performance reasons, SubmitBlockEntry() does minimal processing of data.  Any processing that can be
00382        delayed is performed in EndSubmitEntries().
00383 
00384     \param In
00385            Values - The starting address of the values.
00386     \param In
00387            LDA - The stride between successive columns of Values.
00388     \param In
00389            NumRows - The number of rows passed in.
00390     \param In
00391            NumCols - The number of columns passed in.
00392 
00393     \return Integer error code, set to 0 if successful.
00394     */
00395     int SubmitBlockEntry(double *Values, int LDA, int NumRows, int NumCols);
00396 
00398     /* Submit a block entry that will recorded in the block row that was initiated by one of the
00399        Begin routines listed above.  Once a one of the following routines: BeginInsertGlobalValues(),
00400        BeginInsertMyValues(), BeginReplaceGlobalValues(), BeginReplaceMyValues(), BeginSumIntoGlobalValues(),
00401        BeginSumIntoMyValues(), you \e must call SubmitBlockEntry() NumBlockEntries times to register the values 
00402        corresponding to the block indices passed in to the Begin routine.  If the Epetra_VbrMatrix constuctor
00403        was called in Copy mode, the values will be copied.  However, no copying will be done until the EndSubmitEntries()
00404        function is call to complete submission of the current block row.  If the constructor was called in View mode, all
00405        block entries passed via SubmitBlockEntry() will not be copied, but a pointer will be set to point to the argument Values
00406        that was passed in by the user.
00407 
00408        For performance reasons, SubmitBlockEntry() does minimal processing of data.  Any processing that can be
00409        delayed is performed in EndSubmitEntries().
00410 
00411     \param In
00412            Mat - Preformed dense matrix block.
00413 
00414     \return Integer error code, set to 0 if successful.
00415     */
00416     int SubmitBlockEntry( Epetra_SerialDenseMatrix &Mat );
00417 
00419 
00424     int EndSubmitEntries();
00425 
00427 
00438     int ReplaceDiagonalValues(const Epetra_Vector & Diagonal);
00439 
00441     /* This version of FillComplete assumes that the domain and range
00442        distributions are identical to the matrix row distributions.
00443        \return error code, 0 if successful. Returns a positive warning code of 3
00444         if the matrix is rectangular (meaning that the other overloading of
00445         FillComplete should have been called, with differen domain-map and
00446         range-map specified).
00447     */
00448     int FillComplete();
00449 
00451     /* This version of FillComplete requires the explicit specification of the domain
00452        and range distribution maps.  These maps are used for importing and exporting vector
00453        and multi-vector elements that are needed for distributed matrix computations.  For
00454        example, to compute y = Ax in parallel, we would specify the DomainMap as the distribution
00455        of the vector x and the RangeMap as the distribution of the vector y.
00456     \param In
00457            DomainMap - Map that describes the distribution of vector and multi-vectors in the
00458                  matrix domain.
00459     \param In
00460            RangeMap - Map that describes the distribution of vector and multi-vectors in the
00461                  matrix range.
00462 
00463     \return error code, 0 if successful. positive warning code of 2 if it is detected that the
00464     matrix-graph got out of sync since this matrix was constructed (for instance if
00465     graph.FillComplete() was called by another matrix that shares the graph)
00466     */
00467     int FillComplete(const Epetra_BlockMap& DomainMap, const Epetra_BlockMap& RangeMap);
00468 
00470     bool Filled() const {return(Graph_->Filled());};
00472 
00474 
00475 
00477 
00499     int ExtractGlobalBlockRowPointers(int BlockRow, int MaxNumBlockEntries, 
00500               int & RowDim,  int & NumBlockEntries, 
00501               int * BlockIndices,
00502               Epetra_SerialDenseMatrix ** & Values) const;
00503 
00505 
00527     int ExtractMyBlockRowPointers(int BlockRow, int MaxNumBlockEntries, 
00528           int & RowDim, int & NumBlockEntries, 
00529           int * BlockIndices,
00530           Epetra_SerialDenseMatrix** & Values) const;
00531 
00533 
00549     int BeginExtractGlobalBlockRowCopy(int BlockRow, int MaxNumBlockEntries, 
00550                int & RowDim,  int & NumBlockEntries, 
00551                int * BlockIndices, int * ColDims) const;
00552 
00554 
00570     int BeginExtractMyBlockRowCopy(int BlockRow, int MaxNumBlockEntries, 
00571            int & RowDim, int & NumBlockEntries, 
00572            int * BlockIndices, int * ColDims) const;
00573 
00575 
00590     int ExtractEntryCopy(int SizeOfValues, double * Values, int LDA, bool SumInto) const;
00591 
00593 
00605     int BeginExtractGlobalBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries, 
00606                int * & BlockIndices) const;
00607 
00609 
00621     int BeginExtractMyBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries, 
00622            int * & BlockIndices) const;
00623 
00624 
00626 
00633     int ExtractEntryView(Epetra_SerialDenseMatrix* & entry) const;
00634 
00636 
00650     int ExtractGlobalBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries, 
00651           int * & BlockIndices,
00652           Epetra_SerialDenseMatrix** & Values) const;
00653 
00655 
00669     int ExtractMyBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries, 
00670             int * & BlockIndices,
00671             Epetra_SerialDenseMatrix** & Values) const;
00672 
00673 
00675 
00681     int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
00682 
00684 
00694     int BeginExtractBlockDiagonalCopy(int MaxNumBlockDiagonalEntries, 
00695               int & NumBlockDiagonalEntries, int * RowColDims ) const;
00697 
00712     int ExtractBlockDiagonalEntryCopy(int SizeOfValues, double * Values, int LDA, bool SumInto) const;
00713 
00715 
00723     int BeginExtractBlockDiagonalView(int & NumBlockDiagonalEntries, int * & RowColDims ) const;
00724 
00726 
00736     int ExtractBlockDiagonalEntryView(double * & Values, int & LDA) const;
00738 
00740 
00741 
00742 
00744 
00754     int Multiply1(bool TransA, const Epetra_Vector& x, Epetra_Vector& y) const;
00755 
00757 
00767     int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00768 
00770 
00784     int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_Vector& x, Epetra_Vector& y) const;
00785 
00787 
00801     int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
00802 
00803 
00805 
00815     int InvRowSums(Epetra_Vector& x) const;
00816 
00818 
00825     int LeftScale(const Epetra_Vector& x);
00826 
00828 
00838     int InvColSums(Epetra_Vector& x) const ;
00839 
00841 
00848     int RightScale(const Epetra_Vector& x);
00850 
00852 
00853 
00855     int OptimizeStorage();
00856 
00858     bool StorageOptimized() const {return(StorageOptimized_);};
00859 
00861     bool IndicesAreGlobal() const {return(Graph_->IndicesAreGlobal());};
00862 
00864     bool IndicesAreLocal() const {return(Graph_->IndicesAreLocal());};
00865 
00867     bool IndicesAreContiguous() const {return(Graph_->IndicesAreContiguous());};
00868 
00870     bool LowerTriangular() const {return(Graph_->LowerTriangular());};
00871 
00873     bool UpperTriangular() const {return(Graph_->UpperTriangular());};
00874 
00876     bool NoDiagonal() const {return(Graph_->NoDiagonal());};
00877 
00879   
00881 
00882 
00884     /* Returns the quantity \f$ \| A \|_\infty\f$ such that
00885        \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f].
00886      \warning The NormInf() method will not properly calculate the infinity norm for a matrix that has entries that are
00887      replicated on multiple processors.  */ 
00888     double NormInf() const;
00889 
00891     /* Returns the quantity \f$ \| A \|_1\f$ such that
00892        \f[\| A \|_1 = \max_{1\lej\len} \sum_{i=1}^m |a_{ij}| \f].
00893      \warning The NormOne() method will not properly calculate the one norm for a matrix that has entries that are
00894     */ 
00895     double NormOne() const;
00896 
00898     /* Returns the quantity \f[ \| A \|_{Frobenius} = \sqrt{\sum_{i=1}^m \sum_{j=1}^n\|a_{ij}\|^2}\f]
00899        \warning the NormFrobenius() method will not properly calculate the frobenius norm for a matrix that
00900        has entries which are replicated on multiple processors. In that case, the returned
00901        norm will be larger than the true norm.
00902     */
00903     double NormFrobenius() const;
00904 
00906     int MaxRowDim() const {return(Graph_->MaxRowDim());};
00907 
00909     int MaxColDim() const {return(Graph_->MaxColDim());};
00910 
00912     int GlobalMaxRowDim() const {return(Graph_->GlobalMaxRowDim());};
00913 
00915     int GlobalMaxColDim() const {return(Graph_->GlobalMaxColDim());};
00916 
00918     int NumMyRows() const {return(Graph_->NumMyRows());};
00920     int NumMyCols() const {return(Graph_->NumMyCols());};
00921 
00923     int NumMyNonzeros() const {return(Graph_->NumMyNonzeros());};
00924 
00926 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00927     int NumGlobalRows() const {return(Graph_->NumGlobalRows());};
00928 #endif
00929     long long NumGlobalRows64() const {return(Graph_->NumGlobalRows64());};
00930 
00932 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00933     int NumGlobalCols() const {return(Graph_->NumGlobalCols());};
00934 #endif
00935     long long NumGlobalCols64() const {return(Graph_->NumGlobalCols64());};
00936 
00938     /*
00939      Note that if maps are defined such that some nonzeros appear on
00940      multiple processors, then those nonzeros will be counted multiple
00941      times. If the user wishes to assemble a matrix from overlapping
00942      submatrices, they can use Epetra_FEVbrMatrix.
00943     */
00944 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00945     int NumGlobalNonzeros() const {return(Graph_->NumGlobalNonzeros());};
00946 #endif
00947     long long NumGlobalNonzeros64() const {return(Graph_->NumGlobalNonzeros64());};
00948 
00950     int NumMyBlockRows() const {return(Graph_->NumMyBlockRows());};
00951 
00953     int NumMyBlockCols() const {return(Graph_->NumMyBlockCols());};
00954     
00956     int NumMyBlockEntries() const {return(Graph_->NumMyEntries());};
00957 
00959     int NumMyBlockDiagonals() const {return(Graph_->NumMyBlockDiagonals());};
00960     
00962     int NumMyDiagonals() const {return(Graph_->NumMyDiagonals());};
00963     
00965 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00966     int NumGlobalBlockRows() const {return(Graph_->NumGlobalBlockRows());};
00967 #endif
00968     long long NumGlobalBlockRows64() const {return(Graph_->NumGlobalBlockRows64());};
00969     
00971 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00972     int NumGlobalBlockCols() const {return(Graph_->NumGlobalBlockCols());};
00973 #endif
00974     long long NumGlobalBlockCols64() const {return(Graph_->NumGlobalBlockCols64());};
00975     
00977 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00978     int NumGlobalBlockEntries() const {return(Graph_->NumGlobalEntries());};
00979 #endif
00980     long long NumGlobalBlockEntries64() const {return(Graph_->NumGlobalEntries64());};
00981     
00983 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00984     int NumGlobalBlockDiagonals() const {return(Graph_->NumGlobalBlockDiagonals());};
00985 #endif
00986     long long NumGlobalBlockDiagonals64() const {return(Graph_->NumGlobalBlockDiagonals64());};
00987     
00989 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
00990     int NumGlobalDiagonals() const {return(Graph_->NumGlobalDiagonals());};
00991 #endif
00992     long long NumGlobalDiagonals64() const {return(Graph_->NumGlobalDiagonals64());};
00993 
00995     int NumGlobalBlockEntries(int Row) const {return(Graph_->NumGlobalIndices(Row));};
00996 
00998     int NumAllocatedGlobalBlockEntries(int Row) const{return(Graph_->NumAllocatedGlobalIndices(Row));};
00999 
01001     int MaxNumBlockEntries() const {return(Graph_->MaxNumIndices());};
01002 
01004     int GlobalMaxNumBlockEntries() const {return(Graph_->GlobalMaxNumIndices());};
01005 
01007     int NumMyBlockEntries(int Row) const {return(Graph_->NumMyIndices(Row));};
01008 
01010     int NumAllocatedMyBlockEntries(int Row) const {return(Graph_->NumAllocatedMyIndices(Row));};
01011 
01013 
01017     int MaxNumNonzeros() const {return(Graph_->MaxNumNonzeros());};
01018 
01020 
01022     int GlobalMaxNumNonzeros() const {return(Graph_->GlobalMaxNumNonzeros());};
01023 
01025 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01026 
01027   int  IndexBase() const {
01028     if(RowMap().GlobalIndicesInt())
01029       return (int) IndexBase64();
01030     throw "Epetra_VbrMatrix::IndexBase: GlobalIndices not int.";
01031   }
01032 #endif
01033   long long  IndexBase64() const {return(Graph_->IndexBase64());};
01034 
01036     const Epetra_CrsGraph & Graph() const {return(*Graph_);};
01037 
01039     const Epetra_Import * Importer() const {return(Graph_->Importer());};
01040 
01042     const Epetra_Export * Exporter() const {return(Graph_->Exporter());};
01043 
01045     const Epetra_BlockMap & DomainMap() const {return(Graph_->DomainMap());};
01046 
01048     const Epetra_BlockMap & RangeMap() const  {return(Graph_->RangeMap());};
01049 
01051     const Epetra_BlockMap & RowMap() const {return(Graph_->RowMap());};
01052 
01054     const Epetra_BlockMap & ColMap() const {return(Graph_->ColMap());};
01055 
01057 
01059     const Epetra_Comm & Comm() const {return(Graph_->Comm());};
01060 
01062   
01064 
01065 
01066 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01067     int LRID( int GRID_in) const {return(Graph_->LRID(GRID_in));};
01068 #endif
01069 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
01070     int LRID( long long GRID_in) const {return(Graph_->LRID(GRID_in));};
01071 #endif
01072 
01074 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01075     int GRID(int LRID_in) const {return(Graph_->GRID(LRID_in));};
01076 #endif
01077     long long GRID64( int LRID_in) const {return(Graph_->GRID64(LRID_in));};
01078 
01080 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01081     int LCID( int GCID_in) const {return(Graph_->LCID(GCID_in));};
01082 #endif
01083 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
01084     int LCID( long long GCID_in) const {return(Graph_->LCID(GCID_in));};
01085 #endif
01086 
01088 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01089     int GCID(int LCID_in) const {return(Graph_->GCID(LCID_in));};
01090 #endif
01091     long long GCID64( int LCID_in) const {return(Graph_->GCID64(LCID_in));};
01092  
01094 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01095     bool  MyGRID(int GRID_in) const {return(Graph_->MyGRID(GRID_in));};
01096 #endif
01097 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
01098     bool  MyGRID(long long GRID_in) const {return(Graph_->MyGRID(GRID_in));};
01099 #endif
01100    
01102     bool  MyLRID(int LRID_in) const {return(Graph_->MyLRID(LRID_in));};
01103 
01105 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01106     bool  MyGCID(int GCID_in) const {return(Graph_->MyGCID(GCID_in));};
01107 #endif
01108 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
01109     bool  MyGCID(long long GCID_in) const {return(Graph_->MyGCID(GCID_in));};
01110 #endif
01111    
01113     bool  MyLCID(int LCID_in) const {return(Graph_->MyLCID(LCID_in));};
01114 
01116 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
01117     bool MyGlobalBlockRow(int GID) const {return(Graph_->MyGlobalRow(GID));};
01118 #endif
01119 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
01120     bool MyGlobalBlockRow(long long GID) const {return(Graph_->MyGlobalRow(GID));};
01121 #endif
01122 
01123   
01125 
01126 
01128   virtual void Print(std::ostream & os) const;
01130 
01132 
01133 
01135     const char * Label() const {return(Epetra_Object::Label());};
01136     
01138 
01147   int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
01148 
01150 
01158   int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
01159 
01161 
01174   int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
01175 
01177     bool HasNormInf() const {return(true);};
01178 
01180     bool UseTranspose() const {return(UseTranspose_);};
01181 
01183     const Epetra_Map & OperatorDomainMap() const 
01184     {
01185       if (!HavePointObjects_) GeneratePointObjects();
01186       if (UseTranspose()) return(*OperatorRangeMap_);
01187       else return(*OperatorDomainMap_);
01188     }
01189 
01191     const Epetra_Map & OperatorRangeMap() const 
01192     {
01193       if (!HavePointObjects_) GeneratePointObjects();
01194       if (UseTranspose()) return(*OperatorDomainMap_);
01195       else return(*OperatorRangeMap_);
01196     }
01197 
01199 
01200 
01201 
01203 
01217     int ExtractGlobalRowCopy(int GlobalRow, int Length, int & NumEntries, double *Values, int * Indices) const;
01218 
01220 
01234     int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
01235 
01237 
01245     int NumMyRowEntries(int MyRow, int & NumEntries) const;
01246 
01248     int MaxNumEntries() const;
01249 
01251     const Epetra_BlockMap& Map() const { return Epetra_DistObject::Map(); }
01252 
01254     const Epetra_Map & RowMatrixRowMap() const 
01255       { if (!HavePointObjects_) GeneratePointObjects(); return(*RowMatrixRowMap_); };
01256 
01258     const Epetra_Map & RowMatrixColMap() const 
01259       { if (!HavePointObjects_) GeneratePointObjects(); return(*RowMatrixColMap_); };
01260 
01262     const Epetra_Import * RowMatrixImporter() const 
01263       { if (!HavePointObjects_) GeneratePointObjects(); return(RowMatrixImporter_); };
01264 
01266 
01268 
01269 
01271     const Epetra_BlockMap & BlockImportMap() const {return(Graph_->ImportMap());};
01272 
01274     int TransformToLocal();
01275     
01277     int TransformToLocal(const Epetra_BlockMap* DomainMap, const Epetra_BlockMap* RangeMap);
01279 
01280  protected:
01281     void DeleteMemory();
01282     bool Allocated() const {return(Allocated_);};
01283     int SetAllocated(bool Flag) {Allocated_ = Flag; return(0);};
01284     Epetra_SerialDenseMatrix *** Values() const {return(Entries_);};
01285 
01286   // Internal utilities
01287 
01288   int DoMultiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
01289   int DoSolve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
01290   void InitializeDefaults();
01291   int Allocate();
01292   int BeginInsertValues(int BlockRow, int NumBlockEntries, 
01293       int * BlockIndices, bool IndicesAreLocal);
01294   int BeginReplaceValues(int BlockRow, int NumBlockEntries, 
01295        int *BlockIndices, bool IndicesAreLocal);
01296   int BeginSumIntoValues(int BlockRow, int NumBlockEntries, 
01297        int *BlockIndices, bool IndicesAreLocal);
01298   int SetupForSubmits(int BlockRow, int NumBlockEntries, int * BlockIndices, 
01299           bool IndicesAreLocal, Epetra_CombineMode SubmitMode);
01300   int EndReplaceSumIntoValues();
01301   int EndInsertValues();
01302 
01303   int CopyMat(double * A, int LDA, int NumRows, int NumCols, 
01304         double * B, int LDB, bool SumInto) const;
01305   int BeginExtractBlockRowCopy(int BlockRow, int MaxNumBlockEntries, 
01306              int & RowDim, int & NumBlockEntries, 
01307              int * BlockIndices, int * ColDims, 
01308              bool IndicesAreLocal) const;
01309   int SetupForExtracts(int BlockRow, int & RowDim, int NumBlockEntries,
01310            bool ExtractView, bool IndicesAreLocal) const;
01311   int ExtractBlockDimsCopy(int NumBlockEntries, int * ColDims) const;
01312   int ExtractBlockRowPointers(int BlockRow, int MaxNumBlockEntries, 
01313             int & RowDim, int & NumBlockEntries, 
01314             int * BlockIndices, 
01315             Epetra_SerialDenseMatrix ** & Values,
01316             bool IndicesAreLocal) const;
01317   int BeginExtractBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries, 
01318              int * & BlockIndices, 
01319              bool IndicesAreLocal) const;
01320   int CopyMatDiag(double * A, int LDA, int NumRows, int NumCols, 
01321       double * Diagonal) const;
01322   int ReplaceMatDiag(double * A, int LDA, int NumRows, int NumCols, 
01323          double * Diagonal);
01324 
01325   //This BlockRowMultiply accepts Alpha and Beta arguments. It is called
01326   //from within the 'solve' methods.
01327   void BlockRowMultiply(bool TransA, int RowDim, int NumEntries, 
01328       int * BlockIndices, int RowOff,
01329       int * FirstPointInElementList, int * ElementSizeList,
01330       double Alpha, Epetra_SerialDenseMatrix** As,
01331       double ** X, double Beta, double ** Y, int NumVectors) const;
01332 
01333   //This BlockRowMultiply doesn't accept Alpha and Beta arguments, instead it
01334   //assumes that they are both 1.0. It is called from within the 'Multiply'
01335   //methods.
01336   void BlockRowMultiply(bool TransA, int RowDim, int NumEntries, 
01337       int * BlockIndices, int RowOff,
01338       int * FirstPointInElementList,
01339       int * ElementSizeList,
01340       Epetra_SerialDenseMatrix** As,
01341       double ** X, double ** Y, int NumVectors) const;
01342   //
01343   // Assumes Alpha=Beta=1 and works only on storage optimized matrices
01344   //
01345   void FastBlockRowMultiply(bool TransA, int RowDim, int NumEntries, 
01346           int * BlockIndices, int RowOff,
01347           int * FirstPointInElementList,
01348           int * ElementSizeList,
01349           Epetra_SerialDenseMatrix** As,
01350           double ** X, double ** Y, int NumVectors) const;
01351 
01352   int InverseSums(bool DoRows, Epetra_Vector& x) const;
01353   int Scale(bool DoRows, const Epetra_Vector& x);
01354   void BlockRowNormInf(int RowDim, int NumEntries, 
01355            Epetra_SerialDenseMatrix** As, 
01356            double * Y) const;
01357   void BlockRowNormOne(int RowDim, int NumEntries, int * BlockRowIndices,
01358            Epetra_SerialDenseMatrix** As, 
01359            int * ColFirstPointInElementList, double * x) const;
01360   void SetStaticGraph(bool Flag) {StaticGraph_ = Flag;};
01361 
01362   int CheckSizes(const Epetra_SrcDistObject& A);
01363 
01364   int CopyAndPermute(const Epetra_SrcDistObject & Source,
01365                      int NumSameIDs, 
01366                      int NumPermuteIDs,
01367                      int * PermuteToLIDs,
01368                      int *PermuteFromLIDs,
01369                      const Epetra_OffsetIndex * Indexor);
01370   
01371   int PackAndPrepare(const Epetra_SrcDistObject & Source,
01372                      int NumExportIDs,
01373                      int * ExportLIDs,
01374                      int & LenExports,
01375                      char * & Exports,
01376                      int & SizeOfPacket,
01377                      int * Sizes,
01378                      bool & VarSizes,
01379                      Epetra_Distributor & Distor);
01380   
01381   int UnpackAndCombine(const Epetra_SrcDistObject & Source, 
01382                        int NumImportIDs,
01383                        int * ImportLIDs, 
01384                        int LenImports,
01385                        char * Imports,
01386                        int & SizeOfPacket, 
01387                        Epetra_Distributor & Distor,
01388                        Epetra_CombineMode CombineMode,
01389                        const Epetra_OffsetIndex * Indexor);
01390 
01392   int SortEntries();
01393 
01395   bool Sorted() const {return(Graph_->Sorted());};
01396 
01398   int MergeRedundantEntries();
01399 
01401   bool NoRedundancies() const {return(Graph_->NoRedundancies());};
01402 
01403   bool StaticGraph() const {return(StaticGraph_);};
01404 
01405   int GeneratePointObjects() const;
01406   int BlockMap2PointMap(const Epetra_BlockMap & BlockMap, Epetra_Map * & PointMap) const;
01407   int UpdateOperatorXY(const Epetra_MultiVector& X, const Epetra_MultiVector& Y) const;
01408 
01409   Epetra_CrsGraph * Graph_;
01410   bool Allocated_;
01411   bool StaticGraph_;
01412   bool UseTranspose_;
01413   bool constructedWithFilledGraph_;
01414   bool matrixFillCompleteCalled_;
01415   bool StorageOptimized_;
01416 
01417   int NumMyBlockRows_;
01418 
01419   Epetra_DataAccess CV_;
01420 
01421 
01422   int * NumBlockEntriesPerRow_;
01423   int * NumAllocatedBlockEntriesPerRow_;
01424   int ** Indices_;
01425   int * ElementSizeList_;
01426   int * FirstPointInElementList_;
01427 
01428   Epetra_SerialDenseMatrix ***Entries_;
01429 
01430   double *All_Values_Orig_;
01431   double *All_Values_;
01432 
01433   mutable double NormInf_;
01434   mutable double NormOne_;
01435   mutable double NormFrob_;
01436 
01437   mutable Epetra_MultiVector * ImportVector_;
01438   mutable Epetra_MultiVector * ExportVector_;
01439 
01440   // State variables needed for constructing matrix entry-by-entry
01441   mutable int *TempRowDims_;
01442   mutable Epetra_SerialDenseMatrix **TempEntries_;
01443   mutable int LenTemps_;
01444   mutable int CurBlockRow_;
01445   mutable int CurNumBlockEntries_;
01446   mutable int * CurBlockIndices_;
01447   mutable int CurEntry_;
01448   mutable bool CurIndicesAreLocal_;
01449   mutable Epetra_CombineMode CurSubmitMode_;
01450   
01451   // State variables needed for extracting entries
01452   mutable int CurExtractBlockRow_;
01453   mutable int CurExtractEntry_; 
01454   mutable int CurExtractNumBlockEntries_;
01455   mutable bool CurExtractIndicesAreLocal_;
01456   mutable bool CurExtractView_;
01457   mutable int CurRowDim_;
01458 
01459   // State variable for extracting block diagonal entries
01460   mutable int CurBlockDiag_;
01461 
01462   // Maps and importer that support the Epetra_RowMatrix interface
01463   mutable Epetra_Map * RowMatrixRowMap_;
01464   mutable Epetra_Map * RowMatrixColMap_;
01465   mutable Epetra_Import * RowMatrixImporter_;
01466 
01467   // Maps that support the Epetra_Operator interface
01468   mutable Epetra_Map * OperatorDomainMap_;
01469   mutable Epetra_Map * OperatorRangeMap_;
01470   mutable Epetra_MultiVector * OperatorX_;
01471   mutable Epetra_MultiVector * OperatorY_;
01472 
01473   // bool to indicate if above four point maps and importer have already been created
01474   mutable bool HavePointObjects_;
01475 
01476   bool squareFillCompleteCalled_;
01477 };
01478 
01479 #endif /* EPETRA_VBRMATRIX_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines