Advanced Multi-Physics (AMP)
On-Line Documentation
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AMP::LinearAlgebra::ManagedEpetraMatrix Class Reference

A class that wraps an Epetra_CrsMatrix. More...

#include <ManagedEpetraMatrix.h>

Inheritance diagram for AMP::LinearAlgebra::ManagedEpetraMatrix:
Inheritance graph
[legend]

Public Types

using const_shared_ptr = std::shared_ptr< const Matrix >
 
using shared_ptr = std::shared_ptr< Matrix >
 Convenience typedef.
 

Public Member Functions

template<typename T = double>
void addValueByGlobalID (size_t row, size_t col, T value)
 Add values to those in the matrix.
 
template<typename T >
void addValuesByGlobalID (size_t num_rows, size_t num_cols, size_t *rows, size_t *cols, T *values)
 Add values to those in the matrix.
 
void axpy (AMP::Scalar alpha, const Matrix &X)
 Compute the linear combination of two matrices.
 
void axpy (AMP::Scalar alpha, std::shared_ptr< const Matrix > X)
 Compute the linear combination of two matrices.
 
size_t beginRow () const
 Get the global id of the beginning row.
 
std::shared_ptr< Matrixclone () const override
 Return a matrix with the same non-zero and distributed structure.
 
virtual void copy (std::shared_ptr< const Matrix > X)
 Set this matrix with the same non-zero and distributed structure as x and copy the coefficients.
 
void copyCast (std::shared_ptr< const Matrix > X)
 Set this matrix with the same non-zero and distributed structure as x and copy the coefficients after up/down casting.
 
Vector::shared_ptr createInputVector () const override
 Get a right vector ( For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{x}\) is a right vector )
 
Vector::shared_ptr createOutputVector () const override
 Get a left vector ( For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{y}\) is a left vector )
 
size_t endRow () const
 Get the global id of the ending row.
 
Vector::shared_ptr extractDiagonal (Vector::shared_ptr buf=Vector::shared_ptr()) const override
 Extract the diagonal from a matrix.
 
std::vector< size_tgetColumnIDs (size_t row) const
 Given a row, retrieve the non-zero column indices of the matrix in compressed format.
 
AMP_MPI getComm () const
 Get the comm.
 
Epetra_CrsMatrixgetEpetra_CrsMatrix ()
 
const Epetra_CrsMatrixgetEpetra_CrsMatrix () const
 Return an Epetra_CrsMatrix.
 
uint64_t getID () const
 Get a unique id hash for the matrix.
 
virtual std::shared_ptr< Discretization::DOFManagergetLeftDOFManager () const
 Get the DOFManager associated with a left vector. For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{y}\) is a left vector.
 
std::shared_ptr< MatrixDatagetMatrixData ()
 Return the pointer to the MatrixData.
 
std::shared_ptr< const MatrixDatagetMatrixData () const
 Return the pointer to the MatrixData.
 
virtual std::shared_ptr< Discretization::DOFManagergetRightDOFManager () const
 Get the DOFManager associated with a right vector. For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{x}\) is a right vector.
 
template<typename T = double>
void getRowByGlobalID (size_t row, std::vector< size_t > &cols, std::vector< T > &values) const
 Retrieve a row of the matrix in compressed format.
 
Vector::shared_ptr getRowSums (Vector::shared_ptr buf=Vector::shared_ptr()) const
 Get sum of each row in matrix.
 
Vector::shared_ptr getRowSumsAbsolute (Vector::shared_ptr buf=Vector::shared_ptr(), const bool remove_zeros=false) const
 Get absolute sum of each row in matrix.
 
template<typename T = double>
T getValueByGlobalID (size_t row, size_t col) const
 Get values in the matrix.
 
template<typename T >
void getValuesByGlobalID (size_t num_rows, size_t num_cols, const size_t *rows, const size_t *cols, T *values) const
 Get values in the matrix.
 
AMP::Scalar LinfNorm () const
 Compute the maximum row sum.
 
