A matrix in sparse storage using hashes. More...

#include <compositions.hh>

Classes

struct  Value
 Values of a matrix in sparse notation. More...
 

Public Types

typedef Cmplxtype< T >::type c_type
 Complex type of data type. More...
 
typedef _HashedSMatrix_iterator< T, const T &, const T * > const_iterator
 
typedef std::conditional< std::is_same< typename Realtype< T >::type, T >::value, typename Realtype< T >::type, typename Cmplxtype< T >::type >::type d_type
 Data type, depending if F is real or complex. More...
 
typedef _HashedSMatrix_iterator< T, T &, T * > iterator
 
typedef Realtype< T >::type r_type
 Real type of data type. More...
 
typedef T value_type
 

Public Member Functions

iterator begin (uint row=0)
 Returns iterator over the entrances. More...
 
const_iterator begin (uint row=0) const
 Returns constant iterator over the entrances. More...
 
const uint cols () const
 Number of columns. More...
 
void compress (Real threshold=EPS)
 Compresses the matrix by dropping small entries. More...
 
uint HashBits () const
 
 HashedSparseMatrix (uint r, uint c, uint h)
 Constructor. More...
 
std::ostream & info (std::ostream &os) const
 
Value ** Matrix () const
 
float memory () const
 
void multiply (const concepts::Matrix< T > *const fact, concepts::Matrix< T > &dest) const
 Multiplies this matrix and fact and adds the result to dest. More...
 
void multiply (const HashedSparseMatrix< T > *const fact, concepts::Matrix< T > &dest) const
 Multiplies this matrix and fact and adds the result to dest. More...
 
template<typename F , typename G >
void operator() (const F f[], G g[]) const
 Multiplies the matrix with f. The result is g. More...
 
T & operator() (const uint r, const uint c)
 Returns the entry with index (r,c). More...
 
operator() (const uint r, const uint c) const
 
HashedSparseMatrix< T > & operator*= (const T factor)
 Multiplies all entrices with a certain constant. More...
 
void outputMatlab (std::ostream &ofs) const
 
void outputSparseQR (std::ostream &ofs) const
 
const uint rows () const
 Number of rows. More...
 
template<typename F , typename G >
void transpMult (const F f[], G g[]) const
 Multiplies the transpose of the matrix with f and adds the results to g. More...
 
uint used () const
 Returns the number of used entries in the matrix. More...
 
void write (std::ostream &ofs) const
 
 ~HashedSparseMatrix ()
 

Static Public Member Functions

static iterator end ()
 Last entrance of the particular order. More...
 

Private Member Functions

void dropEntry_ (Value *&v, Value *&vPrev, const uint r, const uint c)
 Removes entry (r,c) from the matrix. More...
 
 HashedSparseMatrix (const HashedSparseMatrix< T > &)
 
void operator= (const HashedSparseMatrix< T > &)
 

Private Attributes

uint _used
 
uint hashBits
 
uint hashMsk
 
Value ** matrix
 
uint nofCols
 Number of columns. More...
 
uint nofRows
 Number of rows. More...
 
Pool< Valuepool
 

Detailed Description

template<class T>
class concepts::HashedSparseMatrix< T >

A matrix in sparse storage using hashes.

Definition at line 34 of file compositions.hh.

Member Typedef Documentation

◆ c_type

template<class T >
typedef Cmplxtype<T>::type concepts::HashedSparseMatrix< T >::c_type

Complex type of data type.

Definition at line 46 of file hashedSMatrix.hh.

◆ const_iterator

template<class T >
typedef _HashedSMatrix_iterator<T, const T&, const T*> concepts::HashedSparseMatrix< T >::const_iterator

Definition at line 52 of file hashedSMatrix.hh.

◆ d_type

template<class T >
typedef std::conditional<std::is_same<typename Realtype<T>::type, T>::value , typename Realtype<T>::type, typename Cmplxtype<T>::type >::type concepts::HashedSparseMatrix< T >::d_type

