CVM Class Library  8.1
This C++ class library encapsulates concepts of vector and different matrices including square, band, symmetric and hermitian ones in Euclidean space of real and complex numbers.
 All Classes Files Functions Variables Typedefs Friends Macros Pages
Public Member Functions | List of all members
basic_srsmatrix< TR > Class Template Reference

End-user class encapsulating symmetric matrix of real numbers. More...

#include <cvm.h>

Inheritance diagram for basic_srsmatrix< TR >:
Inheritance graph
[legend]
Collaboration diagram for basic_srsmatrix< TR >:
Collaboration graph
[legend]

Public Member Functions

 basic_srsmatrix ()
 Default constructor.
 basic_srsmatrix (tint nDim)
 Constructor.
 basic_srsmatrix (TR *pd, tint nDim, TR tol=basic_cvmMachSp< TR >())
 Constructor.
 basic_srsmatrix (const TR *pd, tint nDim, TR tol=basic_cvmMachSp< TR >())
 Constructor.
 basic_srsmatrix (const basic_srsmatrix &m)
 Copy constructor.
 basic_srsmatrix (basic_srsmatrix &&m) noexcept
 Move constructor.
 basic_srsmatrix (const BaseRMatrix &m, TR tol=basic_cvmMachSp< TR >())
 Constructor.
 basic_srsmatrix (const RVector &v)
 Constructor.
 basic_srsmatrix (basic_srsmatrix &m, tint nRowCol, tint nDim)
 Submatrix constructor.
TR operator() (tint nRow, tint nCol) const throw (cvmexception)
 Value of element (not l-value)
const RVector operator() (tint nCol) const throw (cvmexception)
 Column as not l-value.
const RVector operator[] (tint nRow) const throw (cvmexception)
 Row as not l-value.
const RVector diag (tint nDiag) const throw (cvmexception)
 Diagonal (not l-value)
basic_srsmatrixoperator= (const basic_srsmatrix &m) throw (cvmexception)
 Assignment operator.
basic_srsmatrixoperator= (basic_srsmatrix &&m) throw (cvmexception)
 Move assignment operator.
basic_srsmatrixassign (const RVector &v, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Vector (as array) assignment.
basic_srsmatrixassign (const TR *pd, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 External array assignment.
basic_srsmatrixassign (tint nRowCol, const basic_srsmatrix &m) throw (cvmexception)
 Assignment to submatrix.
basic_srsmatrixset (TR d)
 Sets all elements to one value.
basic_srsmatrixset (tint nRow, tint nCol, TR d)
 Sets both elements to keep matrix symmetric.
basic_srsmatrixset_diag (tint nDiag, const RVector &vDiag) throw (cvmexception)
 Sets diagonal(s)
basic_srsmatrixresize (tint nNewDim) throw (cvmexception)
 Changes dimension.
bool operator== (const basic_srsmatrix &m) const
 Matrix comparison.
bool operator!= (const basic_srsmatrix &m) const
 Matrix comparison.
basic_srsmatrixoperator<< (const basic_srsmatrix &m) throw (cvmexception)
 Matrix replacement.
basic_srsmatrix operator+ (const basic_srsmatrix &m) const throw (cvmexception)
 Addition operator.
basic_srsmatrix operator- (const basic_srsmatrix &m) const throw (cvmexception)
 Subtraction operator.
basic_srsmatrixsum (const basic_srsmatrix &m1, const basic_srsmatrix &m2) throw (cvmexception)
 Sum of matrices.
basic_srsmatrixdiff (const basic_srsmatrix &m1, const basic_srsmatrix &m2) throw (cvmexception)
 Difference of matrices.
basic_srsmatrixoperator+= (const basic_srsmatrix &m) throw (cvmexception)
 Increment operator.
basic_srsmatrixoperator-= (const basic_srsmatrix &m) throw (cvmexception)
 Decrement operator.
basic_srsmatrix operator- () const
 Unary minus operator.
basic_srsmatrixoperator++ ()
 Plus identity, prefix.
basic_srsmatrix operator++ (int)
 Plus identity, postfix.
basic_srsmatrixoperator-- ()
 Minus identity, prefix.
basic_srsmatrix operator-- (int)
 Minus identity, postfix.
basic_srsmatrix operator* (TR dMult) const
 Multiply by number operator.
basic_srsmatrix operator/ (TR dDiv) const throw (cvmexception)
 Divide by number operator.
basic_srsmatrixoperator*= (TR dMult)
 Multiply by number and assign.
basic_srsmatrixoperator/= (TR dDiv) throw (cvmexception)
 Divide by number and assign.
basic_srsmatrixnormalize ()
 Matrix normalizer.
basic_srsmatrix operator~ () const
 Does nothing and returns copy of calling symmetric matrix.
basic_srsmatrixtranspose (const basic_srsmatrix &m) throw (cvmexception)
 Assigns symmetric matrix m to calling one and returns reference to the matrix changed.
basic_srsmatrixtranspose ()
 Does nothing and returns reference to calling symmetric matrix.
RVector operator* (const RVector &v) const throw (cvmexception)
 Matrix-vector product.
BaseRMatrix operator* (const BaseRMatrix &m) const throw (cvmexception)
 Matrix-matrix product.
BaseSRMatrix operator* (const BaseSRMatrix &m) const throw (cvmexception)
 Matrix-matrix product.
RVector operator/ (const RVector &v) const throw (cvmexception)
 Linear solver operator.
basic_srsmatrixsyrk (TR alpha, const RVector &v, TR beta) throw (cvmexception)
 Rank-1 update matrix-vector operation.
basic_srsmatrixsyrk (bool bTransp, TR alpha, const BaseRMatrix &m, TR beta) throw (cvmexception)
 Rank-1 update matrix-matrix operation.
basic_srsmatrixsyr2k (TR alpha, const RVector &v1, const RVector &v2, TR beta) throw (cvmexception)
 Rank-1 update matrix-vector operation.
basic_srsmatrixsyr2k (bool bTransp, TR alpha, const BaseRMatrix &m1, const BaseRMatrix &m2, TR beta) throw (cvmexception)
 Rank-1 update matrix-matrix operation.
basic_srsmatrixinv (const basic_srsmatrix &m) throw (cvmexception)
 Matrix inversion.
basic_srsmatrix inv () const throw (cvmexception)
 Matrix inversion.
basic_srsmatrixexp (const basic_srsmatrix &m, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Matrix exponent.
basic_srsmatrix exp (TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Matrix exponent.
basic_srsmatrixpolynom (const basic_srsmatrix &m, const RVector &v) throw (cvmexception)
 Matrix polynomial.
basic_srsmatrix polynom (const RVector &v) const
 Matrix polynomial.
RVector eig (BaseSRMatrix &mEigVect) const throw (cvmexception)
 Eigenvalues and eigenvectors.
RVector eig () const throw (cvmexception)
 Eigenvalues.
BaseSRMatrix cholesky () const throw (cvmexception)
 Cholesky factorization.
BaseSRMatrix bunch_kaufman (tint *nPivots) const throw (cvmexception)
 Bunch-Kaufman factorization.
basic_srsmatrixidentity ()
 Identity matrix.
basic_srsmatrixvanish ()
 Set matrix to zero.
basic_srsmatrixrandomize (TR dFrom, TR dTo)
 Randomizer.
TR norminf () const override
 Infinity norm.
bool is_positive_definite () const
 Is calling symmetric matrix positive definite?
bool equilibrate (RVector &vScalings, RVector &vB) throw (cvmexception)
 Matrix equilibration.
bool equilibrate (RVector &vScalings, BaseRMatrix &mB) throw (cvmexception)
 Matrix equilibration.
- Public Member Functions inherited from basic_srmatrix< TR >
 basic_srmatrix ()
 Default constructor.
 basic_srmatrix (tint nDim)
 Constructor.
 basic_srmatrix (TR *pd, tint nDim)
 Constructor.
 basic_srmatrix (const TR *pd, tint nDim)
 Constructor.
 basic_srmatrix (const basic_srmatrix &m)
 Copy constructor.
 basic_srmatrix (basic_srmatrix &&m) noexcept
 Move constructor.
 basic_srmatrix (const BaseRMatrix &m)
 Constructor.
 basic_srmatrix (const RVector &v)
 Constructor.
 basic_srmatrix (BaseRMatrix &m, tint nRow, tint nCol, tint nDim)
 Submatrix constructor.
type_proxy< TR, TR > operator() (tint nRow, tint nCol) throw (cvmexception)
 Reference to element (l-value)
RVector operator() (tint nCol) throw (cvmexception)
 Column as l-value.
RVector operator[] (tint nRow) throw (cvmexception)
 Row as l-value.
basic_srmatrixoperator= (const basic_srmatrix &m) throw (cvmexception)
 Assignment operator.
basic_srmatrixoperator= (basic_srmatrix &&m) throw (cvmexception)
 Move assignment operator.
basic_srmatrixassign (const RVector &v) throw (cvmexception)
 Vector (as array) assignment.
basic_srmatrixassign (const TR *pd)
 External array assignment.
basic_srmatrixassign (tint nRow, tint nCol, const BaseRMatrix &m) throw (cvmexception)
 Assignment to submatrix.
basic_srmatrixoperator<< (const basic_srmatrix &m) throw (cvmexception)
 Matrix replacement.
basic_srmatrix operator+ (const basic_srmatrix &m) const throw (cvmexception)
 Addition operator.
basic_srmatrix operator- (const basic_srmatrix &m) const throw (cvmexception)
 Subtraction operator.
basic_srmatrixsum (const basic_srmatrix &m1, const basic_srmatrix &m2) throw (cvmexception)
 Sum of matrices.
basic_srmatrixdiff (const basic_srmatrix &m1, const basic_srmatrix &m2) throw (cvmexception)
 Difference of matrices.
basic_srmatrixoperator+= (const basic_srmatrix &m) throw (cvmexception)
 Increment operator.
basic_srmatrixoperator-= (const basic_srmatrix &m) throw (cvmexception)
 Decrement operator.
basic_srmatrixtranspose (const basic_srmatrix &m) throw (cvmexception)
 Matrix transposition.
basic_srmatrix operator* (const basic_srmatrix &m) const throw (cvmexception)
 Matrix-matrix product.
basic_srmatrixoperator*= (const basic_srmatrix &m) throw (cvmexception)
 Matrix-matrix product with assignment.
basic_srmatrixswap_rows (tint n1, tint n2) throw (cvmexception)
 Rows swap.
basic_srmatrixswap_cols (tint n1, tint n2) throw (cvmexception)
 Columns swap.
RVector solve (const RVector &vB, TR &dErr) const throw (cvmexception)
 Linear solver.
RVector solve_tran (const RVector &vB, TR &dErr) const throw (cvmexception)
 Linear solver (transposed)
RVector solve (const RVector &vB) const throw (cvmexception)
 Linear solver.
RVector solve_tran (const RVector &vB) const throw (cvmexception)
 Linear solver (transposed)
BaseRMatrix solve (const BaseRMatrix &mB, TR &dErr) const throw (cvmexception)
 Linear solver.
BaseRMatrix solve_tran (const BaseRMatrix &mB, TR &dErr) const throw (cvmexception)
 Linear solver (transposed)
BaseRMatrix solve (const BaseRMatrix &mB) const throw (cvmexception)
 Linear solver.
BaseRMatrix solve_tran (const BaseRMatrix &mB) const throw (cvmexception)
 Linear solver (transposed)
RVector operator% (const RVector &vB) const throw (cvmexception)
 Linear solver operator (transposed)
RVector solve_lu (const basic_srmatrix &mLU, const tint *pPivots, const RVector &vB, TR &dErr) const throw (cvmexception)
 LU factorization based linear solver.
RVector solve_lu (const basic_srmatrix &mLU, const tint *pPivots, const RVector &vB) const throw (cvmexception)
 LU factorization based linear solver.
BaseRMatrix solve_lu (const basic_srmatrix &mLU, const tint *pPivots, const BaseRMatrix &mB, TR &dErr) const throw (cvmexception)
 LU factorization based linear solver.
BaseRMatrix solve_lu (const basic_srmatrix &mLU, const tint *pPivots, const BaseRMatrix &mB) const throw (cvmexception)
 LU factorization based linear solver.
TR det () const throw (cvmexception)
 Matrix determinant.
basic_srmatrixlow_up (const basic_srmatrix &m, tint *nPivots) throw (cvmexception)
 Low-up (LU) factorization.
basic_srmatrix low_up (tint *nPivots) const throw (cvmexception)
 Low-up (LU) factorization.
TR cond () const throw (cvmexception)
 Condition number reciprocal.
basic_srmatrixinv (const basic_srmatrix &m) throw (cvmexception)
 Matrix inversion.
basic_srmatrixexp (const basic_srmatrix &m, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Matrix exponent.
basic_srmatrixpolynom (const basic_srmatrix &m, const RVector &v) throw (cvmexception)
 Matrix polynomial.
CVector eig (basic_scmatrix< TR, TC > &mEigVect, bool bRightVect=true) const throw (cvmexception)
 Eigenvalues and eigenvectors.
basic_srmatrixcholesky (const basic_srsmatrix< TR > &m) throw (cvmexception)
 Cholesky factorization.
basic_srmatrixbunch_kaufman (const basic_srsmatrix< TR > &m, tint *nPivots) throw (cvmexception)
 Bunch-Kaufman factorization.
void qr (basic_srmatrix< TR > &mQ, basic_srmatrix< TR > &mR) const throw (cvmexception)
 QR factorization.
void lq (basic_srmatrix< TR > &mL, basic_srmatrix< TR > &mQ) const throw (cvmexception)
 LQ factorization.
void ql (basic_srmatrix< TR > &mQ, basic_srmatrix< TR > &mL) const throw (cvmexception)
 QL factorization.
void rq (basic_srmatrix< TR > &mR, basic_srmatrix< TR > &mQ) const throw (cvmexception)
 RQ factorization.
- Public Member Functions inherited from basic_rmatrix< TR >
 basic_rmatrix ()
 Default constructor.
 basic_rmatrix (tint nM, tint nN)
 Constructor.
 basic_rmatrix (TR *pd, tint nM, tint nN)
 Constructor.
 basic_rmatrix (const TR *pd, tint nM, tint nN)
 Constructor.
 basic_rmatrix (const basic_rmatrix &m)
 Copy constructor.
 basic_rmatrix (basic_rmatrix &&m) noexcept
 Move constructor.
 basic_rmatrix (const RVector &v, bool bBeColumn=true)
 Constructor.
 basic_rmatrix (basic_rmatrix &m, tint nRow, tint nCol, tint nHeight, tint nWidth)
 Submatrix constructor.
RVector diag (tint nDiag) throw (cvmexception)
 Diagonal as l-value.
basic_rmatrixoperator= (const basic_rmatrix &m) throw (cvmexception)
 Assignment operator.
basic_rmatrixoperator= (basic_rmatrix &&m) throw (cvmexception)
 Move assignment operator.
basic_rmatrixassign (tint nRow, tint nCol, const basic_rmatrix &m) throw (cvmexception)
 Assignment to submatrix.
basic_rmatrixresize (tint nNewM, tint nNewN) throw (cvmexception)
 Changes dimensions.
bool operator== (const basic_rmatrix &m) const
 Matrix comparison.
bool operator!= (const basic_rmatrix &m) const
 Matrix comparison.
basic_rmatrixoperator<< (const basic_rmatrix &m) throw (cvmexception)
 Matrix replacement.
basic_rmatrix operator+ (const basic_rmatrix &m) const throw (cvmexception)
 Addition operator.
basic_rmatrix operator- (const basic_rmatrix &m) const throw (cvmexception)
 Subtraction operator.
basic_rmatrixsum (const basic_rmatrix &m1, const basic_rmatrix &m2) throw (cvmexception)
 Sum of matrices.
basic_rmatrixdiff (const basic_rmatrix &m1, const basic_rmatrix &m2) throw (cvmexception)
 Difference of matrices.
basic_rmatrixoperator+= (const basic_rmatrix &m) throw (cvmexception)
 Increment operator.
basic_rmatrixoperator-= (const basic_rmatrix &m) throw (cvmexception)
 Decrement operator.
basic_rmatrixtranspose (const basic_rmatrix &m) throw (cvmexception)
 Matrix transposition.
basic_rmatrix operator* (const basic_rmatrix &m) const throw (cvmexception)
 Matrix-matrix product.
basic_rmatrixmult (const basic_rmatrix &m1, const basic_rmatrix &m2) throw (cvmexception)
 Matrix-matrix product.
basic_rmatrixrank1update (const RVector &vCol, const RVector &vRow) throw (cvmexception)
 Rank-1 update.
basic_rmatrixsolve (const basic_srmatrix< TR > &mA, const basic_rmatrix &mB, TR &dErr) throw (cvmexception)
 Linear solver.
basic_rmatrixsolve_tran (const basic_srmatrix< TR > &mA, const basic_rmatrix &mB, TR &dErr) throw (cvmexception)
 Linear solver (transposed)
basic_rmatrixsolve (const basic_srmatrix< TR > &mA, const basic_rmatrix &mB) throw (cvmexception)
 Linear solver.
basic_rmatrixsolve_tran (const basic_srmatrix< TR > &mA, const basic_rmatrix &mB) throw (cvmexception)
 Linear solver (transposed)
basic_rmatrixsolve_lu (const basic_srmatrix< TR > &mA, const basic_srmatrix< TR > &mLU, const tint *pPivots, const basic_rmatrix &mB, TR &dErr) throw (cvmexception)
 LU factorization based linear solver.
basic_rmatrixsolve_lu (const basic_srmatrix< TR > &mA, const basic_srmatrix< TR > &mLU, const tint *pPivots, const basic_rmatrix &mB) throw (cvmexception)
 LU factorization based linear solver.
RVector svd () const throw (cvmexception)
 Singular value decomposition.
RVector svd (basic_srmatrix< TR > &mU, basic_srmatrix< TR > &mVH) const throw (cvmexception)
 Singular value decomposition.
basic_rmatrix pinv (TR threshold=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Pseudo (generalized) inversion.
basic_rmatrixpinv (const basic_rmatrix &mA, TR threshold=basic_cvmMachSp< TR >()) throw (cvmexception)
 Pseudo (generalized) inversion.
basic_rmatrix gels (bool transpose, const basic_rmatrix &mB, basic_rvector< TR > &vErr) const throw (cvmexception)
 Overdetermined or underdetermined linear solver.
basic_rmatrixgels (bool transpose, const basic_rmatrix &mA, const basic_rmatrix &mB, basic_rvector< TR > &vErr) throw (cvmexception)
 Overdetermined or underdetermined linear solver.
basic_rvector< TR > gels (bool transpose, const basic_rvector< TR > &vB, TR &dErr) const throw (cvmexception)
 Overdetermined or underdetermined linear solver.
basic_rmatrix gelsy (const basic_rmatrix &mB, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_rmatrixgelsy (const basic_rmatrix &mA, const basic_rmatrix &mB, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Linear least squares problem.
basic_rvector< TR > gelsy (const basic_rvector< TR > &vB, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_rmatrix gelss (const basic_rmatrix &mB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_rmatrixgelss (const basic_rmatrix &mA, const basic_rmatrix &mB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Linear least squares problem.
basic_rvector< TR > gelss (const basic_rvector< TR > &vB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_rmatrix gelsd (const basic_rmatrix &mB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_rmatrixgelsd (const basic_rmatrix &mA, const basic_rmatrix &mB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Linear least squares problem.
basic_rvector< TR > gelsd (const basic_rvector< TR > &vB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
tint rank (TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Matrix rank.
void qr (basic_rmatrix< TR > &mQ, basic_srmatrix< TR > &mR) const throw (cvmexception)
 QR factorization ("economy" mode)
void qr (basic_srmatrix< TR > &mQ, basic_rmatrix< TR > &mR) const throw (cvmexception)
 QR factorization ("full" mode)
void lq (basic_srmatrix< TR > &mL, basic_rmatrix< TR > &mQ) const throw (cvmexception)
 LQ factorization ("economy" mode)
void lq (basic_rmatrix< TR > &mL, basic_srmatrix< TR > &mQ) const throw (cvmexception)
 LQ factorization ("full" mode)
void rq (basic_srmatrix< TR > &mR, basic_rmatrix< TR > &mQ) const throw (cvmexception)
 RQ factorization ("economy" mode)
void rq (basic_rmatrix< TR > &mR, basic_srmatrix< TR > &mQ) const throw (cvmexception)
 RQ factorization ("full" mode)
void ql (basic_rmatrix< TR > &mQ, basic_srmatrix< TR > &mL) const throw (cvmexception)
 QL factorization ("economy" mode)
void ql (basic_srmatrix< TR > &mQ, basic_rmatrix< TR > &mL) const throw (cvmexception)
 QL factorization ("full" mode)
basic_rmatrixger (TR alpha, const RVector &vCol, const RVector &vRow) throw (cvmexception)
 Rank-1 update matrix-vector operation.
basic_rmatrixgemm (const basic_rmatrix &m1, bool bTrans1, const basic_rmatrix &m2, bool bTrans2, TR dAlpha, TR dBeta) throw (cvmexception)
 Generic matrix-matrix operation.
basic_rmatrixsymm (bool bLeft, const basic_srsmatrix< TR > &ms, const basic_rmatrix &m, TR dAlpha, TR dBeta) throw (cvmexception)
 Generic symmetric matrix-matrix operation.
TR norm2 () const override
 2-norm
- Public Member Functions inherited from Matrix< TR, TR >
tint msize () const
 Number of rows.
tint nsize () const
 Number of columns.
tint ld () const
 Leading dimension.
tint rowofmax () const
 Row with maximum element.
tint rowofmin () const
 Row with minimum element.
tint colofmax () const
 Column with maximum element.
tint colofmin () const
 Column with minimum element.
TR norm1 () const override
 1-norm
- Public Member Functions inherited from basic_array< TR, TR >
 basic_array ()
 Default constructor.
 basic_array (tint nSize, bool bZeroMemory=true)
 Constructor.
 basic_array (TR *pd, tint nSize, tint nIncr=1)
 Constructor.
 basic_array (const TR *pd, tint nSize, tint nIncr=1)
 Constructor.
 basic_array (const TR *begin, const TR *end)
 Constructor.
 basic_array (const basic_array &a)
 Copy constructor.
 basic_array (basic_array &&a) noexcept
 Move constructor.
basic_arrayoperator= (const basic_array &a) throw (cvmexception)
 Assignment operator.
basic_arrayoperator= (basic_array &&a) throw (cvmexception)
 Move assignment operator.
virtual ~basic_array ()
 Destructor.
tint size () const
 Size (length) of array.
TR * get ()
 Pointer to data.
const TR * get () const
 Const pointer to data.
 operator TR * ()
 operator const TR * () const
void assign (size_type n, const TR &val) throw (cvmexception)
 (STL) assigns given value to n-th element (0-based)
void assign (const_iterator begin, const_iterator end) throw (cvmexception)
 (STL) assigns begin-end iteartor range to array
tint incr () const
 Increment between elements.
tint indofmax () const
 Index of element with maximum module.
tint indofmin () const
 Index of element with minimum module.
virtual TR norm () const
 Euclidean norm.
iterator begin ()
 (STL) iterator to begin
const_iterator begin () const
 (STL) const iterator to begin
iterator end ()
 (STL) iterator to end
const_iterator end () const
 (STL) const iterator to end
reverse_iterator rbegin ()
 (STL) iterator to begin reversed
const_reverse_iterator rbegin () const
 (STL) const iterator to begin reversed
reverse_iterator rend ()
 (STL) iterator to end reversed
const_reverse_iterator rend () const
 (STL) const iterator to end reversed
size_type max_size () const
 (STL) maximum possible size of array
size_type capacity () const
 (STL) current capacity of array, equal to size()
bool empty () const
 (STL) is array empty
reference front ()
 (STL) reference to first element
const_reference front () const
 (STL) const reference to first element
reference back ()
 (STL) reference to last element
const_reference back () const
 (STL) const reference to last element
void clear ()
 (STL) clears array, dealocates memory and sets size() to zero
void swap (basic_array &v) throw (cvmexception)
 (STL) swaps array values, throws cvmexception if sizes are different
reference at (size_type n) throw (cvmexception)
 (STL) returns reference to n-th element of array (0-based), throws cvmexception if n is out of boundaries
const_reference at (size_type n) const throw (cvmexception)
 (STL) returns const reference to n-th element of array (0-based), throws cvmexception if n is out of boundaries
void push_back (const TR &x) throw (cvmexception)
 (STL) pushes new value to the end of array
void pop_back () throw (cvmexception)
 (STL) removes last element from array
iterator insert (iterator position, const TR &x) throw (cvmexception)
 (STL) inserts element to given position in array
iterator erase (iterator position) throw (cvmexception)
 (STL) removes element from given position in array

Additional Inherited Members

- Public Types inherited from basic_array< TR, TR >
typedef TR value_type
 STL-specific value type definition.
typedef value_typepointer
 STL-specific value pointer definition.
typedef value_typeiterator
 STL-specific iterator definition.
typedef const value_typeconst_iterator
 STL-specific const iterator definition.
typedef const value_typeconst_pointer
 STL-specific const pointer definition.
typedef value_typereference
 STL-specific reference definition.
typedef const value_typeconst_reference
 STL-specific const reference definition.
typedef size_t size_type
 STL-specific size type definition.
typedef ptrdiff_t difference_type
 STL-specific difference type definition.
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 STL-specific const reverse iterator definition.
typedef std::reverse_iterator
< iterator
reverse_iterator
 STL-specific reverse iterator definition.
- Protected Member Functions inherited from Matrix< TR, TR >
 Matrix ()
 Default constructor.
 Matrix (tint nM, tint nN, tint nLD, bool bZeroMemory)
 Constructor.
 Matrix (TR *pd, tint nM, tint nN, tint nLD, tint nSize)
 Constructor.
 Matrix (const TR *pd, tint nM, tint nN, tint nLD, tint nSize)
 Constructor.
 Matrix (const BaseArray &v, bool bBeColumn)
 Constructor.
 Matrix (Matrix &&m) noexcept
 Move constructor.
Matrixoperator= (Matrix &&m) throw (cvmexception)
 Move assignment operator.
- Protected Member Functions inherited from SqMatrix< TR, TR >
 SqMatrix ()
 internal constructor
virtual ~SqMatrix ()
- Protected Attributes inherited from Matrix< TR, TR >
tint mm
 Number of rows.
tint mn
 Number of columns.
tint mld
 Leading dimension.

Detailed Description

template<typename TR>
class basic_srsmatrix< TR >

End-user class encapsulating symmetric matrix of real numbers.

TR type stands for treal. Please use predefined srsmatrix class in your applications.

See Also
Matrix

Definition at line 32036 of file cvm.h.

Constructor & Destructor Documentation

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( )
inline

Default constructor.

Creates empty symmetric matrix. No memory gets allocated.

Example:
using namespace cvm;
std::cout << m.msize() << " " << m.nsize() << " " << m.size()
<< std::endl << std::endl;
m.resize (3);
m.set(1.);
std::cout << m;
prints
0 0 0
1 1 1
1 1 1
1 1 1

Definition at line 32069 of file cvm.h.

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( tint  nDim)
inlineexplicit

Constructor.

Creates $n\times n$ srsmatrix object where $n$ is passed in nDim parameter. Constructor sets all elements to zero. It throws cvmexception in case of non-positive size passed or memory allocation failure. Example:

using namespace cvm;
srsmatrix m(4);
std::cout << m.msize() << " " << m.nsize() << " " << m.size()
<< std::endl << std::endl;
m.set(1.);
std::cout << m;

prints

4 4 16
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
Parameters
[in]nDimNumber of rows and columns.

Definition at line 32099 of file cvm.h.

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( TR *  pd,
tint  nDim,
TR  tol = basic_cvmMachSp<TR>() 
)
inline

Constructor.

Creates $n\times n$ srsmatrix object where $n$ is passed in nDim parameter. It throws cvmexception in case of non-positive size passed or if the matrix created doesn't appear to be symmetric. Symmetry tolerance is set by parameter tol. Unlike others, this constructor does not allocate memory. It just shares memory with array pointed to by pd (for matrices nIncr=1 is always satisfied). If subsequent application flow would change the array passed so it becomes not symmetric matrix anymore then results are not predictable.

Example:
using namespace cvm;
double a[] = {1., 1., 1., 1., 1., 1., 1., 1., 1.};
srsmatrix m (a, 3);
m.set(2,1,5.);
std::cout << m << std::endl;
std::cout << a[0] << " " << a[1] << " " << a[2] << " "
<< a[3] << " " << a[4] << " " << a[5] << " " << std::endl;
prints
1 5 1
5 1 1
1 1 1
1 5 1 5 1 1
See Also
http://cvmlib.com/faq.htm
basic_rmatrix::basic_rmatrix(TR*,tint,tint)
Parameters
[in]pdPointer to array to share memory with.
[in]nDimNumber of rows and columns.
[in]tolSymmetry tolerance.

Definition at line 32138 of file cvm.h.

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( const TR *  pd,
tint  nDim,
TR  tol = basic_cvmMachSp<TR>() 
)
inline

Constructor.

Creates $n\times n$ srsmatrix object where $n$ is passed in nDim parameter. Constructor throws cvmexception in case of non-positive sizes passed or if the matrix created doesn't appear to be symmetric. Symmetry tolerance is set by parameter tol. This is const version, it allocates memory and copies every element (deep copy) from external array pointed to by pd parameter. It copies nDim*nDim elements total. Example:

using namespace cvm;
const double a[] = {1., 1., 1., 1., 1., 1., 1., 1., 1.};
srmatrix m (a, 3);
m(1,1) = 5.;
std::cout << m << std::endl;
std::cout << a[0] << " " << a[1] << " " << a[2] << std::endl;

prints

5 1 1
1 1 1
1 1 1
1 1 1
See Also
http://cvmlib.com/faq.htm
basic_rmatrix::basic_rmatrix(const TR*,tint,tint)
Parameters
[in]pdConst pointer to external array.
[in]nDimNumber of rows and columns.
[in]tolSymmetry tolerance.

Definition at line 32177 of file cvm.h.

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( const basic_srsmatrix< TR > &  m)
inline

Copy constructor.

Creates srsmatrix object as a copy of symmetric matrix m. It throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
srsmatrix m (a, 3);
srmatrix mc(m);
m.set(2,3,7.77);
std::cout << m << std::endl << mc;
prints
1 2 3
2 5 7.77
3 7.77 9
1 2 3
2 5 6
3 6 9
Parameters
[in]msrsmatrix to copy from.

Definition at line 32209 of file cvm.h.

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( basic_srsmatrix< TR > &&  m)
inline

Move constructor.

Implements move semantics introduced in new C++ standard. Moves data ownership from other matrix to newly created object. It's usually executed implicitly in cases like this:

rvector a(b + c);

or this

rvector a = b + c;

Here temporary result of calling b.operator+(c) will not be destroyed but rather moved to newly created object a.

Parameters
[in]mrvalue reference to other matrix.

Definition at line 32232 of file cvm.h.

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( const BaseRMatrix m,
TR  tol = basic_cvmMachSp<TR>() 
)
inlineexplicit

Constructor.

Creates srsmatrix object as a copy of matrix m. It's assumed that $m\times n$ matrix m must have equal sizes, i.e. $m = n$ is satisfied, and must be symmetric. Symmetry tolerance is set by parameter tol. Constructor throws cvmexception if this is not true or in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
rmatrix m(a, 3, 3);
srsmatrix ms(m);
std::cout << ms;
prints
1 2 3
2 5 6
3 6 9
Parameters
[in]mrmatrix to copy from.
[in]tolSymmetry tolerance.

Definition at line 32262 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( const RVector v)
inlineexplicit

Constructor.

Creates srsmatrix object of size v.size() by v.size() and assigns vector v to its main diagonal. Constructor throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5.};
const rvector v(a, 5);
srsmatrix m(v);
std::cout << m;
prints
1 0 0 0 0
0 2 0 0 0
0 0 3 0 0
0 0 0 4 0
0 0 0 0 5
Parameters
[in]vrvector to copy main diagonal from.

Definition at line 32294 of file cvm.h.

template<typename TR>
basic_srsmatrix< TR >::basic_srsmatrix ( basic_srsmatrix< TR > &  m,
tint  nRowCol,
tint  nDim 
)
inline

Submatrix constructor.

Creates srsmatrix object as submatrix of symmetric matrix m. It means that the object created shares memory with some part of m. This part is defined by its upper left corner (parameter nRowCol, CVM0 based) and its dimension (parameter nDim).

Example:
using namespace cvm;
srsmatrix m(5);
srsmatrix subm(m, 2, 2);
subm.set(1.);
std::cout << m;
prints
0 0 0 0 0
0 1 1 0 0
0 1 1 0 0
0 0 0 0 0
Parameters
[in]mParent srsmatrix to attach to.
[in]nRowColRow and column to start from (CVM0 based).
[in]nDimDimension of square submatrix.

Definition at line 32325 of file cvm.h.

Member Function Documentation

template<typename TR>
TR basic_srsmatrix< TR >::operator() ( tint  nRow,
tint  nCol 
) const throw (cvmexception)
inline

Value of element (not l-value)

Operator returns value of a particular element of calling matrix by its row and column index. Indexes passed are CVM0 based. Operator throws cvmexception if nRow or nCol is outside of boundaries.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
double a[] = {1., 2., 3., 4., 5., 6.};
const rmatrix m (a, 2, 3);
std::cout << m(1,1) << " " << m(2,3) << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
1.00e+00 6.00e+00
See Also
http://cvmlib.com/faq.htm
Parameters
[in]nRowRow index (CVM0 based).
[in]nColColumn index (CVM0 based).
Returns
TR treal value.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32330 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
const RVector basic_srsmatrix< TR >::operator() ( tint  nCol) const throw (cvmexception)
inline

Column as not l-value.

Operator creates rvector object as a copy of nCol-th column (CVM0 based) of calling matrix. Operator throws cvmexception if nCol is outside of boundaries.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
double a[] = {1., 2., 3., 4., 5., 6.};
const rmatrix m (a, 2, 3);
std::cout << m(2) << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
3.00e+00 4.00e+00
Parameters
[in]nColIndex of column (CVM0 based).
Returns
rvector Column value.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32338 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
const RVector basic_srsmatrix< TR >::operator[] ( tint  nRow) const throw (cvmexception)
inline

Row as not l-value.

Operator creates rvector object as a copy of nRow-th row (CVM0 based) of calling matrix. Operator throws cvmexception if nRow is outside of boundaries.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
double a[] = {1., 2., 3., 4., 5., 6.};
const rmatrix m (a, 2, 3);
std::cout << m[1] << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
1.00e+00 3.00e+00 5.00e+00
Parameters
[in]nRowIndex of row (CVM0 based).
Returns
rvector Row value.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32345 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
const RVector basic_srsmatrix< TR >::diag ( tint  nDiag) const throw (cvmexception)
inline

Diagonal (not l-value)

Operator creates rvector object as a copy of nDiag-th diagonal of calling matrix where nDiag=0 for main diagonal, nDiag<0 for lower diagonals and nDiag>0 for upper ones. Operator throws cvmexception if nDiag is outside of boundaries.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
const rmatrix ms(a,3,3);
std::cout << ms << std::endl;
std::cout << ms.diag(0) << ms.diag(1);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
1 4 7
2 5 8
3 6 9
1 5 9
4 8
Parameters
[in]nDiagIndex of diagonal (0 for main diagonal, negative for lower, positive for upper one).
Returns
rvector Diagonal value.

Reimplemented from basic_rmatrix< TR >.

Definition at line 32353 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator= ( const basic_srsmatrix< TR > &  m) throw (cvmexception)
inline

Assignment operator.

Sets every element of calling srsmatrix to be equal to appropriate element of symmetric matrix m and returns reference to the matrix changed. Operator throws cvmexception in case of different matrix dimensions.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
const srsmatrix m1(a, 3);
srsmatrix m2(3);
m2 = m1;
std::cout << m2;
prints
1 2 3
2 5 6
3 6 9
Parameters
[in]msrsmatrix to assign from.
Returns
Reference to changed calling matrix.

Definition at line 32382 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator= ( basic_srsmatrix< TR > &&  m) throw (cvmexception)
inline

Move assignment operator.

Implements move semantics introduced in new C++ standard. Moves data ownership from other matrix to calling object. It's usually executed implicitly in cases like this:

a = b + c;

Here temporary result of calling b.operator+(c) will not be destroyed but rather moved to calling object a.

Parameters
[in]mrvalue reference to other matrix.

Definition at line 32402 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::assign ( const RVector v,
TR  tol = basic_cvmMachSp<TR>() 
) throw (cvmexception)
inline

Vector (as array) assignment.

Sets every element of calling symmetric matrix to be equal to appropriate element of rvector v as an array. Assignment is performed according to matrix storage (by columns). It's assumed that vector passed is long enough to fill calling matrix. Function throws cvmexception otherwise. Function also throws cvmexception if the matrix changed doesn't appear to be symmetric. Symmetry tolerance is set by parameter tol.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
rvector v(a,9);
srsmatrix m(3);
m.assign(v);
std::cout << m;
prints
1 2 3
2 5 6
3 6 9
Parameters
[in]vrvector to assign.
[in]tolSymmetry tolerance.
Returns
Reference to changed calling matrix.

Definition at line 32436 of file cvm.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::assign ( const TR *  pd,
TR  tol = basic_cvmMachSp<TR>() 
) throw (cvmexception)
inline

External array assignment.

Sets every element of calling symmetric matrix to be equal to appropriate element of array pointed to by parameter pd and returns reference to the matrix changed. Assignment is performed according to matrix storage (by columns). It's assumed that array passed is long enough to fill calling matrix. Function throws cvmexception if the matrix changed doesn't appear to be symmetric. Symmetry tolerance is set by parameter tol.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
srsmatrix m(3);
m.assign(a);
std::cout << m;
prints
1 2 3
2 5 6
3 6 9
Parameters
[in]pdConst pointer to external array.
[in]tolSymmetry tolerance.
Returns
Reference to changed calling matrix.

Definition at line 32473 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::assign ( tint  nRowCol,
const basic_srsmatrix< TR > &  m 
) throw (cvmexception)
inline

Assignment to submatrix.

Sets main submatrix of calling symmetric matrix beginning with row and column nRowCol to symmetric matrix m and returns reference to the matrix changed. Function throws cvmexception if nRowCol is not positive or matrix m doesn't fit. Indexes are CVM0 based.

Example:
using namespace cvm;
srsmatrix m1(5);
srsmatrix m2(2);
m1.set(1.);
m2.set(2.);
m1.assign(2,m2);
std::cout << m1;
prints
1 1 1 1 1
1 2 2 1 1
1 2 2 1 1
1 1 1 1 1
1 1 1 1 1
Parameters
[in]nRowColRow and column index (CVM0 based).
[in]mReference to symmetric matrix to assign.
Returns
Reference to changed calling matrix.

Definition at line 32510 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::set ( TR  d)
inline

Sets all elements to one value.

Sets every element of calling matrix to be equal to parameter d and returns reference to the matrix changed.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
rmatrix m(2, 3);
m.set(3.);
std::cout << m;
prints
3.00e+000 3.00e+000 3.00e+000
3.00e+000 3.00e+000 3.00e+000
Parameters
[in]dValue to set to.
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32518 of file cvm.h.

Here is the caller graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::set ( tint  nRow,
tint  nCol,
TR  d 
)
inline

Sets both elements to keep matrix symmetric.

Sets main submatrix of calling symmetric matrix beginning with row and column nRowCol to symmetric matrix m and returns reference to the matrix changed. Function throws cvmexception if nRowCol is out of boundaries (it's CVM0 based).

Example:
using namespace cvm;
srsmatrix m(3);
m.set(3.);
m.set(1,3,7.);
std::cout << m;
prints
3 3 7
3 3 3
7 3 3
Parameters
[in]nRowRow (and column) index to set (CVM0 based).
[in]nColColumn (and row) index to set (CVM0 based).
[in]dElement value to set to.
Returns
Reference to changed calling matrix.

Definition at line 32550 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::set_diag ( tint  nDiag,
const RVector vDiag 
) throw (cvmexception)
inline

Sets diagonal(s)

Assigns vector vDiag to $i$-th diagonal of calling matrix ( $i$ is passed in nDiag parameter), where $i=0$ for main diagonal, $i<0$ for lower diagonals and $i>0$ for upper ones. If $i\not=0$, then function assigns the vector to both $i$-th and $-i$-th diagonals (thus calling matrix remains symmetric). Function returns reference to the matrix changed. Function throws cvmexception if parameter nDiag is outside of boundaries or if vector vDiag passed has size not equal to msize()-abs(nDiag).

Example:
using namespace cvm;
srsmatrix m(3);
rvector v(2);
m.set(3.);
v.set(1.);
m.set_diag(1,v);
std::cout << m;
prints
3 1 3
1 3 1
3 1 3
Parameters
[in]nDiagDiagonal index to set.
[in]vDiagrvector to set diagonal(s) to.
Returns
Reference to changed calling matrix.

Definition at line 32586 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::resize ( tint  nNewDim) throw (cvmexception)
inline

Changes dimension.

Changes dimension of calling square matrix to nNewDim and returns reference to the matrix changed. In case of increasing of its size, the matrix is filled up with zeroes. Function throws cvmexception in case of negative dimension passed or memory allocation failure.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4.};
srmatrix m(a, 2);
std::cout << m << std::endl;
m.resize (3);
std::cout << m;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
1 3
2 4
1 3 0
2 4 0
0 0 0
Parameters
[in]nNewDimNew dimension.
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32595 of file cvm.h.

template<typename TR>
bool basic_srsmatrix< TR >::operator== ( const basic_srsmatrix< TR > &  m) const
inline

Matrix comparison.

Operator compares calling symmetric matrix with symmetric matrix m and returns true if they have same dimensions and their appropriate elements differ by not more than cvmMachMin() (the smallest normalized positive number). Returns false otherwise.

Example:
using namespace cvm;
double a[] = {1., 2., 2., 3.};
srsmatrix m1(a, 2);
srsmatrix m2(2);
m2.set(1,1,1.);
m2.set(1,2,2.);
m2.set(2,2,3.);
std::cout << (m1 == m2) << std::endl;
prints
1
See Also
operator !=()
Parameters
[in]msrsmatrix to compare to.
Returns
bool Result of comparison.

Definition at line 32628 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
bool basic_srsmatrix< TR >::operator!= ( const basic_srsmatrix< TR > &  m) const
inline

Matrix comparison.

Operator compares calling symmetric matrix with symmetric matrix m and returns true if they have different sizes or at least one of their appropriate elements differs by more than cvmMachMin() (the smallest normalized positive number). Returns false otherwise.

Example:
using namespace cvm;
double a[] = {1., 2., 2., 3.};
srsmatrix m1(a, 2);
srsmatrix m2(2);
m2.set(1,1,1.0001);
m2.set(1,2,2.);
m2.set(2,2,3.);
std::cout << (m1 != m2) << std::endl;
prints
1
See Also
operator ==()
Parameters
[in]msrsmatrix to compare to.
Returns
bool Result of comparison.

Definition at line 32659 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator<< ( const basic_srsmatrix< TR > &  m) throw (cvmexception)
inline

Matrix replacement.

Destroys calling symmetric matrix, creates a new one as a copy of m and returns reference to the matrix changed. Operator throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
srsmatrix m(a, 3);
srsmatrix mc(1);
std::cout << m << std::endl << mc << std::endl;
mc << m;
std::cout << mc;
prints
1 2 3
2 5 6
3 6 9
0
1 2 3
2 5 6
3 6 9
See Also
operator =()
Parameters
[in]msrsmatrix to replace by.
Returns
Reference to changed calling matrix.

Definition at line 32695 of file cvm.h.

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::operator+ ( const basic_srsmatrix< TR > &  m) const throw (cvmexception)
inline

Addition operator.

Creates object of type srsmatrix as sum of calling symmetric matrix and symmetric matrix m. Operator throws cvmexception in case of different sizes of the operands or memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
srsmatrix m1(a, 3);
srsmatrix m2(3);
m2.set(1.);
std::cout << m1 + m2 << std::endl << m1 + m1;
prints
2 3 4
3 6 7
4 7 10
2 4 6
4 10 12
6 12 18
See Also
sum()
Parameters
[in]msrsmatrix to add to calling one.
Returns
Sum of matrices.

Definition at line 32733 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::operator- ( const basic_srsmatrix< TR > &  m) const throw (cvmexception)
inline

Subtraction operator.

Creates object of type srsmatrix as difference of calling symmetric matrix and symmetric matrix m. It throws cvmexception in case of different sizes of the operands or memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
srsmatrix m1(a, 3);
srsmatrix m2(3);
m2.set(1.);
std::cout << m1 - m2 << std::endl << m1 - m1;
prints
0 1 2
1 4 5
2 5 8
0 0 0
0 0 0
0 0 0
See Also
diff()
Parameters
[in]msrsmatrix to subtract from calling one.
Returns
Difference of matrices.

Definition at line 32771 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::sum ( const basic_srsmatrix< TR > &  m1,
const basic_srsmatrix< TR > &  m2 
) throw (cvmexception)
inline

Sum of matrices.

Assigns sum of symmetric matrices m1 and m2 to calling symmetric matrix and returns reference to the matrices changed. It throws cvmexception in case of different sizes of the operands.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
const srsmatrix m1(a, 3);
srsmatrix m2(3);
srsmatrix m(3);
m2.set(1.);
std::cout << m.sum(m1, m2) << std::endl;
std::cout << m.sum(m, m2);
prints
2 3 4
3 6 7
4 7 10
3 4 5
4 7 8
5 8 11
See Also
operator +()
Parameters
[in]m1First srsmatrix summand.
[in]m2Second srsmatrix summand.
Returns
Reference to changed calling matrix.

Definition at line 32811 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::diff ( const basic_srsmatrix< TR > &  m1,
const basic_srsmatrix< TR > &  m2 
) throw (cvmexception)
inline

Difference of matrices.

Assigns difference of symmetric matrices m1 and m2 to calling symmetric matrix and returns reference to the matrix changed. It throws cvmexception in case of different sizes of the operands.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
const srsmatrix m1(a, 3);
srsmatrix m2(3);
srsmatrix m(3);
m2.set(1.);
std::cout << m.diff(m1, m2) << std::endl;
std::cout << m.diff(m, m2);
prints
0 1 2
1 4 5
2 5 8
-1 0 1
0 3 4
1 4 7
See Also
operator -()
Parameters
[in]m1First srsmatrix subtrahend.
[in]m2Second srsmatrix subtrahend.
Returns
Reference to changed calling matrix.

Definition at line 32851 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator+= ( const basic_srsmatrix< TR > &  m) throw (cvmexception)
inline

Increment operator.

Adds srsmatrix m to calling symmetric matrix and returns reference to the matrix changed. It throws cvmexception in case of different sizes of the operands.

Example:
using namespace cvm;
srsmatrix m1(3);
srsmatrix m2(3);
m1.set(1.);
m2.set(2.);
m1 += m2;
std::cout << m1 << std::endl;
// well, you can do this too, but temporary object would be created
m2 += m2;
std::cout << m2;
prints
3 3 3
3 3 3
3 3 3
4 4 4
4 4 4
4 4 4
See Also
operator +()
sum()
Parameters
[in]msrsmatrix to increment by.
Returns
Reference to changed calling matrix.

Definition at line 32895 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator-= ( const basic_srsmatrix< TR > &  m) throw (cvmexception)
inline

Decrement operator.

Subtracts srsmatrix m from calling symmetric matrix and returns reference to the matrix changed. It throws cvmexception in case of different sizes of the operands.

Example:
using namespace cvm;
srsmatrix m1(3);
srsmatrix m2(3);
m1.set(1.);
m2.set(2.);
m1 -= m2;
std::cout << m1 << std::endl;
// well, you can do this too, but temporary object would be created
m2 -= m2;
std::cout << m2;
prints
-1 -1 -1
-1 -1 -1
-1 -1 -1
0 0 0
0 0 0
0 0 0
See Also
operator -()
diff()
Parameters
[in]msrsmatrix to decrement by.
Returns
Reference to changed calling matrix.

Definition at line 32938 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::operator- ( ) const
inline

Unary minus operator.

Creates object of type srsmatrix as calling symmetric matrix multiplied by -1. It throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
srsmatrix m(a, 3);
std::cout << -m;
prints
-1 -2 -3
-2 -5 -6
-3 -6 -9
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32966 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator++ ( )
inline

Plus identity, prefix.

Adds identity matrix to calling square matrix and returns reference to the matrix changed.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
srmatrix m (a, 3);
m++;
std::cout << m << std::endl;
std::cout << ++m;
prints
2 4 7
2 6 8
3 6 10
3 4 7
2 7 8
3 6 11
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32975 of file cvm.h.

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::operator++ ( int  )
inline

Plus identity, postfix.

Adds identity matrix to calling square matrix and returns reference to the matrix changed.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
srmatrix m (a, 3);
m++;
std::cout << m << std::endl;
std::cout << ++m;
prints
2 4 7
2 6 8
3 6 10
3 4 7
2 7 8
3 6 11
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32982 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator-- ( )
inline

Minus identity, prefix.

Subtracts identity matrix from calling square matrix and returns reference to the matrix changed.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
srmatrix m (a, 3);
m--;
std::cout << m << std::endl;
std::cout << --m;
prints
0 4 7
2 4 8
3 6 8
-1 4 7
2 3 8
3 6 7
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32989 of file cvm.h.

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::operator-- ( int  )
inline

Minus identity, postfix.

Subtracts identity matrix from calling square matrix and returns reference to the matrix changed.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
srmatrix m (a, 3);
m--;
std::cout << m << std::endl;
std::cout << --m;
prints
0 4 7
2 4 8
3 6 8
-1 4 7
2 3 8
3 6 7
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 32996 of file cvm.h.

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::operator* ( TR  dMult) const
inline

Multiply by number operator.

Creates object of type srmatrix as product of calling square matrix and number dMult. It throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
srmatrix m(a, 3);
std::cout << m * 5.;
prints
5 20 35
10 25 40
15 30 45
See Also
operator *=()
Parameters
[in]dMultNumber to multiply by.
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33002 of file cvm.h.

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::operator/ ( TR  dDiv) const throw (cvmexception)
inline

Divide by number operator.

Creates object of type srmatrix as quotient of calling square matrix and number dDiv. It throws cvmexception if dDiv has absolute value equal or less than cvmMachMin() (the smallest normalized positive number). It also throws exception in case of memory allocation failure.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
srmatrix m(a, 3);
std::cout << m / 4.;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
0.25 1 1.75
0.5 1.25 2
0.75 1.5 2.25
See Also
operator /=()
Parameters
[in]dDivNumber to divide by.
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33009 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator*= ( TR  dMult)
inline

Multiply by number and assign.

Multiplies calling matrix by number dMult and returns reference to the matrix changed.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6.};
rmatrix m(a, 2, 3);
m *= 2.;
std::cout << m;
prints
2 6 10
4 8 12
See Also
operator *(TR) const
Parameters
[in]dMultNumber to multiply by.
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33016 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::operator/= ( TR  dDiv) throw (cvmexception)
inline

Divide by number and assign.

Divides calling matrix by number dDiv and returns reference to the matrix changed. It throws cvmexception if dDiv has absolute value equal or less than cvmMachMin() (the smallest normalized positive number).

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
double a[] = {1., 2., 3., 4., 5., 6.};
rmatrix m(a, 2, 3);
m /= 2.;
std::cout << m;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
5.00e-01 1.50e+00 2.50e+00
1.00e+00 2.00e+00 3.00e+00
See Also
operator /(TR) const
Parameters
[in]dDivNumber to divide by.
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33022 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::normalize ( )
inline

Matrix normalizer.

Normalizes calling matrix so its Euclidean norm() becomes equal to 1 if it was greater than cvmMachMin() (the smallest normalized positive number) before the call. Does nothing otherwise.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
double a[] = {1., 2., 3., 4., 5., 6.};
rmatrix m(a, 2, 3);
m.normalize();
std::cout << m << m.norm() << std::endl;
prints
1.05e-01 3.14e-01 5.24e-01
2.10e-01 4.19e-01 6.29e-01
1
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33028 of file cvm.h.

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::operator~ ( ) const
inline

Does nothing and returns copy of calling symmetric matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33037 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::transpose ( const basic_srsmatrix< TR > &  m) throw (cvmexception)
inline

Assigns symmetric matrix m to calling one and returns reference to the matrix changed.

Definition at line 33044 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::transpose ( )
inline

Does nothing and returns reference to calling symmetric matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33053 of file cvm.h.

template<typename TR>
RVector basic_srsmatrix< TR >::operator* ( const RVector v) const throw (cvmexception)
inline

Matrix-vector product.

Creates object of type rvector as product of calling matrix and vector v. Function throws cvmexception if the number of columns of the calling matrix differs from size of the vector v. Use basic_rvector::mult(const basic_rmatrix<TR>&,const basic_rvector<TR>&) to avoid new object creation.

Example:
using namespace cvm;
try {
rmatrix m(2, 3);
rvector v(3);
m.set(1.);
v.set(1.);
std::cout << m * v;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
3 3
See Also
basic_rvector::mult(const basic_rmatrix<TR>&,const basic_rvector<TR>&)
Parameters
[in]vrvector to compute product with.
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33057 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
BaseRMatrix basic_srsmatrix< TR >::operator* ( const BaseRMatrix m) const throw (cvmexception)
inline

Matrix-matrix product.

Creates object of type rmatrix as product of calling square matrix and matrix m. Operator throws cvmexception if number of columns of calling matrix differs from number of rows of the matrix m. Use mult() to avoid new object creation.

Example:
using namespace cvm;
try {
srmatrix ms(3);
rmatrix m(3,2);
ms.set(1.);
m.set(1.);
std::cout << ms * m;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
3 3
3 3
3 3
Parameters
[in]mrmatrix to compute product with.
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33066 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
BaseSRMatrix basic_srsmatrix< TR >::operator* ( const BaseSRMatrix m) const throw (cvmexception)
inline

Matrix-matrix product.

Creates object of type srmatrix as product of calling symmetric matrix and square matrix m. Operator throws cvmexception if dimension of calling matrix differs from dimension the matrix m. Use mult() to avoid new object creation.

Example:
using namespace cvm;
try {
srsmatrix ms(3);
srmatrix m(3);
ms.set(1.);
m.set(2.);
std::cout << ms * m << std::endl;
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.};
const srsmatrix ms2(a, 3);
std::cout << ms2 * ms;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
6 6 6
6 6 6
6 6 6
6 6 6
13 13 13
18 18 18
Parameters
[in]msrmatrix to compute product with.
Returns
Result object.

Definition at line 33113 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
RVector basic_srsmatrix< TR >::operator/ ( const RVector vB) const throw (cvmexception)
inline

Linear solver operator.

Creates rvector object as solution $x$ of linear equation $A*x=b$ where calling matrix is square matrix $A$ and parameter vB is vector $b$. Operator throws cvmexception in case of inappropriate sizes of the operands or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (12);
try {
double m[] = {1., -1., 1., 2., -2., 1., 3., -2., 1.};
double b[] = {1., 2., 3.};
srmatrix ma(m, 3);
rvector vb(b, 3);
rvector vx(3);
vx = ma / vb;
std::cout << ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
+0.000000000000e+000 +0.000000000000e+000 +0.000000000000e+000
Parameters
[in]vBrvector $b$.
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33125 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::syrk ( TR  alpha,
const RVector v,
TR  beta 
) throw (cvmexception)
inline

Rank-1 update matrix-vector operation.

Calls one of DSYRK routines of the BLAS library performing rank-1 update matrix-vector operation defined as

\[ A=\alpha\,\begin{pmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{pmatrix} \begin{pmatrix} v_1 & v_2 & \cdots & x_n \end{pmatrix} + \beta A, \]

where $\alpha$ and $\beta$ are real numbers (parameters alpha and beta), $A$ is calling symmetric matrix and $v$ is real vector (parameter v). Function returns reference to the matrix changed and throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
const treal alpha = 2.12;
const treal beta = -3.07;
rvector v(3);
srsmatrix ms(3), ms2(3);
v.randomize(-3.,2.);
ms.randomize(-1.,2.);
ms2 = ms;
ms.syrk (alpha, v, beta);
ms2 = alpha * srsmatrix(v.rank1update(v)) + beta * ms2;
std::cout << ms - ms2;
prints
0 0 0
0 0 0
0 0 0
See Also
http://www.netlib.org/blas
Parameters
[in]alphaMultiplier $\alpha$.
[in]vrvector $v$.
[in]betaMultiplier $\beta$.
Returns
Reference to changed calling matrix.

Definition at line 33176 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::syrk ( bool  bTransp,
TR  alpha,
const BaseRMatrix m,
TR  beta 
) throw (cvmexception)
inline

Rank-1 update matrix-matrix operation.

Calls one of DSYRK routines of the BLAS library performing rank-1 update matrix-vector operation defined as

\[ A=\alpha MM^T + \beta A\quad\text{or}\quad A=\alpha M^TM + \beta A. \]

where $\alpha$ and $\beta$ are real numbers (parameters alpha and beta), $A$ is calling symmetric matrix and $M$ is real matrix (parameter m). First operation is performed if bTransp passed is false and second one otherwise. Function returns reference to the matrix changed and throws cvmexception in case of inappropriate sizes of the operands.

Example 1:
using namespace cvm;
const treal alpha = 2.12;
const treal beta = -3.07;
rmatrix m(3,3);
srsmatrix ms(3), ms2(3);
m.randomize(-1.,2.);
ms.randomize(-1.,2.);
ms2 = ms;
ms.syrk (false, alpha, m, beta);
ms2 = alpha * srsmatrix (m * ~m) + beta * ms2;
std::cout << ms - ms2;
prints
0 0 0
0 0 0
0 0 0
Example 2:
using namespace cvm;
const treal alpha = 2.12;
const treal beta = -3.07;
rmatrix m(3,3);
srsmatrix ms(3), ms2(3);
m.randomize(-1.,2.);
ms.randomize(-1.,2.);
ms2 = ms;
ms.syrk (true, alpha, m, beta);
ms2 = alpha * srsmatrix (~m * m) + beta * ms2;
std::cout << ms - ms2;
prints
0 0 0
0 0 0
0 0 0
See Also
http://www.netlib.org/blas
Parameters
[in]bTranspUse transposed operation.
[in]alphaMultiplier $\alpha$.
[in]mrmatrix $M$.
[in]betaMultiplier $\beta$.
Returns
Reference to changed calling matrix.

Definition at line 33246 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::syr2k ( TR  alpha,
const RVector v1,
const RVector v2,
TR  beta 
) throw (cvmexception)
inline

Rank-1 update matrix-vector operation.

Calls SSYR2K or DSYR2K routine of the BLAS library performing rank-1 update matrix-vector operation defined as

\[ A=\alpha v_1 v_2' + \alpha v_2 v_1' + \beta A, \]

where $\alpha$ and $\beta$ are real numbers (parameters alpha and beta), $A$ is calling symmetric matrix and $v_1$ and $v_2$ are real vectors (parameters v1 and v2). Function returns reference to the matrix changed and throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
const treal alpha = 2.12;
const treal beta = -3.07;
rvector v1(4);
rvector v2(4);
srsmatrix ms(4), ms2(4);
v1.randomize(-1.,3.);
v2.randomize(-1.,3.);
ms.randomize(-1.,3.);
ms2 = ms;
ms.syr2k (alpha, v1, v2, beta);
ms2 = alpha * srsmatrix(v1.rank1update(v2) + v2.rank1update(v1)) + beta * ms2;
std::cout << ms - ms2;
prints
+0.00e+000 -1.33e-015 +0.00e+000 +0.00e+000
-1.33e-015 +0.00e+000 +4.44e-016 +0.00e+000
+0.00e+000 +4.44e-016 -5.55e-017 +0.00e+000
+0.00e+000 +0.00e+000 +0.00e+000 -8.88e-016
See Also
http://www.netlib.org/blas
Parameters
[in]alphaMultiplier $\alpha$.
[in]v1rvector $v_1$.
[in]v2rvector $v_2$.
[in]betaMultiplier $\beta$.
Returns
Reference to changed calling matrix.

Definition at line 33299 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::syr2k ( bool  bTransp,
TR  alpha,
const BaseRMatrix m1,
const BaseRMatrix m2,
TR  beta 
) throw (cvmexception)
inline

Rank-1 update matrix-matrix operation.

Calls SSYR2K or DSYR2K routine of the BLAS library performing rank-1 update matrix-matrix operation defined as

\[ A=\alpha M_1 M_2^T + \alpha M_2 M_1^T + \beta A\quad \text{or}\quad A=\alpha M_1^T M_2 + \alpha M_2^T M_1 + \beta A. \]

where $\alpha$ and $\beta$ are real numbers (parameters alpha and beta), $A$ is calling symmetric matrix and $M_1$ and $M_2$ are real matrices (parameters m1 and m2). First operation is performed if bTransp passed is false and second one otherwise. Function returns reference to the matrix changed and throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
const treal alpha = 2.12;
const treal beta = -3.07;
rmatrix m1(3,3), m2(3,3);
srsmatrix ms(3), ms2(3);
m1.randomize(-2.,2.);
m2.randomize(-2.,2.);
ms.randomize(-1.,2.);
ms2 = ms;
ms.syr2k (false, alpha, m1, m2, beta);
ms2 = alpha * srsmatrix (m1 * ~m2 + m2 * ~m1) + beta * ms2;
std::cout << ms - ms2;
prints
+1.11e-015 +0.00e+000 +0.00e+000
+0.00e+000 +8.88e-016 +1.78e-015
+0.00e+000 +1.78e-015 -1.78e-015
Example:
using namespace cvm;
const treal alpha = 2.12;
const treal beta = -3.07;
rmatrix m1(3,3), m2(3,3);
srsmatrix ms(3), ms2(3);
m1.randomize(-2.,2.);
m2.randomize(-2.,2.);
ms.randomize(-1.,2.);
ms2 = ms;
ms.syr2k (true, alpha, m1, m2, beta);
ms2 = alpha * srsmatrix (~m1 * m2 + ~m2 * m1) + beta * ms2;
std::cout << ms - ms2;
prints
+0.00e+000 +1.78e-015 +0.00e+000
+1.78e-015 +0.00e+000 +1.33e-015
+0.00e+000 +1.33e-015 +0.00e+000
See Also
http://www.netlib.org/blas
Parameters
[in]bTranspUse transposed version of the operation.
[in]alphaMultiplier $\alpha$.
[in]m1rmatrix $M_1$.
[in]m2rmatrix $M_2$.
[in]betaMultiplier $\beta$.
Returns
Reference to changed calling matrix.

Definition at line 33376 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::inv ( const basic_srsmatrix< TR > &  m) throw (cvmexception)
inline

Matrix inversion.

This version sets calling matrix to be equal to symmetric matrix m inverted. Function throws cvmexception in case of inappropriate sizes of the operands or when the matrix to be inverted is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (5);
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.05};
const srsmatrix m(a, 3);
srsmatrix mi(3);
mi.inv(m);
std::cout << mi << std::endl;
std::cout << mi * m - eye_real(3);
prints
1.85000e+002 -2.00000e+000 -6.00000e+001
-2.00000e+000 1.00000e+000 -0.00000e+000
-6.00000e+001 -0.00000e+000 2.00000e+001
0.00000e+000 0.00000e+000 0.00000e+000
0.00000e+000 0.00000e+000 0.00000e+000
0.00000e+000 0.00000e+000 0.00000e+000
Parameters
[in]msrsmatrix to invert.
Returns
Reference to changed calling matrix.

Definition at line 33423 of file cvm.h.

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::inv ( ) const throw (cvmexception)
inline

Matrix inversion.

This version creates srsmatrix object equal to calling symmetric matrix inverted. Function throws cvmexception in case of memory allocation failure or when the matrix to be inverted is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (5);
double a[] = {1., 2., 3., 2., 5., 6., 3., 6., 9.05};
const srsmatrix m(a, 3);
const srsmatrix mi = m.inv();
std::cout << mi << std::endl;
std::cout << mi * m - eye_real(3);
prints
1.85000e+002 -2.00000e+000 -6.00000e+001
-2.00000e+000 1.00000e+000 0.00000e+000
-6.00000e+001 0.00000e+000 2.00000e+001
0.00000e+000 0.00000e+000 0.00000e+000
0.00000e+000 0.00000e+000 0.00000e+000
0.00000e+000 0.00000e+000 0.00000e+000
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33458 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::exp ( const basic_srsmatrix< TR > &  m,
TR  tol = basic_cvmMachSp<TR>() 
) throw (cvmexception)
inline

Matrix exponent.

Computes exponent of symmetric matrix using Pade approximation defined as

\[ R_{pq}(z)=D_{pq}(z)^{-1}N_{pq}(z)=1+z+\dots+z^p/p!\,, \]

where

\[\begin{aligned} N_{pq}(z)&=\sum_{k=0}^p\frac{(p+q-k)!p!}{(p+q)!k!(q-k)!}z^k,\\ D_{pq}(z)&=\sum_{k=0}^q\frac{(p+q-k)!p!}{(p+q)!k!(q-k)!}(-z)^k \end{aligned}\]

along with the matrix normalizing as described in Gene H. Golub, Charles F. Van Loan. Matrix Computations, The Johns Hopkins University Press, 1996, 694~p., ISBN 0-8018-5413-X, p. 572. Function uses DMEXP (or SMEXP for float version) FORTRAN subroutine implementing the algorithm. This version sets calling matrix to be equal to exponent of symmetric matrix m and returns reference to the matrix changed. The algorithm uses parameter tol as $\varepsilon(p,q)$ in order to choose constants $p$ and $q$ so that

\[ \varepsilon(p,q)\ge 2^{3-(p+q)}\frac{p!q!}{(p+q)!(p+q+1)!}. \]

This parameter is equal to the largest relative spacing (see cvmMachSp() ) by default. Function throws cvmexception in case of inappropriate sizes of the operands or when LAPACK subroutine fails.

Example
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (15);
double a[] = {1., 2., 1., 2., 0., -1., 1., -1., 2.};
const srsmatrix m(a, 3);
srsmatrix me(3);
me.exp(m);
std::cout << me;
prints
9.198262499129191e+000 5.558586002658862e+000 3.852443363622595e+000
5.558586002658862e+000 5.345819135506598e+000 -1.706142639036265e+000
3.852443363622593e+000 -1.706142639036266e+000 1.090440513816545e+001
Matlab output:
Columns 1 through 2
9.198262499129212e+000 5.558586002658862e+000
5.558586002658865e+000 5.345819135506588e+000
3.852443363622600e+000 -1.706142639036258e+000
Column 3
3.852443363622601e+000
-1.706142639036260e+000
1.090440513816545e+001
Parameters
[in]msrsmatrix to compute exponent for.
[in]tolComputation tolerance.
Returns
Reference to changed calling matrix.

Definition at line 33526 of file cvm.h.

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::exp ( TR  tol = basic_cvmMachSp<TR>()) const throw (cvmexception)
inline

Matrix exponent.

Computes exponent of symmetric matrix using Pade approximation defined as

\[ R_{pq}(z)=D_{pq}(z)^{-1}N_{pq}(z)=1+z+\dots+z^p/p!\,, \]

where

\[\begin{aligned} N_{pq}(z)&=\sum_{k=0}^p\frac{(p+q-k)!p!}{(p+q)!k!(q-k)!}z^k,\\ D_{pq}(z)&=\sum_{k=0}^q\frac{(p+q-k)!p!}{(p+q)!k!(q-k)!}(-z)^k \end{aligned}\]

along with the matrix normalizing as described in Gene H. Golub, Charles F. Van Loan. Matrix Computations, The Johns Hopkins University Press, 1996, 694~p., ISBN 0-8018-5413-X, p. 572. Function uses DMEXP (or SMEXP for float version) FORTRAN subroutine implementing the algorithm. This version creates object of type srsmatrix as exponent of calling symmetric matrix. The algorithm uses parameter tol as $\varepsilon(p,q)$ in order to choose constants $p$ and $q$ so that

\[ \varepsilon(p,q)\ge 2^{3-(p+q)}\frac{p!q!}{(p+q)!(p+q+1)!}. \]

This parameter is equal to the largest relative spacing (see cvmMachSp() ) by default. Function throws cvmexception in case of inappropriate sizes of the operands or when LAPACK subroutine fails.

Example
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (15);
double a[] = {1., 2., 1., 2., 0., -1., 1., -1., 2.};
const srsmatrix m(a, 3);
std::cout << m.exp();
prints
9.198262499129184e+000 5.558586002658855e+000 3.852443363622591e+000
5.558586002658857e+000 5.345819135506593e+000 -1.706142639036265e+000
3.852443363622590e+000 -1.706142639036266e+000 1.090440513816545e+001
Matlab output:
Columns 1 through 2
9.198262499129212e+000 5.558586002658862e+000
5.558586002658865e+000 5.345819135506588e+000
3.852443363622600e+000 -1.706142639036258e+000
Column 3
3.852443363622601e+000
-1.706142639036260e+000
1.090440513816545e+001
Parameters
[in]tolComputation tolerance.
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33589 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::polynom ( const basic_srsmatrix< TR > &  m,
const RVector v 
) throw (cvmexception)
inline

Matrix polynomial.

Computes symmetric matrix polynomial defined as

\[ p(A)=b_0I+b_1A+\dots+b_qA^q \]

using the Horner's rule:

\[ \newcommand{\floor}{\operatorname{floor}}p(A)=\sum_{k=0}^r B_k(A^s)^k,\quad s=\floor(\!\sqrt{q}\,),\ r=\floor(q/s) \]

where

\[ B_k=\begin{cases} \sum\limits_{i=0}^{s-1}b_{sk+i} A^i, & k=0,1,\dots,r-1\\ \sum\limits_{i=0}^{q-sr}b_{sr+i} A^i, & k=r. \end{cases} \]

See also Gene H. Golub, Charles F. Van Loan. Matrix Computations, The Johns Hopkins University Press, 1996, 694~p., ISBN 0-8018-5413-X, p. 568. The coefficients $b_0,b_1,\dots,b_q$ are passed in parameter v, where $q$ is equal to v.size()-1, so the function computes matrix polynomial equal to

\[ \mathtt{v[1]*I + v[2]*m +\cdots + v[v.size()]*m^{v.size()-1}} \]

This version sets calling matrix to be equal to the polynomial of symmetric matrix m. Function uses DPOLY (or SPOLY for float version) FORTRAN subroutine implementing the Horner's algorithm. Function throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (7);
double a[] = {1., 2., 1., 2., 0., -1., 1., -1., 2.};
double av[] = {2.2, 1.3, 1.1, -0.9, 0.2,
-0.45, 45, -30, 10, 3, 3.2};
const rvector v(av, 11);
const srsmatrix m(a, 3);
mp.polynom(m,v);
std::cout << mp;
prints
6.2127400e+004 2.3998000e+004 3.4100550e+004
2.3998000e+004 2.8026850e+004 1.0102550e+004
3.4100550e+004 1.0102550e+004 5.2024850e+004
Matlab output:
Columns 1 through 2
6.212740000000001e+004 2.399800000000000e+004
2.399800000000000e+004 2.802685000000000e+004
3.410055000000000e+004 1.010255000000000e+004
Column 3
3.410055000000000e+004
1.010255000000000e+004
5.202485000000000e+004
Parameters
[in]msrsmatrix to compute polynomial for.
[in]vVector of coefficients.
Returns
Reference to changed calling matrix.

Definition at line 33663 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srsmatrix basic_srsmatrix< TR >::polynom ( const RVector v) const
inline

Matrix polynomial.

Computes symmetric matrix polynomial defined as

\[ p(A)=b_0I+b_1A+\dots+b_qA^q \]

using the Horner's rule:

\[ \newcommand{\floor}{\operatorname{floor}}p(A)=\sum_{k=0}^r B_k(A^s)^k,\quad s=\floor(\!\sqrt{q}\,),\ r=\floor(q/s) \]

where

\[ B_k=\begin{cases} \sum\limits_{i=0}^{s-1}b_{sk+i} A^i, & k=0,1,\dots,r-1\\ \sum\limits_{i=0}^{q-sr}b_{sr+i} A^i, & k=r. \end{cases} \]

See also Gene H. Golub, Charles F. Van Loan. Matrix Computations, The Johns Hopkins University Press, 1996, 694~p., ISBN 0-8018-5413-X, p. 568. The coefficients $b_0,b_1,\dots,b_q$ are passed in parameter v, where $q$ is equal to v.size()-1, so the function computes matrix polynomial equal to

\[ \mathtt{v[1]*I + v[2]*m +\cdots + v[v.size()]*m^{v.size()-1}} \]

This version creates object of type srsmatrix as the polynomial of calling symmetric matrix. Function uses DPOLY (or SPOLY for float version) FORTRAN subroutine implementing the Horner's algorithm. Function throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (7);
double a[] = {1., 2., 1., 2., 0., -1., 1., -1., 2.};
double av[] = {2.2, 1.3, 1.1, -0.9, 0.2,
-0.45, 45, -30, 10, 3, 3.2};
const rvector v(av, 11);
const srsmatrix m(a, 3);
std::cout << m.polynom (v);
prints
6.2127400e+004 2.3998000e+004 3.4100550e+004
2.3998000e+004 2.8026850e+004 1.0102550e+004
3.4100550e+004 1.0102550e+004 5.2024850e+004
Matlab output:
Columns 1 through 2
6.212740000000001e+004 2.399800000000000e+004
2.399800000000000e+004 2.802685000000000e+004
3.410055000000000e+004 1.010255000000000e+004
Column 3
3.410055000000000e+004
1.010255000000000e+004
5.202485000000000e+004
Parameters
[in]vVector of coefficients.
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33736 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
RVector basic_srsmatrix< TR >::eig ( BaseSRMatrix mEigVect) const throw (cvmexception)
inline

Eigenvalues and eigenvectors.

Solves symmetric eigenvalue problem and creates rvector object equal to eigenvalues of calling matrix. The symmetric eigenvalue problem is defined as follows: given symmetric matrix $A$, find the eigenvalues $\lambda$ and the corresponding eigenvectors $z$ that satisfy the equation

\[ Az = \lambda z. \]

Eigenvalues and eigenvectors of symmetric real matrix $A$ are real. Function sets output parameter mEigVect to be equal to square matrix containing eigenvectors as columns. Function throws cvmexception in case of inappropriate calling object sizes or in case of convergence error.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (10);
double a[] = {1., 2., 1., 2., 0., -1., 1., -1., 2.};
const srsmatrix m(a, 3);
srmatrix me(3);
rvector v(3);
v = m.eig(me);
std::cout << v << std::endl;
std::cout << m * me(1) - me(1) * v(1);
std::cout << m * me(2) - me(2) * v(2);
std::cout << m * me(3) - me(3) * v(3);
prints
-2.0489173395e+000 2.3568958679e+000 2.6920214716e+000
4.4408920985e-016 0.0000000000e+000 5.5511151231e-016
-1.1102230246e-016 2.2204460493e-016 2.2204460493e-016
0.0000000000e+000 -1.1102230246e-016 -4.4408920985e-016
See Also
rvector::eig()
Parameters
[out]mEigVectEigenvectors of calling symmetric matrix.
Returns
Result object.

Definition at line 33787 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
RVector basic_srsmatrix< TR >::eig ( ) const throw (cvmexception)
inline

Eigenvalues.

Solves symmetric eigenvalue problem and creates rvector object equal to eigenvalues of calling symmetric matrix. The eigenvalue problem is defined as follows: given symmetric matrix $A$, find the eigenvalues $\lambda$ and the corresponding eigenvectors $z$ that satisfy the equation

\[ Az = \lambda z. \]

Eigenvalues and eigenvectors of symmetric real matrix $A$ are real. Function throws cvmexception in case of memory allocation failure or convergence error.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (10);
double a[] = {1., 2., 1., 2., 0., -1., 1., -1., 2.};
const srsmatrix m(a, 3);
std::cout << m.eig();
prints
-2.0489173395e+000 2.3568958679e+000 2.6920214716e+000
See Also
rvector::eig()
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33824 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
BaseSRMatrix basic_srsmatrix< TR >::cholesky ( ) const throw (cvmexception)
inline

Cholesky factorization.

Forms the Cholesky factorization of symmetric positive-definite calling matrix $A$ defined as

\[ A=U^T U, \]

where $U$ is upper triangular matrix. It utilizes one of DPOTRF routines of the LAPACK library. Function creates srmatrix object equal to the factorization. Function throws cvmexception in case of convergence error.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 1., 2., 5., -1., 1., -1., 20.};
const srsmatrix m(a, 3);
srmatrix h = m.cholesky();
std::cout << h << std::endl;
std::cout << ~h * h - m;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
1 2 1
0 1 -3
0 0 3.16228
0 0 0
0 0 0
0 0 0
See Also
http://www.netlib.org/lapack
basic_srmatrix::cholesky()
Returns
Result object.

Definition at line 33870 of file cvm.h.

template<typename TR>
BaseSRMatrix basic_srsmatrix< TR >::bunch_kaufman ( tint nPivots) const throw (cvmexception)
inline

Bunch-Kaufman factorization.

Forms the Bunch-Kaufman factorization of symmetric calling matrix (cited from the MKL library documentation):

\[ A=PUDU^TP^T, \]

where $A$ is calling symmetric matrix, $P$ is a permutation matrix, $U$ and $L$ are upper and lower triangular matrices with unit diagonal, and $D$ is a symmetric block-diagonal matrix with 1-by-1 and 2-by-2 diagonal blocks. $U$ and $L$ have 2-by-2 unit diagonal blocks corresponding to the 2-by-2 blocks of $D$. It utilizes one of DSYTRF routines of the LAPACK library. Function creates srmatrix object equal to the factorization of symmetric calling matrix. Function throws cvmexception in case of convergence error. Function is mostly designed to be used for subsequent calls of DSYTRS, DSYCON and DSYTRI routines of the LAPACK library. Currently it's used internally in det() flow when argument is symmetric but not positive-definite.

See Also
http://www.netlib.org/lapack
basic_srmatrix::bunch_kaufman()
Parameters
[out]nPivotsPivot indices array.
Returns
Result object.

Definition at line 33908 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::identity ( )
inline

Identity matrix.

Sets calling matrix to be equal to identity matrix and returns reference to the matrix changed.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (3);
srmatrix m(3);
m.randomize(0.,1.);
std::cout << m << std::endl;
std::cout << m.identity();
prints
9.423e-01 2.950e-01 8.429e-01
2.013e-01 3.250e-01 2.904e-01
7.920e-01 2.405e-02 7.801e-01
1.000e+00 0.000e+00 0.000e+00
0.000e+00 1.000e+00 0.000e+00
0.000e+00 0.000e+00 1.000e+00
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33915 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::vanish ( )
inline

Set matrix to zero.

Sets every element of calling square matrix to be equal to zero and returns reference to the matrix changed. This function is faster than, for example, set(TR) with zero parameter passed.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (3);
srmatrix m(3);
m.randomize(0.,1.);
std::cout << m << std::endl;
std::cout << m.vanish ();
prints
1.747e-01 7.563e-01 5.163e-01
9.657e-01 6.619e-01 8.036e-01
6.392e-01 6.658e-01 6.495e-01
0.000e+00 0.000e+00 0.000e+00
0.000e+00 0.000e+00 0.000e+00
0.000e+00 0.000e+00 0.000e+00
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33922 of file cvm.h.

template<typename TR>
basic_srsmatrix& basic_srsmatrix< TR >::randomize ( TR  dFrom,
TR  dTo 
)
inline

Randomizer.

Fills calling matrix with pseudo-random numbers distributed between dFrom and dTo. Function returns reference to the matrix changed.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (7);
rmatrix m(3,4);
m.randomize(-2.,3.);
std::cout << m;
prints
9.6853542e-01 2.7761467e+00 2.3791009e+00 -3.4452345e-01
2.9029511e+00 -9.5519883e-01 -4.9131748e-01 -1.2561113e+00
1.5219886e+00 -1.4494461e+00 2.8193304e+00 4.8817408e-01
Parameters
[in]dFromFirst limit.
[in]dToSecond limit.
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 33928 of file cvm.h.

template<typename TR>
TR basic_srsmatrix< TR >::norminf ( ) const
inlineoverridevirtual

Infinity norm.

Infinity norm of calling array that for vectors is defined as

\[ {\|x\|}_\infty=\max_{i=1,\dots,n} |x_i| \]

and for matrices as

\[ {\|A\|}_\infty=\max_{i=1,\dots,m} \sum_{j=1}^{n} |a_{ij}|, \]

Example:
using namespace cvm;
double a[] = {1., 2., 3., -4., 5., -6.};
const rvector v (a, 3);
const rmatrix m (a, 2, 3);
std::cout << v << v.norminf () << std::endl;
std::cout << m << m.norminf () << std::endl;
prints
1 2 3
3
1 3 5
2 -4 -6
12
Returns
treal Norm value

Reimplemented from Matrix< TR, TR >.

Definition at line 33935 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
bool basic_srsmatrix< TR >::is_positive_definite ( ) const
inline

Is calling symmetric matrix positive definite?

Returns
true if calling symmetric matrix is positive definite.

Definition at line 33944 of file cvm.h.

template<typename TR>
bool basic_srsmatrix< TR >::equilibrate ( RVector vScalings,
RVector vB 
) throw (cvmexception)
inline

Matrix equilibration.

Useful for further solve and solve_lu calling.

Returns
true if equilibration was needed and performed.

Definition at line 33966 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
bool basic_srsmatrix< TR >::equilibrate ( RVector vScalings,
BaseRMatrix mB 
) throw (cvmexception)
inline

Matrix equilibration.

Useful for further solve and solve_lu calling.

Returns
true if equilibration was needed and performed.

Definition at line 33985 of file cvm.h.

Here is the call graph for this function:


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