void makeConsistent (AMP::LinearAlgebra::ScatterType t)
 Perform communication to ensure values in the matrix are the same across cores.
 
 ManagedEpetraMatrix (Epetra_CrsMatrix *m, bool dele=false)
 Constructor from Epetra_CrsMatrix.
 
 ManagedEpetraMatrix (std::shared_ptr< MatrixData > data)
 
 ManagedEpetraMatrix (std::shared_ptr< MatrixParameters > p)
 Constructor.
 
virtual std::uint16_t mode () const
 Return CSR mode of the matrix.
 
void mult (std::shared_ptr< const Vector > in, std::shared_ptr< Vector > out)
 Matrix-vector multiplication.
 
void multTranspose (std::shared_ptr< const Vector > in, std::shared_ptr< Vector > out)
 Matrix transpose-vector multiplication.
 
size_t numberColumnIDs (size_t row) const
 Given a row, retrieve the number of non-zero column indices of the matrix.
 
size_t numGlobalColumns () const
 Get the number of global columns in the matrix.
 
size_t numGlobalRows () const
 Get the number of global rows in the matrix.
 
size_t numLocalColumns () const
 Get the number of local columns in the matrix.
 
size_t numLocalRows () const
 Get the number of local rows in the matrix.
 
virtual void registerChildObjects (AMP::IO::RestartManager *manager) const
 Register any child objects.
 
void scale (AMP::Scalar alpha)
 Scale the matrix by a scalar.
 
void scale (AMP::Scalar alpha, Vector::const_shared_ptr D)
 Diagonally scale matrix.
 
void scaleInv (AMP::Scalar alpha, Vector::const_shared_ptr D)
 Scale matrix by inverse of diagonal matrix.
 
virtual void setBackend (AMP::Utilities::Backend)
 Replace current backend with different one, no-op if same, no-op if not a CSRMatrix.
 
void setDiagonal (Vector::const_shared_ptr in)
 Set the diagonal to the values in a vector.
 
void setIdentity ()
 Set the matrix to the identity matrix.
 
template<typename T = double>
void setRowByGlobalID (size_t row, const std::vector< size_t > &cols, const std::vector< T > &values)
 Set values for a row in the matrix.
 
void setScalar (AMP::Scalar alpha)
 Set the non-zeros of the matrix to a scalar.
 
template<typename T = double>
void setValueByGlobalID (size_t row, size_t col, T value)
 Set values in the matrix.
 
template<typename T >
void setValuesByGlobalID (size_t num_rows, size_t num_cols, const size_t *rows, const size_t *cols, const T *values)
 Set values in the matrix.
 
std::shared_ptr< Matrixtranspose () const override
 Return a new matrix that is the transpose of this one.
 
virtual void writeRestart (int64_t fid) const
 Write restart data to file.
 
void zero ()
 Set the non-zeros of the matrix to zero.
 
virtual ~ManagedEpetraMatrix ()
 Destructor.
 

Static Public Member Functions

static shared_ptr matMatMult (shared_ptr A, shared_ptr B)
 Compute the product of two matrices.
 
static void matMatMult (shared_ptr A, shared_ptr B, shared_ptr C)
 Compute the product of two matrices.
 

Protected Member Functions

 ManagedEpetraMatrix ()=delete
 Empty constructor.
 
 ManagedEpetraMatrix (const ManagedEpetraMatrix &rhs)
 Copy constructor.
 
void multiply (shared_ptr other_op, shared_ptr &result) override
 Multiply two matrices and store in a third result = this * other_op.
 
ManagedEpetraMatrixoperator= (const ManagedEpetraMatrix &rhs)=delete
 Assignment operator.
 
std::string type () const override
 Return the type of the matrix.
 

Protected Attributes

std::shared_ptr< MatrixDatad_matrixData
 Pointer to data.
 
std::shared_ptr< MatrixOperationsd_matrixOps
 

Detailed Description

A class that wraps an Epetra_CrsMatrix.

This class stores an Epetra_FECrsMatrix and provides the AMP interface to this matrix.

