CEPS  24.01
Cardiac ElectroPhysiology Simulator
DistributedMatrix Class Reference

Detailed Description

Sparse matrix distributed between process.

A note about matrix assembly if the implementation is PETSc: PETSc requires to "assemble" a matrix before most of the operations it used for. You can use the finalize() method of this class to do so in a single step.

Due to how PETSc handles assembly, all zero values are compressed out when assembling a matrix: the non-zero structure of the matrix is altered. This is pretty bad as the user has no direct control over this. PETSc documentation says that explicit zeros must be inserted before the final assembly if the extra space is needed.

More details: The non-zero structure is altered at the first "final assembly". If the values where not explicitly set using MatSetValues(...), then the memory is freed, and any attempt to set or add values after that assembly will cause a petsc error saying that a new non-zero caused a malloc. While this can be good for performance in "normal" situations, it is troublesome when we want to simply duplicate a matrix that has just been created, as PETSc refuses to duplicate a non-assembled matrix. Therefore, if we assemble the newly created matrix without setting any value, we lose the non-zero structure... leading to PETSc flooding us with "New nonzero at ..." messages.

Definition at line 75 of file DistributedMatrix.hpp.

#include <DistributedMatrix.hpp>

Public Member Functions

 DistributedMatrix ()
 Empty constructor. More...
 
 DistributedMatrix (CepsInt M, CepsInt N, CepsInt m, CepsInt n)
 Constructor with numbers of rows and columns. More...
 
 DistributedMatrix (const DistributedMatrix &templateMatrix, CepsBool copyValues=false)
 Constructor with structure template, or copy constructor. More...
 
 DistributedMatrix (const CepsString &file)
 Constructor from a binary file. More...
 
 ~DistributedMatrix ()
 Destructor. The underlying object is cleaned. More...
 
void ignoreOffProcEntries (CepsBool flag)
 Choose to ignore entries destined to other processes when setting or adding values in the matrix. More...
 
void setSymmetric (CepsBool flag=true)
 Set whether this matrix is symmetric or not. More...
 
void setSize (CepsInt M, CepsInt N, CepsInt m, CepsInt n)
 Set distributed matrix global and local size. More...
 
void setNonZeroStructure (const CepsInt d_nnz[], const CepsInt o_nnz[])
 Set the matrix non-zero structure. More...
 
void setNonZeroStructure (CepsInt d_nz, CepsInt o_nz)
 Set the matrix non-zero structure. More...
 
void setValue (CepsMathScalar value, CepsGlobalIndex i, CepsGlobalIndex j)
 Sets A(i,j) (replace if existing) More...
 
void addValue (CepsMathScalar value, CepsGlobalIndex i, CepsGlobalIndex j)
 Adds value to A(i,j) (sets if not existing already) More...
 
void getValues (CepsMathScalar *values, CepsInt nbRows, CepsInt nbColumns, const CepsGlobalIndex *rowIndices, const CepsGlobalIndex *columnIndices)
 Get multiple values in the matrix. More...
 
void setValues (const CepsMathScalar *values, CepsInt nbRows, CepsInt nbColumns, const CepsGlobalIndex *rowIndices, const CepsGlobalIndex *columnIndices)
 Set multiple values in the matrix at once. More...
 
void addValues (const CepsMathScalar *values, CepsInt nbRows, CepsInt nbColumns, const CepsGlobalIndex *rowIndices, const CepsGlobalIndex *columnIndices)
 Add multiple values in the matrix at once. More...
 
void addSubMatrix (const CepsMathDynamic2D &subMat, const CepsVector< CepsGlobalIndex > &indicesI, const CepsVector< CepsGlobalIndex > &indicesJ)
 Add each element of a small square matrix in a distributed matrix. More...
 
void getSubMatrix (const CepsVector< CepsGlobalIndex > &indicesI, const CepsVector< CepsGlobalIndex > &indicesJ, CepsMathDynamic2D &subMat)
 Insert each element of a distributed matrix in a small Eigen submatrix. More...
 