Data type, depending if F is real or complex.

Definition at line 49 of file hashedSMatrix.hh.

◆ iterator

template<class T >
typedef _HashedSMatrix_iterator<T, T&, T*> concepts::HashedSparseMatrix< T >::iterator

Definition at line 51 of file hashedSMatrix.hh.

◆ r_type

template<class T >
typedef Realtype<T>::type concepts::HashedSparseMatrix< T >::r_type

Real type of data type.

Definition at line 44 of file hashedSMatrix.hh.

◆ value_type

template<class T >
typedef T concepts::HashedSparseMatrix< T >::value_type

Definition at line 42 of file hashedSMatrix.hh.

Constructor & Destructor Documentation

◆ HashedSparseMatrix() [1/2]

template<class T >
concepts::HashedSparseMatrix< T >::HashedSparseMatrix ( uint  r,
uint  c,
uint  h 
)

Constructor.

Parameters
rNumber of rows
cNumber of columns
hNumber of hash bits

◆ ~HashedSparseMatrix()

template<class T >
concepts::HashedSparseMatrix< T >::~HashedSparseMatrix ( )

◆ HashedSparseMatrix() [2/2]

template<class T >
concepts::HashedSparseMatrix< T >::HashedSparseMatrix ( const HashedSparseMatrix< T > &  )
private

Member Function Documentation

◆ begin() [1/2]

template<class T >
iterator concepts::HashedSparseMatrix< T >::begin ( uint  row = 0)

Returns iterator over the entrances.

The order is row-wise, but unsorted inside the row. The iterator stands at the first entrance in row (in the particular order).

◆ begin() [2/2]

template<class T >
const_iterator concepts::HashedSparseMatrix< T >::begin ( uint  row = 0) const

Returns constant iterator over the entrances.

The order is row-wise, but unsorted inside the row. The iterator stands at the first entrance in row (in the particular order).

◆ cols()

template<class T >
const uint concepts::HashedSparseMatrix< T >::cols ( ) const
inline

Number of columns.

Definition at line 106 of file hashedSMatrix.hh.

◆ compress()

template<class T >
void concepts::HashedSparseMatrix< T >::compress ( Real  threshold = EPS)

Compresses the matrix by dropping small entries.

All matrix entries which are smaller than a certain threshold times the largest entry of the matrix are deleted from the matrix. To delete a small entry, dropEntry_ is used.

◆ dropEntry_()

template<class T >
void concepts::HashedSparseMatrix< T >::dropEntry_ ( Value *&  v,
Value *&  vPrev,
const uint  r,
const uint  c 
)
private

Removes entry (r,c) from the matrix.

The storage of the matrix entry is not released and will only be released on destruction of the whole matrix. Trying to remove a non-existing entry simply does nothing.

Parameters
vPointer to the entry which should be removed
vPrevPointer to the entry before the one to be removed
rRow index
cColumn index

◆ end()

template<class T >
static iterator concepts::HashedSparseMatrix< T >::end ( )
static

Last entrance of the particular order.

◆ HashBits()

template<class T >
uint concepts::HashedSparseMatrix< T >::HashBits ( ) const
inline

Definition at line 92 of file hashedSMatrix.hh.

◆ info()

template<class T >
std::ostream& concepts::HashedSparseMatrix< T >::info ( std::ostream &  os) const

◆ Matrix()

template<class T >
Value** concepts::HashedSparseMatrix< T >::Matrix ( ) const
inline

Definition at line 91 of file hashedSMatrix.hh.

◆ memory()

template<class T >
float concepts::HashedSparseMatrix< T >::memory ( ) const
inline

Definition at line 124 of file hashedSMatrix.hh.

◆ multiply() [1/2]

template<class T >
void concepts::HashedSparseMatrix< T >::multiply ( const concepts::Matrix< T > *const  fact,
concepts::Matrix< T > &  dest 
) const

