HLIBpro  2.3.1
Public Member Functions | List of all members
TMatrix Class Referenceabstract

Base class for all matrices, defining basic properties, e.g. underlying block index and processor set.

#include <TMatrix.hh>

Inheritance diagram for TMatrix:
TLinearOperator TLockable TTypeInfo TBlockMatrix TDenseMatrix TGhostMatrix TRkMatrix TSparseMatrix TUniformMatrix TZeroMatrix TH2Matrix THMatrix

Public Member Functions

 TMatrix (const value_type_t avalue_type=real_valued)
 construct zero sized matrix
 
 TMatrix (const TBlockCluster *bcl, const value_type_t avalue_type=real_valued)
 construct matrix of size defined by block cluster bcl
 
 TMatrix (const TBlockIndexSet &bis, const value_type_t avalue_type=real_valued)
 construct matrix of size defined by block index set bis
 
 TMatrix (const TMatrix &A)
 copy constructor
 
virtual ~TMatrix ()
 dtor
 
int id () const
 return ID
 
void set_id (const int aid)
 set ID
 
virtual size_t rows () const =0
 return number of rows
 
virtual size_t cols () const =0
 return number of columns
 
TIndexSet row_is () const
 return row index set
 
TIndexSet col_is () const
 return column index set
 
TBlockIndexSet block_is () const
 return block index set
 
virtual idx_t row_ofs () const
 return first index (number) in row
 
virtual idx_t col_ofs () const
 return first index (number) in column
 
virtual void set_size (const size_t n, const size_t m)=0
 set size of matrix
 
virtual void set_ofs (const idx_t r, const idx_t c)
 set index set offsets
 
virtual void set_block_is (const TBlockIndexSet &is)
 set block index set of matrix
 
bool is_nonsym () const
 return true if matrix is unsymmetric
 
bool is_symmetric () const
 return true if matrix is symmetric
 
bool is_hermitian () const
 return true if matrix is hermitian
 
matform_t form () const
 return matrix format
 
void set_nonsym ()
 set matrix to be unsymmetric
 
void set_symmetric ()
 set matrix to be symmetric
 
void set_hermitian ()
 set matrix to be hermitian
 
virtual void set_form (const matform_t f)
 set matrix format
 
virtual bool is_zero () const
 return true, if matrix is zero
 
virtual bool is_blocked () const
 return true, if matrix is blocked
 
virtual bool is_dense () const
 return true, if matrix is dense
 
virtual bool is_self_adjoint () const
 return true, if operator is self adjoint
 
const TProcSetprocs () const
 return matrix processor set
 
uint nprocs () const
 return number of processors in local set
 
virtual void set_procs (const TProcSet &ps, const bool recursive=false)
 set processor set of matrix
 
virtual void copy_struct (const TMatrix *M)
 
value_type_t value_type () const
 return value type of matrix
 
void set_value_type (const value_type_t vt)
 set value type of matrix
 
bool is_real () const
 return true if matrix is real valued
 
bool is_complex () const
 return true if matrix is complex valued
 
void set_complex (const bool b, const bool force=false)
 
virtual void to_real ()=0
 change data representation to real valued (if possible)
 
virtual void to_complex ()=0
 change data representation to complex valued
 
virtual real entry (const idx_t i, const idx_t j) const
 
virtual const complex centry (const idx_t i, const idx_t j) const
 
const TBlockClustercluster () const
 return corresponding block cluster of matrix
 
virtual void set_cluster (const TBlockCluster *c)
 set block cluster of matrix
 
virtual void apply (const TVector *x, TVector *y, const matop_t op) const
 
virtual void apply_add (const real alpha, const TVector *x, TVector *y, const matop_t op) const
 
virtual auto domain_vector () const -> std::unique_ptr< TVector >
 return vector in domain space
 
virtual auto range_vector () const -> std::unique_ptr< TVector >
 return vector in range space
 
virtual void transpose ()
 transpose matrix
 
virtual void conjugate ()
 conjugate matrix coefficients
 
virtual void truncate (const TTruncAcc &acc)=0
 truncate matrix to accuracy acc
 
virtual void scale (const real alpha)
 compute this ≔ α·this
 
virtual void add (const real alpha, const TMatrix *matrix)
 compute this ≔ this + α · matrix
 
virtual void mul_vec (const real alpha, const TVector *x, const real beta, TVector *y, const matop_t op=MATOP_NORM) const
 compute y ≔ β·y + α·op(M)·x, with M = this
 
virtual TMatrixmul_right (const real alpha, const TMatrix *B, const matop_t op_A, const matop_t op_B) const
 compute α·op(A)·op(B), with A = this
 
virtual TMatrixmul_left (const real alpha, const TMatrix *A, const matop_t op_A, const matop_t op_B) const
 compute α·op(A)·op(B), with B = this
 
virtual void cscale (const complex alpha)
 compute this ≔ α·this
 
