Class xlifepp::SparseMatrix#

template<typename K>
class SparseMatrix : public std::map<NumPair, K>#

Inheritence diagram for xlifepp::SparseMatrix:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "4" [label="xlifepp::SparseMatrix< real_t >" tooltip="xlifepp::SparseMatrix< real_t >"] "2" [label="std::map< NumPair, K >" tooltip="std::map< NumPair, K >"] "3" [label="std::map< K, T >" tooltip="std::map< K, T >"] "1" [label="xlifepp::SparseMatrix< K >" tooltip="xlifepp::SparseMatrix< K >" fillcolor="#BFBFBF"] "4" -> "1" [dir=forward tooltip="template-instance"] "2" -> "3" [dir=forward tooltip="template-instance"] "1" -> "2" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for xlifepp::SparseMatrix:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "2" [label="std::map< NumPair, K >" tooltip="std::map< NumPair, K >"] "3" [label="std::map< K, T >" tooltip="std::map< K, T >"] "1" [label="xlifepp::SparseMatrix< K >" tooltip="xlifepp::SparseMatrix< K >" fillcolor="#BFBFBF"] "2" -> "3" [dir=forward tooltip="template-instance"] "1" -> "2" [dir=forward tooltip="public-inheritance"] }

to deal with numeric sparse matrix (say real or complex vector) using (i,j,v) representation

Public Types

typedef std::map<NumPair, K>::iterator it_sm#

useful typedefs to iterators

Public Functions

inline SparseMatrix(const char *f)#

constructor from input file given by name

inline SparseMatrix(const Matrix<K> &m)#

constructor from a standard matrix

inline SparseMatrix(const number_t n, SpecialMatrix sm)#

constructor for v*Id matrix (v!=0)

inline SparseMatrix(const number_t r = 0, const number_t c = 0)#

constructor for null rectangular matrix

inline SparseMatrix(const std::vector<K> &v)#

constructor for diagonal square matrix

inline SparseMatrix(const string_t &f)#

constructor from input file given by name

inline SparseMatrix<K> &adjoint()#

matrix adjoint

inline it_sm begin()#

overloaded iterator begin

inline cit_sm begin() const#

overloaded const_iterator begin

inline SparseMatrix &clean()#

remove zeros without changing matrix size

inline number_t cols() const#

access to the the mumber of cols_

inline void complexCastWarning(const string_t &s, const size_t r, const size_t c) const#

warning: try to cast a complex to a real

inline SparseMatrix<K> &conjugate()#

to its conjugate (assuming conj(real)->real)

template<typename KK>
inline SparseMatrix<K> &diagProduct(const std::vector<KK> &diag)#

product by a diagonal matrix M = diag*M

inline NumPair dims() const#

dimensions

inline void divideByZero(const string_t &s) const#

error: divide by 0 in matrix operation s matrix dimension dim(op1)

inline it_sm end()#

overloaded iterator end

inline cit_sm end() const#

overloaded const_iterator begin

inline SparseMatrix<real_t> imag() const#

imaginary part of a (complex) matrix

inline bool isSelfAdjoint() const#

self adjoint matrix test

inline void isSingular() const#

error: non invertible matrix

inline bool isSkewAdjoint() const#

skew adjoint matrix test

inline bool isSkewSymmetric() const#

skew-symmetric matrix test

inline bool isSymmetric() const#

symmetric matrix test

inline void loadFromFile(const char *f)#

load matrix from file read from file a sparse matrix, formated as:

i j aij
....
inline void mismatchDims(const string_t &s, const size_t r, const size_t c) const#

error: in matrix operation s dimensions disagree dim(op1)= … dim(op2)=…

inline void nonSquare(const string_t &s, const size_t r, const size_t c) const#

error: operation forbidden for non square matrix

inline K &operator()(number_t i, number_t j)#

read/write access ( i > 0, j > 0 )

inline const K &operator()(number_t i, number_t j) const#

protected access ( i > 0, j > 0 )

template<typename KK>
inline SparseMatrix<K> &operator*=(const KK &x)#

overloaded *= multiply by a scalar

template<typename KK>
inline SparseMatrix<K> &operator+=(const KK &x)#

add a scalar

template<typename KK>
inline SparseMatrix<K> &operator+=(const SparseMatrix<KK> &b)#

accumulated matrix addition A+=B

template<typename KK>
inline SparseMatrix<K> &operator-=(const KK &x)#

subtract a scalar

template<typename KK>
inline SparseMatrix<K> &operator-=(const SparseMatrix<KK> &b)#

accumulated matrix subtraction (with cast)

template<typename KK>
inline SparseMatrix<K> &operator/=(const KK &x)#

overloaded /= divide by scalar

inline void print() const#

write on default file stream

inline void print(std::ofstream &os) const#

write on a file stream

template<typename KK>
inline SparseMatrix<K> &productDiag(std::vector<KK> diag)#

product by a diagonal matrix M = M*diag

inline SparseMatrix<real_t> real() const#

real part of a (complex) matrix

inline SparseMatrix &resize(number_t m, number_t n)#

change matrix size, removing outside coeff

inline number_t rows() const#

access to the the mumber of rows_

inline void saveToFile(const char *f) const#

save matrix to file formated as: i j aij

template<typename KK>
inline bool shareDims(const SparseMatrix<KK> &m) const#

true if matrices bear same dimensions

inline number_t size() const#

overloaded size()

inline real_t squaredNorm() const#

return squared norm of the matrix

inline Matrix<K> toMatrix() const#

create dense matrix from sparse matrix

inline SparseMatrix<K> &transpose()#

matrix transpostion

inline string_t typeStr() const#

type of matrix as string (see specialization)