Definition at line 25 of file ManagedEpetraMatrix.h.

Member Typedef Documentation

◆ const_shared_ptr

Definition at line 34 of file Matrix.h.

◆ shared_ptr

using AMP::LinearAlgebra::Matrix::shared_ptr = std::shared_ptr<Matrix>
inherited

Convenience typedef.

Definition at line 33 of file Matrix.h.

Constructor & Destructor Documentation

◆ ManagedEpetraMatrix() [1/5]

AMP::LinearAlgebra::ManagedEpetraMatrix::ManagedEpetraMatrix ( )
protecteddelete

Empty constructor.

◆ ManagedEpetraMatrix() [2/5]

AMP::LinearAlgebra::ManagedEpetraMatrix::ManagedEpetraMatrix ( const ManagedEpetraMatrix rhs)
protected

Copy constructor.

◆ ManagedEpetraMatrix() [3/5]

AMP::LinearAlgebra::ManagedEpetraMatrix::ManagedEpetraMatrix ( std::shared_ptr< MatrixParameters p)
explicit

Constructor.

Parameters
[in]pThe description of the matrix

◆ ManagedEpetraMatrix() [4/5]

AMP::LinearAlgebra::ManagedEpetraMatrix::ManagedEpetraMatrix ( std::shared_ptr< MatrixData data)

◆ ManagedEpetraMatrix() [5/5]

AMP::LinearAlgebra::ManagedEpetraMatrix::ManagedEpetraMatrix ( Epetra_CrsMatrix m,
bool  dele = false 
)
explicit

Constructor from Epetra_CrsMatrix.

Parameters
[in]mMatrix to wrap
[in]deleIf true, this class deletes the matrix

◆ ~ManagedEpetraMatrix()

virtual AMP::LinearAlgebra::ManagedEpetraMatrix::~ManagedEpetraMatrix ( )
inlinevirtual

Destructor.

Definition at line 57 of file ManagedEpetraMatrix.h.

Member Function Documentation

◆ addValueByGlobalID()

template<typename T = double>
void AMP::LinearAlgebra::Matrix::addValueByGlobalID ( size_t  row,
size_t  col,
T  value 
)
inlineinherited

Add values to those in the matrix.

Parameters
[in]rowThe row id of value
[in]colThe column id of value
[in]valueThe value to add to the matrix

This method may fail if the matrix has not allocated a particular (row,col) specified, depending on the actual subclass of matrix used.

Definition at line 355 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::addValuesByGlobalID().

◆ addValuesByGlobalID()

template<typename T >
void AMP::LinearAlgebra::Matrix::addValuesByGlobalID ( size_t  num_rows,
size_t  num_cols,
size_t rows,
size_t cols,
T values 
)
inlineinherited

Add values to those in the matrix.

Parameters
[in]num_rowsThe number of rows represented in values
[in]num_colsThe number of cols represented in values
[in]rowsThe row ids of values
[in]colsThe column ids of values
[in]valuesThe values to add to the matrix (row-major ordering)

This method may fail if the matrix has not allocated a particular (row,col) specified, depending on the actual subclass of matrix used.

Definition at line 210 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

Referenced by AMP::LinearAlgebra::Matrix::addValueByGlobalID().

◆ axpy() [1/2]

void AMP::LinearAlgebra::Matrix::axpy ( AMP::Scalar  alpha,
const Matrix X 
)
inherited

Compute the linear combination of two matrices.

Parameters
[in]alphascalar
[in]Xmatrix

Compute \(\mathbf{THIS} = \alpha\mathbf{X} + \mathbf{THIS}\)

◆ axpy() [2/2]

void AMP::LinearAlgebra::Matrix::axpy ( AMP::Scalar  alpha,
std::shared_ptr< const Matrix X 
)
inherited

Compute the linear combination of two matrices.

Parameters
[in]alphascalar
[in]Xmatrix

Compute \(\mathbf{THIS} = \alpha\mathbf{X} + \mathbf{THIS}\)

◆ beginRow()

size_t AMP::LinearAlgebra::Matrix::beginRow ( ) const
inlineinherited