Multiplies this matrix and fact and adds the result to dest.

Definition at line 238 of file hashedSMatrix.hh.

◆ multiply() [2/2]

template<class T >
void concepts::HashedSparseMatrix< T >::multiply ( const HashedSparseMatrix< T > *const  fact,
concepts::Matrix< T > &  dest 
) const

Multiplies this matrix and fact and adds the result to dest.

Definition at line 214 of file hashedSMatrix.hh.

◆ operator()() [1/3]

template<class T >
template<class F , class G >
void concepts::HashedSparseMatrix< T >::operator() ( const F  f[],
g[] 
) const

Multiplies the matrix with f. The result is g.

Definition at line 258 of file hashedSMatrix.hh.

◆ operator()() [2/3]

template<class T >
T& concepts::HashedSparseMatrix< T >::operator() ( const uint  r,
const uint  c 
)

Returns the entry with index (r,c).

If this entry does not yet exist, it is created.

Parameters
rRow index
cColumn index

◆ operator()() [3/3]

template<class T >
T concepts::HashedSparseMatrix< T >::operator() ( const uint  r,
const uint  c 
) const

◆ operator*=()

template<class T >
HashedSparseMatrix<T>& concepts::HashedSparseMatrix< T >::operator*= ( const T  factor)

Multiplies all entrices with a certain constant.

◆ operator=()

template<class T >
void concepts::HashedSparseMatrix< T >::operator= ( const HashedSparseMatrix< T > &  )
private

◆ outputMatlab()

template<class T >
void concepts::HashedSparseMatrix< T >::outputMatlab ( std::ostream &  ofs) const

◆ outputSparseQR()

template<class T >
void concepts::HashedSparseMatrix< T >::outputSparseQR ( std::ostream &  ofs) const

◆ rows()

template<class T >
const uint concepts::HashedSparseMatrix< T >::rows ( ) const
inline

Number of rows.

Definition at line 104 of file hashedSMatrix.hh.

◆ transpMult()

template<class T >
template<class F , class G >
void concepts::HashedSparseMatrix< T >::transpMult ( const F  f[],
g[] 
) const

Multiplies the transpose of the matrix with f and adds the results to g.

Precondition
g is set to 0

Definition at line 205 of file hashedSMatrix.hh.

◆ used()

template<class T >
uint concepts::HashedSparseMatrix< T >::used ( ) const
inline

Returns the number of used entries in the matrix.

Definition at line 123 of file hashedSMatrix.hh.

◆ write()

template<class T >
void concepts::HashedSparseMatrix< T >::write ( std::ostream &  ofs) const

Member Data Documentation

◆ _used

template<class T >
uint concepts::HashedSparseMatrix< T >::_used
private

Definition at line 168 of file hashedSMatrix.hh.

◆ hashBits

template<class T >
uint concepts::HashedSparseMatrix< T >::hashBits
private

Definition at line 176 of file hashedSMatrix.hh.

◆ hashMsk

template<class T >
uint concepts::HashedSparseMatrix< T >::hashMsk
private

Definition at line 177 of file hashedSMatrix.hh.

◆ matrix

template<class T >
Value** concepts::HashedSparseMatrix< T >::matrix
private

Definition at line 167 of file hashedSMatrix.hh.

◆ nofCols

template<class T >
uint concepts::HashedSparseMatrix< T >::nofCols
private

Number of columns.

Definition at line 174 of file hashedSMatrix.hh.

◆ nofRows

template<class T >
uint concepts::HashedSparseMatrix< T >::nofRows
private

Number of rows.

Definition at line 171 of file hashedSMatrix.hh.

◆ pool

template<class T >
Pool<Value> concepts::HashedSparseMatrix< T >::pool
private

Definition at line 166 of file hashedSMatrix.hh.


The documentation for this class was generated from the following files:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich