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::Matrix Class Referenceabstract

An abstract interface for using and manipulating matrices. More...

#include <Matrix.h>

Inheritance diagram for AMP::LinearAlgebra::Matrix:
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.
 
virtual shared_ptr clone () const =0
 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.
 
virtual Vector::shared_ptr createInputVector () const =0
 Get a right vector ( For \(\mathbf{y}^T\mathbf{Ax}\), \(\mathbf{x}\) is a right vector )
 
virtual Vector::shared_ptr createOutputVector () const =0
 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.
 
virtual Vector::shared_ptr extractDiagonal (Vector::shared_ptr buf=Vector::shared_ptr()) const =0
 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.
 
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.
 
 Matrix (int64_t fid, AMP::IO::RestartManager *manager)
 Read restart data to file.
 
 Matrix (std::shared_ptr< MatrixData > data)
 Constructor.
 
 Matrix (std::shared_ptr< MatrixParametersBase > params)
 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.
 
virtual std::shared_ptr< Matrixtranspose () const
 Return a new matrix that is the transpose of this one.
 
virtual std::string type () const =0
 Return the type of the matrix.
 
virtual void writeRestart (int64_t fid) const
 Write restart data to file.
 
void zero ()
 Set the non-zeros of the matrix to zero.
 
virtual ~Matrix ()
 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

 Matrix ()
 Protected constructor.
 
 Matrix (const Matrix &)
 Protected copy constructor.
 
virtual void multiply (shared_ptr other_op, shared_ptr &result)=0
 Multiply two matrices and store in a third result = this * other_op.
 
Matrixoperator= (const Matrix &)=delete
 Protected assignment operator.
 

Protected Attributes

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

Detailed Description

An abstract interface for using and manipulating matrices.

There are several different varieties of distributed memory matrices. While most operations between the varieties can be abstracted away from the user, some cannot. For this reason, most of the time, this class will suffice as the way to interact with a matrix. Matrix creation may require use of one of the derived classes.

Definition at line 29 of file Matrix.h.

Member Typedef Documentation

◆ const_shared_ptr

Definition at line 34 of file Matrix.h.

◆ shared_ptr

Convenience typedef.

Definition at line 33 of file Matrix.h.

Constructor & Destructor Documentation

◆ Matrix() [1/5]

AMP::LinearAlgebra::Matrix::Matrix ( std::shared_ptr< MatrixParametersBase params)
explicit

Constructor.

Parameters
[in]paramsDescription of the matrix

◆ Matrix() [2/5]

AMP::LinearAlgebra::Matrix::Matrix ( std::shared_ptr< MatrixData data)
explicit

Constructor.

Parameters
[in]dataMatrixData object associated with matrix

◆ ~Matrix()

virtual AMP::LinearAlgebra::Matrix::~Matrix ( )
virtual

Destructor.

◆ Matrix() [3/5]

AMP::LinearAlgebra::Matrix::Matrix ( int64_t  fid,
AMP::IO::RestartManager manager 
)

Read restart data to file.

This function will create a variable from the restart file

Parameters
fidFile identifier to write
managerRestart manager

◆ Matrix() [4/5]

AMP::LinearAlgebra::Matrix::Matrix ( )
protected

Protected constructor.

◆ Matrix() [5/5]

AMP::LinearAlgebra::Matrix::Matrix ( const Matrix )
protected

Protected copy constructor.

Member Function Documentation

◆ addValueByGlobalID()

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

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 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 
)
inline

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 d_matrixData.

Referenced by addValueByGlobalID().

◆ axpy() [1/2]

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

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 
)

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
inline

Get the global id of the beginning row.

Returns
beginning global row id

Definition at line 317 of file Matrix.h.

References d_matrixData.

◆ clone()

virtual shared_ptr AMP::LinearAlgebra::Matrix::clone ( ) const
pure virtual

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

Returns
The new matrix

Implemented in AMP::LinearAlgebra::CSRMatrix< Config >, AMP::LinearAlgebra::DenseSerialMatrix, AMP::LinearAlgebra::NativePetscMatrix, and AMP::LinearAlgebra::ManagedEpetraMatrix.

◆ copy()

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

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)

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

◆ createInputVector()

virtual Vector::shared_ptr AMP::LinearAlgebra::Matrix::createInputVector ( ) const
pure virtual

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

Returns
A newly created right vector

Implemented in AMP::LinearAlgebra::CSRMatrix< Config >, AMP::LinearAlgebra::DenseSerialMatrix, AMP::LinearAlgebra::NativePetscMatrix, and AMP::LinearAlgebra::ManagedEpetraMatrix.