Get the global id of the beginning row.

Returns
beginning global row id

Definition at line 317 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ clone()

std::shared_ptr< Matrix > AMP::LinearAlgebra::ManagedEpetraMatrix::clone ( ) const
overridevirtual

Return a matrix with the same non-zero and distributed structure.

Returns
The new matrix

Implements AMP::LinearAlgebra::Matrix.

◆ copy()

virtual void AMP::LinearAlgebra::Matrix::copy ( std::shared_ptr< const Matrix X)
virtualinherited

Set this matrix with the same non-zero and distributed structure as x and copy the coefficients.

Reimplemented in AMP::LinearAlgebra::NativePetscMatrix.

◆ copyCast()

void AMP::LinearAlgebra::Matrix::copyCast ( std::shared_ptr< const Matrix X)
inherited

Set this matrix with the same non-zero and distributed structure as x and copy the coefficients after up/down casting.

◆ createInputVector()

Vector::shared_ptr AMP::LinearAlgebra::ManagedEpetraMatrix::createInputVector ( ) const
overridevirtual

Get a right vector ( For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{x}\) is a right vector )

Returns
A newly created right vector

Implements AMP::LinearAlgebra::Matrix.

◆ createOutputVector()

Vector::shared_ptr AMP::LinearAlgebra::ManagedEpetraMatrix::createOutputVector ( ) const
overridevirtual

Get a left vector ( For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{y}\) is a left vector )

Returns
A newly created left vector

Implements AMP::LinearAlgebra::Matrix.

◆ endRow()

size_t AMP::LinearAlgebra::Matrix::endRow ( ) const
inlineinherited

Get the global id of the ending row.

Returns
ending global row id

Definition at line 322 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ extractDiagonal()

Vector::shared_ptr AMP::LinearAlgebra::ManagedEpetraMatrix::extractDiagonal ( Vector::shared_ptr  buf = Vector::shared_ptr()) const
overridevirtual

Extract the diagonal from a matrix.

Parameters
[in]bufAn optional vector to use as a buffer
Returns
A vector of the diagonal values

Implements AMP::LinearAlgebra::Matrix.

◆ getColumnIDs()

std::vector< size_t > AMP::LinearAlgebra::Matrix::getColumnIDs ( size_t  row) const
inlineinherited

Given a row, retrieve the non-zero column indices of the matrix in compressed format.

Parameters
[in]rowWhich row

Definition at line 281 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ getComm()

AMP_MPI AMP::LinearAlgebra::Matrix::getComm ( ) const
inlineinherited

Get the comm.

Definition at line 325 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ getEpetra_CrsMatrix() [1/2]

Epetra_CrsMatrix & AMP::LinearAlgebra::ManagedEpetraMatrix::getEpetra_CrsMatrix ( )

◆ getEpetra_CrsMatrix() [2/2]

const Epetra_CrsMatrix & AMP::LinearAlgebra::ManagedEpetraMatrix::getEpetra_CrsMatrix ( ) const

Return an Epetra_CrsMatrix.

Returns
An Epetra_CrsMatrix view of this matrix

◆ getID()

uint64_t AMP::LinearAlgebra::Matrix::getID ( ) const
inherited

Get a unique id hash for the matrix.

◆ getLeftDOFManager()

virtual std::shared_ptr< Discretization::DOFManager > AMP::LinearAlgebra::Matrix::getLeftDOFManager ( ) const
inlinevirtualinherited

Get the DOFManager associated with a left vector. For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{y}\) is a left vector.

Returns
The DOFManager associated with a left vector

Reimplemented in AMP::LinearAlgebra::NativePetscMatrix.

Definition at line 340 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ getMatrixData() [1/2]

std::shared_ptr< MatrixData > AMP::LinearAlgebra::Matrix::getMatrixData ( )
inlineinherited

Return the pointer to the MatrixData.

Definition at line 388 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ getMatrixData() [2/2]

std::shared_ptr< const MatrixData > AMP::LinearAlgebra::Matrix::getMatrixData ( ) const
inlineinherited

Return the pointer to the MatrixData.

Definition at line 391 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ getRightDOFManager()

virtual std::shared_ptr< Discretization::DOFManager > AMP::LinearAlgebra::Matrix::getRightDOFManager ( ) const
inlinevirtualinherited

Get the DOFManager associated with a right vector. For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{x}\) is a right vector.

Returns
The DOFManager associated with a right vector

Reimplemented in AMP::LinearAlgebra::NativePetscMatrix.

Definition at line 331 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ getRowByGlobalID()

template<typename T = double>
void AMP::LinearAlgebra::Matrix::getRowByGlobalID ( size_t  row,
std::vector< size_t > &  cols,
std::vector< T > &  values 
) const
inlineinherited

Retrieve a row of the matrix in compressed format.

Parameters
[in]rowWhich row
[out]colsThe column ids of the returned values
[out]valuesThe values in the row

Definition at line 267 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ getRowSums()

Vector::shared_ptr AMP::LinearAlgebra::Matrix::getRowSums ( Vector::shared_ptr  buf = Vector::shared_ptr()) const
inherited

Get sum of each row in matrix.

Parameters
[in]bufAn optional vector to use as a buffer
Returns
A vector of the sums

◆ getRowSumsAbsolute()

Vector::shared_ptr AMP::LinearAlgebra::Matrix::getRowSumsAbsolute ( Vector::shared_ptr  buf = Vector::shared_ptr(),
const bool  remove_zeros = false 
) const
inherited

Get absolute sum of each row in matrix.

Parameters
[in]bufAn optional vector to use as a buffer
[in]remove_zerosDo we want to remove zeros
Returns
A vector of the sums

◆ getValueByGlobalID()

template<typename T = double>
T AMP::LinearAlgebra::Matrix::getValueByGlobalID ( size_t  row,
size_t  col 
) const
inlineinherited

Get values in the matrix.

Parameters
[in]rowThe row id of value
[in]colThe column id of value

This method will return zero for any values that have not been allocated.

Definition at line 380 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::getValuesByGlobalID().

◆ getValuesByGlobalID()

template<typename T >
void AMP::LinearAlgebra::Matrix::getValuesByGlobalID ( size_t  num_rows,
size_t  num_cols,
const size_t rows,
const size_t cols,
T values 
) const
inlineinherited

Get values in the matrix.

Parameters
[in]num_rowsThe number of rows represented in values
[in]num_colsThe number of cols represented in values
[in]rowsThe row ids of values
[in]colsThe column ids of values
[out]valuesThe values to get from the matrix (row-major ordering)

This method will return zero for any entries that have not been allocated or are not ghosts on the current processor.

Definition at line 255 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

Referenced by AMP::LinearAlgebra::Matrix::getValueByGlobalID().

◆ LinfNorm()

AMP::Scalar AMP::LinearAlgebra::Matrix::LinfNorm ( ) const
inherited

Compute the maximum row sum.

Returns
The L-infinity norm of the matrix

◆ makeConsistent()

void AMP::LinearAlgebra::Matrix::makeConsistent ( AMP::LinearAlgebra::ScatterType  t)
inlineinherited

Perform communication to ensure values in the matrix are the same across cores.

Definition at line 289 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ matMatMult() [1/2]

static shared_ptr AMP::LinearAlgebra::Matrix::matMatMult ( shared_ptr  A,
shared_ptr  B 
)
staticinherited

Compute the product of two matrices.

Parameters
[in]ALeft multiplicand
[in]BRight multiplicand
Returns
The product \(\mathbf{AB}\).

◆ matMatMult() [2/2]

static void AMP::LinearAlgebra::Matrix::matMatMult ( shared_ptr  A,
shared_ptr  B,
shared_ptr  C 
)
staticinherited

Compute the product of two matrices.

Parameters
[in]ALeft multiplicand
[in]BRight multiplicand
[in,out]CResult matrix

◆ mode()

virtual std::uint16_t AMP::LinearAlgebra::Matrix::mode ( ) const
virtualinherited

