Class xlifepp::Matrix#

template<typename K>
class Matrix : public std::vector<K>#

Inheritence diagram for xlifepp::Matrix:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "6" [label="xlifepp::Matrix< ComplexScalar >" tooltip="xlifepp::Matrix< ComplexScalar >"] "8" [label="xlifepp::Matrix< T >" tooltip="xlifepp::Matrix< T >"] "7" [label="xlifepp::Matrix< real_t >" tooltip="xlifepp::Matrix< real_t >"] "5" [label="xlifepp::MatrixEigenDense< ComplexScalar >" tooltip="xlifepp::MatrixEigenDense< ComplexScalar >"] "3" [label="std::vector< T >" tooltip="std::vector< T >"] "2" [label="std::vector< K >" tooltip="std::vector< K >"] "1" [label="xlifepp::Matrix< K >" tooltip="xlifepp::Matrix< K >" fillcolor="#BFBFBF"] "4" [label="xlifepp::MatrixEigenDense< K >" tooltip="xlifepp::MatrixEigenDense< K >"] "6" -> "1" [dir=forward tooltip="template-instance"] "8" -> "1" [dir=forward tooltip="template-instance"] "7" -> "1" [dir=forward tooltip="template-instance"] "5" -> "4" [dir=forward tooltip="template-instance"] "5" -> "6" [dir=forward tooltip="public-inheritance"] "2" -> "3" [dir=forward tooltip="template-instance"] "1" -> "2" [dir=forward tooltip="public-inheritance"] "4" -> "1" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for xlifepp::Matrix:

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

to deal with numeric matrix (say real or complex vector).

inherited from std::vector<K> (dense storage by row) may be used even for matrix of matrices but restricted usage !

Subclassed by xlifepp::MatrixEigenDense< K >

Public Types

typedef std::vector<K>::iterator it_vk#

useful typedefs to iterators

typedef K type_t#

alias on matrix coefficient type

Public Functions

inline Matrix()#

default constructor (1x1 matrix)

inline Matrix(const char *f)#

constructor from input file given by name

inline Matrix(const dimen_t d, const SpecialMatrix sm)#

constructor for special square matrix

inline Matrix(const dimen_t r, const dimen_t c)#

constructor for null rectangular matrix

inline Matrix(const dimen_t r, const dimen_t c, const K &v)#

constructor for constant rectangular matrix

template<typename Iterator>
inline Matrix(const dimen_t r, const dimen_t c, Iterator it_v, Iterator it_ve)#

constructor from iterators

template<typename KK>
inline Matrix(const Matrix<KK> &m)#

copy constructor

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

constructor for diagonal square matrix

inline Matrix(const std::vector<std::vector<K>> &vv)#

constructor from a sd::vector of std::vectors

inline Matrix(const std::vector<Vector<K>> &vv)#

constructor from a std::vector of Vectors

inline Matrix(const string_t &f)#

constructor from input file given by name

inline Matrix<K> &adddiag(const K x)#

add x to diagonal coefficients

inline Matrix<K> &adjoint()#

matrix self-adjoint

inline it_vk begin()#

overloaded iterator begin

inline cit_vk begin() const#

overloaded const_iterator begin

inline void changesize(const dimen_t r, const dimen_t c, const K &v = K())#

resize matrix and assign v

inline void changesize(const dimen_t r, const K &v = K())#

resize squared matrix and assign v

inline Vector<K> column(const dimen_t c) const#

return c-th (c > 0) column as a stl vector

inline void column(const dimen_t c, const std::vector<K> &v)#

set c-th column (c > 0) from a stl vector

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 Matrix<K> &conjugate()#

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

inline Vector<K> diag() const#

return diagonal as a Vector

inline Matrix<K> &diag(const K x)#

reset matrix as a diagonal matrix with constant diagonal entries

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

change matrix into diagonal matrix made of diagonal of matrix

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

reset matrix as a diagonal matrix with stl vector entries as diagonal entries

inline Matrix<K> &diagProduct(const std::vector<K> &diag)#

product by a diagonal matrix M = diag*M

inline dimPair dims() const#

dimensions

inline void divideByZero(const string_t &s) const#

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

std::pair<number_t, number_t> elementSize() const#

specialisation of elementSize

inline std::pair<number_t, number_t> elementSize() const

return size of element of a matrix of matrices or a matrix of vectors (size of first block!)

inline it_vk end()#

overloaded iterator end

inline cit_vk end() const#

overloaded const_iterator begin

inline Matrix<K> get(const std::pair<dimen_t, dimen_t> &rs, const std::pair<dimen_t, dimen_t> &cs) const#

return matrix coefficients along rs.first->rs.second and cs.first->cs.second numbers (indices starts from 1)

inline Matrix<K> get(const std::vector<dimen_t> &rs, const std::vector<dimen_t> &cs) const#

return matrix coefficients along rs and cs numbers (indices starts from 1)

