jacobi.template
Public Member Functions | Protected Attributes | Friends | List of all members
CRS_Matrix Class Reference

#include <getmatrix.h>

Inheritance diagram for CRS_Matrix:
Matrix FEM_Matrix

Public Member Functions

 CRS_Matrix ()
 
 CRS_Matrix (CRS_Matrix const &)=default
 
virtual ~CRS_Matrix () override
 
void GetDiag (std::vector< double > &d) const override
 
void Mult (std::vector< double > &w, std::vector< double > const &u) const override
 ‍** More...
 
void Defect (std::vector< double > &w, std::vector< double > const &f, std::vector< double > const &u) const override
 
void Debug () const override
 
int fetch (int row, int col) const override
 
bool Compare2Old (int nnode, int const id[], int const ik[], double const sk[]) const
 
- Public Member Functions inherited from Matrix
 Matrix (int nrows, int ncols)
 
 Matrix (Matrix const &)=default
 
virtual ~Matrix ()
 
bool isSquare () const
 
int Nrows () const
 
int Ncols () const
 
const std::vector< double > & GetDiag () const
 

Protected Attributes

int _nnz
 number of non-zero entries More...
 
std::vector< int > _id
 start indices of matrix rows More...
 
std::vector< int > _ik
 column indices More...
 
std::vector< double > _sk
 non-zero values More...
 
- Protected Attributes inherited from Matrix
int _nrows
 number of rows in matrix More...
 
int _ncols
 number of columns in matrix More...
 
std::vector< double > _dd
 diagonal matrix elements More...
 

Friends

void DefectRestrict (CRS_Matrix const &SK, BisectInterpolation const &P, std::vector< double > &fc, std::vector< double > &ff, std::vector< double > &uf)
 

Detailed Description

Matrix in CRS format (compressed row storage; also named CSR), see an introduction.

Definition at line 131 of file getmatrix.h.

Constructor & Destructor Documentation

◆ CRS_Matrix() [1/2]

CRS_Matrix::CRS_Matrix ( )

Constructor

Definition at line 42 of file getmatrix.cpp.

◆ CRS_Matrix() [2/2]

CRS_Matrix::CRS_Matrix ( CRS_Matrix const &  )
default

◆ ~CRS_Matrix()

CRS_Matrix::~CRS_Matrix ( )
overridevirtual

Destructor.

Definition at line 46 of file getmatrix.cpp.

Member Function Documentation

◆ Compare2Old()

bool CRS_Matrix::Compare2Old ( int  nnode,
int const  id[],
int const  ik[],
double const  sk[] 
) const

Compare this CRS matrix with an external CRS matrix stored in C-Style.

The method prints statements on differences found.

Parameters
[in]nnoderow number of external matrix
[in]idstart indices of matrix rows of external matrix
[in]ikcolumn indices of external matrix
[in]sknon-zero values of external matrix
Returns
true iff all data are identical.

Definition at line 146 of file getmatrix.cpp.

◆ Debug()

void CRS_Matrix::Debug ( ) const
overridevirtual

Show the matrix entries.

Implements Matrix.

Definition at line 123 of file getmatrix.cpp.

◆ Defect()

void CRS_Matrix::Defect ( std::vector< double > &  w,
std::vector< double > const &  f,
std::vector< double > const &  u 
) const
overridevirtual

Calculates the defect/residuum w := f - K*u.

Parameters
[in,out]wresulting vector (preallocated)
[in]fload vector
[in]uvector

Implements Matrix.

Definition at line 66 of file getmatrix.cpp.

◆ fetch()

int CRS_Matrix::fetch ( int  row,
int  col 
) const
inlineoverridevirtual

Finds in a CRS matrix the access index for an entry at row row and column col.

Parameters
[in]rowrow index
[in]colcolumn index
Returns
index for element (row, col). If no appropriate entry exists then -1 will be returned.
Warning
assert() stops the function in case that matrix element (row, col) doesn't exist.

Implements Matrix.

Definition at line 103 of file getmatrix.cpp.

◆ GetDiag()

void CRS_Matrix::GetDiag ( std::vector< double > &  d) const
overridevirtual

Extracts the diagonal elements of the sparse matrix.

Parameters
[in,out]d(prellocated) vector of diagonal elements

Implements Matrix.

Definition at line 86 of file getmatrix.cpp.

◆ Mult()

void CRS_Matrix::Mult ( std::vector< double > &  w,
std::vector< double > const &  u 
) const
overridevirtual

‍**

Performs the matrix-vector product w := K*u.

Parameters
[in,out]wresulting vector (preallocated)
[in]uvector

Implements Matrix.

Definition at line 49 of file getmatrix.cpp.

Friends And Related Function Documentation

◆ DefectRestrict

void DefectRestrict ( CRS_Matrix const &  SK,
BisectInterpolation const &  P,
std::vector< double > &  fc,
std::vector< double > &  ff,
std::vector< double > &  uf 
)
friend

Calculates the defect and projects it to the next coarser level \( f_C := P^T \cdot (f_F - SK\cdot u_F) \).

Parameters
[in]SKmatrix on fine mesh
[in]Pprolongation operator
[in,out]fcresulting coarse mesh vector (preallocated)
[in]ffr.h.s. on fine mesh
[in]ufstatus vector on fine mesh

Member Data Documentation

◆ _id

std::vector<int> CRS_Matrix::_id
protected

start indices of matrix rows

Definition at line 225 of file getmatrix.h.

◆ _ik

std::vector<int> CRS_Matrix::_ik
protected

column indices

Definition at line 226 of file getmatrix.h.

◆ _nnz

int CRS_Matrix::_nnz
protected

number of non-zero entries

Definition at line 224 of file getmatrix.h.

◆ _sk

std::vector<double> CRS_Matrix::_sk
protected

non-zero values

Definition at line 227 of file getmatrix.h.


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