Return CSR mode of the matrix.

Reimplemented in AMP::LinearAlgebra::CSRMatrix< Config >.

◆ mult()

void AMP::LinearAlgebra::Matrix::mult ( std::shared_ptr< const Vector in,
std::shared_ptr< Vector out 
)
inherited

Matrix-vector multiplication.

Parameters
[in]inThe vector to multiply
[out]outThe resulting vectory

Compute \(\mathbf{Ain} = \mathbf{out}\).

◆ multiply()

void AMP::LinearAlgebra::ManagedEpetraMatrix::multiply ( shared_ptr  other_op,
shared_ptr result 
)
overrideprotectedvirtual

Multiply two matrices and store in a third result = this * other_op.

Parameters
[in]other_opThe other matrix to multiply
[out]resultThe matrix to store the result

Implements AMP::LinearAlgebra::Matrix.

◆ multTranspose()

void AMP::LinearAlgebra::Matrix::multTranspose ( std::shared_ptr< const Vector in,
std::shared_ptr< Vector out 
)
inherited

Matrix transpose-vector multiplication.

Parameters
[in]inThe vector to multiply
[out]outThe resulting vectory

Compute \(\mathbf{A}^T\mathbf{in} = \mathbf{out}\).

◆ numberColumnIDs()

size_t AMP::LinearAlgebra::Matrix::numberColumnIDs ( size_t  row) const
inlineinherited

Given a row, retrieve the number of non-zero column indices of the matrix.

Parameters
[in]rowWhich row

Definition at line 276 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ numGlobalColumns()

size_t AMP::LinearAlgebra::Matrix::numGlobalColumns ( ) const
inlineinherited

Get the number of global columns in the matrix.

Returns
The number of global columns

Definition at line 312 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ numGlobalRows()

size_t AMP::LinearAlgebra::Matrix::numGlobalRows ( ) const
inlineinherited

Get the number of global rows in the matrix.

Returns
The number of global rows

Definition at line 302 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ numLocalColumns()

size_t AMP::LinearAlgebra::Matrix::numLocalColumns ( ) const
inlineinherited

Get the number of local columns in the matrix.

Returns
The number of local columns

Definition at line 307 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ numLocalRows()

size_t AMP::LinearAlgebra::Matrix::numLocalRows ( ) const
inlineinherited

Get the number of local rows in the matrix.

Returns
The number of local rows

Definition at line 297 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

◆ operator=()

Assignment operator.

◆ registerChildObjects()

virtual void AMP::LinearAlgebra::Matrix::registerChildObjects ( AMP::IO::RestartManager manager) const
virtualinherited

Register any child objects.

This function will register child objects with the manager

Parameters
managerRestart manager

◆ scale() [1/2]

void AMP::LinearAlgebra::Matrix::scale ( AMP::Scalar  alpha)
inherited

Scale the matrix by a scalar.

Parameters
[in]alphaThe value to scale by

Compute \(\mathbf{A} = \alpha\mathbf{A}\)

◆ scale() [2/2]

void AMP::LinearAlgebra::Matrix::scale ( AMP::Scalar  alpha,
Vector::const_shared_ptr  D 
)
inherited

Diagonally scale matrix.

Parameters
[in]alphaScaling applied to all rows
[in]DVector of scales, one for each row

Compute \(\mathbf{A} = \alpha\mathbf{D}\mathbf{A}\)

◆ scaleInv()

void AMP::LinearAlgebra::Matrix::scaleInv ( AMP::Scalar  alpha,
Vector::const_shared_ptr  D 
)
inherited

Scale matrix by inverse of diagonal matrix.

Parameters
[in]alphaScaling applied to all rows
[in]DArray of inverse scales, one for each row

Compute \(\mathbf{A} = \alpha\mathbf{D}^{-1}\mathbf{A}\)

◆ setBackend()

virtual void AMP::LinearAlgebra::Matrix::setBackend ( AMP::Utilities::Backend  )
virtualinherited