void zeroRowsAndColumns (CepsInt nbRows, CepsGlobalIndex *rows, CepsMathScalar diagonalValue=1.0)
 Sets the indicated rows and columns values to zero for symmetric matrices. More...
 
void zeroRows (CepsInt nbRows, CepsGlobalIndex *rows, CepsMathScalar diagonalValue=1.0)
 Sets the indicated rows to zero. More...
 
void zero ()
 Zeroes all entries. More...
 
void identity ()
 Sets to identity matrix. Fails if matrix is not square. More...
 
void add (DistributedMatrix &X, CepsMathScalar a, CepsBool sameNonZeroStructure=true)
 Adds a*X to this. More...
 
CepsMathScalar lInfNorm () const
 $l^inf$-norm of matrix More...
 
CepsMathScalar l1Norm () const
 $l^1$-norm of matrix More...
 
CepsMathScalar l2Norm () const
 $l^2$-norm of matrix More...
 
void copy (DistributedMatrix &A) const
 Copy values from this matrix to matrix A of same non-zero structure. More...
 
void duplicate (DistributedMatrix &dest, CepsBool copyValues) const
 Copy non-zero structure to dest matrix. Optionally values. More...
 
void getSize (CepsInt *M, CepsInt *N) const
 Get the global size of the matrix. More...
 
void getLocalSize (CepsInt *m, CepsInt *n) const
 Get the local size of the matrix. More...
 
void getLocalRange (CepsGlobalIndex *lo, CepsGlobalIndex *hi) const
 Get the range of rows owned by current process. More...
 
void getLocalRow (const CepsMathScalar **values, CepsGlobalIndex row, CepsInt *nbNonZero, const CepsGlobalIndex **nonZeroCols) const
 Read-only access to the values of matrix row. More...
 
void releaseLocalRow (const CepsMathScalar **values, CepsGlobalIndex row, CepsInt *nbNonZero, const CepsGlobalIndex **nonZeroCols)
 Release access to the values of matrix row after reading. More...
 
void getLocalRow (CepsVector< CepsMathScalar > &rowValues, CepsGlobalIndex row)
 Get a copy of the non-zero values stored in a local row. More...
 
void getEntireLocalRow (CepsVector< CepsMathScalar > &rowValues, CepsGlobalIndex row) const
 Get a copy of all values stored in a local row, including zeros. More...
 
void getColumnAsDistributedVector (DistributedVector &v, CepsGlobalIndex column) const
 Fills a DistributedVector with values of column. More...
 
void setColumnAsDistributedVector (DistributedVector &v, CepsGlobalIndex column)
 Sets the values of a distributed vector in matrix column. More...
 
void getDiagonalAsDistributedVector (DistributedVector &v) const
 Fills a DistributedVector with values of diagonal. More...
 
void setDiagonalAsDistributedVector (DistributedVector &v)
 Sets the values of a distributed vector in matrix diagonal. More...
 
void getDiagonalFootPrintAsDistributedVector (DistributedVector &v, CepsReal epsilon=1E-12) const
 Fills a DistributedVector with the footprint (zero or non-zero) of diagonal. More...
 
const PetscMatrix & getMatrix () const
 The underlying matrix. More...
 
void save (const CepsString &filename)
 Matrix is saved in binary format. More...
 
void load (const CepsString &filename)
 Matrix is loaded from specified file in binary format. More...
 
void beginAssembly ()
 Begin matrix assembly. More...
 
void endAssembly ()
 Wait for the end of matrix assembly. More...
 
void finalize ()
 Performs assembly. More...
 
void flush ()
 Use when switching between calls to adding and setting values. More...
 
CepsBool isAssembled () const
 Safety check. More...
 
void assertAssembled (CepsString info="") const
 Safetier check. More...
 
CepsBool isSymmetric () const
 True if matrix is symmetric. More...
 
void checkProperlySet () const
 Will fail if matrix is not properly set (correct sizes and memory preallocation). More...
 
void view () const
 Displays the matrix on standard output. More...
 
DistributedMatrixoperator*= (const CepsMathScalar &scalar)
 Short mult by scalar. More...
 

Private Attributes

PetscMatrix m_A
 The main object. More...
 
CepsGlobalIndex m_lo
 Index of first local row. More...
 
CepsGlobalIndex m_hi
 Index of last local row +1. More...
 
CepsBool m_properlySet
 Safety flag to check for sizes and memory preallocation. More...
 

Friends

class TestDistributedMatrix
 

Constructor & Destructor Documentation

◆ DistributedMatrix() [1/4]

DistributedMatrix::DistributedMatrix ( )

Empty constructor.

Users must call DistributedMatrix::setSize(...) and DistributedMatrix::setNonZeroStructure(...) after calling this constructor.

Definition at line 33 of file PETScMatrix.cpp.

◆ DistributedMatrix() [2/4]

DistributedMatrix::DistributedMatrix ( CepsInt  M,
CepsInt  N,
CepsInt  m,
CepsInt  n 
)

Constructor with numbers of rows and columns.

Users must call DistributedMatrix::setNonZeroStructure(...) after calling this constructor.

Parameters
[in]Mglobal number of rows
[in]Nglobal number of columns
[in]mlocal number of rows (on current process)
[in]nlocal number of columns (on current process)

Definition at line 47 of file PETScMatrix.cpp.

◆ DistributedMatrix() [3/4]

DistributedMatrix::DistributedMatrix ( const DistributedMatrix templateMatrix,
CepsBool  copyValues = false 
)
explicit

Constructor with structure template, or copy constructor.

Parameters
[in]templateMatrixdistributed matrix to use as reference
[in]copyValueswhether the values should be copied or not. Default to false

Definition at line 61 of file PETScMatrix.cpp.

◆ DistributedMatrix() [4/4]

DistributedMatrix::DistributedMatrix ( const CepsString file)
explicit

Constructor from a binary file.

See also
DistributedMatrix::load(const CepsString& filename)

Definition at line 72 of file PETScMatrix.cpp.

◆ ~DistributedMatrix()

DistributedMatrix::~DistributedMatrix ( )

Destructor. The underlying object is cleaned.

Definition at line 83 of file PETScMatrix.cpp.

Member Function Documentation

◆ add()

void DistributedMatrix::add ( DistributedMatrix X,
CepsMathScalar  a,
CepsBool  sameNonZeroStructure = true 
)

Adds a*X to this.

Parameters
Xmatrix
ascale factor
sameNonZeroStructurewhether the two matrices have the same non-zero pattern. Default to true

Definition at line 246 of file PETScMatrix.cpp.

◆ addSubMatrix()

void DistributedMatrix::addSubMatrix ( const CepsMathDynamic2D subMat,
const CepsVector< CepsGlobalIndex > &  indicesI,
const CepsVector< CepsGlobalIndex > &  indicesJ 
)

Add each element of a small square matrix in a distributed matrix.

This method is useful when trying to add the contribution of an finite element inside a symmetric distributed matrix.

Parameters
[in]subMatthe matrix of size (N*N) to add
[in]indicesIan array of size N that holds the global matrix row indices where the values must be added
[in]indicesJan array of size N that holds the global matrix column indices where the values must be added

Definition at line 38 of file DistributedMatrix.cpp.

◆ addValue()

void DistributedMatrix::addValue ( CepsMathScalar  value,
CepsGlobalIndex  i,
CepsGlobalIndex  j 
)

Adds value to A(i,j) (sets if not existing already)

Do not forget to call the matrix assembly methods after setting values

Definition at line 153 of file PETScMatrix.cpp.

◆ addValues()

void DistributedMatrix::addValues ( const CepsMathScalar values,
CepsInt  nbRows,
CepsInt  nbColumns,
const CepsGlobalIndex rowIndices,
const CepsGlobalIndex columnIndices 
)

Add multiple values in the matrix at once.

Essentially the same as DistributedMatrix::setMultipleValues(...), but adding to instead of overwriting the previous value.

Definition at line 186 of file PETScMatrix.cpp.

◆ assertAssembled()

void DistributedMatrix::assertAssembled ( CepsString  info = "") const

Safetier check.

Parameters
infoDisplayed as in "call finalize before <info>"

Definition at line 584 of file PETScMatrix.cpp.

◆ beginAssembly()

void DistributedMatrix::beginAssembly ( )

Begin matrix assembly.

Code not related to this matrix can be called between this method and the call to endMatrixAssembly().

Definition at line 535 of file PETScMatrix.cpp.

◆ checkProperlySet()

void DistributedMatrix::checkProperlySet ( ) const

Will fail if matrix is not properly set (correct sizes and memory preallocation).

Definition at line 602 of file PETScMatrix.cpp.

◆ copy()

void DistributedMatrix::copy ( DistributedMatrix A) const

Copy values from this matrix to matrix A of same non-zero structure.

Not to be used on a non-finalized matrix. Call DistributedMatrix::finalize() before copying.

Definition at line 283 of file PETScMatrix.cpp.

◆ duplicate()

void DistributedMatrix::duplicate ( DistributedMatrix dest,
CepsBool  copyValues 
) const

Copy non-zero structure to dest matrix. Optionally values.

Not to be used on a non-finalized matrix. Call DistributedMatrix::finalize() before copying.

Parameters
[in]desta pointer to the destination matrix
[in]copyValuestrue if the duplicated matrix should have same numerical values as the original

Definition at line 293 of file PETScMatrix.cpp.

◆ endAssembly()

void DistributedMatrix::endAssembly ( )

Wait for the end of matrix assembly.

No operation using this matrix should be done before assembly. Use this method only when the matrix has been completely assembled, as the unused memory space is freed.

Definition at line 542 of file PETScMatrix.cpp.

◆ finalize()

void DistributedMatrix::finalize ( )

Performs assembly.

Definition at line 549 of file PETScMatrix.cpp.

◆ flush()

void DistributedMatrix::flush ( )

Use when switching between calls to adding and setting values.

Definition at line 557 of file PETScMatrix.cpp.

◆ getColumnAsDistributedVector()

void DistributedMatrix::getColumnAsDistributedVector ( DistributedVector v,
CepsGlobalIndex  column 
) const

Fills a DistributedVector with values of column.

The decompositions of matrix and vector must be the same.

Parameters
[out]va DistributedVector to receive all values from the col
[in]columnglobal matrix index of the column to get

Definition at line 428 of file PETScMatrix.cpp.

◆ getDiagonalAsDistributedVector()

void DistributedMatrix::getDiagonalAsDistributedVector ( DistributedVector v) const

Fills a DistributedVector with values of diagonal.

The decompositions of matrix and vector must be the same.

Parameters
[out]va DistributedVector to receive all values from the diagonal

Definition at line 483 of file PETScMatrix.cpp.

◆ getDiagonalFootPrintAsDistributedVector()

void DistributedMatrix::getDiagonalFootPrintAsDistributedVector ( DistributedVector v,
CepsReal  epsilon = 1E-12 
) const

Fills a DistributedVector with the footprint (zero or non-zero) of diagonal.

The decompositions of matrix and vector must be the same.

Parameters
[out]va DistributedVector to receive all values from the diagonal

Definition at line 501 of file PETScMatrix.cpp.

◆ getEntireLocalRow()

void DistributedMatrix::getEntireLocalRow ( CepsVector< CepsMathScalar > &  rowValues,
CepsGlobalIndex  row 
) const

Get a copy of all values stored in a local row, including zeros.

Get a copy of the non-zero values stored in a local row. N.B this method cannot get rows not owned by current process. Using this method does not require the use of DistributedMatrix::releaseLocalRow(...) but is much slower. Use DistributedMatrix::getLocalRow(...) if only reading values is required.

Parameters
[out]rowValuesa vector that will contain the copied values. The vector's size is equal to the number of non zero values of this matrix row.
[in]rowglobal matrix index of the row to get

Definition at line 396 of file PETScMatrix.cpp.

◆ getLocalRange()

void DistributedMatrix::getLocalRange ( CepsGlobalIndex lo,
CepsGlobalIndex hi 
) const

Get the range of rows owned by current process.

Parameters
[out]lowill hold the first local row
[out]hiwill hold last + 1 local row

Definition at line 324 of file PETScMatrix.cpp.

◆ getLocalRow() [1/2]