◆ createOutputVector()

virtual Vector::shared_ptr AMP::LinearAlgebra::Matrix::createOutputVector ( ) const
pure virtual

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

Returns
A newly created left vector

Implemented in AMP::LinearAlgebra::CSRMatrix< Config >, AMP::LinearAlgebra::DenseSerialMatrix, AMP::LinearAlgebra::NativePetscMatrix, and AMP::LinearAlgebra::ManagedEpetraMatrix.

◆ endRow()

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

Get the global id of the ending row.

Returns
ending global row id

Definition at line 322 of file Matrix.h.

References d_matrixData.

◆ extractDiagonal()

virtual Vector::shared_ptr AMP::LinearAlgebra::Matrix::extractDiagonal ( Vector::shared_ptr  buf = Vector::shared_ptr()) const
pure virtual

Extract the diagonal from a matrix.

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

Implemented in AMP::LinearAlgebra::CSRMatrix< Config >, AMP::LinearAlgebra::DenseSerialMatrix, AMP::LinearAlgebra::ManagedEpetraMatrix, and AMP::LinearAlgebra::NativePetscMatrix.

◆ getColumnIDs()

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

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 d_matrixData.

◆ getComm()

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

Get the comm.

Definition at line 325 of file Matrix.h.

References d_matrixData.

◆ getID()

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

Get a unique id hash for the matrix.

◆ getLeftDOFManager()

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

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 d_matrixData.

◆ getMatrixData() [1/2]

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

Return the pointer to the MatrixData.

Definition at line 388 of file Matrix.h.

References d_matrixData.

◆ getMatrixData() [2/2]

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

Return the pointer to the MatrixData.

Definition at line 391 of file Matrix.h.

References d_matrixData.

◆ getRightDOFManager()

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

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 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
inline

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 d_matrixData.

◆ getRowSums()

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

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

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
inline

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 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
inline

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 d_matrixData.

Referenced by getValueByGlobalID().

◆ LinfNorm()

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

Compute the maximum row sum.

Returns
The L-infinity norm of the matrix

◆ makeConsistent()

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

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

Definition at line 289 of file Matrix.h.

References d_matrixData.

◆ matMatMult() [1/2]

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

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 
)
static

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
virtual

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 
)

Matrix-vector multiplication.

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

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

◆ multiply()

virtual void AMP::LinearAlgebra::Matrix::multiply ( shared_ptr  other_op,
shared_ptr result 
)
protectedpure virtual

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

Implemented in AMP::LinearAlgebra::CSRMatrix< Config >, AMP::LinearAlgebra::DenseSerialMatrix, and AMP::LinearAlgebra::ManagedEpetraMatrix.

◆ multTranspose()

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

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
inline

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 d_matrixData.

◆ numGlobalColumns()

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

Get the number of global columns in the matrix.

Returns
The number of global columns

Definition at line 312 of file Matrix.h.

References d_matrixData.

◆ numGlobalRows()

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

Get the number of global rows in the matrix.

Returns
The number of global rows

Definition at line 302 of file Matrix.h.

References d_matrixData.

◆ numLocalColumns()

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

Get the number of local columns in the matrix.

Returns
The number of local columns

Definition at line 307 of file Matrix.h.

References d_matrixData.

◆ numLocalRows()

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

Get the number of local rows in the matrix.

Returns
The number of local rows

Definition at line 297 of file Matrix.h.

References d_matrixData.

◆ operator=()

Protected assignment operator.

◆ registerChildObjects()

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

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)

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 
)

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 
)

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  )
virtual

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)

Set the diagonal to the values in a vector.

Parameters
[in]inThe values to set the diagonal to

◆ setIdentity()

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

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 
)
inline

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 d_matrixData.

◆ setScalar()

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

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 
)
inline

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 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 
)
inline

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 d_matrixData.

Referenced by setValueByGlobalID().

◆ transpose()

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

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

Returns
A copy of this matrix transposed.

Reimplemented in AMP::LinearAlgebra::CSRMatrix< Config >, AMP::LinearAlgebra::DenseSerialMatrix, and AMP::LinearAlgebra::ManagedEpetraMatrix.

Definition at line 443 of file Matrix.h.

References AMP_ERROR.

◆ type()

virtual std::string AMP::LinearAlgebra::Matrix::type ( ) const
pure virtual

◆ writeRestart()

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

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 ( )

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
protected

◆ d_matrixOps

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

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