ergo
mat::MatrixTriangular< Treal, Tmatrix > Class Template Reference

Upper non-unit triangular matrix. More...

#include <MatrixBase.h>

Inheritance diagram for mat::MatrixTriangular< Treal, Tmatrix >:
mat::MatrixBase< Treal, Tmatrix > mat::FileWritable

Public Types

typedef VectorGeneral< Treal, typename Tmatrix::VectorType > VectorType
 
typedef Treal real
 

Public Member Functions

 MatrixTriangular ()
 Default constructor. More...
 
 MatrixTriangular (const MatrixTriangular< Treal, Tmatrix > &tri)
 Copy constructor. More...
 
MatrixTriangular< Treal, Tmatrix > & operator= (const MatrixTriangular< Treal, Tmatrix > &tri)
 
MatrixTriangular< Treal, Tmatrix > & operator= (int const k)
 Set matrix to zero or identity: A = 0 or A = 1. More...
 
void assign_from_sparse (std::vector< int > const &rowind, std::vector< int > const &colind, std::vector< Treal > const &values, SizesAndBlocks const &newRows, SizesAndBlocks const &newCols)
 Assign from sparse matrix given by three vectors. More...
 
void add_values (std::vector< int > const &rowind, std::vector< int > const &colind, std::vector< Treal > const &values)
 Add given set of values to the matrix (+=). More...
 
void get_values (std::vector< int > const &rowind, std::vector< int > const &colind, std::vector< Treal > &values) const
 Get values given by row and column index lists. More...
 
void get_all_values (std::vector< int > &rowind, std::vector< int > &colind, std::vector< Treal > &values) const
 Get all values and corresponding row and column index lists, in matrix. More...
 
void inch (const MatrixGeneral< Treal, Tmatrix > &SPD, const Treal threshold, const side looking=left, const inchversion version=unstable)
 
void inch (const MatrixSymmetric< Treal, Tmatrix > &SPD, const Treal threshold, const side looking=left, const inchversion version=unstable)
 
void thresh (Treal const threshold, normType const norm)
 
Treal frob () const
 
Treal eucl (Treal const requestedAccuracy, int maxIter=-1) const
 
Treal eucl_thresh (Treal const threshold)
 
Treal eucl_thresh_congr_trans_measure (Treal const threshold, MatrixSymmetric< Treal, Tmatrix > &trA)
 
void frob_thresh (Treal threshold)
 
size_t nnz () const
 
size_t nvalues () const
 
void write_to_buffer (void *buffer, const int n_bytes) const
 
void read_from_buffer (void *buffer, const int n_bytes)
 
void random ()
 
template<typename TRule >
void setElementsByRule (TRule &rule)
 Uses rule depending on the row and column indexes to set matrix elements The Trule class should have the function "Treal = set(int row,int col)" which is used to set the elements. More...
 
MatrixTriangular< Treal, Tmatrix > & operator+= (XY< Treal, MatrixTriangular< Treal, Tmatrix > > const &sm)
 B += alpha * A. More...
 
std::string obj_type_id () const
 
- Public Member Functions inherited from mat::MatrixBase< Treal, Tmatrix >
void resetSizesAndBlocks (SizesAndBlocks const &newRows, SizesAndBlocks const &newCols)
 
void getRows (SizesAndBlocks &rowsCopy) const
 
void getCols (SizesAndBlocks &colsCopy) const
 
bool is_empty () const
 Check if matrix is empty. More...
 
Treal trace () const
 
void add_identity (Treal alpha)
 
MatrixBase< Treal, Tmatrix > & operator*= (Treal const alpha)
 
bool operator== (int k) const
 
void clear ()
 Release memory for the information written to file. More...
 
size_t memory_usage () const
 
void write_to_buffer_count (int &n_bytes) const
 
int get_nrows () const
 
int get_ncols () const
 
Tmatrix const & getMatrix () const
 
Tmatrix & getMatrix ()
 
Treal maxAbsValue () const
 Get largest absolute value of matrix element in the matrix. More...
 
- Public Member Functions inherited from mat::FileWritable
void writeToFile ()
 Write object to file if filewrite is active. More...
 
void readFromFile ()
 Read object from file if filewrite is active. More...
 
void copyToFile (const char *destFileName)
 
void copyFromFile (const char *sourceFileName)
 
bool isOnFile ()
 Check if object is on file. More...
 
long int fileSize ()
 Return file size. More...
 

Protected Member Functions

void writeToFileProt (std::ofstream &file) const
 Write object to file. More...
 
void readFromFileProt (std::ifstream &file)
 Read object from file. More...
 
- Protected Member Functions inherited from mat::MatrixBase< Treal, Tmatrix >
 MatrixBase ()
 
 MatrixBase (const MatrixBase< Treal, Tmatrix > &other)
 
MatrixBase< Treal, Tmatrix > & operator= (const MatrixBase< Treal, Tmatrix > &other)
 
MatrixBase< Treal, Tmatrix > & operator= (const Xtrans< MatrixGeneral< Treal, Tmatrix > > &mt)
 
void write_to_buffer_base (void *buffer, const int n_bytes, const matrix_type mattype) const
 
void read_from_buffer_base (void *buffer, const int n_bytes, const matrix_type mattype)
 
void writeToFileBase (std::ofstream &file, matrix_type const mattype) const
 
void readFromFileBase (std::ifstream &file, matrix_type const mattype)
 
void inMemorySet (bool inMem)
 Make object invalid (false) via this function when object is written to file and valid (true) when object is read from file. More...
 
- Protected Member Functions inherited from mat::FileWritable
 FileWritable ()
 Gives each object a unique ID-number and filename. More...
 
virtual ~FileWritable ()
 Removes file, if any. More...
 
 FileWritable (FileWritable const &)
 
FileWritableoperator= (FileWritable const &)
 

Additional Inherited Members

- Static Public Member Functions inherited from mat::FileWritable
static void setPath (char const *const newPath)
 Set the path to which the objects will be written. More...
 
static void activate ()
 Activate the filewriting. More...
 
static std::string getStatsFileSizes ()
 
static std::string writeAndReadAll ()
 
static void resetStats ()
 
static std::string getStatsTimeWrite ()
 
static std::string getStatsTimeRead ()
 
static std::string getStatsTimeCopyAndAssign ()
 
static std::string getStatsCountWrite ()
 
static std::string getStatsCountRead ()
 
static std::string getStatsCountCopyAndAssign ()
 
- Protected Types inherited from mat::FileWritable
typedef std::map< std::string, double > TypeTimeMap
 
typedef std::map< std::string, int > TypeCountMap
 
typedef std::set< FileWritable * > ObjPtrSet
 
- Static Protected Member Functions inherited from mat::MatrixBase< Treal, Tmatrix >
static void getPermutedIndexes (std::vector< int > const &index, std::vector< int > const &permutation, std::vector< int > &newIndex)
 
- Static Protected Member Functions inherited from mat::FileWritable
static std::string getStatsTime (TypeTimeMap &theMap)
 
static std::string getStatsCount (TypeCountMap &theMap)
 
static std::string getStatsFileSizes (ObjPtrSet const &set)
 
- Protected Attributes inherited from mat::MatrixBase< Treal, Tmatrix >
ValidPtr< Tmatrix > matrixPtr
 

Detailed Description

template<typename Treal, typename Tmatrix>
class mat::MatrixTriangular< Treal, Tmatrix >

Upper non-unit triangular matrix.

This class belongs to the matrix API

Treal: Type for real numbers

Tmatrix: The matrix class

See also
MatrixBase
MatrixGeneral
MatrixSymmetric

Member Typedef Documentation

◆ real

template<typename Treal, typename Tmatrix>
typedef Treal mat::MatrixTriangular< Treal, Tmatrix >::real

◆ VectorType

template<typename Treal, typename Tmatrix>
typedef VectorGeneral<Treal, typename Tmatrix::VectorType> mat::MatrixTriangular< Treal, Tmatrix >::VectorType

Constructor & Destructor Documentation

◆ MatrixTriangular() [1/2]

template<typename Treal, typename Tmatrix>
mat::MatrixTriangular< Treal, Tmatrix >::MatrixTriangular ( )
inline

Default constructor.

◆ MatrixTriangular() [2/2]

template<typename Treal, typename Tmatrix>
mat::MatrixTriangular< Treal, Tmatrix >::MatrixTriangular ( const MatrixTriangular< Treal, Tmatrix > &  tri)
inlineexplicit

Copy constructor.

Member Function Documentation

◆ add_values()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::add_values ( std::vector< int > const &  rowind,
std::vector< int > const &  colind,
std::vector< Treal > const &  values 
)
inline

Add given set of values to the matrix (+=).

The values should be in upper triangle.

References mat::MatrixBase< Treal, Tmatrix >::matrixPtr.

◆ assign_from_sparse()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::assign_from_sparse ( std::vector< int > const &  rowind,
std::vector< int > const &  colind,
std::vector< Treal > const &  values,
SizesAndBlocks const &  newRows,
SizesAndBlocks const &  newCols 
)
inline

Assign from sparse matrix given by three vectors.

The vectors contain row indices, column indices and values. The indices start at zero. The elements to be added must be in upper triangle. Information about sizes and blocks for rows as well as columns must also be given.

Warning
All indexing start at zero.

References mat::MatrixBase< Treal, Tmatrix >::matrixPtr, and mat::MatrixBase< Treal, Tmatrix >::resetSizesAndBlocks().

Referenced by mainFun().

◆ eucl()

◆ eucl_thresh()

template<typename Treal , typename Tmatrix >
Treal mat::MatrixTriangular< Treal, Tmatrix >::eucl_thresh ( Treal const  threshold)

◆ eucl_thresh_congr_trans_measure()