inline Matrix<K> get(dimen_t r, const std::pair<dimen_t, dimen_t> &cs) const#

shortcuts to get routine

inline size_t hsize() const#

row length (number of columns)

inline Matrix<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 dense matrix, formated as:

nbRows nb_Cols
a11 a12 ........
a21 a22 ........
....
inline Matrix<K> lower() const#

lower part with matrix diag

inline Matrix<K> lower(const K &d) const#

lower part with diag equal to d

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 multLeftMatrixCol(K *mat, K *R, number_t p) const#

R = mat * M.

inline void multLeftMatrixRow(K *mat, K *R, number_t p) const#

R = mat * M.

inline void multMatrixCol(K *mat, K *R, number_t p) const#

R = M * mat.

inline void multMatrixRow(K *mat, K *R, number_t p) const#

R = M * mat.

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

error: operation forbidden for non square matrix

inline dimen_t numberOfCols() const#

number of columns

inline dimen_t numberOfColumns() const#

number of columns

inline dimen_t numberOfRows() const#

number of rows

inline K &operator()(const dimen_t r, const dimen_t c)#

read/write access ( r > 0, c > 0 )

inline const K &operator()(const dimen_t r, const dimen_t c) const#

protected access ( r > 0, c > 0 )

inline Matrix<K> operator()(const std::vector<dimen_t> &rs, const std::vector<dimen_t> &cs) const#

overload ()

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

overloaded *= multiply by a scalar

inline Matrix<K> &operator+=(const K &x)#

addition to scalar

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

accumulated matrix addition A+=B

inline Matrix<K> &operator-=(const K &x)#

subtract a scalar

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

accumulated matrix subtraction (with cast)

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

overloaded /= divide by scalar

inline Matrix<K> &operator=(const Matrix<K> &m)#

assignment operator= (deep copy)

template<typename KK>
inline Matrix<K> &operator=(const Matrix<KK> &m)#

assignment operator=(deep copy)

inline Matrix<K> &operator=(const std::vector<std::vector<K>> &vv)#

assignment operator= vector of vector

inline Matrix<K> &operator=(const std::vector<Vector<K>> &vv)#

assignment operator= vector of Vector

inline void print() const#

write on default file stream

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

write on a file stream

inline Matrix<K> &productDiag(std::vector<K> diag)#

product by a diagonal matrix M = M*diag

inline Matrix<real_t> real() const#

real part of a (complex) matrix

inline Matrix<K> &roundToZero(real_t aszero = 10 * theEpsilon)#

round to 0 all coefficients smaller (in norm) than a aszero, storage is not modified

inline Vector<K> row(const dimen_t r) const#

return r-th row (r > 0) as a stl vector (read only)

inline void row(const dimen_t r, const std::vector<K> &v)#

set r-th row (r > 0) from a stl vector

inline dimen_t &rows()#

access to the the member rows_ (writable)

inline void saveToFile(const char *f)#

save matrix to file

inline void set(const std::pair<dimen_t, dimen_t> &rs, const std::pair<dimen_t, dimen_t> &cs, const std::vector<K> &mat)#

set matrix coefficients along rs.first->rs.second and cs.first->cs.second numbers (indices starts from 1) rs and cs numbers has to be in current matrix index bounds matrix is given as a vector with row storage

inline void set(const std::vector<dimen_t> &rs, const std::vector<dimen_t> &cs, const std::vector<K> &mat)#

set matrix coefficients along rs and cs numbers (indices starts from 1) rs and cs numbers has to be in current matrix index bounds matrix is given as a vector with row storage

inline void set(dimen_t r, const std::pair<dimen_t, dimen_t> &cs, const std::vector<K> &mat)#

shorcuts to set routine

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

true if matrices bear same dimensions

inline size_t size() const#

overloaded size()

inline real_t squaredNorm() const#

return squared norm of the matrix

StrucType strucType() const#

specialisation of strucType

inline StrucType strucType() const

get structure type

inline Matrix<K> subMatrix(number_t r1, number_t r2, number_t c1, number_t c2) const#

extract M[r1,r2],[c1,c2], indices start from 1

inline Matrix<K> &transpose()#

matrix self-transpostion

inline string_t typeStr() const#

type of matrix as string

inline Matrix<K> upper() const#

upper part with matrix diag

inline Matrix<K> upper(const K &d) const#

upper part with diag equal to d

ValueType valueType() const#

specialisation of valueType

inline ValueType valueType() const

get value type

inline size_t vsize() const#

column length (number of rows)

Friends

friend std::ostream &operator<<(std::ostream &os, const Matrix<complex_t> &m)#

complex matrix flux insertion (write)

flux insertion (write)

friend std::ostream &operator<<(std::ostream &os, const Matrix<real_t> &m)#

real matrix flux insertion (write)

flux insertion (write)

inline friend std::istream &operator>>(std::istream &is, Matrix<K> &m)#

flux extraction(read)