Advanced Multi-Physics (AMP)
On-Line Documentation
CSRMatrixOperationsDefault.h
Go to the documentation of this file.
1#ifndef included_CSRMatrixOperationsDefault_H_
2#define included_CSRMatrixOperationsDefault_H_
3
4#include "AMP/matrices/data/CSRMatrixData.h"
5#include "AMP/matrices/data/MatrixData.h"
6#include "AMP/matrices/operations/MatrixOperations.h"
7#include "AMP/matrices/operations/default/CSRLocalMatrixOperationsDefault.h"
8#include "AMP/matrices/operations/default/spgemm/CSRMatrixSpGEMMDefault.h"
9#include "AMP/vectors/Vector.h"
10
11#include <map>
12
13namespace AMP::LinearAlgebra {
14
15template<typename Config>
17{
18public:
19 using allocator_type = typename Config::allocator_type;
20 static_assert( std::is_same_v<typename allocator_type::value_type, void> );
21
24
26
27 using gidx_t = typename Config::gidx_t;
28 using lidx_t = typename Config::lidx_t;
29 using scalar_t = typename Config::scalar_t;
30
32 : d_localops_diag( std::make_shared<localops_t>() ),
33 d_localops_offd( std::make_shared<localops_t>() )
34 {
35 }
36
43 void mult( std::shared_ptr<const Vector> x,
44 MatrixData const &A,
45 std::shared_ptr<Vector> y ) override;
46
53 void multTranspose( std::shared_ptr<const Vector> in,
54 MatrixData const &A,
55 std::shared_ptr<Vector> out ) override;
56
62 void scale( AMP::Scalar alpha, MatrixData &A ) override;
63
70 void scale( AMP::Scalar alpha, std::shared_ptr<const Vector> D, MatrixData &A ) override;
71
78 void scaleInv( AMP::Scalar alpha, std::shared_ptr<const Vector> D, MatrixData &A ) override;
79
85 void matMatMult( std::shared_ptr<MatrixData> A,
86 std::shared_ptr<MatrixData> B,
87 std::shared_ptr<MatrixData> C ) override;
88
95 void axpy( AMP::Scalar alpha, const MatrixData &X, MatrixData &Y ) override;
96
101 void setScalar( AMP::Scalar alpha, MatrixData &A ) override;
102
107 void zero( MatrixData &A ) override;
108
113 void setDiagonal( std::shared_ptr<const Vector> in, MatrixData &A ) override;
114
119 void extractDiagonal( MatrixData const &A, std::shared_ptr<Vector> buf ) override;
120
125 void getRowSums( MatrixData const &A, std::shared_ptr<Vector> buf ) override;
126
133 std::shared_ptr<Vector> buf,
134 const bool remove_zeros = false ) override;
135
139 void setIdentity( MatrixData &A ) override;
140
145 AMP::Scalar LinfNorm( const MatrixData &X ) const override;
146
152 void copy( const MatrixData &X, MatrixData &Y ) override;
153
159 void copyCast( const MatrixData &X, MatrixData &Y ) override;
160
161 template<typename ConfigIn>
162 static void
163 copyCast( CSRMatrixData<typename ConfigIn::template set_alloc_t<Config::allocator>> *X,
164 matrixdata_t *Y );
165
166 std::string type() const override { return "CSRMatrixOperationsDefault"; }
167
173 void writeRestart( int64_t fid ) const override;
174
176 : d_localops_diag( std::make_shared<localops_t>() ),
177 d_localops_offd( std::make_shared<localops_t>() )
178 {
179 }
180
181protected:
182 std::shared_ptr<localops_t> d_localops_diag;
183 std::shared_ptr<localops_t> d_localops_offd;
184 std::map<std::pair<std::shared_ptr<matrixdata_t>, std::shared_ptr<matrixdata_t>>,
187};
188
189} // namespace AMP::LinearAlgebra
190
191#endif
#define X(C)
Class to manage reading/writing restart data.
CSRLocalMatrixData< Config > localmatrixdata_t
void writeRestart(int64_t fid) const override
Write restart data to file.
AMP::Scalar LinfNorm(const MatrixData &X) const override
Compute the maximum row sum.
void mult(std::shared_ptr< const Vector > x, MatrixData const &A, std::shared_ptr< Vector > y) override
Matrix-vector multiplication.
std::map< std::pair< std::shared_ptr< matrixdata_t >, std::shared_ptr< matrixdata_t > >, CSRMatrixSpGEMMDefault< Config > > d_SpGEMMHelpers
void setIdentity(MatrixData &A) override
Set the matrix to the identity matrix.
void getRowSumsAbsolute(MatrixData const &A, std::shared_ptr< Vector > buf, const bool remove_zeros=false) override
Extract the absolute row sums into a vector.
typename matrixdata_t::localmatrixdata_t localmatrixdata_t
void copyCast(const MatrixData &X, MatrixData &Y) override
Set Y matrix with the same non-zero and distributed structure as x and copy the coefficients after up...
void zero(MatrixData &A) override
Set the non-zeros of the matrix to zero.
void setScalar(AMP::Scalar alpha, MatrixData &A) override
Set the non-zeros of the matrix to a scalar.
void scale(AMP::Scalar alpha, MatrixData &A) override
Scale the matrix by a scalar.
void scale(AMP::Scalar alpha, std::shared_ptr< const Vector > D, MatrixData &A) override
Scale the matrix by a scalar and diagonal matrix.
void matMatMult(std::shared_ptr< MatrixData > A, std::shared_ptr< MatrixData > B, std::shared_ptr< MatrixData > C) override
Compute the product of two matrices.
void getRowSums(MatrixData const &A, std::shared_ptr< Vector > buf) override
Extract the row sums into a vector.
void extractDiagonal(MatrixData const &A, std::shared_ptr< Vector > buf) override
Extract the diagonal values into a vector.
void multTranspose(std::shared_ptr< const Vector > in, MatrixData const &A, std::shared_ptr< Vector > out) override
Matrix transpose-vector multiplication.
void setDiagonal(std::shared_ptr< const Vector > in, MatrixData &A) override
Set the diagonal to the values in a vector.
void axpy(AMP::Scalar alpha, const MatrixData &X, MatrixData &Y) override
Compute the linear combination of two matrices.
void scaleInv(AMP::Scalar alpha, std::shared_ptr< const Vector > D, MatrixData &A) override
Scale the matrix by a scalar and inverse of diagonal matrix.
CSRMatrixOperationsDefault(int64_t, AMP::IO::RestartManager *)
static void copyCast(CSRMatrixData< typename ConfigIn::template set_alloc_t< Config::allocator > > *X, matrixdata_t *Y)
std::string type() const override
Return the type of the matrix operations class.
void copy(const MatrixData &X, MatrixData &Y) override
Set Y matrix with the same non-zero and distributed structure as x and copy the coefficients.
Scalar is a class used to store a scalar variable that may be different types/precision.
Definition Scalar.h:21



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:40.
Comments on this page