GEOS
MatrixBase.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_LINEARALGEBRA_INTERFACES_MATRIXBASE_HPP_
21 #define GEOS_LINEARALGEBRA_INTERFACES_MATRIXBASE_HPP_
22 
25 #include "LvArray/src/output.hpp"
26 
27 namespace geos
28 {
29 
30 class DofManager;
31 
35 enum class RowSumType
36 {
37  SumValues,
38  SumAbsValues,
39  SumSqrValues,
40  MaxAbsValues
41 };
42 
47 enum class MatrixPatternOp
48 {
49  Equal, // Caller guarantees patterns of arguments are exactly the same
50  Subset, // Caller guarantees pattern of second argument is a subset of the first
51  Restrict, // Restrict pattern of second argument, ignoring any entries that don't exist in first
52  Extend // Extend pattern of the first argument with entries from the second
53 };
54 
74 template< typename MATRIX, typename VECTOR >
75 class MatrixBase : public virtual LinearOperator< VECTOR >
76 {
77 protected:
78 
81 
83  using Matrix = MATRIX;
84 
86  using Vector = VECTOR;
87 
88  using Base::numGlobalRows;
89  using Base::numGlobalCols;
91  using Base::numLocalRows;
92  using Base::numLocalCols;
94 
99 
104  inline bool closed() const { return m_closed; }
105 
110  inline bool assembled() const { return m_assembled; }
111 
117  inline bool ready() const { return closed() && assembled(); }
118 
125  inline bool modifiable() const { return !closed() && assembled(); }
126 
132  inline bool insertable() const { return !closed() && !assembled(); }
133 
138  virtual bool created() const = 0;
139 
141 
143 
159  void setDofManager( DofManager const * const dofManager )
160  {
162  }
163 
167  DofManager const * dofManager() const
168  {
169  return m_dofManager;
170  }
171 
173 
178 
187  virtual void
188  createWithLocalSize( localIndex const localSize,
189  localIndex const maxEntriesPerRow,
190  MPI_Comm const & comm )
191  {
192  createWithLocalSize( localSize, localSize, maxEntriesPerRow, comm );
193  }
194 
205  virtual void
207  localIndex const maxEntriesPerRow,
208  MPI_Comm const & comm )
209  {
210  createWithGlobalSize( globalSize, globalSize, maxEntriesPerRow, comm );
211  }
212 
221  virtual void
222  createWithLocalSize( localIndex const localRows,
223  localIndex const localCols,
224  localIndex const maxEntriesPerRow,
225  MPI_Comm const & comm ) = 0;
226 
235  virtual void
237  globalIndex const globalCols,
238  localIndex const maxEntriesPerRow,
239  MPI_Comm const & comm ) = 0;
240 
250  virtual void create( CRSMatrixView< real64 const, globalIndex const > const & localMatrix,
251  localIndex const numLocalColumns,
252  MPI_Comm const & comm )
253  {
254  localMatrix.move( hostMemorySpace, false );
255 
256  localIndex maxEntriesPerRow = 0;
257  for( localIndex i = 0; i < localMatrix.numRows(); ++i )
258  {
259  maxEntriesPerRow = std::max( maxEntriesPerRow, localMatrix.numNonZeros( i ) );
260  }
261 
262  createWithLocalSize( localMatrix.numRows(),
263  numLocalColumns,
264  maxEntriesPerRow,
265  comm );
266 
267  globalIndex const rankOffset = ilower();
268 
269  open();
270  for( localIndex localRow = 0; localRow < localMatrix.numRows(); ++localRow )
271  {
272  insert( localRow + rankOffset, localMatrix.getColumns( localRow ), localMatrix.getEntries( localRow ) );
273  }
274  close();
275  }
276 
278 
283 
290  virtual void open() = 0;
291 
298  virtual void close() = 0;
299 
303  virtual void reset()
304  {
305  m_assembled = false;
306  m_closed = true;
307  }
308 
310 
315 
320  virtual void set( real64 const value ) = 0;
321 
325  virtual void zero() = 0;
326 
328 
340 
347  virtual void add( globalIndex const rowIndex,
348  globalIndex const colIndex,
349  real64 const value ) = 0;
350 
357  virtual void set( globalIndex const rowIndex,
358  globalIndex const colIndex,
359  real64 const value ) = 0;
360 
367  virtual void insert( globalIndex const rowIndex,
368  globalIndex const colIndex,
369  real64 const value ) = 0;
370 
378  virtual void add( globalIndex const rowIndex,
379  globalIndex const * colIndices,
380  real64 const * values,
381  localIndex const size ) = 0;
382 
390  virtual void set( globalIndex const rowIndex,
391  globalIndex const * colIndices,
392  real64 const * values,
393  localIndex const size ) = 0;
394 
402  virtual void insert( globalIndex const rowIndex,
403  globalIndex const * colIndices,
404  real64 const * values,
405  localIndex const size ) = 0;
406 
413  virtual void add( globalIndex const rowIndex,
414  arraySlice1d< globalIndex const > const & colIndices,
415  arraySlice1d< real64 const > const & values ) = 0;
416 
423  virtual void set( globalIndex const rowIndex,
424  arraySlice1d< globalIndex const > const & colIndices,
425  arraySlice1d< real64 const > const & values ) = 0;
426 
433  virtual void insert( globalIndex const rowIndex,
434  arraySlice1d< globalIndex const > const & colIndices,
435  arraySlice1d< real64 const > const & values ) = 0;
436 
443  virtual void add( arraySlice1d< globalIndex const > const & rowIndices,
444  arraySlice1d< globalIndex const > const & colIndices,
445  arraySlice2d< real64 const > const & values ) = 0;
446 
453  virtual void set( arraySlice1d< globalIndex const > const & rowIndices,
454  arraySlice1d< globalIndex const > const & colIndices,
455  arraySlice2d< real64 const > const & values ) = 0;
456 
463  virtual void insert( arraySlice1d< globalIndex const > const & rowIndices,
464  arraySlice1d< globalIndex const > const & colIndices,
465  arraySlice2d< real64 const > const & values ) = 0;
466 
477  virtual void add( globalIndex const * rowIndices,
478  globalIndex const * colIndices,
479  real64 const * values,
480  localIndex const numRows,
481  localIndex const numCols ) = 0;
482 
493  virtual void set( globalIndex const * rowIndices,
494  globalIndex const * colIndices,
495  real64 const * values,
496  localIndex const numRows,
497  localIndex const numCols ) = 0;
498 
509  virtual void insert( globalIndex const * rowIndices,
510  globalIndex const * colIndices,
511  real64 const * values,
512  localIndex const numRows,
513  localIndex const numCols ) = 0;
514 
522  virtual void insert( arrayView1d< globalIndex const > const & rowIndices,
523  arrayView1d< globalIndex const > const & colIndices,
524  arrayView1d< real64 const > const & values ) = 0;
525 
527 
532 
533  virtual void apply( Vector const & src, Vector & dst ) const override = 0;
534 
540  virtual void applyTranspose( Vector const & src, Vector & dst ) const = 0;
541 
553  virtual void residual( Vector const & x, Vector const & b, Vector & r ) const override
554  {
555  if( &b != &r )
556  {
557  r.copy( b );
558  }
559  gemv( -1.0, x, 1.0, r );
560  }
561 
572  virtual void multiply( Matrix const & src,
573  Matrix & dst ) const = 0;
574 
585  virtual void leftMultiplyTranspose( Matrix const & src,
586  Matrix & dst ) const = 0;
587 
598  virtual void rightMultiplyTranspose( Matrix const & src,
599  Matrix & dst ) const = 0;
600 
607  virtual void multiplyRAP( Matrix const & R,
608  Matrix const & P,
609  Matrix & dst ) const
610  {
611  GEOS_LAI_ASSERT( ready() );
612  GEOS_LAI_ASSERT( R.ready() );
613  GEOS_LAI_ASSERT( P.ready() );
614  GEOS_LAI_ASSERT_EQ( numGlobalRows(), R.numGlobalCols() );
615  GEOS_LAI_ASSERT_EQ( numGlobalCols(), P.numGlobalRows() );
616 
617  Matrix AP;
618  multiply( P, AP );
619  R.multiply( AP, dst );
620  }
621 
628  virtual void multiplyP1tAP2( Matrix const & P1,
629  Matrix const & P2,
630  Matrix & dst ) const
631  {
632  GEOS_LAI_ASSERT( ready() );
633  GEOS_LAI_ASSERT( P1.ready() );
634  GEOS_LAI_ASSERT( P2.ready() );
635  GEOS_LAI_ASSERT_EQ( numLocalRows(), P1.numLocalRows() );
636  GEOS_LAI_ASSERT_EQ( numLocalCols(), P2.numLocalRows() );
637 
638  Matrix AP2;
639  multiply( P2, AP2 );
640  P1.leftMultiplyTranspose( AP2, dst );
641  }
642 
648  virtual void multiplyPtAP( Matrix const & P,
649  Matrix & dst ) const
650  {
651  multiplyP1tAP2( P, P, dst );
652  }
653 
659  virtual void multiplyRARt( Matrix const & R,
660  Matrix & dst ) const
661  {
662  Matrix P;
663  R.transpose( P );
664  multiplyPtAP( P, dst );
665  }
666 
680  virtual void gemv( real64 const alpha,
681  Vector const & x,
682  real64 const beta,
683  Vector & y,
684  bool useTranspose = false ) const = 0;
685 
691  virtual void separateComponentFilter( Matrix & dst,
692  integer const dofPerPoint ) const = 0;
693 
694 
695 
700  virtual void scale( real64 const scalingFactor ) = 0;
701 
706  virtual void leftScale( Vector const & vec ) = 0;
707 
712  virtual void rightScale( Vector const & vec ) = 0;
713 
720  virtual void leftRightScale( Vector const & vecLeft,
721  Vector const & vecRight ) = 0;
722 
727  virtual void computeScalingVector( Vector & scaling ) const = 0;
728 
734  virtual void rescaleRows( arrayView1d< globalIndex const > const & rowIndices,
735  RowSumType const rowSumType ) = 0;
736 
745  virtual void transpose( Matrix & dst ) const = 0;
746 
756  virtual real64 clearRow( globalIndex const row,
757  bool const keepDiag = false,
758  real64 const diagValue = 0.0 ) = 0;
759 
769  virtual void addEntries( Matrix const & src,
770  MatrixPatternOp const op,
771  real64 const scale ) = 0;
772 
781  virtual void addDiagonal( Vector const & src,
782  real64 const scale ) = 0;
783 
792  virtual void clampEntries( real64 const lo,
793  real64 const hi,
794  bool const excludeDiag ) = 0;
795 
797 
802 
809  virtual localIndex maxRowLengthLocal() const = 0;
810 
817  virtual localIndex maxRowLength() const
818  {
819  return MpiWrapper::max( maxRowLengthLocal(), this->comm() );
820  }
821 
827  virtual localIndex rowLength( globalIndex const globalRowIndex ) const = 0;
828 
834  virtual void getRowLengths( arrayView1d< localIndex > const & lengths ) const = 0;
835 
841  virtual void getRowLocalLengths( arrayView1d< localIndex > const & lengths ) const = 0;
842 
849  virtual void getRowCopy( globalIndex const globalRow,
850  arraySlice1d< globalIndex > const & colIndices,
851  arraySlice1d< real64 > const & values ) const = 0;
852 
857  virtual void extractDiagonal( Vector & dst ) const = 0;
858 
863  virtual void extract( CRSMatrixView< real64, globalIndex > const & localMat ) const = 0;
864 
869  virtual void extract( CRSMatrixView< real64, globalIndex const > const & localMat ) const = 0;
870 
876  {
877  array1d< localIndex > rowLengths( numLocalRows() );
878  getRowLengths( rowLengths.toView() );
879  rowLengths.move( LvArray::MemorySpace::host );
881  localMat.resizeFromRowCapacities< parallelHostPolicy >( numLocalRows(), numGlobalCols(), rowLengths.data() );
882  extract( localMat.toView() );
883  return localMat;
884  }
885 
891  virtual void extractLocal( CRSMatrixView< real64, localIndex > const & localMat ) const = 0;
892 
899  {
900  array1d< localIndex > rowLengths( numLocalRows() );
901  getRowLocalLengths( rowLengths.toView() );
903  localMat.resizeFromRowCapacities< parallelHostPolicy >( numLocalRows(), numGlobalCols(), rowLengths.data() );
904  extractLocal( localMat.toView() );
905  return localMat;
906  }
907 
913  virtual void getRowSums( Vector & dst, RowSumType const rowSumType ) const = 0;
914 
919  virtual globalIndex ilower() const = 0;
920 
927  virtual globalIndex iupper() const = 0;
928 
938  virtual globalIndex jlower() const = 0;
939 
947  virtual globalIndex jupper() const = 0;
948 
953  virtual real64 normInf() const = 0;
954 
959  virtual real64 norm1() const = 0;
960 
965  virtual real64 normFrobenius() const = 0;
966 
971  virtual real64 normMax() const = 0;
972 
978  virtual real64 normMax( arrayView1d< globalIndex const > const & rowIndices ) const = 0;
979 
985  virtual localIndex getLocalRowID( globalIndex const index ) const = 0;
986 
992  virtual globalIndex getGlobalRowID( localIndex const index ) const = 0;
993 
995 
1000 
1005  virtual void print( std::ostream & os = std::cout ) const = 0;
1006 
1016  virtual void write( string const & filename,
1017  LAIOutputFormat const format = LAIOutputFormat::MATRIX_MARKET ) const = 0;
1018 
1020 
1027  friend std::ostream & operator<<( std::ostream & os, Matrix const & matrix )
1028  {
1029  matrix.print( os );
1030  return os;
1031  }
1032 
1034  bool m_closed = true;
1035 
1037  bool m_assembled = false;
1038 
1041 
1042 };
1043 
1044 } // namespace geos
1045 
1046 #endif //GEOS_LINEARALGEBRA_INTERFACES_MATRIXBASE_HPP_
The DoFManager is responsible for allocating global dofs, constructing sparsity patterns,...
Definition: DofManager.hpp:45
Abstract base class for linear operators.
virtual globalIndex numGlobalCols() const =0
VECTOR Vector
Alias for template parameter.
virtual globalIndex numGlobalRows() const =0
virtual localIndex numLocalNonzeros() const
virtual globalIndex numGlobalNonzeros() const
virtual localIndex numLocalRows() const =0
virtual localIndex numLocalCols() const =0
virtual MPI_Comm comm() const =0
Get the MPI communicator the matrix was created with.
Common base template for all matrix wrapper types.
Definition: MatrixBase.hpp:76
virtual void multiply(Matrix const &src, Matrix &dst) const =0
Matrix/Matrix multiplication.
virtual void rightMultiplyTranspose(Matrix const &src, Matrix &dst) const =0
Matrix/Matrix transpose multiplication.
virtual localIndex numLocalCols() const=0
virtual real64 norm1() const =0
Returns the one norm of the matrix.
virtual bool created() const =0
Query matrix creation status.
virtual void multiplyPtAP(Matrix const &P, Matrix &dst) const
Compute the triple product dst = P^T * this * P
Definition: MatrixBase.hpp:648
virtual globalIndex ilower() const =0
Returns the index of the first global row owned by that processor.
virtual void add(globalIndex const *rowIndices, globalIndex const *colIndices, real64 const *values, localIndex const numRows, localIndex const numCols)=0
Add a dense block of values.
virtual real64 normMax(arrayView1d< globalIndex const > const &rowIndices) const =0
Returns the max norm of the matrix on a subset of rows.
virtual void insert(arraySlice1d< globalIndex const > const &rowIndices, arraySlice1d< globalIndex const > const &colIndices, arraySlice2d< real64 const > const &values)=0
Insert a dense block of values.
virtual void residual(Vector const &x, Vector const &b, Vector &r) const override
Compute residual r = b - A * x.
Definition: MatrixBase.hpp:553
virtual void createWithGlobalSize(globalIndex const globalRows, globalIndex const globalCols, localIndex const maxEntriesPerRow, MPI_Comm const &comm)=0
Create a rectangular matrix from number of rows/columns.
virtual void multiplyRAP(Matrix const &R, Matrix const &P, Matrix &dst) const
Compute the triple product dst = R * this * P
Definition: MatrixBase.hpp:607
virtual void set(globalIndex const rowIndex, globalIndex const *colIndices, real64 const *values, localIndex const size)=0
Set elements to one row using c-style arrays.
virtual localIndex numLocalRows() const=0
friend std::ostream & operator<<(std::ostream &os, Matrix const &matrix)
Stream insertion operator for all matrix types.
void setDofManager(DofManager const *const dofManager)
Associate a DofManager with this matrix.
Definition: MatrixBase.hpp:159
MATRIX Matrix
Type alias for actual derived matrix class.
Definition: MatrixBase.hpp:83
bool assembled() const
Query matrix assembled status.
Definition: MatrixBase.hpp:110
virtual void write(string const &filename, LAIOutputFormat const format=LAIOutputFormat::MATRIX_MARKET) const =0
Write the matrix to filename in a matlab-compatible format.
virtual void getRowCopy(globalIndex const globalRow, arraySlice1d< globalIndex > const &colIndices, arraySlice1d< real64 > const &values) const =0
Returns a copy of the data in row globalRow.
virtual void transpose(Matrix &dst) const =0
Matrix transposition.
virtual void set(real64 const value)=0
Set all non-zero elements to a value.
virtual void leftMultiplyTranspose(Matrix const &src, Matrix &dst) const =0
Matrix/Matrix transpose multiplication.
virtual void add(globalIndex const rowIndex, globalIndex const colIndex, real64 const value)=0
Add to one element.
virtual void leftScale(Vector const &vec)=0
Pre-multiplies (left) with diagonal matrix consisting of the values in vec.
virtual void getRowLocalLengths(arrayView1d< localIndex > const &lengths) const =0
Get the local row lengths of every local row (number of nonzeros in local columns)
bool closed() const
Query matrix closed status.
Definition: MatrixBase.hpp:104
virtual void createWithGlobalSize(globalIndex const globalSize, localIndex const maxEntriesPerRow, MPI_Comm const &comm)
Create a square matrix from global number of rows.
Definition: MatrixBase.hpp:206
virtual globalIndex jlower() const =0
Returns the index of the first global col owned by that processor.
virtual void apply(Vector const &src, Vector &dst) const override=0
Apply operator to a vector, dst = this(src).
virtual void clampEntries(real64 const lo, real64 const hi, bool const excludeDiag)=0
Clamp each matrix value between values of lo and hi.
bool m_closed
Flag indicating whether the matrix is currently open for adding new entries.
virtual void rescaleRows(arrayView1d< globalIndex const > const &rowIndices, RowSumType const rowSumType)=0
Rescales selected rows of matrix using row sum reciprocal as a factor.
virtual void separateComponentFilter(Matrix &dst, integer const dofPerPoint) const =0
Apply a separate component approximation (filter) to this matrix.
virtual void leftRightScale(Vector const &vecLeft, Vector const &vecRight)=0
Post-multiplies (right) with diagonal matrix consisting of the values in vecRight and pre-multiplies ...
bool insertable() const
Query matrix status.
Definition: MatrixBase.hpp:132
bool m_assembled
Flag indicating whether the matrix (sparsity pattern) has been assembled.
virtual real64 normFrobenius() const =0
Returns the Frobenius norm of the matrix.
virtual void applyTranspose(Vector const &src, Vector &dst) const =0
Apply transpose of the matrix to a vector.
virtual void scale(real64 const scalingFactor)=0
Multiply all elements by scalingFactor.
virtual void getRowSums(Vector &dst, RowSumType const rowSumType) const =0
Populate a vector with row sums of this.
virtual globalIndex getGlobalRowID(localIndex const index) const =0
Map a local row index to global row index.
virtual void createWithLocalSize(localIndex const localSize, localIndex const maxEntriesPerRow, MPI_Comm const &comm)
Create a square matrix from local number of rows.
Definition: MatrixBase.hpp:188
virtual globalIndex numGlobalRows() const=0
virtual real64 normInf() const =0
Returns the infinity norm of the matrix.
virtual void insert(globalIndex const rowIndex, globalIndex const colIndex, real64 const value)=0
Insert one element.
virtual void zero()=0
Set all elements to zero.
virtual void open()=0
Open matrix for adding new entries.
virtual void addDiagonal(Vector const &src, real64 const scale)=0
Add (scaled) entries of a vector to the diagonal of this matrix.
virtual real64 normMax() const =0
Returns the max norm of the matrix (the largest absolute element value).
virtual void insert(globalIndex const rowIndex, arraySlice1d< globalIndex const > const &colIndices, arraySlice1d< real64 const > const &values)=0
Insert elements of one row using array1d.
virtual void add(globalIndex const rowIndex, globalIndex const *colIndices, real64 const *values, localIndex const size)=0
Add elements to one row using c-style arrays.
virtual void insert(globalIndex const *rowIndices, globalIndex const *colIndices, real64 const *values, localIndex const numRows, localIndex const numCols)=0
Insert dense matrix.
virtual void computeScalingVector(Vector &scaling) const =0
Compute left and right scaling vectors for diagonal scaling.
virtual void extractDiagonal(Vector &dst) const =0
Extract diagonal values into a vector.
virtual void insert(globalIndex const rowIndex, globalIndex const *colIndices, real64 const *values, localIndex const size)=0
Insert elements to one row using c-style arrays.
virtual localIndex maxRowLength() const
Returns the number of nonzero entries in the longest row of the matrix.
Definition: MatrixBase.hpp:817
virtual void add(globalIndex const rowIndex, arraySlice1d< globalIndex const > const &colIndices, arraySlice1d< real64 const > const &values)=0
Add elements to one row using array1d.
DofManager const * m_dofManager
(optional) DofManager associated with this matrix
CRSMatrix< real64, globalIndex > extract() const
Extract local part of the matrix.
Definition: MatrixBase.hpp:875
virtual void set(globalIndex const *rowIndices, globalIndex const *colIndices, real64 const *values, localIndex const numRows, localIndex const numCols)=0
Set a dense block of values.
virtual void set(arraySlice1d< globalIndex const > const &rowIndices, arraySlice1d< globalIndex const > const &colIndices, arraySlice2d< real64 const > const &values)=0
Set a dense block of values.
virtual localIndex maxRowLengthLocal() const =0
Returns the number of nonzero entries in the longest local row of the matrix.
virtual void print(std::ostream &os=std::cout) const =0
Print the matrix in Trilinos format to a stream.
virtual void multiplyRARt(Matrix const &R, Matrix &dst) const
Compute the triple product dst = R * this * R^T
Definition: MatrixBase.hpp:659
virtual void getRowLengths(arrayView1d< localIndex > const &lengths) const =0
Get the row lengths of every local row.
virtual void add(arraySlice1d< globalIndex const > const &rowIndices, arraySlice1d< globalIndex const > const &colIndices, arraySlice2d< real64 const > const &values)=0
Add a dense block of values.
virtual void extractLocal(CRSMatrixView< real64, localIndex > const &localMat) const =0
Extract block of the matrix corresponding to locally owned columns using previously allocated storage...
virtual globalIndex iupper() const =0
Returns index one past the last global row owned by that processor.
DofManager const * dofManager() const
Definition: MatrixBase.hpp:167
virtual void rightScale(Vector const &vec)=0
Post-multiplies (right) with diagonal matrix consisting of the values in vec.
virtual globalIndex numGlobalCols() const=0
bool ready() const
Query matrix ready status.
Definition: MatrixBase.hpp:117
virtual void set(globalIndex const rowIndex, arraySlice1d< globalIndex const > const &colIndices, arraySlice1d< real64 const > const &values)=0
Set elements of one row using array1d.
virtual real64 clearRow(globalIndex const row, bool const keepDiag=false, real64 const diagValue=0.0)=0
Clear a row, and optionally set diagonal element to diagValue.
virtual void extract(CRSMatrixView< real64, globalIndex const > const &localMat) const =0
Extract local part of the matrix using previously allocated storage and structure.
bool modifiable() const
Query matrix status.
Definition: MatrixBase.hpp:125
virtual localIndex getLocalRowID(globalIndex const index) const =0
Map a global row index to local row index.
virtual void reset()
Reset the matrix to default state.
Definition: MatrixBase.hpp:303
virtual void multiplyP1tAP2(Matrix const &P1, Matrix const &P2, Matrix &dst) const
Compute the triple product dst = P1^T * this * P2
Definition: MatrixBase.hpp:628
virtual void gemv(real64 const alpha, Vector const &x, real64 const beta, Vector &y, bool useTranspose=false) const =0
Compute gemv y = alpha*A*x + beta*y.
virtual localIndex rowLength(globalIndex const globalRowIndex) const =0
Get row length via global row index.
virtual void extract(CRSMatrixView< real64, globalIndex > const &localMat) const =0
Extract local part of the matrix using previously allocated storage.
virtual void close()=0
Assemble and compress the matrix.
virtual void createWithLocalSize(localIndex const localRows, localIndex const localCols, localIndex const maxEntriesPerRow, MPI_Comm const &comm)=0
Create a rectangular matrix from number of rows/columns.
virtual void addEntries(Matrix const &src, MatrixPatternOp const op, real64 const scale)=0
Add entries of another matrix to this.
CRSMatrix< real64, localIndex > extractLocal() const
Extract block of the matrix corresponding to locally owned columns.
Definition: MatrixBase.hpp:898
virtual globalIndex jupper() const =0
Returns index one past the last global col owned by that processor.
virtual void create(CRSMatrixView< real64 const, globalIndex const > const &localMatrix, localIndex const numLocalColumns, MPI_Comm const &comm)
Create parallel matrix from a local CRS matrix.
Definition: MatrixBase.hpp:250
virtual void set(globalIndex const rowIndex, globalIndex const colIndex, real64 const value)=0
Set one element.
virtual void insert(arrayView1d< globalIndex const > const &rowIndices, arrayView1d< globalIndex const > const &colIndices, arrayView1d< real64 const > const &values)=0
Insert values stored in 3 linear vectors.
#define GEOS_LAI_ASSERT_EQ(lhs, rhs)
Definition: common.hpp:49
#define GEOS_LAI_ASSERT(expr)
Definition: common.hpp:35
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
Definition: DataTypes.hpp:179
RowSumType
Type of row sum to compute.
Definition: MatrixBase.hpp:36
GEOS_GLOBALINDEX_TYPE globalIndex
Global index type (for indexing objects across MPI partitions).
Definition: DataTypes.hpp:87
LvArray::CRSMatrix< T, COL_INDEX, INDEX_TYPE, LvArray::ChaiBuffer > CRSMatrix
Alias for CRS Matrix class.
Definition: DataTypes.hpp:305
LAIOutputFormat
Definition: common.hpp:142
ArraySlice< T, 2, USD > arraySlice2d
Alias for 2D array slice.
Definition: DataTypes.hpp:199
double real64
64-bit floating point type.
Definition: DataTypes.hpp:98
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Definition: DataTypes.hpp:84
ArraySlice< T, 1, USD > arraySlice1d
Alias for 1D array slice.
Definition: DataTypes.hpp:183
LvArray::CRSMatrixView< T, COL_INDEX, INDEX_TYPE const, LvArray::ChaiBuffer > CRSMatrixView
Alias for CRS Matrix View.
Definition: DataTypes.hpp:309
int integer
Signed integer type.
Definition: DataTypes.hpp:81
Array< T, 1 > array1d
Alias for 1D array.
Definition: DataTypes.hpp:175
MatrixPatternOp
Describes relationship between and treatment of nonzero patterns of arguments in matrix functions lik...
Definition: MatrixBase.hpp:48
static T max(T const &value, MPI_Comm comm=MPI_COMM_GEOS)
Convenience function for a MPI_Allreduce using a MPI_MAX operation.