virtual void cadd (const complex alpha, const TMatrix *matrix)
 compute this ≔ this + α · matrix
 
virtual void cmul_vec (const complex alpha, const TVector *x, const complex beta, TVector *y, const matop_t op=MATOP_NORM) const
 compute y ≔ β·y + α·op(M)·x, with M = this
 
virtual TMatrixcmul_right (const complex alpha, const TMatrix *B, const matop_t op_A, const matop_t op_B) const
 compute α·op(A)·op(B), with A = this
 
virtual TMatrixcmul_left (const complex alpha, const TMatrix *A, const matop_t op_A, const matop_t op_B) const
 compute α·op(A)·op(B), with B = this
 
virtual size_t byte_size () const
 return size in bytes used by this object
 
virtual size_t global_byte_size () const
 
virtual auto create () const -> std::unique_ptr< TMatrix >=0
 return matrix of same class (but no content)
 
virtual auto copy () const -> std::unique_ptr< TMatrix >
 return copy of matrix
 
virtual auto copy (const TTruncAcc &acc, const bool coarsen=false) const -> std::unique_ptr< TMatrix >
 return copy of matrix with accuracy acc and optional coarsening
 
virtual void copy_to (TMatrix *A) const
 copy matrix into matrix A
 
virtual void copy_to (TMatrix *A, const TTruncAcc &acc, const bool coarsen=false) const
 copy matrix into matrix A with accuracy acc and optional coarsening
 
virtual auto row_vector () const -> std::unique_ptr< TVector >
 return appropriate row vector object for matrix
 
virtual auto col_vector () const -> std::unique_ptr< TVector >
 return appropriate column vector object for matrix
 
virtual void read (TByteStream &s)
 read data from stream s and copy to matrix
 
virtual void build (TByteStream &s)
 use data from stream s to build matrix
 
virtual void write (TByteStream &s) const
 write data to stream s
 
virtual size_t bs_size () const
 returns size of object in bytestream
 
virtual void sum (const TProcSet &p, const uint pid, const uint nparts, TByteStream *bs, const TTruncAcc &acc)
 
virtual void check_data () const
 test data for invalid values, e.g. INF and NAN
 
virtual void print (const uint ofs=0) const
 print basic info about matrix to stdout
 
- Public Member Functions inherited from TTypeInfo
virtual typeid_t type () const =0
 return type ID of object
 
virtual bool is_type (const typeid_t t) const
 return true if local object is of given type ID t
 
virtual std::string typestr () const
 return string representation of type
 
- Public Member Functions inherited from TLockable
TMutexmutex ()
 give access to internal mutex
 
void lock ()
 lock local mutex
 
void unlock ()
 unlock local mutex
 
size_t byte_size () const
 return size in bytes used by this object
 

Member Function Documentation

virtual void apply ( const TVector x,
TVector y,
const matop_t  op 
) const
inlinevirtual

mapping function of linear operator $A$, e.g. $ y := A(x)$. Depending on op, either $A$, $A^T$ or $A^H$ is applied.

Implements TLinearOperator.

virtual void apply_add ( const real  alpha,
const TVector x,
TVector y,
const matop_t  op 
) const
inlinevirtual

mapping function with update: $ y := y + \alpha A(x)$. Depending on op, either $A$, $A^T$ or $A^H$ is applied.

Implements TLinearOperator.

virtual const complex centry ( const idx_t  i,
const idx_t  j 
) const
virtual

return index (i,j) of the matrix (complex valued)

  • i and j are global indices, e.g. not w.r.t. local index set

Reimplemented in TDenseMatrix, TRkMatrix, TUniformMatrix, TBlockMatrix, TSparseMatrix, TZeroMatrix, TH2Matrix, and THMatrix.

virtual void copy_struct ( const TMatrix M)
inlinevirtual

copy complete structural information from given matrix, e.g. size, offsets and field type

Reimplemented in TBlockMatrix, TH2Matrix, and THMatrix.

virtual real entry ( const idx_t  i,
const idx_t  j 
) const
virtual

return index (i,j) of the matrix (real valued)

  • i and j are global indices, e.g. not w.r.t. local index set

Reimplemented in TDenseMatrix, TRkMatrix, TUniformMatrix, TBlockMatrix, TSparseMatrix, TZeroMatrix, TH2Matrix, and THMatrix.

virtual size_t global_byte_size ( ) const
virtual

return size in bytes used by this distributed object, i.e. of all distributed sub matrices

void set_complex ( const bool  b,
const bool  force = false 
)
inline

set internal representation to either real or complex valued; if force is true, the change is performed independent on current state

virtual void sum ( const TProcSet p,
const uint  pid,
const uint  nparts,
TByteStream bs,
const TTruncAcc acc 
)
virtual

sum up nparts parallel copies of matrix

  • if bs != NULL it will be used