ParGeMSLR
Public Member Functions | List of all members
pargemslr::CooMatrixClass< T > Class Template Reference

Class of COO matrices. Note that most coo matrix functions are not yet on the device. More...

#include <coo_matrix.hpp>

Inheritance diagram for pargemslr::CooMatrixClass< T >:
pargemslr::MatrixClass< T >

Public Member Functions

 CooMatrixClass ()
 The constructor of CooMatrixClass. More...
 
 CooMatrixClass (const CooMatrixClass< T > &mat)
 The copy constructor of CooMatrixClass. More...
 
 CooMatrixClass (CooMatrixClass< T > &&mat)
 The move constructor of CooMatrixClass. More...
 
CooMatrixClass< T > & operator= (const CooMatrixClass< T > &mat)
 The = operator of CooMatrixClass. More...
 
CooMatrixClass< T > & operator= (CooMatrixClass< T > &&mat)
 The = operator of CooMatrixClass. More...
 
virtual int Clear ()
 Free the current matrix. More...
 
virtual ~CooMatrixClass ()
 The destructor of CooMatrixClass. More...
 
int Setup (int nrows, int ncols)
 Free the current matrix, and create the new matrix using the default reserved memory size on the host. More...
 
int Setup (int nrows, int ncols, int reserve)
 Free the current matrix, and create the new matrix and reserve some space in the host memory. More...
 
int Setup (int nrows, int ncols, int reserve, int location)
 Free the current matrix, and create the new matrix and reserve some space in the memory. More...
 
virtual int GetDataLocation () const
 Get the data location of the matrix. More...
 
virtual int GetNumRowsLocal () const
 Get the local number of rows of the matrix. More...
 
virtual int GetNumColsLocal () const
 Get the local number of columns of the matrix. More...
 
virtual long int GetNumNonzeros () const
 Get the number of nonzeros in this matrix. More...
 
int SetNumCols (int cols)
 Set the number of cols in this matrix. More...
 
int SetNumNonzeros ()
 Set the number of nonzeros in this matrix. More...
 
virtual int Eye ()
 Create an indentity matrix. More...
 
virtual int Fill (const T &v)
 Fill the matrix pattern with constant value. More...
 
virtual int Scale (const T &alpha)
 Scale the matrix. More...
 
virtual int MoveData (const int &location)
 Move the data to another memory location. More...
 
int PushBack (int row, int col, T v)
 Insert value to the COO matrix. More...
 
int * GetI () const
 Get the I pointer of the matrix. More...
 
int * GetJ () const
 Get the J pointer of the matrix. More...
 
T * GetData () const
 Get the data pointer of the matrix. More...
 
IntVectorClass< int > & GetIVector ()
 Get the reference to the I vector. More...
 
const IntVectorClass< int > & GetIVector () const
 Get the reference to the I vector. More...
 
IntVectorClass< int > & GetJVector ()
 Get the reference to the J vector. More...
 
const IntVectorClass< int > & GetJVector () const
 Get the reference to the J vector. More...
 
SequentialVectorClass< T > & GetDataVector ()
 Get the reference to the data vector. More...
 
const SequentialVectorClass< T > & GetDataVector () const
 Get the reference to the data vector. More...
 
int ToCsr (int location, CsrMatrixClass< T > &csrmat_out)
 Convert the matrix to csr. More...
 
int Laplacian (int nx, int ny, int nz, T alphax, T alphay, T alphaz, T shift, bool rand_perturb=false)
 Generate Laplacian matrix, 5-pt for 2D problem and 7-pt for 3D problem. More...
 
int Helmholtz (int n, T w)
 Generate 3D Helmholtz matrix with 7-pt on [0,1]^3. -\Delta u - w^2 u = f. More...
 
int ReadFromMMFile (const char *matfile, int idxin)
 Read matrix on the host memory, matrix market format. More...
 
int PlotPatternGnuPlot (const char *datafilename, int *rperm, int *cperm, int conditiona, int conditionb)
 Plot the pattern of the csr matrix using gnuplot. Similar to spy in the MATLAB. Function for testing purpose. More...
 
- Public Member Functions inherited from pargemslr::MatrixClass< T >
 MatrixClass ()
 The constructor of MatrixClass. More...
 
 MatrixClass (const MatrixClass< T > &mat)
 The copy constructor of MatrixClass. More...
 
 MatrixClass (MatrixClass< T > &&mat)
 The move constructor of MatrixClass. More...
 
virtual ~MatrixClass ()
 The destructor of MatrixClass. More...
 
virtual int MatVec (char trans, const T &alpha, const VectorClass< T > &x, const T &beta, VectorClass< T > &y)
 In place Matrix-Vector product ==> y := alpha*A*x + beta*y, or y := alpha*A'*x + beta*y. More...
 
virtual int MatVec (char trans, const T &alpha, const VectorClass< T > &x, const T &beta, const VectorClass< T > &y, VectorClass< T > &z)
 In place Matrix-Vector product ==> z := alpha*A*x + beta*y, or z := alpha*A'*x + beta*y. More...
 
PrecisionEnum GetPrecision () const
 Return the precision of the matrix. More...
 

Detailed Description

template<typename T>
class pargemslr::CooMatrixClass< T >

Class of COO matrices. Note that most coo matrix functions are not yet on the device.

Constructor & Destructor Documentation

◆ CooMatrixClass() [1/3]

template<typename T >
template pargemslr::CooMatrixClass< T >::CooMatrixClass ( )

The constructor of CooMatrixClass.

◆ CooMatrixClass() [2/3]

template<typename T >
pargemslr::CooMatrixClass< T >::CooMatrixClass ( const CooMatrixClass< T > &  mat)

The copy constructor of CooMatrixClass.

Parameters
[in]matThe other matrix.

◆ CooMatrixClass() [3/3]

template<typename T >
pargemslr::CooMatrixClass< T >::CooMatrixClass ( CooMatrixClass< T > &&  mat)

The move constructor of CooMatrixClass.

Parameters
[in]matThe other matrix.

◆ ~CooMatrixClass()

template<typename T >
template pargemslr::CooMatrixClass< T >::~CooMatrixClass ( )
virtual

The destructor of CooMatrixClass.

Member Function Documentation

◆ Clear()

template<typename T >
template int pargemslr::CooMatrixClass< T >::Clear ( )
virtual

Free the current matrix.

Returns
Return error message.

Reimplemented from pargemslr::MatrixClass< T >.

◆ Eye()

template<typename T >
template int pargemslr::CooMatrixClass< T >::Eye ( )
virtual

Create an indentity matrix.

Returns
Return error message.

Reimplemented from pargemslr::MatrixClass< T >.

◆ Fill()

template<typename T >
template int pargemslr::CooMatrixClass< T >::Fill ( const T &  v)
virtual

Fill the matrix pattern with constant value.

Parameters
[in]vThe value to be filled.
Returns
Return error message.

Reimplemented from pargemslr::MatrixClass< T >.

◆ GetData()

template<typename T >
template complexd * pargemslr::CooMatrixClass< T >::GetData ( ) const

Get the data pointer of the matrix.

Returns
Return the data pointer.

◆ GetDataLocation()

template<typename T >
template int pargemslr::CooMatrixClass< T >::GetDataLocation ( ) const
virtual

Get the data location of the matrix.

Returns
Return the data location of the matrix.

Get the data location of the matrix.

Returns
Return the length of the vector.

Reimplemented from pargemslr::MatrixClass< T >.

◆ GetDataVector() [1/2]

template<typename T >
template SequentialVectorClass< complexd > & pargemslr::CooMatrixClass< T >::GetDataVector ( )

Get the reference to the data vector.

Returns
Return the reference to the data vector.

◆ GetDataVector() [2/2]

template<typename T >
template const SequentialVectorClass< complexd > & pargemslr::CooMatrixClass< T >::GetDataVector ( ) const

Get the reference to the data vector.

Returns
Return the reference to the data vector.

◆ GetI()

template<typename T >
template int * pargemslr::CooMatrixClass< T >::GetI ( ) const

