Epetra Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Epetra_VbrMatrix.h
Go to the documentation of this file.
1 /*
2 //@HEADER
3 // ************************************************************************
4 //
5 // Epetra: Linear Algebra Services Package
6 // Copyright 2011 Sandia Corporation
7 //
8 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9 // the U.S. Government retains certain rights in this software.
10 //
11 // Redistribution and use in source and binary forms, with or without
12 // modification, are permitted provided that the following conditions are
13 // met:
14 //
15 // 1. Redistributions of source code must retain the above copyright
16 // notice, this list of conditions and the following disclaimer.
17 //
18 // 2. Redistributions in binary form must reproduce the above copyright
19 // notice, this list of conditions and the following disclaimer in the
20 // documentation and/or other materials provided with the distribution.
21 //
22 // 3. Neither the name of the Corporation nor the names of the
23 // contributors may be used to endorse or promote products derived from
24 // this software without specific prior written permission.
25 //
26 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 //
38 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
39 //
40 // ************************************************************************
41 //@HEADER
42 */
43 
44 #ifndef EPETRA_VBRMATRIX_H
45 #define EPETRA_VBRMATRIX_H
46 
47 #if defined(Epetra_SHOW_DEPRECATED_WARNINGS)
48 #ifdef __GNUC__
49 #warning "The Epetra package is deprecated"
50 #endif
51 #endif
52 
53 
54 
55 // FIXME long long : whole file
56 
57 #include <Epetra_ConfigDefs.h>
58 #include <Epetra_DistObject.h>
59 #include <Epetra_CompObject.h>
60 #include <Epetra_BLAS.h>
61 #include <Epetra_RowMatrix.h>
62 #include <Epetra_Operator.h>
63 #include <Epetra_CrsGraph.h>
65 class Epetra_BlockMap;
66 class Epetra_Map;
67 class Epetra_Import;
68 class Epetra_Export;
69 class Epetra_Vector;
70 class Epetra_MultiVector;
71 
73 
180 class EPETRA_LIB_DLL_EXPORT Epetra_VbrMatrix : public Epetra_DistObject,
181  public Epetra_CompObject,
182  public Epetra_BLAS,
183  public virtual Epetra_RowMatrix {
184  public:
185 
187 
188 
199  Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, int *NumBlockEntriesPerRow);
200 
202 
213  Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, int NumBlockEntriesPerRow);
214 
216 
228  Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, const Epetra_BlockMap& ColMap, int *NumBlockEntriesPerRow);
229 
231 
244  Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, const Epetra_BlockMap& ColMap, int NumBlockEntriesPerRow);
245 
247 
257 
259  Epetra_VbrMatrix(const Epetra_VbrMatrix & Matrix);
260 
262  virtual ~Epetra_VbrMatrix();
264 
266 
267 
269 
271 
277  int PutScalar(double ScalarConstant);
278 
280 
286  int Scale(double ScalarConstant);
287 
289 
294  int DirectSubmitBlockEntry(int GlobalBlockRow, int GlobalBlockCol,
295  const double *values, int LDA,
296  int NumRows, int NumCols, bool sum_into);
297 
299 
309  int BeginInsertGlobalValues(int BlockRow,
310  int NumBlockEntries,
311  int * BlockIndices);
312 
314 
324  int BeginInsertMyValues(int BlockRow, int NumBlockEntries, int * BlockIndices);
325 
327 
337  int BeginReplaceGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
338 
340 
350  int BeginReplaceMyValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
351 
353 
363  int BeginSumIntoGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
364 
366 
376  int BeginSumIntoMyValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
377 
379  /* Submit a block entry that will recorded in the block row that was initiated by one of the
380  Begin routines listed above. Once a one of the following routines: BeginInsertGlobalValues(),
381  BeginInsertMyValues(), BeginReplaceGlobalValues(), BeginReplaceMyValues(), BeginSumIntoGlobalValues(),
382  BeginSumIntoMyValues(), you \e must call SubmitBlockEntry() NumBlockEntries times to register the values
383  corresponding to the block indices passed in to the Begin routine. If the Epetra_VbrMatrix constuctor
384  was called in Copy mode, the values will be copied. However, no copying will be done until the EndSubmitEntries()
385  function is call to complete submission of the current block row. If the constructor was called in View mode, all
386  block entries passed via SubmitBlockEntry() will not be copied, but a pointer will be set to point to the argument Values
387  that was passed in by the user.
388 
389  For performance reasons, SubmitBlockEntry() does minimal processing of data. Any processing that can be
390  delayed is performed in EndSubmitEntries().
391 
392  \param In
393  Values - The starting address of the values.
394  \param In
395  LDA - The stride between successive columns of Values.
396  \param In
397  NumRows - The number of rows passed in.
398  \param In
399  NumCols - The number of columns passed in.
400 
401  \return Integer error code, set to 0 if successful.
402  */
403  int SubmitBlockEntry(double *Values, int LDA, int NumRows, int NumCols);
404 
406  /* Submit a block entry that will recorded in the block row that was initiated by one of the
407  Begin routines listed above. Once a one of the following routines: BeginInsertGlobalValues(),
408  BeginInsertMyValues(), BeginReplaceGlobalValues(), BeginReplaceMyValues(), BeginSumIntoGlobalValues(),
409  BeginSumIntoMyValues(), you \e must call SubmitBlockEntry() NumBlockEntries times to register the values
410  corresponding to the block indices passed in to the Begin routine. If the Epetra_VbrMatrix constuctor
411  was called in Copy mode, the values will be copied. However, no copying will be done until the EndSubmitEntries()
412  function is call to complete submission of the current block row. If the constructor was called in View mode, all
413  block entries passed via SubmitBlockEntry() will not be copied, but a pointer will be set to point to the argument Values
414  that was passed in by the user.
415 
416  For performance reasons, SubmitBlockEntry() does minimal processing of data. Any processing that can be
417  delayed is performed in EndSubmitEntries().
418 
419  \param In
420  Mat - Preformed dense matrix block.
421 
422  \return Integer error code, set to 0 if successful.
423  */
424  int SubmitBlockEntry( Epetra_SerialDenseMatrix &Mat );
425 
427 
432  int EndSubmitEntries();
433 
435 
446  int ReplaceDiagonalValues(const Epetra_Vector & Diagonal);
447 
449  /* This version of FillComplete assumes that the domain and range
450  distributions are identical to the matrix row distributions.
451  \return error code, 0 if successful. Returns a positive warning code of 3
452  if the matrix is rectangular (meaning that the other overloading of
453  FillComplete should have been called, with differen domain-map and
454  range-map specified).
455  */
456  int FillComplete();
457 
459  /* This version of FillComplete requires the explicit specification of the domain
460  and range distribution maps. These maps are used for importing and exporting vector
461  and multi-vector elements that are needed for distributed matrix computations. For
462  example, to compute y = Ax in parallel, we would specify the DomainMap as the distribution
463  of the vector x and the RangeMap as the distribution of the vector y.
464  \param In
465  DomainMap - Map that describes the distribution of vector and multi-vectors in the
466  matrix domain.
467  \param In
468  RangeMap - Map that describes the distribution of vector and multi-vectors in the
469  matrix range.
470 
471  \return error code, 0 if successful. positive warning code of 2 if it is detected that the
472  matrix-graph got out of sync since this matrix was constructed (for instance if
473  graph.FillComplete() was called by another matrix that shares the graph)
474  */
475  int FillComplete(const Epetra_BlockMap& DomainMap, const Epetra_BlockMap& RangeMap);
476 
478  bool Filled() const {return(Graph_->Filled());};
480 
482 
483 
485 
507  int ExtractGlobalBlockRowPointers(int BlockRow, int MaxNumBlockEntries,
508  int & RowDim, int & NumBlockEntries,
509  int * BlockIndices,
510  Epetra_SerialDenseMatrix ** & Values) const;
511 
513 
535  int ExtractMyBlockRowPointers(int BlockRow, int MaxNumBlockEntries,
536  int & RowDim, int & NumBlockEntries,
537  int * BlockIndices,
538  Epetra_SerialDenseMatrix** & Values) const;
539 
541 
557  int BeginExtractGlobalBlockRowCopy(int BlockRow, int MaxNumBlockEntries,
558  int & RowDim, int & NumBlockEntries,
559  int * BlockIndices, int * ColDims) const;
560 
562 
578  int BeginExtractMyBlockRowCopy(int BlockRow, int MaxNumBlockEntries,
579  int & RowDim, int & NumBlockEntries,
580  int * BlockIndices, int * ColDims) const;
581 
583 
598  int ExtractEntryCopy(int SizeOfValues, double * Values, int LDA, bool SumInto) const;
599 
601 
613  int BeginExtractGlobalBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
614  int * & BlockIndices) const;
615 
617 
629  int BeginExtractMyBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
630  int * & BlockIndices) const;
631 
632 
634 
641  int ExtractEntryView(Epetra_SerialDenseMatrix* & entry) const;
642 
644 
658  int ExtractGlobalBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
659  int * & BlockIndices,
660  Epetra_SerialDenseMatrix** & Values) const;
661 
663 
677  int ExtractMyBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
678  int * & BlockIndices,
679  Epetra_SerialDenseMatrix** & Values) const;
680 
681 
683 
689  int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
690 
692 
702  int BeginExtractBlockDiagonalCopy(int MaxNumBlockDiagonalEntries,
703  int & NumBlockDiagonalEntries, int * RowColDims ) const;
705 
720  int ExtractBlockDiagonalEntryCopy(int SizeOfValues, double * Values, int LDA, bool SumInto) const;
721 
723 
731  int BeginExtractBlockDiagonalView(int & NumBlockDiagonalEntries, int * & RowColDims ) const;
732 
734 
744  int ExtractBlockDiagonalEntryView(double * & Values, int & LDA) const;
746 
748 
749 
750 
752 
762  int Multiply1(bool TransA, const Epetra_Vector& x, Epetra_Vector& y) const;
763 
765 
775  int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
776 
778 
792  int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_Vector& x, Epetra_Vector& y) const;
793 
795 
809  int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
810 
811 
813 
823  int InvRowSums(Epetra_Vector& x) const;
824 
826 
833  int LeftScale(const Epetra_Vector& x);
834 
836 
846  int InvColSums(Epetra_Vector& x) const ;
847 
849 
856  int RightScale(const Epetra_Vector& x);
858 
860 
861 
863  int OptimizeStorage();
864 
866  bool StorageOptimized() const {return(StorageOptimized_);};
867 
869  bool IndicesAreGlobal() const {return(Graph_->IndicesAreGlobal());};
870 
872  bool IndicesAreLocal() const {return(Graph_->IndicesAreLocal());};
873 
875  bool IndicesAreContiguous() const {return(Graph_->IndicesAreContiguous());};
876 
878  bool LowerTriangular() const {return(Graph_->LowerTriangular());};
879 
881  bool UpperTriangular() const {return(Graph_->UpperTriangular());};
882 
884  bool NoDiagonal() const {return(Graph_->NoDiagonal());};
885 
887 
889 
890 
892  /* Returns the quantity \f$ \| A \|_\infty\f$ such that
893  \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f].
894  \warning The NormInf() method will not properly calculate the infinity norm for a matrix that has entries that are
895  replicated on multiple processors. */
896  double NormInf() const;
897 
899  /* Returns the quantity \f$ \| A \|_1\f$ such that
900  \f[\| A \|_1 = \max_{1\lej\len} \sum_{i=1}^m |a_{ij}| \f].
901  \warning The NormOne() method will not properly calculate the one norm for a matrix that has entries that are
902  */
903  double NormOne() const;
904 
906  /* Returns the quantity \f[ \| A \|_{Frobenius} = \sqrt{\sum_{i=1}^m \sum_{j=1}^n\|a_{ij}\|^2}\f]
907  \warning the NormFrobenius() method will not properly calculate the frobenius norm for a matrix that
908  has entries which are replicated on multiple processors. In that case, the returned
909  norm will be larger than the true norm.
910  */
911  double NormFrobenius() const;
912 
914  int MaxRowDim() const {return(Graph_->MaxRowDim());};
915 
917  int MaxColDim() const {return(Graph_->MaxColDim());};
918 
920  int GlobalMaxRowDim() const {return(Graph_->GlobalMaxRowDim());};
921 
923  int GlobalMaxColDim() const {return(Graph_->GlobalMaxColDim());};
924 
926  int NumMyRows() const {return(Graph_->NumMyRows());};
928  int NumMyCols() const {return(Graph_->NumMyCols());};
929 
931  int NumMyNonzeros() const {return(Graph_->NumMyNonzeros());};
932 
934 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
935  int NumGlobalRows() const {return(Graph_->NumGlobalRows());};
936 #endif
937  long long NumGlobalRows64() const {return(Graph_->NumGlobalRows64());};
938 
940 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
941  int NumGlobalCols() const {return(Graph_->NumGlobalCols());};
942 #endif
943  long long NumGlobalCols64() const {return(Graph_->NumGlobalCols64());};
944 
946  /*
947  Note that if maps are defined such that some nonzeros appear on
948  multiple processors, then those nonzeros will be counted multiple
949  times. If the user wishes to assemble a matrix from overlapping
950  submatrices, they can use Epetra_FEVbrMatrix.
951  */
952 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
953  int NumGlobalNonzeros() const {return(Graph_->NumGlobalNonzeros());};
954 #endif
955  long long NumGlobalNonzeros64() const {return(Graph_->NumGlobalNonzeros64());};
956 
958  int NumMyBlockRows() const {return(Graph_->NumMyBlockRows());};
959 
961  int NumMyBlockCols() const {return(Graph_->NumMyBlockCols());};
962 
964  int NumMyBlockEntries() const {return(Graph_->NumMyEntries());};
965 
967  int NumMyBlockDiagonals() const {return(Graph_->NumMyBlockDiagonals());};
968 
970  int NumMyDiagonals() const {return(Graph_->NumMyDiagonals());};
971 
973 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
974  int NumGlobalBlockRows() const {return(Graph_->NumGlobalBlockRows());};
975 #endif
976  long long NumGlobalBlockRows64() const {return(Graph_->NumGlobalBlockRows64());};
977 
979 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
980  int NumGlobalBlockCols() const {return(Graph_->NumGlobalBlockCols());};
981 #endif
982  long long NumGlobalBlockCols64() const {return(Graph_->NumGlobalBlockCols64());};
983 
985 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
986  int NumGlobalBlockEntries() const {return(Graph_->NumGlobalEntries());};
987 #endif
988  long long NumGlobalBlockEntries64() const {return(Graph_->NumGlobalEntries64());};
989 
991 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
992  int NumGlobalBlockDiagonals() const {return(Graph_->NumGlobalBlockDiagonals());};
993 #endif
994  long long NumGlobalBlockDiagonals64() const {return(Graph_->NumGlobalBlockDiagonals64());};
995 
997 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
998  int NumGlobalDiagonals() const {return(Graph_->NumGlobalDiagonals());};
999 #endif
1000  long long NumGlobalDiagonals64() const {return(Graph_->NumGlobalDiagonals64());};
1001 
1003  int NumGlobalBlockEntries(int Row) const {return(Graph_->NumGlobalIndices(Row));};
1004 
1006  int NumAllocatedGlobalBlockEntries(int Row) const{return(Graph_->NumAllocatedGlobalIndices(Row));};
1007 
1009  int MaxNumBlockEntries() const {return(Graph_->MaxNumIndices());};
1010 
1012  int GlobalMaxNumBlockEntries() const {return(Graph_->GlobalMaxNumIndices());};
1013 
1015  int NumMyBlockEntries(int Row) const {return(Graph_->NumMyIndices(Row));};
1016 
1018  int NumAllocatedMyBlockEntries(int Row) const {return(Graph_->NumAllocatedMyIndices(Row));};
1019 
1021 
1025  int MaxNumNonzeros() const {return(Graph_->MaxNumNonzeros());};
1026 
1028 
1030  int GlobalMaxNumNonzeros() const {return(Graph_->GlobalMaxNumNonzeros());};
1031 
1033 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1034  int IndexBase() const {
1036  if(RowMap().GlobalIndicesInt())
1037  return (int) IndexBase64();
1038  throw "Epetra_VbrMatrix::IndexBase: GlobalIndices not int.";
1039  }
1040 #endif
1041  long long IndexBase64() const {return(Graph_->IndexBase64());};
1042 
1044  const Epetra_CrsGraph & Graph() const {return(*Graph_);};
1045 
1047  const Epetra_Import * Importer() const {return(Graph_->Importer());};
1048 
1050  const Epetra_Export * Exporter() const {return(Graph_->Exporter());};
1051 
1053  const Epetra_BlockMap & DomainMap() const {return(Graph_->DomainMap());};
1054 
1056  const Epetra_BlockMap & RangeMap() const {return(Graph_->RangeMap());};
1057 
1059  const Epetra_BlockMap & RowMap() const {return(Graph_->RowMap());};
1060 
1062  const Epetra_BlockMap & ColMap() const {return(Graph_->ColMap());};
1063 
1065 
1067  const Epetra_Comm & Comm() const {return(Graph_->Comm());};
1068 
1070 
1072 
1073 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1075  int LRID( int GRID_in) const {return(Graph_->LRID(GRID_in));};
1076 #endif
1077 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1078  int LRID( long long GRID_in) const {return(Graph_->LRID(GRID_in));};
1079 #endif
1080 
1082 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1083  int GRID(int LRID_in) const {return(Graph_->GRID(LRID_in));};
1084 #endif
1085  long long GRID64( int LRID_in) const {return(Graph_->GRID64(LRID_in));};
1086 
1088 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1089  int LCID( int GCID_in) const {return(Graph_->LCID(GCID_in));};
1090 #endif
1091 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1092  int LCID( long long GCID_in) const {return(Graph_->LCID(GCID_in));};
1093 #endif
1094 
1096 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1097  int GCID(int LCID_in) const {return(Graph_->GCID(LCID_in));};
1098 #endif
1099  long long GCID64( int LCID_in) const {return(Graph_->GCID64(LCID_in));};
1100 
1102 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1103  bool MyGRID(int GRID_in) const {return(Graph_->MyGRID(GRID_in));};
1104 #endif
1105 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1106  bool MyGRID(long long GRID_in) const {return(Graph_->MyGRID(GRID_in));};
1107 #endif
1108 
1110  bool MyLRID(int LRID_in) const {return(Graph_->MyLRID(LRID_in));};
1111 
1113 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1114  bool MyGCID(int GCID_in) const {return(Graph_->MyGCID(GCID_in));};
1115 #endif
1116 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1117  bool MyGCID(long long GCID_in) const {return(Graph_->MyGCID(GCID_in));};
1118 #endif
1119 
1121  bool MyLCID(int LCID_in) const {return(Graph_->MyLCID(LCID_in));};
1122 
1124 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1125  bool MyGlobalBlockRow(int GID) const {return(Graph_->MyGlobalRow(GID));};
1126 #endif
1127 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1128  bool MyGlobalBlockRow(long long GID) const {return(Graph_->MyGlobalRow(GID));};
1129 #endif
1130 
1131 
1133 
1134 
1136  virtual void Print(std::ostream & os) const;
1138 
1140 
1141 
1143  const char * Label() const {return(Epetra_Object::Label());};
1144 
1146 
1155  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
1156 
1158 
1166  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
1167 
1169 
1182  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
1183 
1185  bool HasNormInf() const {return(true);};
1186 
1188  bool UseTranspose() const {return(UseTranspose_);};
1189 
1192  {
1193  if (!HavePointObjects_) GeneratePointObjects();
1194  if (UseTranspose()) return(*OperatorRangeMap_);
1195  else return(*OperatorDomainMap_);
1196  }
1197 
1200  {
1201  if (!HavePointObjects_) GeneratePointObjects();
1202  if (UseTranspose()) return(*OperatorDomainMap_);
1203  else return(*OperatorRangeMap_);
1204  }
1205 
1207 
1209 
1211 
1225  int ExtractGlobalRowCopy(int GlobalRow, int Length, int & NumEntries, double *Values, int * Indices) const;
1226 
1228 
1242  int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
1243 
1245 
1253  int NumMyRowEntries(int MyRow, int & NumEntries) const;
1254 
1256  int MaxNumEntries() const;
1257 
1259  const Epetra_BlockMap& Map() const { return Epetra_DistObject::Map(); }
1260 
1262  const Epetra_Map & RowMatrixRowMap() const
1263  { if (!HavePointObjects_) GeneratePointObjects(); return(*RowMatrixRowMap_); };
1264 
1266  const Epetra_Map & RowMatrixColMap() const
1267  { if (!HavePointObjects_) GeneratePointObjects(); return(*RowMatrixColMap_); };
1268 
1271  { if (!HavePointObjects_) GeneratePointObjects(); return(RowMatrixImporter_); };
1272 
1274 
1276 
1277 
1279  const Epetra_BlockMap & BlockImportMap() const {return(Graph_->ImportMap());};
1280 
1282  int TransformToLocal();
1283 
1285  int TransformToLocal(const Epetra_BlockMap* DomainMap, const Epetra_BlockMap* RangeMap);
1287 
1288  protected:
1289  void DeleteMemory();
1290  bool Allocated() const {return(Allocated_);};
1291  int SetAllocated(bool Flag) {Allocated_ = Flag; return(0);};
1292  Epetra_SerialDenseMatrix *** Values() const {return(Entries_);};
1293 
1294  // Internal utilities
1295 
1296  int DoMultiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
1297  int DoSolve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
1298  void InitializeDefaults();
1299  int Allocate();
1300  int BeginInsertValues(int BlockRow, int NumBlockEntries,
1301  int * BlockIndices, bool IndicesAreLocal);
1302  int BeginReplaceValues(int BlockRow, int NumBlockEntries,
1303  int *BlockIndices, bool IndicesAreLocal);
1304  int BeginSumIntoValues(int BlockRow, int NumBlockEntries,
1305  int *BlockIndices, bool IndicesAreLocal);
1306  int SetupForSubmits(int BlockRow, int NumBlockEntries, int * BlockIndices,
1307  bool IndicesAreLocal, Epetra_CombineMode SubmitMode);
1308  int EndReplaceSumIntoValues();
1309  int EndInsertValues();
1310 
1311  int CopyMat(double * A, int LDA, int NumRows, int NumCols,
1312  double * B, int LDB, bool SumInto) const;
1313  int BeginExtractBlockRowCopy(int BlockRow, int MaxNumBlockEntries,
1314  int & RowDim, int & NumBlockEntries,
1315  int * BlockIndices, int * ColDims,
1316  bool IndicesAreLocal) const;
1317  int SetupForExtracts(int BlockRow, int & RowDim, int NumBlockEntries,
1318  bool ExtractView, bool IndicesAreLocal) const;
1319  int ExtractBlockDimsCopy(int NumBlockEntries, int * ColDims) const;
1320  int ExtractBlockRowPointers(int BlockRow, int MaxNumBlockEntries,
1321  int & RowDim, int & NumBlockEntries,
1322  int * BlockIndices,
1323  Epetra_SerialDenseMatrix ** & Values,
1324  bool IndicesAreLocal) const;
1325  int BeginExtractBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
1326  int * & BlockIndices,
1327  bool IndicesAreLocal) const;
1328  int CopyMatDiag(double * A, int LDA, int NumRows, int NumCols,
1329  double * Diagonal) const;
1330  int ReplaceMatDiag(double * A, int LDA, int NumRows, int NumCols,
1331  double * Diagonal);
1332 
1333  //This BlockRowMultiply accepts Alpha and Beta arguments. It is called
1334  //from within the 'solve' methods.
1335  void BlockRowMultiply(bool TransA, int RowDim, int NumEntries,
1336  int * BlockIndices, int RowOff,
1337  int * FirstPointInElementList, int * ElementSizeList,
1338  double Alpha, Epetra_SerialDenseMatrix** As,
1339  double ** X, double Beta, double ** Y, int NumVectors) const;
1340 
1341  //This BlockRowMultiply doesn't accept Alpha and Beta arguments, instead it
1342  //assumes that they are both 1.0. It is called from within the 'Multiply'
1343  //methods.
1344  void BlockRowMultiply(bool TransA, int RowDim, int NumEntries,
1345  int * BlockIndices, int RowOff,
1346  int * FirstPointInElementList,
1347  int * ElementSizeList,
1349  double ** X, double ** Y, int NumVectors) const;
1350  //
1351  // Assumes Alpha=Beta=1 and works only on storage optimized matrices
1352  //
1353  void FastBlockRowMultiply(bool TransA, int RowDim, int NumEntries,
1354  int * BlockIndices, int RowOff,
1355  int * FirstPointInElementList,
1356  int * ElementSizeList,
1358  double ** X, double ** Y, int NumVectors) const;
1359 
1360  int InverseSums(bool DoRows, Epetra_Vector& x) const;
1361  int Scale(bool DoRows, const Epetra_Vector& x);
1362  void BlockRowNormInf(int RowDim, int NumEntries,
1364  double * Y) const;
1365  void BlockRowNormOne(int RowDim, int NumEntries, int * BlockRowIndices,
1367  int * ColFirstPointInElementList, double * x) const;
1368  void SetStaticGraph(bool Flag) {StaticGraph_ = Flag;};
1369 
1370  int CheckSizes(const Epetra_SrcDistObject& A);
1371 
1372  int CopyAndPermute(const Epetra_SrcDistObject & Source,
1373  int NumSameIDs,
1374  int NumPermuteIDs,
1375  int * PermuteToLIDs,
1376  int *PermuteFromLIDs,
1377  const Epetra_OffsetIndex * Indexor,
1378  Epetra_CombineMode CombineMode = Zero);
1379 
1380  int PackAndPrepare(const Epetra_SrcDistObject & Source,
1381  int NumExportIDs,
1382  int * ExportLIDs,
1383  int & LenExports,
1384  char * & Exports,
1385  int & SizeOfPacket,
1386  int * Sizes,
1387  bool & VarSizes,
1388  Epetra_Distributor & Distor);
1389 
1390  int UnpackAndCombine(const Epetra_SrcDistObject & Source,
1391  int NumImportIDs,
1392  int * ImportLIDs,
1393  int LenImports,
1394  char * Imports,
1395  int & SizeOfPacket,
1396  Epetra_Distributor & Distor,
1397  Epetra_CombineMode CombineMode,
1398  const Epetra_OffsetIndex * Indexor);
1399 
1401  int SortEntries();
1402 
1404  bool Sorted() const {return(Graph_->Sorted());};
1405 
1407  int MergeRedundantEntries();
1408 
1410  bool NoRedundancies() const {return(Graph_->NoRedundancies());};
1411 
1412  bool StaticGraph() const {return(StaticGraph_);};
1413 
1414  int GeneratePointObjects() const;
1415  int BlockMap2PointMap(const Epetra_BlockMap & BlockMap, Epetra_Map * & PointMap) const;
1416  int UpdateOperatorXY(const Epetra_MultiVector& X, const Epetra_MultiVector& Y) const;
1417 
1425 
1427 
1429 
1430 
1433  int ** Indices_;
1436 
1438 
1440  double *All_Values_;
1441 
1442  mutable double NormInf_;
1443  mutable double NormOne_;
1444  mutable double NormFrob_;
1445 
1448 
1449  // State variables needed for constructing matrix entry-by-entry
1450  mutable int *TempRowDims_;
1452  mutable int LenTemps_;
1453  mutable int CurBlockRow_;
1454  mutable int CurNumBlockEntries_;
1455  mutable int * CurBlockIndices_;
1456  mutable int CurEntry_;
1457  mutable bool CurIndicesAreLocal_;
1459 
1460  // State variables needed for extracting entries
1461  mutable int CurExtractBlockRow_;
1462  mutable int CurExtractEntry_;
1465  mutable bool CurExtractView_;
1466  mutable int CurRowDim_;
1467 
1468  // State variable for extracting block diagonal entries
1469  mutable int CurBlockDiag_;
1470 
1471  // Maps and importer that support the Epetra_RowMatrix interface
1475 
1476  // Maps that support the Epetra_Operator interface
1481 
1482  // bool to indicate if above four point maps and importer have already been created
1483  mutable bool HavePointObjects_;
1484 
1486 };
1487 
1488 #endif /* EPETRA_VBRMATRIX_H */
const Epetra_Import * Importer() const
Returns the Epetra_Import object that contains the import operations for distributed operations...
Epetra_MultiVector: A class for constructing and using dense multi-vectors, vectors and matrices in p...
int NumMyBlockEntries(int Row) const
Returns the current number of nonzero Block entries in specified local row on this processor...
bool MyGlobalBlockRow(long long GID) const
int SetUseTranspose(bool UseTranspose_in)
If set true, transpose of this operator will be applied.
long long IndexBase64() const
Epetra_Map: A class for partitioning vectors and matrices.
Definition: Epetra_Map.h:127
int MaxNumNonzeros() const
Returns the maximum number of nonzero entries across all block rows on this processor.
const Epetra_Import * RowMatrixImporter() const
Returns the Epetra_Import object that contains the import operations for distributed operations...
const Epetra_BlockMap & RangeMap() const
Returns the Epetra_BlockMap object associated with the range of this matrix operator.
virtual int RightScale(const Epetra_Vector &x)=0
Scales the Epetra_RowMatrix on the right with a Epetra_Vector x.
const Epetra_Map & RowMatrixColMap() const
Returns the Epetra_Map object associated with columns of this matrix.
int SetAllocated(bool Flag)
int NumGlobalCols() const
Returns the number of global matrix columns.
virtual double NormOne() const =0
Returns the one norm of the global matrix.
Epetra_Distributor: The Epetra Gather/Scatter Setup Base Class.
virtual int CopyAndPermute(const Epetra_SrcDistObject &Source, int NumSameIDs, int NumPermuteIDs, int *PermuteToLIDs, int *PermuteFromLIDs, const Epetra_OffsetIndex *Indexor, Epetra_CombineMode CombineMode=Zero)=0
Perform ID copies and permutations that are on processor.
Epetra_OffsetIndex: This class builds index for efficient mapping of data from one Epetra_CrsGraph ba...
const Epetra_CrsGraph & Graph() const
Returns a pointer to the Epetra_CrsGraph object associated with this matrix.
long long NumGlobalDiagonals64() const
bool NoDiagonal() const
If matrix has no diagonal entries based on global row/column index comparisons, this query returns tr...
virtual int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Returns the result of a Epetra_Operator inverse applied to an Epetra_MultiVector X in Y...
virtual void Print(std::ostream &os) const
Print method.
bool NoRedundancies() const
If MergeRedundantEntries() has been called, this query returns true, otherwise it returns false...
bool Allocated() const
long long NumGlobalBlockDiagonals64() const
const Epetra_BlockMap & ColMap() const
Returns the ColMap as an Epetra_BlockMap (the Epetra_Map base class) needed for implementing Epetra_R...
const Epetra_BlockMap & BlockImportMap() const
Use BlockColMap() instead.
void SetStaticGraph(bool Flag)
bool MyGRID(int GRID_in) const
Returns true if the GRID passed in belongs to the calling processor in this map, otherwise returns fa...
int NumGlobalBlockEntries(int Row) const
Returns the current number of nonzero Block entries in specified global row on this processor...
bool IndicesAreGlobal() const
If matrix indices has not been transformed to local, this query returns true, otherwise it returns fa...
Epetra_DataAccess CV_
Epetra_SerialDenseMatrix *** Values() const
int NumMyRows() const
Returns the number of matrix rows owned by the calling processor.
int NumMyBlockRows() const
Returns the number of Block matrix rows owned by the calling processor.
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Definition: Epetra_Export.h:70
Epetra_VbrMatrix: A class for the construction and use of real-valued double-precision variable block...
Epetra_Vector: A class for constructing and using dense vectors on a parallel computer.
virtual int ExtractDiagonalCopy(Epetra_Vector &Diagonal) const =0
Returns a copy of the main diagonal in a user-provided vector.
virtual int LeftScale(const Epetra_Vector &x)=0
Scales the Epetra_RowMatrix on the left with a Epetra_Vector x.
int * NumAllocatedBlockEntriesPerRow_
Epetra_CompObject & operator=(const Epetra_CompObject &src)
const Epetra_Export * Exporter() const
Returns the Epetra_Export object that contains the export operations for distributed operations...
Epetra_SerialDenseMatrix: A class for constructing and using real double precision general dense matr...
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
Definition: Epetra_Import.h:71
bool MyLRID(int LRID_in) const
Returns true if the LRID passed in belongs to the calling processor in this map, otherwise returns fa...
Epetra_Map * OperatorRangeMap_
virtual int InvRowSums(Epetra_Vector &x) const =0
Computes the sum of absolute values of the rows of the Epetra_RowMatrix, results returned in x...
int NumGlobalBlockCols() const
Returns the number of global Block matrix columns.
bool MyGCID(long long GCID_in) const
bool Filled() const
If FillComplete() has been called, this query returns true, otherwise it returns false.
bool UseTranspose() const
Returns the current UseTranspose setting.
int GRID(int LRID_in) const
Returns the global row index for give local row index, returns IndexBase-1 if we don&#39;t have this loca...
virtual int CheckSizes(const Epetra_SrcDistObject &Source)=0
Allows the source and target (this) objects to be compared for compatibility, return nonzero if not...
bool StorageOptimized() const
If OptimizeStorage() has been called, this query returns true, otherwise it returns false...
const Epetra_Comm & Comm() const
Fills a matrix with rows from a source matrix based on the specified importer.
int MaxColDim() const
Returns the maximum column dimension of all block entries on this processor.
bool MyGRID(long long GRID_in) const
Epetra_Map * RowMatrixRowMap_
const Epetra_BlockMap & Map() const
Map() method inherited from Epetra_DistObject.
long long GRID64(int LRID_in) const
bool LowerTriangular() const
If matrix is lower triangular in local index space, this query returns true, otherwise it returns fal...
Epetra_MultiVector * ImportVector_
int LCID(long long GCID_in) const
Epetra_BLAS: The Epetra BLAS Wrapper Class.
Definition: Epetra_BLAS.h:78
const Epetra_BlockMap & DomainMap() const
Returns the Epetra_BlockMap object associated with the domain of this matrix operator.
virtual int NumMyRowEntries(int MyRow, int &NumEntries) const =0
Returns the number of nonzero entries in MyRow.
virtual int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Returns the result of a Epetra_Operator applied to a Epetra_MultiVector X in Y.
virtual int MaxNumEntries() const =0
Returns the maximum of NumMyRowEntries() over all rows.
virtual const char * Label() const
Epetra_Object Label access funtion.
long long NumGlobalBlockEntries64() const
int GlobalMaxColDim() const
Returns the maximum column dimension of all block entries across all processors.
Epetra_MultiVector * OperatorY_
Epetra_Comm: The Epetra Communication Abstract Base Class.
Definition: Epetra_Comm.h:81
int NumMyNonzeros() const
Returns the number of nonzero entriesowned by the calling processor .
virtual bool UseTranspose() const =0
Returns the current UseTranspose setting.
int GlobalMaxNumBlockEntries() const
Returns the maximum number of nonzero entries across all rows on this processor.
long long NumGlobalBlockRows64() const
int NumMyBlockDiagonals() const
Returns the number of local nonzero block diagonal entries, based on global row/column index comparis...
int LRID(int GRID_in) const
Returns the local row index for given global row index, returns -1 if no local row for this global ro...
Epetra_MultiVector * ExportVector_
int NumGlobalBlockEntries() const
Returns the number of nonzero block entries in the global matrix.
Epetra_CompObject: Functionality and data that is common to all computational classes.
virtual double NormInf() const =0
Returns the infinity norm of the global matrix.
virtual int UnpackAndCombine(const Epetra_SrcDistObject &Source, int NumImportIDs, int *ImportLIDs, int LenImports, char *Imports, int &SizeOfPacket, Epetra_Distributor &Distor, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor)=0
Perform any unpacking and combining after call to DoTransfer().
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
const Epetra_BlockMap & RowMap() const
Returns the RowMap object as an Epetra_BlockMap (the Epetra_Map base class) needed for implementing E...
int NumGlobalDiagonals() const
Returns the number of global nonzero diagonal entries, based on global row/column index comparisions...
bool MyGlobalBlockRow(int GID) const
Returns true of GID is owned by the calling processor, otherwise it returns false.
int MaxRowDim() const
Returns the maximum row dimension of all block entries on this processor.
bool IndicesAreLocal() const
If matrix indices has been transformed to local, this query returns true, otherwise it returns false...
Epetra_CrsGraph * Graph_
int GlobalMaxRowDim() const
Returns the maximum row dimension of all block entries across all processors.
bool StaticGraph() const
int NumMyCols() const
Returns the number of matrix columns owned by the calling processor.
Epetra_Import * RowMatrixImporter_
const Epetra_Map & OperatorRangeMap() const
Returns the Epetra_Map object associated with the range of this matrix operator.
const Epetra_Map & RowMatrixRowMap() const
Returns the EpetraMap object associated with the rows of this matrix.
bool MyGCID(int GCID_in) const
Returns true if the GCID passed in belongs to the calling processor in this map, otherwise returns fa...
int NumMyDiagonals() const
Returns the number of local nonzero diagonal entries, based on global row/column index comparisons...
virtual int Multiply(bool TransA, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Returns the result of a Epetra_RowMatrix multiplied by a Epetra_MultiVector X in Y.
int GlobalMaxNumNonzeros() const
Returns the maximum number of nonzero entries across all block rows on all processors.
long long NumGlobalRows64() const
int LRID(long long GRID_in) const
int LCID(int GCID_in) const
Returns the local column index for given global column index, returns -1 if no local column for this ...
Epetra_CombineMode CurSubmitMode_
int NumGlobalRows() const
Returns the number of global matrix rows.
Epetra_SerialDenseMatrix *** Entries_
Epetra_Map * RowMatrixColMap_
const Epetra_Map & OperatorDomainMap() const
Returns the Epetra_Map object associated with the domain of this matrix operator. ...
Epetra_Map * OperatorDomainMap_
long long NumGlobalNonzeros64() const
bool UpperTriangular() const
If matrix is upper triangular in local index space, this query returns true, otherwise it returns fal...
int NumMyBlockCols() const
Returns the number of Block matrix columns owned by the calling processor.
Epetra_CombineMode
long long NumGlobalBlockCols64() const
int NumAllocatedMyBlockEntries(int Row) const
Returns the allocated number of nonzero Block entries in specified local row on this processor...
virtual int ExtractMyRowCopy(int MyRow, int Length, int &NumEntries, double *Values, int *Indices) const =0
Returns a copy of the specified local row in user-provided arrays.
int GCID(int LCID_in) const
Returns the global column index for give local column index, returns IndexBase-1 if we don&#39;t have thi...
virtual int InvColSums(Epetra_Vector &x) const =0
Computes the sum of absolute values of the columns of the Epetra_RowMatrix, results returned in x...
Epetra_SerialDenseMatrix ** TempEntries_
int NumAllocatedGlobalBlockEntries(int Row) const
Returns the allocated number of nonzero Block entries in specified global row on this processor...
Epetra_SrcDistObject: A class for supporting flexible source distributed objects for import/export op...
Epetra_MultiVector * OperatorX_
Epetra_RowMatrix: A pure virtual class for using real-valued double-precision row matrices...
Epetra_DataAccess
bool HasNormInf() const
Returns true because this class can compute an Inf-norm.
bool IndicesAreContiguous() const
If matrix indices are packed into single array (done in OptimizeStorage()) return true...
int NumMyBlockEntries() const
Returns the number of nonzero block entries in the calling processor&#39;s portion of the matrix...
int MaxNumBlockEntries() const
Returns the maximum number of nonzero entries across all rows on this processor.
virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector &X, Epetra_MultiVector &Y) const =0
Returns result of a local-only solve using a triangular Epetra_RowMatrix with Epetra_MultiVectors X a...
long long NumGlobalCols64() const
const char * Label() const
Returns a character string describing the operator.
long long GCID64(int LCID_in) const
bool MyLCID(int LCID_in) const
Returns true if the LRID passed in belongs to the calling processor in this map, otherwise returns fa...
int NumGlobalNonzeros() const
Returns the number of nonzero entries in the global matrix.
int NumGlobalBlockRows() const
Returns the number of global Block matrix rows.
int NumGlobalBlockDiagonals() const
Returns the number of global nonzero block diagonal entries, based on global row/column index compari...
Epetra_CrsGraph: A class for constructing and using sparse compressed row graphs. ...
bool Sorted() const
If SortEntries() has been called, this query returns true, otherwise it returns false.
Epetra_DistObject: A class for constructing and using dense multi-vectors, vectors and matrices in pa...
virtual int PackAndPrepare(const Epetra_SrcDistObject &Source, int NumExportIDs, int *ExportLIDs, int &LenExports, char *&Exports, int &SizeOfPacket, int *Sizes, bool &VarSizes, Epetra_Distributor &Distor)=0
Perform any packing or preparation required for call to DoTransfer().
const Epetra_BlockMap & Map() const
Returns the address of the Epetra_BlockMap for this multi-vector.