void DistributedMatrix::getLocalRow ( CepsVector< CepsMathScalar > &  rowValues,
CepsGlobalIndex  row 
)

Get a copy of the non-zero values stored in a local row.

N.B this method cannot get rows not owned by current process. Using this method does not require the use of DistributedMatrix::releaseLocalRow(...) but is much slower. Use DistributedMatrix::getLocalRow(...) if only reading values is required.

Parameters
[out]rowValuesa vector that will contain the copied values. The vector's size is equal to the number of non zero values of this matrix row.
[in]rowglobal matrix index of the row to get

Definition at line 359 of file PETScMatrix.cpp.

◆ getLocalRow() [2/2]

void DistributedMatrix::getLocalRow ( const CepsMathScalar **  values,
CepsGlobalIndex  row,
CepsInt nbNonZero,
const CepsGlobalIndex **  nonZeroCols 
) const

Read-only access to the values of matrix row.

Users must call DistributedMatrix::releaseLocalRow() after reading operations are done to avoid bleeding memory. Similar in essence to DistributedVector::data()

Parameters
[out]valuespointer on row values
[in]rowglobal matrix row index in the matrix
[out]nbNonZerowill be set to the number of non-zero values. Can be nullptr if the information is not needed.
[out]nonZeroColspointer on the array of non zero cols. Can be nullptr if not needed

Definition at line 332 of file PETScMatrix.cpp.

◆ getLocalSize()

void DistributedMatrix::getLocalSize ( CepsInt m,
CepsInt n 
) const

Get the local size of the matrix.

Parameters
[out]mwill hold the number of local rows
[out]nwill hold the number of local columns

Definition at line 316 of file PETScMatrix.cpp.

◆ getMatrix()

const PetscMatrix & DistributedMatrix::getMatrix ( ) const

The underlying matrix.

Definition at line 80 of file DistributedMatrix.cpp.

◆ getSize()

void DistributedMatrix::getSize ( CepsInt M,
CepsInt N 
) const

Get the global size of the matrix.

Parameters
[out]Mwill hold the number of rows
[out]Nwill hold the number of columns

Definition at line 308 of file PETScMatrix.cpp.

◆ getSubMatrix()

void DistributedMatrix::getSubMatrix ( const CepsVector< CepsGlobalIndex > &  indicesI,
const CepsVector< CepsGlobalIndex > &  indicesJ,
CepsMathDynamic2D subMat 
)

Insert each element of a distributed matrix in a small Eigen submatrix.

See also
DistributedMatrix::addSubMatrix(...)
Parameters
[in]indicesIan array of size N that holds the global matrix row indices where the values must be added
[in]indicesJan array of size N that holds the global matrix column indices where the values must be added
[out]subMatthe matrix of size N*N to get

Definition at line 63 of file DistributedMatrix.cpp.

◆ getValues()

void DistributedMatrix::getValues ( CepsMathScalar values,
CepsInt  nbRows,
CepsInt  nbColumns,
const CepsGlobalIndex rowIndices,
const CepsGlobalIndex columnIndices 
)

Get multiple values in the matrix.

Parameters
[out]values1 dimensional array containing the values to be obtained Must be preallocated (nbRows*nbColumns)
[in]nbRowssize of the rowIndices parameter, the number of rows that will be get by this call
[in]nbColumnsidentical to nbRows, but for columns instead
[in]rowIndicesthe global matrix indices of the rows where the values must be obtained from
[in]columnIndicesidentical to rowIndices but for columns instead

Definition at line 160 of file PETScMatrix.cpp.

◆ identity()

void DistributedMatrix::identity ( )

Sets to identity matrix. Fails if matrix is not square.

Definition at line 227 of file PETScMatrix.cpp.

◆ ignoreOffProcEntries()

void DistributedMatrix::ignoreOffProcEntries ( CepsBool  flag)

Choose to ignore entries destined to other processes when setting or adding values in the matrix.

Increases matrix assembly performance but the user must make sure that the local values are correctly generated.

Parameters
[in]flagtrue if off-proc entries are to be ignored.

Definition at line 90 of file PETScMatrix.cpp.

◆ isAssembled()

CepsBool DistributedMatrix::isAssembled ( ) const

Safety check.

Definition at line 574 of file PETScMatrix.cpp.

◆ isSymmetric()

CepsBool DistributedMatrix::isSymmetric ( ) const

True if matrix is symmetric.

If the implementation is PETSc: Warning! This method does not compute anything! It just checks if the symmetric flag has been turned on for this matrix. Apparently, PETSc does not support symmetry checking for MPIAIJ matrices... Note: if the user did not set the flag explicitly with DistributedMatrix::setSymmetric(...), then you should not use this method! Returns false by default.

Definition at line 565 of file PETScMatrix.cpp.

◆ l1Norm()

CepsMathScalar DistributedMatrix::l1Norm ( ) const

$l^1$-norm of matrix

Definition at line 265 of file PETScMatrix.cpp.

◆ l2Norm()

CepsMathScalar DistributedMatrix::l2Norm ( ) const

$l^2$-norm of matrix

Definition at line 274 of file PETScMatrix.cpp.

◆ lInfNorm()

CepsMathScalar DistributedMatrix::lInfNorm ( ) const

$l^inf$-norm of matrix

Definition at line 256 of file PETScMatrix.cpp.

◆ load()

void DistributedMatrix::load ( const CepsString filename)

Matrix is loaded from specified file in binary format.

See also
DistributedMatrix::save(...)
Parameters
[in]filenamefile name

Definition at line 523 of file PETScMatrix.cpp.

◆ operator*=()

DistributedMatrix & DistributedMatrix::operator*= ( const CepsMathScalar scalar)

Short mult by scalar.

Definition at line 612 of file PETScMatrix.cpp.

◆ releaseLocalRow()

void DistributedMatrix::releaseLocalRow ( const CepsMathScalar **  values,
CepsGlobalIndex  row,
CepsInt nbNonZero,
const CepsGlobalIndex **  nonZeroCols 
)

Release access to the values of matrix row after reading.

Definition at line 347 of file PETScMatrix.cpp.

◆ save()

void DistributedMatrix::save ( const CepsString filename)

Matrix is saved in binary format.

Can then be read using DistributedMatrix::load(...)

Parameters
[in]filenamefile name

Definition at line 513 of file PETScMatrix.cpp.

◆ setColumnAsDistributedVector()

void DistributedMatrix::setColumnAsDistributedVector ( DistributedVector v,
CepsGlobalIndex  column 
)

Sets the values of a distributed vector in matrix column.

N.B. the distriuted vector cannot insert new values. Adding terms off the non-zero structure of the matrix will fail.

Parameters
[in]vDistributedVector containing all values to set into the column
[in]columnglobal matrix index of the column to set

Definition at line 455 of file PETScMatrix.cpp.

◆ setDiagonalAsDistributedVector()

void DistributedMatrix::setDiagonalAsDistributedVector ( DistributedVector v)

Sets the values of a distributed vector in matrix diagonal.

N.B. the distriuted vector cannot insert new values. Adding terms off the non-zero structure of the matrix will fail.

Parameters
[in]vDistributedVector containing all values to set into the diagonal

◆ setNonZeroStructure() [1/2]

void DistributedMatrix::setNonZeroStructure ( CepsInt  d_nz,
CepsInt  o_nz 
)

Set the matrix non-zero structure.

Similar to DistributedMatrix::setNonZeroStructure(const CepsInt d_nnz[], const CepsInt o_nnz[]) but with same number of non-zero terms on each line of the local submatrix.

Parameters
[in]d_nznumber of non-zero elements in each row on the diagonal portion of the matrix.
[in]o_nzsimilary to d_nz, but for off-diagonal portion of the matrix

Definition at line 133 of file PETScMatrix.cpp.

◆ setNonZeroStructure() [2/2]

void DistributedMatrix::setNonZeroStructure ( const CepsInt  d_nnz[],
const CepsInt  o_nnz[] 
)

Set the matrix non-zero structure.