Get the I pointer of the matrix.

Returns
Return the data pointer.

◆ GetIVector() [1/2]

template<typename T >
template IntVectorClass< int > & pargemslr::CooMatrixClass< T >::GetIVector ( )

Get the reference to the I vector.

Returns
Return the reference to the I vector.

◆ GetIVector() [2/2]

template<typename T >
template const IntVectorClass< int > & pargemslr::CooMatrixClass< T >::GetIVector ( ) const

Get the reference to the I vector.

Returns
Return the reference to the I vector.

◆ GetJ()

template<typename T >
template int * pargemslr::CooMatrixClass< T >::GetJ ( ) const

Get the J pointer of the matrix.

Returns
Return the data pointer.

◆ GetJVector() [1/2]

template<typename T >
template IntVectorClass< int > & pargemslr::CooMatrixClass< T >::GetJVector ( )

Get the reference to the J vector.

Returns
Return the reference to the J vector.

◆ GetJVector() [2/2]

template<typename T >
template const IntVectorClass< int > & pargemslr::CooMatrixClass< T >::GetJVector ( ) const

Get the reference to the J vector.

Returns
Return the reference to the J vector.

◆ GetNumColsLocal()

template<typename T >
template int pargemslr::CooMatrixClass< T >::GetNumColsLocal ( ) const
virtual

Get the local number of columns of the matrix.

Returns
Return the local number of columns of the matrix.

Get the local number of columns of the matrix.

Returns
Return the length of the matrix.

Implements pargemslr::MatrixClass< T >.

◆ GetNumNonzeros()

template<typename T >
template long int pargemslr::CooMatrixClass< T >::GetNumNonzeros ( ) const
virtual

Get the number of nonzeros in this matrix.

Returns
Return the number of nonzeros in this matrix.

Reimplemented from pargemslr::MatrixClass< T >.

◆ GetNumRowsLocal()

template<typename T >
template int pargemslr::CooMatrixClass< T >::GetNumRowsLocal ( ) const
virtual

Get the local number of rows of the matrix.

Returns
Return the local number of rows of the matrix.

Get the local number of rows of the matrix.

Returns
Return the length of the matrix.

Implements pargemslr::MatrixClass< T >.

◆ Helmholtz()

template<typename T >
template int pargemslr::CooMatrixClass< T >::Helmholtz ( int  n,
w 
)

Generate 3D Helmholtz matrix with 7-pt on [0,1]^3. -\Delta u - w^2 u = f. Robin boundary condition u'-iwu = 0 is used.

Parameters
[in]nProblem size.
[in]wThe w value.
Returns
Return error message.

◆ Laplacian()

template<typename T >
template int pargemslr::CooMatrixClass< T >::Laplacian ( int  nx,
int  ny,
int  nz,
alphax,
alphay,
alphaz,
shift,
bool  rand_perturb = false 
)

Generate Laplacian matrix, 5-pt for 2D problem and 7-pt for 3D problem.

Parameters
[in]nx
[in]ny
[in]nzProblem size on each dimension
[in]alphax
[in]alphay
[in]alphazAlpha value on each direction
[in]shiftThe shift value on diagonal.
[in]rand_perturbSet to true to add extra random real pertubation to diagonal entries as abs(shift)*Rand(). We only add shift that might makes the problem harder.
Returns
Return error message.

◆ MoveData()

template<typename T >
template int pargemslr::CooMatrixClass< T >::MoveData ( const int &  location)
virtual

Move the data to another memory location.

Parameters
[in]locationThe location move to.
Returns
Return error message.

Reimplemented from pargemslr::MatrixClass< T >.

◆ operator=() [1/2]

template<typename T >
CooMatrixClass< T > & pargemslr::CooMatrixClass< T >::operator= ( const CooMatrixClass< T > &  mat)

The = operator of CooMatrixClass.

Parameters
[in]matThe other matrix.
Returns
Return this matrix.

◆ operator=() [2/2]

template<typename T >
CooMatrixClass< T > & pargemslr::CooMatrixClass< T >::operator= ( CooMatrixClass< T > &&  mat)

The = operator of CooMatrixClass.

Parameters
[in]matThe other matrix.
Returns
Return this matrix.

◆ PlotPatternGnuPlot()

template<typename T >
template int pargemslr::CooMatrixClass< T >::PlotPatternGnuPlot ( const char *  datafilename,
int *  rperm,
int *  cperm,
int  conditiona,
int  conditionb 
)

Plot the pattern of the csr matrix using gnuplot. Similar to spy in the MATLAB. Function for testing purpose.

Parameters
[in]datafilenameThe filename of the temp file holding the data.
[in]rpermThe row permutation vector.
[in]cpermThe column permutation vector. Set either rperm or cperm to NULL to spy(A), otherwise spy(A(rperm,cperm)).
[in]conditionaFirst condition.
[in]conditionbSecend condition, only plot when conditiona == conditionb.
Returns
Return error message.

◆ PushBack()

template<typename T >
template int pargemslr::CooMatrixClass< T >::PushBack ( int  row,
int  col,
v 
)

Insert value to the COO matrix.

Parameters
[in]row.
[in]colThe col/row to be inserted into the csr/csc.
[in]vThe value to be inserted.
Returns
Return error message.

◆ ReadFromMMFile()

template<typename T >
template int pargemslr::CooMatrixClass< T >::ReadFromMMFile ( const char *  matfile,
int  idxin 
)

Read matrix on the host memory, matrix market format.

Parameters
[in]matfileThe file.
[in]idxinThe index base of the input file. 0-based or 1-based.
Returns
Return error message.

◆ Scale()

template<typename T >
template int pargemslr::CooMatrixClass< T >::Scale ( const T &  alpha)
virtual

Scale the matrix.

Parameters
[in]alphaThe scale.
Returns
Return error message.

Reimplemented from pargemslr::MatrixClass< T >.

◆ SetNumCols()

template<typename T >
template int pargemslr::CooMatrixClass< T >::SetNumCols ( int  cols)

Set the number of cols in this matrix.

Returns
Return error message.

◆ SetNumNonzeros()

template<typename T >
template int pargemslr::CooMatrixClass< T >::SetNumNonzeros ( )

Set the number of nonzeros in this matrix.

Returns
Return error message.

◆ Setup() [1/3]

template<typename T >
template int pargemslr::CooMatrixClass< T >::Setup ( int  nrows,
int  ncols 
)

Free the current matrix, and create the new matrix. The default reserved memory size on the host is MAX(nrow, ncol)*_coo_reserve_fact.

Parameters
[in]nrowsThe number of rows of the new matrix.
[in]ncolsThe number of cols of the new matrix.
Returns
Return the length of the matrix.

◆ Setup() [2/3]

template<typename T >
template int pargemslr::CooMatrixClass< T >::Setup ( int  nrows,
int  ncols,
int  reserve 
)

Free the current matrix, and create the new matrix and reserve some space in the host memory.

Parameters
[in]nrowsThe number of rows of the new matrix.
[in]ncolsThe number of cols of the new matrix.
[in]reserveThe reserved vector length. A good estimation can avoid to many re-allocation when inserting values.
Returns
Return the length of the matrix.

◆ Setup() [3/3]

template<typename T >
template int pargemslr::CooMatrixClass< T >::Setup ( int  nrows,
int  ncols,
int  reserve,
int  location 
)

Free the current matrix, and create the new matrix and reserve some space in the memory.

Parameters
[in]nrowsThe number of rows of the new matrix.
[in]ncolsThe number of cols of the new matrix.
[in]reserveThe reserved vector length. A good estimation can avoid to many re-allocation when inserting values.
[in]locationThe location of the memory.
Returns
Return the length of the matrix.

◆ ToCsr()

template<typename T >
template int pargemslr::CooMatrixClass< T >::ToCsr ( int  location,
CsrMatrixClass< T > &  csrmat_out 
)

Convert the matrix to csr.

Parameters
[in]locationThe location of the output csr matrix.
[out]csrmat_outThe output csr matrix.
Returns
Return error message.

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