template<typename Treal , typename Tmatrix >
Treal mat::MatrixTriangular< Treal, Tmatrix >::eucl_thresh_congr_trans_measure ( Treal const  threshold,
MatrixSymmetric< Treal, Tmatrix > &  trA 
)

◆ frob()

template<typename Treal, typename Tmatrix>
Treal mat::MatrixTriangular< Treal, Tmatrix >::frob ( ) const
inline

◆ frob_thresh()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::frob_thresh ( Treal  threshold)
inline

◆ get_all_values()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::get_all_values ( std::vector< int > &  rowind,
std::vector< int > &  colind,
std::vector< Treal > &  values 
) const
inline

Get all values and corresponding row and column index lists, in matrix.

Only upper triangle values are returned.

Warning
All indexing start at zero.

References mat::MatrixBase< Treal, Tmatrix >::matrixPtr, and mat::MatrixTriangular< Treal, Tmatrix >::nnz().

Referenced by mainFun().

◆ get_values()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::get_values ( std::vector< int > const &  rowind,
std::vector< int > const &  colind,
std::vector< Treal > &  values 
) const
inline

Get values given by row and column index lists.

Input arrays contain row and column indices. The wanted elements must in upper triangle. The output array contains values for the given indices.

Warning
All indexing start at zero.

References mat::MatrixBase< Treal, Tmatrix >::matrixPtr.

Referenced by mainFun().

◆ inch() [1/2]

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::inch ( const MatrixGeneral< Treal, Tmatrix > &  SPD,
const Treal  threshold,
const side  looking = left,
const inchversion  version = unstable 
)
inline

◆ inch() [2/2]

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::inch ( const MatrixSymmetric< Treal, Tmatrix > &  SPD,
const Treal  threshold,
const side  looking = left,
const inchversion  version = unstable 
)
inline

◆ nnz()

template<typename Treal, typename Tmatrix>
size_t mat::MatrixTriangular< Treal, Tmatrix >::nnz ( ) const
inline

◆ nvalues()

template<typename Treal, typename Tmatrix>
size_t mat::MatrixTriangular< Treal, Tmatrix >::nvalues ( ) const
inline

◆ obj_type_id()

template<typename Treal, typename Tmatrix>
std::string mat::MatrixTriangular< Treal, Tmatrix >::obj_type_id ( ) const
inlinevirtual

Reimplemented from mat::MatrixBase< Treal, Tmatrix >.

◆ operator+=()

template<typename Treal , typename Tmatrix >
MatrixTriangular< Treal, Tmatrix > & mat::MatrixTriangular< Treal, Tmatrix >::operator+= ( XY< Treal, MatrixTriangular< Treal, Tmatrix > > const &  sm)
inline

B += alpha * A.

◆ operator=() [1/2]

template<typename Treal, typename Tmatrix>
MatrixTriangular<Treal, Tmatrix>& mat::MatrixTriangular< Treal, Tmatrix >::operator= ( const MatrixTriangular< Treal, Tmatrix > &  tri)
inline

◆ operator=() [2/2]

template<typename Treal, typename Tmatrix>
MatrixTriangular<Treal, Tmatrix>& mat::MatrixTriangular< Treal, Tmatrix >::operator= ( int const  k)
inline

Set matrix to zero or identity: A = 0 or A = 1.

Only zero and one are valid arguments.

References mat::MatrixBase< Treal, Tmatrix >::matrixPtr.

◆ random()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::random ( )
inline

◆ read_from_buffer()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::read_from_buffer ( void *  buffer,
const int  n_bytes 
)
inline

◆ readFromFileProt()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::readFromFileProt ( std::ifstream &  )
inlineprotectedvirtual

Read object from file.

Defined in derived class.

Implements mat::FileWritable.

References mat::matrix_triang, and mat::MatrixBase< Treal, Tmatrix >::readFromFileBase().

◆ setElementsByRule()

template<typename Treal, typename Tmatrix>
template<typename TRule >
void mat::MatrixTriangular< Treal, Tmatrix >::setElementsByRule ( TRule &  rule)
inline

Uses rule depending on the row and column indexes to set matrix elements The Trule class should have the function "Treal = set(int row,int col)" which is used to set the elements.

References mat::MatrixBase< Treal, Tmatrix >::matrixPtr.

Referenced by mainFun().

◆ thresh()

template<typename Treal , typename Tmatrix >
void mat::MatrixTriangular< Treal, Tmatrix >::thresh ( Treal const  threshold,
normType const  norm 
)

References mat::frobNorm.

◆ write_to_buffer()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::write_to_buffer ( void *  buffer,
const int  n_bytes 
) const
inline

◆ writeToFileProt()

template<typename Treal, typename Tmatrix>
void mat::MatrixTriangular< Treal, Tmatrix >::writeToFileProt ( std::ofstream &  ) const
inlineprotectedvirtual

Write object to file.

Defined in derived class.

Implements mat::FileWritable.

References mat::matrix_triang, and mat::MatrixBase< Treal, Tmatrix >::writeToFileBase().


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