Replace current backend with different one, no-op if same, no-op if not a CSRMatrix.

Reimplemented in AMP::LinearAlgebra::CSRMatrix< Config >.

◆ setDiagonal()

void AMP::LinearAlgebra::Matrix::setDiagonal ( Vector::const_shared_ptr  in)
inherited

Set the diagonal to the values in a vector.

Parameters
[in]inThe values to set the diagonal to

◆ setIdentity()

void AMP::LinearAlgebra::Matrix::setIdentity ( )
inherited

Set the matrix to the identity matrix.

◆ setRowByGlobalID()

template<typename T = double>
void AMP::LinearAlgebra::Matrix::setRowByGlobalID ( size_t  row,
const std::vector< size_t > &  cols,
const std::vector< T > &  values 
)
inlineinherited

Set values for a row in the matrix.

Parameters
[in]rowWhich row
[in]colsThe column ids to set
[in]valuesThe values to set

Definition at line 239 of file Matrix.h.

References AMP_ASSERT, and AMP::LinearAlgebra::Matrix::d_matrixData.

◆ setScalar()

void AMP::LinearAlgebra::Matrix::setScalar ( AMP::Scalar  alpha)
inherited

Set the non-zeros of the matrix to a scalar.

Parameters
[in]alphaThe value to set the non-zeros to

◆ setValueByGlobalID()

template<typename T = double>
void AMP::LinearAlgebra::Matrix::setValueByGlobalID ( size_t  row,
size_t  col,
T  value 
)
inlineinherited

Set values in the matrix.

Parameters
[in]rowThe row id of value
[in]colThe column id of value
[in]valueThe value to set to the matrix

This method may fail if the matrix has not allocated a particular (row,col) specified, depending on the actual subclass of matrix used.

Definition at line 369 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::setValuesByGlobalID().

◆ setValuesByGlobalID()

template<typename T >
void AMP::LinearAlgebra::Matrix::setValuesByGlobalID ( size_t  num_rows,
size_t  num_cols,
const size_t rows,
const size_t cols,
const T values 
)
inlineinherited

Set values in the matrix.

Parameters
[in]num_rowsThe number of rows represented in values
[in]num_colsThe number of cols represented in values
[in]rowsThe row ids of values
[in]colsThe column ids of values
[in]valuesThe values to set to the matrix (row-major ordering)

This method may fail if the matrix has not allocated a particular (row,col) specified, depending on the actual subclass of matrix used.

Definition at line 226 of file Matrix.h.

References AMP::LinearAlgebra::Matrix::d_matrixData.

Referenced by AMP::LinearAlgebra::Matrix::setValueByGlobalID().

◆ transpose()

std::shared_ptr< Matrix > AMP::LinearAlgebra::ManagedEpetraMatrix::transpose ( ) const
overridevirtual

Return a new matrix that is the transpose of this one.

Returns
A copy of this matrix transposed.

Reimplemented from AMP::LinearAlgebra::Matrix.

◆ type()

std::string AMP::LinearAlgebra::ManagedEpetraMatrix::type ( ) const
inlineoverrideprotectedvirtual

Return the type of the matrix.

Implements AMP::LinearAlgebra::Matrix.

Definition at line 40 of file ManagedEpetraMatrix.h.

◆ writeRestart()

virtual void AMP::LinearAlgebra::Matrix::writeRestart ( int64_t  fid) const
virtualinherited

Write restart data to file.

This function will write the mesh to an HDF5 file

Parameters
fidFile identifier to write

◆ zero()

void AMP::LinearAlgebra::Matrix::zero ( )
inherited

Set the non-zeros of the matrix to zero.

May not deallocate space.

Member Data Documentation

◆ d_matrixData

std::shared_ptr<MatrixData> AMP::LinearAlgebra::Matrix::d_matrixData
protectedinherited

◆ d_matrixOps

std::shared_ptr<MatrixOperations> AMP::LinearAlgebra::Matrix::d_matrixOps
protectedinherited

Definition at line 440 of file Matrix.h.


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



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:42.
Comments on this page