Parameters
[in]d_nnzan array of size m where m is the local of rows. It holds, for each row, the number of non-zero elements, in the diagonal portion of the matrix. (i.e. the local block matrix)
[in]o_nnzsimilar to d_nnz, but for off-diagonal portion of the matrix.

Definition at line 118 of file PETScMatrix.cpp.

◆ setSize()

void DistributedMatrix::setSize ( CepsInt  M,
CepsInt  N,
CepsInt  m,
CepsInt  n 
)

Set distributed matrix global and local size.

As implementation does not use PETSC_DECIDE for the local sizes, these must be correct when calling this method.

Parameters
[in]Mglobal number of rows
[in]Nglobal number of columns
[in]mlocal number or rows
[in]nlocal number of columns

Definition at line 108 of file PETScMatrix.cpp.

◆ setSymmetric()

void DistributedMatrix::setSymmetric ( CepsBool  flag = true)

Set whether this matrix is symmetric or not.

Definition at line 98 of file PETScMatrix.cpp.

◆ setValue()

void DistributedMatrix::setValue ( CepsMathScalar  value,
CepsGlobalIndex  i,
CepsGlobalIndex  j 
)

Sets A(i,j) (replace if existing)

Do not forget to call the matrix assembly methods after setting values

Definition at line 146 of file PETScMatrix.cpp.

◆ setValues()

void DistributedMatrix::setValues ( const CepsMathScalar values,
CepsInt  nbRows,
CepsInt  nbColumns,
const CepsGlobalIndex rowIndices,
const CepsGlobalIndex columnIndices 
)

Set multiple values in the matrix at once.

Do not forget to call the matrix assembly methods after setting values

Parameters
[in]values1 dimensional array of size nRows*nCols containing the values to be added
[in]nbRowssize of the rowIndices parameter, the number of rows that will be modified by this call
[in]nbColumnsidentical to nbRows, but for columns instead
[in]rowIndicesthe global matrix indices of the rows where the values must be set
[in]columnIndicesidentical to rowIndices but for columns instead

Definition at line 173 of file PETScMatrix.cpp.

◆ view()

void DistributedMatrix::view ( ) const

Displays the matrix on standard output.

Definition at line 594 of file PETScMatrix.cpp.

◆ zero()

void DistributedMatrix::zero ( )

Zeroes all entries.

Definition at line 220 of file PETScMatrix.cpp.

◆ zeroRows()

void DistributedMatrix::zeroRows ( CepsInt  nbRows,
CepsGlobalIndex rows,
CepsMathScalar  diagonalValue = 1.0 
)

Sets the indicated rows to zero.

Parameters
[in]nbRowsnumber of rows to zero
[in]rowsglobal indices of the rows
[in]diagonalValuethe value to assign to diagonal

Definition at line 211 of file PETScMatrix.cpp.

◆ zeroRowsAndColumns()

void DistributedMatrix::zeroRowsAndColumns ( CepsInt  nbRows,
CepsGlobalIndex rows,
CepsMathScalar  diagonalValue = 1.0 
)

Sets the indicated rows and columns values to zero for symmetric matrices.

Parameters
[in]nbRowsnumber of rows to zero
[in]rowsglobal indices of the rows
[in]diagonalValuethe value to assign to diagonal

Definition at line 199 of file PETScMatrix.cpp.

Friends And Related Function Documentation

◆ TestDistributedMatrix

friend class TestDistributedMatrix
friend

Definition at line 542 of file DistributedMatrix.hpp.

Field Documentation

◆ m_A

PetscMatrix DistributedMatrix::m_A
private

The main object.

Definition at line 545 of file DistributedMatrix.hpp.

◆ m_hi

CepsGlobalIndex DistributedMatrix::m_hi
private

Index of last local row +1.

Definition at line 547 of file DistributedMatrix.hpp.

◆ m_lo

CepsGlobalIndex DistributedMatrix::m_lo
private

Index of first local row.

Definition at line 546 of file DistributedMatrix.hpp.

◆ m_properlySet

CepsBool DistributedMatrix::m_properlySet
private

Safety flag to check for sizes and memory preallocation.

Definition at line 548 of file DistributedMatrix.hpp.


The documentation for this class was generated from the following files: