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 // FIXME long long : whole file
48 
49 #include <Epetra_ConfigDefs.h>
50 #include <Epetra_DistObject.h>
51 #include <Epetra_CompObject.h>
52 #include <Epetra_BLAS.h>
53 #include <Epetra_RowMatrix.h>
54 #include <Epetra_Operator.h>
55 #include <Epetra_CrsGraph.h>
57 class Epetra_BlockMap;
58 class Epetra_Map;
59 class Epetra_Import;
60 class Epetra_Export;
61 class Epetra_Vector;
62 class Epetra_MultiVector;
63 
65 
172 class EPETRA_LIB_DLL_EXPORT Epetra_VbrMatrix : public Epetra_DistObject,
173  public Epetra_CompObject,
174  public Epetra_BLAS,
175  public virtual Epetra_RowMatrix {
176  public:
177 
179 
180 
191  Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, int *NumBlockEntriesPerRow);
192 
194 
205  Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, int NumBlockEntriesPerRow);
206 
208 
220  Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, const Epetra_BlockMap& ColMap, int *NumBlockEntriesPerRow);
221 
223 
236  Epetra_VbrMatrix(Epetra_DataAccess CV, const Epetra_BlockMap& RowMap, const Epetra_BlockMap& ColMap, int NumBlockEntriesPerRow);
237 
239 
249 
251  Epetra_VbrMatrix(const Epetra_VbrMatrix & Matrix);
252 
254  virtual ~Epetra_VbrMatrix();
256 
258 
259 
261 
263 
269  int PutScalar(double ScalarConstant);
270 
272 
278  int Scale(double ScalarConstant);
279 
281 
286  int DirectSubmitBlockEntry(int GlobalBlockRow, int GlobalBlockCol,
287  const double *values, int LDA,
288  int NumRows, int NumCols, bool sum_into);
289 
291 
301  int BeginInsertGlobalValues(int BlockRow,
302  int NumBlockEntries,
303  int * BlockIndices);
304 
306 
316  int BeginInsertMyValues(int BlockRow, int NumBlockEntries, int * BlockIndices);
317 
319 
329  int BeginReplaceGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
330 
332 
342  int BeginReplaceMyValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
343 
345 
355  int BeginSumIntoGlobalValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
356 
358 
368  int BeginSumIntoMyValues(int BlockRow, int NumBlockEntries, int *BlockIndices);
369 
371  /* Submit a block entry that will recorded in the block row that was initiated by one of the
372  Begin routines listed above. Once a one of the following routines: BeginInsertGlobalValues(),
373  BeginInsertMyValues(), BeginReplaceGlobalValues(), BeginReplaceMyValues(), BeginSumIntoGlobalValues(),
374  BeginSumIntoMyValues(), you \e must call SubmitBlockEntry() NumBlockEntries times to register the values
375  corresponding to the block indices passed in to the Begin routine. If the Epetra_VbrMatrix constuctor
376  was called in Copy mode, the values will be copied. However, no copying will be done until the EndSubmitEntries()
377  function is call to complete submission of the current block row. If the constructor was called in View mode, all
378  block entries passed via SubmitBlockEntry() will not be copied, but a pointer will be set to point to the argument Values
379  that was passed in by the user.
380 
381  For performance reasons, SubmitBlockEntry() does minimal processing of data. Any processing that can be
382  delayed is performed in EndSubmitEntries().
383 
384  \param In
385  Values - The starting address of the values.
386  \param In
387  LDA - The stride between successive columns of Values.
388  \param In
389  NumRows - The number of rows passed in.
390  \param In
391  NumCols - The number of columns passed in.
392 
393  \return Integer error code, set to 0 if successful.
394  */
395  int SubmitBlockEntry(double *Values, int LDA, int NumRows, int NumCols);
396 
398  /* Submit a block entry that will recorded in the block row that was initiated by one of the
399  Begin routines listed above. Once a one of the following routines: BeginInsertGlobalValues(),
400  BeginInsertMyValues(), BeginReplaceGlobalValues(), BeginReplaceMyValues(), BeginSumIntoGlobalValues(),
401  BeginSumIntoMyValues(), you \e must call SubmitBlockEntry() NumBlockEntries times to register the values
402  corresponding to the block indices passed in to the Begin routine. If the Epetra_VbrMatrix constuctor
403  was called in Copy mode, the values will be copied. However, no copying will be done until the EndSubmitEntries()
404  function is call to complete submission of the current block row. If the constructor was called in View mode, all
405  block entries passed via SubmitBlockEntry() will not be copied, but a pointer will be set to point to the argument Values
406  that was passed in by the user.
407 
408  For performance reasons, SubmitBlockEntry() does minimal processing of data. Any processing that can be
409  delayed is performed in EndSubmitEntries().
410 
411  \param In
412  Mat - Preformed dense matrix block.
413 
414  \return Integer error code, set to 0 if successful.
415  */
416  int SubmitBlockEntry( Epetra_SerialDenseMatrix &Mat );
417 
419 
424  int EndSubmitEntries();
425 
427 
438  int ReplaceDiagonalValues(const Epetra_Vector & Diagonal);
439 
441  /* This version of FillComplete assumes that the domain and range
442  distributions are identical to the matrix row distributions.
443  \return error code, 0 if successful. Returns a positive warning code of 3
444  if the matrix is rectangular (meaning that the other overloading of
445  FillComplete should have been called, with differen domain-map and
446  range-map specified).
447  */
448  int FillComplete();
449 
451  /* This version of FillComplete requires the explicit specification of the domain
452  and range distribution maps. These maps are used for importing and exporting vector
453  and multi-vector elements that are needed for distributed matrix computations. For
454  example, to compute y = Ax in parallel, we would specify the DomainMap as the distribution
455  of the vector x and the RangeMap as the distribution of the vector y.
456  \param In
457  DomainMap - Map that describes the distribution of vector and multi-vectors in the
458  matrix domain.
459  \param In
460  RangeMap - Map that describes the distribution of vector and multi-vectors in the
461  matrix range.
462 
463  \return error code, 0 if successful. positive warning code of 2 if it is detected that the
464  matrix-graph got out of sync since this matrix was constructed (for instance if
465  graph.FillComplete() was called by another matrix that shares the graph)
466  */
467  int FillComplete(const Epetra_BlockMap& DomainMap, const Epetra_BlockMap& RangeMap);
468 
470  bool Filled() const {return(Graph_->Filled());};
472 
474 
475 
477 
499  int ExtractGlobalBlockRowPointers(int BlockRow, int MaxNumBlockEntries,
500  int & RowDim, int & NumBlockEntries,
501  int * BlockIndices,
502  Epetra_SerialDenseMatrix ** & Values) const;
503 
505 
527  int ExtractMyBlockRowPointers(int BlockRow, int MaxNumBlockEntries,
528  int & RowDim, int & NumBlockEntries,
529  int * BlockIndices,
530  Epetra_SerialDenseMatrix** & Values) const;
531 
533 
549  int BeginExtractGlobalBlockRowCopy(int BlockRow, int MaxNumBlockEntries,
550  int & RowDim, int & NumBlockEntries,
551  int * BlockIndices, int * ColDims) const;
552 
554 
570  int BeginExtractMyBlockRowCopy(int BlockRow, int MaxNumBlockEntries,
571  int & RowDim, int & NumBlockEntries,
572  int * BlockIndices, int * ColDims) const;
573 
575 
590  int ExtractEntryCopy(int SizeOfValues, double * Values, int LDA, bool SumInto) const;
591 
593 
605  int BeginExtractGlobalBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
606  int * & BlockIndices) const;
607 
609 
621  int BeginExtractMyBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
622  int * & BlockIndices) const;
623 
624 
626 
633  int ExtractEntryView(Epetra_SerialDenseMatrix* & entry) const;
634 
636 
650  int ExtractGlobalBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
651  int * & BlockIndices,
652  Epetra_SerialDenseMatrix** & Values) const;
653 
655 
669  int ExtractMyBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
670  int * & BlockIndices,
671  Epetra_SerialDenseMatrix** & Values) const;
672 
673 
675 
681  int ExtractDiagonalCopy(Epetra_Vector & Diagonal) const;
682 
684 
694  int BeginExtractBlockDiagonalCopy(int MaxNumBlockDiagonalEntries,
695  int & NumBlockDiagonalEntries, int * RowColDims ) const;
697 
712  int ExtractBlockDiagonalEntryCopy(int SizeOfValues, double * Values, int LDA, bool SumInto) const;
713 
715 
723  int BeginExtractBlockDiagonalView(int & NumBlockDiagonalEntries, int * & RowColDims ) const;
724 
726 
736  int ExtractBlockDiagonalEntryView(double * & Values, int & LDA) const;
738 
740 
741 
742 
744 
754  int Multiply1(bool TransA, const Epetra_Vector& x, Epetra_Vector& y) const;
755 
757 
767  int Multiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
768 
770 
784  int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_Vector& x, Epetra_Vector& y) const;
785 
787 
801  int Solve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
802 
803 
805 
815  int InvRowSums(Epetra_Vector& x) const;
816 
818 
825  int LeftScale(const Epetra_Vector& x);
826 
828 
838  int InvColSums(Epetra_Vector& x) const ;
839 
841 
848  int RightScale(const Epetra_Vector& x);
850 
852 
853 
855  int OptimizeStorage();
856 
858  bool StorageOptimized() const {return(StorageOptimized_);};
859 
861  bool IndicesAreGlobal() const {return(Graph_->IndicesAreGlobal());};
862 
864  bool IndicesAreLocal() const {return(Graph_->IndicesAreLocal());};
865 
867  bool IndicesAreContiguous() const {return(Graph_->IndicesAreContiguous());};
868 
870  bool LowerTriangular() const {return(Graph_->LowerTriangular());};
871 
873  bool UpperTriangular() const {return(Graph_->UpperTriangular());};
874 
876  bool NoDiagonal() const {return(Graph_->NoDiagonal());};
877 
879 
881 
882 
884  /* Returns the quantity \f$ \| A \|_\infty\f$ such that
885  \f[\| A \|_\infty = \max_{1\lei\lem} \sum_{j=1}^n |a_{ij}| \f].
886  \warning The NormInf() method will not properly calculate the infinity norm for a matrix that has entries that are
887  replicated on multiple processors. */
888  double NormInf() const;
889 
891  /* Returns the quantity \f$ \| A \|_1\f$ such that
892  \f[\| A \|_1 = \max_{1\lej\len} \sum_{i=1}^m |a_{ij}| \f].
893  \warning The NormOne() method will not properly calculate the one norm for a matrix that has entries that are
894  */
895  double NormOne() const;
896 
898  /* Returns the quantity \f[ \| A \|_{Frobenius} = \sqrt{\sum_{i=1}^m \sum_{j=1}^n\|a_{ij}\|^2}\f]
899  \warning the NormFrobenius() method will not properly calculate the frobenius norm for a matrix that
900  has entries which are replicated on multiple processors. In that case, the returned
901  norm will be larger than the true norm.
902  */
903  double NormFrobenius() const;
904 
906  int MaxRowDim() const {return(Graph_->MaxRowDim());};
907 
909  int MaxColDim() const {return(Graph_->MaxColDim());};
910 
912  int GlobalMaxRowDim() const {return(Graph_->GlobalMaxRowDim());};
913 
915  int GlobalMaxColDim() const {return(Graph_->GlobalMaxColDim());};
916 
918  int NumMyRows() const {return(Graph_->NumMyRows());};
920  int NumMyCols() const {return(Graph_->NumMyCols());};
921 
923  int NumMyNonzeros() const {return(Graph_->NumMyNonzeros());};
924 
926 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
927  int NumGlobalRows() const {return(Graph_->NumGlobalRows());};
928 #endif
929  long long NumGlobalRows64() const {return(Graph_->NumGlobalRows64());};
930 
932 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
933  int NumGlobalCols() const {return(Graph_->NumGlobalCols());};
934 #endif
935  long long NumGlobalCols64() const {return(Graph_->NumGlobalCols64());};
936 
938  /*
939  Note that if maps are defined such that some nonzeros appear on
940  multiple processors, then those nonzeros will be counted multiple
941  times. If the user wishes to assemble a matrix from overlapping
942  submatrices, they can use Epetra_FEVbrMatrix.
943  */
944 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
945  int NumGlobalNonzeros() const {return(Graph_->NumGlobalNonzeros());};
946 #endif
947  long long NumGlobalNonzeros64() const {return(Graph_->NumGlobalNonzeros64());};
948 
950  int NumMyBlockRows() const {return(Graph_->NumMyBlockRows());};
951 
953  int NumMyBlockCols() const {return(Graph_->NumMyBlockCols());};
954 
956  int NumMyBlockEntries() const {return(Graph_->NumMyEntries());};
957 
959  int NumMyBlockDiagonals() const {return(Graph_->NumMyBlockDiagonals());};
960 
962  int NumMyDiagonals() const {return(Graph_->NumMyDiagonals());};
963 
965 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
966  int NumGlobalBlockRows() const {return(Graph_->NumGlobalBlockRows());};
967 #endif
968  long long NumGlobalBlockRows64() const {return(Graph_->NumGlobalBlockRows64());};
969 
971 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
972  int NumGlobalBlockCols() const {return(Graph_->NumGlobalBlockCols());};
973 #endif
974  long long NumGlobalBlockCols64() const {return(Graph_->NumGlobalBlockCols64());};
975 
977 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
978  int NumGlobalBlockEntries() const {return(Graph_->NumGlobalEntries());};
979 #endif
980  long long NumGlobalBlockEntries64() const {return(Graph_->NumGlobalEntries64());};
981 
983 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
984  int NumGlobalBlockDiagonals() const {return(Graph_->NumGlobalBlockDiagonals());};
985 #endif
986  long long NumGlobalBlockDiagonals64() const {return(Graph_->NumGlobalBlockDiagonals64());};
987 
989 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
990  int NumGlobalDiagonals() const {return(Graph_->NumGlobalDiagonals());};
991 #endif
992  long long NumGlobalDiagonals64() const {return(Graph_->NumGlobalDiagonals64());};
993 
995  int NumGlobalBlockEntries(int Row) const {return(Graph_->NumGlobalIndices(Row));};
996 
998  int NumAllocatedGlobalBlockEntries(int Row) const{return(Graph_->NumAllocatedGlobalIndices(Row));};
999 
1001  int MaxNumBlockEntries() const {return(Graph_->MaxNumIndices());};
1002 
1004  int GlobalMaxNumBlockEntries() const {return(Graph_->GlobalMaxNumIndices());};
1005 
1007  int NumMyBlockEntries(int Row) const {return(Graph_->NumMyIndices(Row));};
1008 
1010  int NumAllocatedMyBlockEntries(int Row) const {return(Graph_->NumAllocatedMyIndices(Row));};
1011 
1013 
1017  int MaxNumNonzeros() const {return(Graph_->MaxNumNonzeros());};
1018 
1020 
1022  int GlobalMaxNumNonzeros() const {return(Graph_->GlobalMaxNumNonzeros());};
1023 
1025 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1026  int IndexBase() const {
1028  if(RowMap().GlobalIndicesInt())
1029  return (int) IndexBase64();
1030  throw "Epetra_VbrMatrix::IndexBase: GlobalIndices not int.";
1031  }
1032 #endif
1033  long long IndexBase64() const {return(Graph_->IndexBase64());};
1034 
1036  const Epetra_CrsGraph & Graph() const {return(*Graph_);};
1037 
1039  const Epetra_Import * Importer() const {return(Graph_->Importer());};
1040 
1042  const Epetra_Export * Exporter() const {return(Graph_->Exporter());};
1043 
1045  const Epetra_BlockMap & DomainMap() const {return(Graph_->DomainMap());};
1046 
1048  const Epetra_BlockMap & RangeMap() const {return(Graph_->RangeMap());};
1049 
1051  const Epetra_BlockMap & RowMap() const {return(Graph_->RowMap());};
1052 
1054  const Epetra_BlockMap & ColMap() const {return(Graph_->ColMap());};
1055 
1057 
1059  const Epetra_Comm & Comm() const {return(Graph_->Comm());};
1060 
1062 
1064 
1065 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1067  int LRID( int GRID_in) const {return(Graph_->LRID(GRID_in));};
1068 #endif
1069 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1070  int LRID( long long GRID_in) const {return(Graph_->LRID(GRID_in));};
1071 #endif
1072 
1074 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1075  int GRID(int LRID_in) const {return(Graph_->GRID(LRID_in));};
1076 #endif
1077  long long GRID64( int LRID_in) const {return(Graph_->GRID64(LRID_in));};
1078 
1080 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1081  int LCID( int GCID_in) const {return(Graph_->LCID(GCID_in));};
1082 #endif
1083 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1084  int LCID( long long GCID_in) const {return(Graph_->LCID(GCID_in));};
1085 #endif
1086 
1088 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1089  int GCID(int LCID_in) const {return(Graph_->GCID(LCID_in));};
1090 #endif
1091  long long GCID64( int LCID_in) const {return(Graph_->GCID64(LCID_in));};
1092 
1094 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1095  bool MyGRID(int GRID_in) const {return(Graph_->MyGRID(GRID_in));};
1096 #endif
1097 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1098  bool MyGRID(long long GRID_in) const {return(Graph_->MyGRID(GRID_in));};
1099 #endif
1100 
1102  bool MyLRID(int LRID_in) const {return(Graph_->MyLRID(LRID_in));};
1103 
1105 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1106  bool MyGCID(int GCID_in) const {return(Graph_->MyGCID(GCID_in));};
1107 #endif
1108 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1109  bool MyGCID(long long GCID_in) const {return(Graph_->MyGCID(GCID_in));};
1110 #endif
1111 
1113  bool MyLCID(int LCID_in) const {return(Graph_->MyLCID(LCID_in));};
1114 
1116 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
1117  bool MyGlobalBlockRow(int GID) const {return(Graph_->MyGlobalRow(GID));};
1118 #endif
1119 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
1120  bool MyGlobalBlockRow(long long GID) const {return(Graph_->MyGlobalRow(GID));};
1121 #endif
1122 
1123 
1125 
1126 
1128  virtual void Print(std::ostream & os) const;
1130 
1132 
1133 
1135  const char * Label() const {return(Epetra_Object::Label());};
1136 
1138 
1147  int SetUseTranspose(bool UseTranspose_in) {UseTranspose_ = UseTranspose_in; return(0);};
1148 
1150 
1158  int Apply(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
1159 
1161 
1174  int ApplyInverse(const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
1175 
1177  bool HasNormInf() const {return(true);};
1178 
1180  bool UseTranspose() const {return(UseTranspose_);};
1181 
1184  {
1185  if (!HavePointObjects_) GeneratePointObjects();
1186  if (UseTranspose()) return(*OperatorRangeMap_);
1187  else return(*OperatorDomainMap_);
1188  }
1189 
1192  {
1193  if (!HavePointObjects_) GeneratePointObjects();
1194  if (UseTranspose()) return(*OperatorDomainMap_);
1195  else return(*OperatorRangeMap_);
1196  }
1197 
1199 
1201 
1203 
1217  int ExtractGlobalRowCopy(int GlobalRow, int Length, int & NumEntries, double *Values, int * Indices) const;
1218 
1220 
1234  int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const;
1235 
1237 
1245  int NumMyRowEntries(int MyRow, int & NumEntries) const;
1246 
1248  int MaxNumEntries() const;
1249 
1251  const Epetra_BlockMap& Map() const { return Epetra_DistObject::Map(); }
1252 
1254  const Epetra_Map & RowMatrixRowMap() const
1255  { if (!HavePointObjects_) GeneratePointObjects(); return(*RowMatrixRowMap_); };
1256 
1258  const Epetra_Map & RowMatrixColMap() const
1259  { if (!HavePointObjects_) GeneratePointObjects(); return(*RowMatrixColMap_); };
1260 
1263  { if (!HavePointObjects_) GeneratePointObjects(); return(RowMatrixImporter_); };
1264 
1266 
1268 
1269 
1271  const Epetra_BlockMap & BlockImportMap() const {return(Graph_->ImportMap());};
1272 
1274  int TransformToLocal();
1275 
1277  int TransformToLocal(const Epetra_BlockMap* DomainMap, const Epetra_BlockMap* RangeMap);
1279 
1280  protected:
1281  void DeleteMemory();
1282  bool Allocated() const {return(Allocated_);};
1283  int SetAllocated(bool Flag) {Allocated_ = Flag; return(0);};
1284  Epetra_SerialDenseMatrix *** Values() const {return(Entries_);};
1285 
1286  // Internal utilities
1287 
1288  int DoMultiply(bool TransA, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
1289  int DoSolve(bool Upper, bool Trans, bool UnitDiagonal, const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
1290  void InitializeDefaults();
1291  int Allocate();
1292  int BeginInsertValues(int BlockRow, int NumBlockEntries,
1293  int * BlockIndices, bool IndicesAreLocal);
1294  int BeginReplaceValues(int BlockRow, int NumBlockEntries,
1295  int *BlockIndices, bool IndicesAreLocal);
1296  int BeginSumIntoValues(int BlockRow, int NumBlockEntries,
1297  int *BlockIndices, bool IndicesAreLocal);
1298  int SetupForSubmits(int BlockRow, int NumBlockEntries, int * BlockIndices,
1299  bool IndicesAreLocal, Epetra_CombineMode SubmitMode);
1300  int EndReplaceSumIntoValues();
1301  int EndInsertValues();
1302 
1303  int CopyMat(double * A, int LDA, int NumRows, int NumCols,
1304  double * B, int LDB, bool SumInto) const;
1305  int BeginExtractBlockRowCopy(int BlockRow, int MaxNumBlockEntries,
1306  int & RowDim, int & NumBlockEntries,
1307  int * BlockIndices, int * ColDims,
1308  bool IndicesAreLocal) const;
1309  int SetupForExtracts(int BlockRow, int & RowDim, int NumBlockEntries,
1310  bool ExtractView, bool IndicesAreLocal) const;
1311  int ExtractBlockDimsCopy(int NumBlockEntries, int * ColDims) const;
1312  int ExtractBlockRowPointers(int BlockRow, int MaxNumBlockEntries,
1313  int & RowDim, int & NumBlockEntries,
1314  int * BlockIndices,
1315  Epetra_SerialDenseMatrix ** & Values,
1316  bool IndicesAreLocal) const;
1317  int BeginExtractBlockRowView(int BlockRow, int & RowDim, int & NumBlockEntries,
1318  int * & BlockIndices,
1319  bool IndicesAreLocal) const;
1320  int CopyMatDiag(double * A, int LDA, int NumRows, int NumCols,
1321  double * Diagonal) const;
1322  int ReplaceMatDiag(double * A, int LDA, int NumRows, int NumCols,
1323  double * Diagonal);
1324 
1325  //This BlockRowMultiply accepts Alpha and Beta arguments. It is called
1326  //from within the 'solve' methods.
1327  void BlockRowMultiply(bool TransA, int RowDim, int NumEntries,
1328  int * BlockIndices, int RowOff,
1329  int * FirstPointInElementList, int * ElementSizeList,
1330  double Alpha, Epetra_SerialDenseMatrix** As,
1331  double ** X, double Beta, double ** Y, int NumVectors) const;
1332 
1333  //This BlockRowMultiply doesn't accept Alpha and Beta arguments, instead it
1334  //assumes that they are both 1.0. It is called from within the 'Multiply'
1335  //methods.
1336  void BlockRowMultiply(bool TransA, int RowDim, int NumEntries,
1337  int * BlockIndices, int RowOff,
1338  int * FirstPointInElementList,
1339  int * ElementSizeList,
1341  double ** X, double ** Y, int NumVectors) const;
1342  //
1343  // Assumes Alpha=Beta=1 and works only on storage optimized matrices
1344  //
1345  void FastBlockRowMultiply(bool TransA, int RowDim, int NumEntries,
1346  int * BlockIndices, int RowOff,
1347  int * FirstPointInElementList,
1348  int * ElementSizeList,
1350  double ** X, double ** Y, int NumVectors) const;
1351 
1352  int InverseSums(bool DoRows, Epetra_Vector& x) const;
1353  int Scale(bool DoRows, const Epetra_Vector& x);
1354  void BlockRowNormInf(int RowDim, int NumEntries,
1356  double * Y) const;
1357  void BlockRowNormOne(int RowDim, int NumEntries, int * BlockRowIndices,
1359  int * ColFirstPointInElementList, double * x) const;
1360  void SetStaticGraph(bool Flag) {StaticGraph_ = Flag;};
1361 
1362  int CheckSizes(const Epetra_SrcDistObject& A);
1363 
1364  int CopyAndPermute(const Epetra_SrcDistObject & Source,
1365  int NumSameIDs,
1366  int NumPermuteIDs,
1367  int * PermuteToLIDs,
1368  int *PermuteFromLIDs,
1369  const Epetra_OffsetIndex * Indexor,
1370  Epetra_CombineMode CombineMode = Zero);
1371 
1372  int PackAndPrepare(const Epetra_SrcDistObject & Source,
1373  int NumExportIDs,
1374  int * ExportLIDs,
1375  int & LenExports,
1376  char * & Exports,
1377  int & SizeOfPacket,
1378  int * Sizes,
1379  bool & VarSizes,
1380  Epetra_Distributor & Distor);
1381 
1382  int UnpackAndCombine(const Epetra_SrcDistObject & Source,
1383  int NumImportIDs,
1384  int * ImportLIDs,
1385  int LenImports,
1386  char * Imports,
1387  int & SizeOfPacket,
1388  Epetra_Distributor & Distor,
1389  Epetra_CombineMode CombineMode,
1390  const Epetra_OffsetIndex * Indexor);
1391 
1393  int SortEntries();
1394 
1396  bool Sorted() const {return(Graph_->Sorted());};
1397 
1399  int MergeRedundantEntries();
1400 
1402  bool NoRedundancies() const {return(Graph_->NoRedundancies());};
1403 
1404  bool StaticGraph() const {return(StaticGraph_);};
1405 
1406  int GeneratePointObjects() const;
1407  int BlockMap2PointMap(const Epetra_BlockMap & BlockMap, Epetra_Map * & PointMap) const;
1408  int UpdateOperatorXY(const Epetra_MultiVector& X, const Epetra_MultiVector& Y) const;
1409 
1417 
1419 
1421 
1422 
1425  int ** Indices_;
1428 
1430 
1432  double *All_Values_;
1433 
1434  mutable double NormInf_;
1435  mutable double NormOne_;
1436  mutable double NormFrob_;
1437 
1440 
1441  // State variables needed for constructing matrix entry-by-entry
1442  mutable int *TempRowDims_;
1444  mutable int LenTemps_;
1445  mutable int CurBlockRow_;
1446  mutable int CurNumBlockEntries_;
1447  mutable int * CurBlockIndices_;
1448  mutable int CurEntry_;
1449  mutable bool CurIndicesAreLocal_;
1451 
1452  // State variables needed for extracting entries
1453  mutable int CurExtractBlockRow_;
1454  mutable int CurExtractEntry_;
1457  mutable bool CurExtractView_;
1458  mutable int CurRowDim_;
1459 
1460  // State variable for extracting block diagonal entries
1461  mutable int CurBlockDiag_;
1462 
1463  // Maps and importer that support the Epetra_RowMatrix interface
1467 
1468  // Maps that support the Epetra_Operator interface
1473 
1474  // bool to indicate if above four point maps and importer have already been created
1475  mutable bool HavePointObjects_;
1476 
1478 };
1479 
1480 #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:119
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:62
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:63
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:70
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:73
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.