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_scmatrix< TR, TC > Class Template Reference

End-user class encapsulating square matrix of complex numbers. More...

#include <cvm.h>

Inheritance diagram for basic_scmatrix< TR, TC >:
Inheritance graph
[legend]
Collaboration diagram for basic_scmatrix< TR, TC >:
Collaboration graph
[legend]

Public Member Functions

 basic_scmatrix ()
 Default constructor.
 basic_scmatrix (tint nDim)
 Constructor.
 basic_scmatrix (TC *pd, tint nDim)
 Constructor.
 basic_scmatrix (const TC *pd, tint nDim)
 Constructor.
 basic_scmatrix (const basic_scmatrix &m)
 Copy constructor.
 basic_scmatrix (basic_scmatrix &&m) noexcept
 Move constructor.
 basic_scmatrix (const BaseCMatrix &m)
 Constructor.
 basic_scmatrix (const CVector &v)
 Constructor.
 basic_scmatrix (const basic_srmatrix< TR > &m, bool bRealPart=true)
 Constructor.
 basic_scmatrix (const TR *pRe, const TR *pIm, tint nDim)
 Constructor.
 basic_scmatrix (const basic_srmatrix< TR > &mRe, const basic_srmatrix< TR > &mIm)
 Constructor.
 basic_scmatrix (BaseCMatrix &m, tint nRow, tint nCol, tint nDim)
 Submatrix constructor.
type_proxy< TC, TR > operator() (tint nRow, tint nCol) throw (cvmexception)
 Reference to element (l-value)
TC operator() (tint nRow, tint nCol) const throw (cvmexception)
 Value of element (not l-value)
CVector operator() (tint nCol) throw (cvmexception)
 Column as l-value.
const CVector operator() (tint nCol) const throw (cvmexception)
 Column as not l-value.
CVector operator[] (tint nRow) throw (cvmexception)
 Row as l-value.
const CVector operator[] (tint nRow) const throw (cvmexception)
 Row as not l-value.
const basic_srmatrix< TR > real () const
 Real part (not l-value)
const basic_srmatrix< TR > imag () const
 Imaginary part (not l-value)
basic_scmatrixoperator= (const basic_scmatrix &m) throw (cvmexception)
 Assignment operator.
basic_scmatrixoperator= (basic_scmatrix &&m) throw (cvmexception)
 Move assignment operator.
basic_scmatrixassign (const CVector &v) throw (cvmexception)
 Vector (as array) assignment.
basic_scmatrixassign (const TC *pd)
 External array assignment.
basic_scmatrixassign (tint nRow, tint nCol, const BaseCMatrix &m) throw (cvmexception)
 Assignment to submatrix.
basic_scmatrixset (TC c)
 Sets all elements to one value.
basic_scmatrixassign_real (const basic_srmatrix< TR > &mRe) throw (cvmexception)
 Assignment to real parts.
basic_scmatrixassign_imag (const basic_srmatrix< TR > &mIm) throw (cvmexception)
 Assignment to imaginary parts.
basic_scmatrixset_real (TR d)
 Sets all real parts to one value.
basic_scmatrixset_imag (TR d)
 Sets all imaginary parts to one value.
basic_scmatrixresize (tint nNewDim) throw (cvmexception)
 Changes dimension.
basic_scmatrixoperator<< (const basic_scmatrix &m) throw (cvmexception)
 Matrix replacement.
basic_scmatrix operator+ (const basic_scmatrix &m) const throw (cvmexception)
 Addition operator.
basic_scmatrix operator- (const basic_scmatrix &m) const throw (cvmexception)
 Subtraction operator.
basic_scmatrixsum (const basic_scmatrix &m1, const basic_scmatrix &m2) throw (cvmexception)
 Sum of matrices.
basic_scmatrixdiff (const basic_scmatrix &m1, const basic_scmatrix &m2) throw (cvmexception)
 Difference of matrices.
basic_scmatrixoperator+= (const basic_scmatrix &m) throw (cvmexception)
 Increment operator.
basic_scmatrixoperator-= (const basic_scmatrix &m) throw (cvmexception)
 Decrement operator.
basic_scmatrix operator- () const
 Unary minus operator.
basic_scmatrixoperator++ ()
 Plus identity, prefix.
basic_scmatrix operator++ (int)
 Plus identity, postfix.
basic_scmatrixoperator-- ()
 Minus identity, prefix.
basic_scmatrix operator-- (int)
 Minus identity, postfix.
basic_scmatrix operator* (TR dMult) const
 Multiply by real number operator.
basic_scmatrix operator/ (TR dDiv) const throw (cvmexception)
 Divide by real number operator.
basic_scmatrix operator* (TC cMult) const
 Multiply by complex number operator.
basic_scmatrix operator/ (TC cDiv) const throw (cvmexception)
 Divide by complex number operator.
basic_scmatrixoperator*= (TR dMult)
 Multiply by real number and assign.
basic_scmatrixoperator/= (TR dDiv)
 Divide by real number and assign.
basic_scmatrixoperator*= (TC cMult)
 Multiply by complex number and assign.
basic_scmatrixoperator/= (TC cDiv)
 Divide by complex number and assign.
basic_scmatrixnormalize ()
 Matrix normalizer.
basic_scmatrix operator! () const throw (cvmexception)
 Matrix transposition.
basic_scmatrix operator~ () const throw (cvmexception)
 Matrix conjugation.
basic_scmatrixtranspose (const basic_scmatrix &m) throw (cvmexception)
 Matrix transposition.
basic_scmatrixconj (const basic_scmatrix &m) throw (cvmexception)
 Matrix conjugation.
basic_scmatrixtranspose () throw (cvmexception)
 Matrix transposition (in-place)
basic_scmatrixconj () throw (cvmexception)
 Matrix conjugation (in-place)
CVector operator* (const CVector &v) const throw (cvmexception)
 Matrix-vector product.
BaseCMatrix operator* (const BaseCMatrix &m) const throw (cvmexception)
 Matrix-matrix product.
basic_scmatrix operator* (const basic_scmatrix &m) const throw (cvmexception)
 Matrix-matrix product.
basic_scmatrixoperator*= (const basic_scmatrix &m) throw (cvmexception)
 Matrix-matrix product with assignment.
basic_scmatrixswap_rows (tint n1, tint n2) throw (cvmexception)
 Rows swap.
basic_scmatrixswap_cols (tint n1, tint n2) throw (cvmexception)
 Columns swap.
CVector solve (const CVector &vB, TR &dErr) const throw (cvmexception)
 Linear solver.
CVector solve_tran (const CVector &vB, TR &dErr) const throw (cvmexception)
 Linear solver (transposed)
CVector solve_conj (const CVector &vB, TR &dErr) const throw (cvmexception)
 Linear solver (hermitian conjugated)
CVector solve (const CVector &vB) const throw (cvmexception)
 Linear solver.
CVector solve_tran (const CVector &vB) const throw (cvmexception)
 Linear solver (transposed)
CVector solve_conj (const CVector &vB) const throw (cvmexception)
 Linear solver (hermitian conjugated)
BaseCMatrix solve (const BaseCMatrix &mB, TR &dErr) const throw (cvmexception)
 Linear solver.
BaseCMatrix solve_tran (const BaseCMatrix &mB, TR &dErr) const throw (cvmexception)
 Linear solver (transposed)
BaseCMatrix solve_conj (const BaseCMatrix &mB, TR &dErr) const throw (cvmexception)
 Linear solver (hermitian conjugated)
BaseCMatrix solve (const BaseCMatrix &mB) const throw (cvmexception)
 Linear solver.
BaseCMatrix solve_tran (const BaseCMatrix &mB) const throw (cvmexception)
 Linear solver (transposed)
BaseCMatrix solve_conj (const BaseCMatrix &mB) const throw (cvmexception)
 Linear solver (hermitian conjugated)
CVector operator% (const CVector &vB) const throw (cvmexception)
 Linear solver operator (transposed)
CVector operator/ (const CVector &vB) const throw (cvmexception)
 Linear solver operator.
CVector solve_lu (const basic_scmatrix &mLU, const tint *pPivots, const CVector &vB, TR &dErr) const throw (cvmexception)
 LU factorization based linear solver.
CVector solve_lu (const basic_scmatrix &mLU, const tint *pPivots, const CVector &vB) const throw (cvmexception)
 LU factorization based linear solver.
BaseCMatrix solve_lu (const basic_scmatrix &mLU, const tint *pPivots, const BaseCMatrix &mB, TR &dErr) const throw (cvmexception)
 LU factorization based linear solver.
BaseCMatrix solve_lu (const basic_scmatrix &mLU, const tint *pPivots, const BaseCMatrix &mB) const throw (cvmexception)
 LU factorization based linear solver.
TC det () const throw (cvmexception)
 Matrix determinant.
basic_scmatrixlow_up (const basic_scmatrix &m, tint *nPivots) throw (cvmexception)
 Low-up (LU) factorization.
basic_scmatrix low_up (tint *nPivots) const throw (cvmexception)
 Low-up (LU) factorization.
TR cond () const throw (cvmexception)
 Condition number reciprocal.
basic_scmatrixinv (const basic_scmatrix &m) throw (cvmexception)
 Matrix inversion.
basic_scmatrix inv () const throw (cvmexception)
 Matrix inversion.
basic_scmatrixexp (const basic_scmatrix &m, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Matrix exponent.
basic_scmatrix exp (TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Matrix exponent.
basic_scmatrixpolynom (const basic_scmatrix &m, const CVector &v) throw (cvmexception)
 Matrix polynomial.
basic_scmatrix polynom (const CVector &v) const
 Matrix polynomial.
CVector eig (basic_scmatrix &mEigVect, bool bRightVect=true) const throw (cvmexception)
 Eigenvalues and eigenvectors.
CVector eig () const throw (cvmexception)
 Eigenvalues.
basic_scmatrixcholesky (const basic_schmatrix< TR, TC > &m) throw (cvmexception)
 Cholesky factorization.
basic_scmatrixbunch_kaufman (const basic_schmatrix< TR, TC > &m, tint *nPivots) throw (cvmexception)
 Bunch-Kaufman factorization.
void qr (basic_scmatrix< TR, TC > &mQ, basic_scmatrix< TR, TC > &mR) const throw (cvmexception)
 QR factorization.
void lq (basic_scmatrix< TR, TC > &mL, basic_scmatrix< TR, TC > &mQ) const throw (cvmexception)
 LQ factorization.
void ql (basic_scmatrix< TR, TC > &mQ, basic_scmatrix< TR, TC > &mL) const throw (cvmexception)
 QL factorization.
void rq (basic_scmatrix< TR, TC > &mR, basic_scmatrix< TR, TC > &mQ) const throw (cvmexception)
 RQ factorization.
basic_scmatrixidentity ()
 Identity matrix.
basic_scmatrixvanish ()
 Set matrix to zero.
basic_scmatrixrandomize_real (TR dFrom, TR dTo)
 Randomizer (real part)
basic_scmatrixrandomize_imag (TR dFrom, TR dTo)
 Randomizer (imaginary part)
- Public Member Functions inherited from basic_cmatrix< TR, TC >
 basic_cmatrix ()
 Default constructor.
 basic_cmatrix (tint nM, tint nN)
 Constructor.
 basic_cmatrix (TC *pd, tint nM, tint nN)
 Constructor.
 basic_cmatrix (const TC *pd, tint nM, tint nN)
 Constructor.
 basic_cmatrix (const basic_cmatrix &m)
 Copy constructor.
 basic_cmatrix (basic_cmatrix &&m) noexcept
 Move constructor.
 basic_cmatrix (const CVector &v, bool bBeColumn=true)
 Constructor.
 basic_cmatrix (const basic_rmatrix< TR > &m, bool bRealPart=true)
 Constructor.
 basic_cmatrix (const TR *pRe, const TR *pIm, tint nM, tint nN)
 Constructor.
 basic_cmatrix (const basic_rmatrix< TR > &mRe, const basic_rmatrix< TR > &mIm)
 Constructor.
 basic_cmatrix (basic_cmatrix &m, tint nRow, tint nCol, tint nHeight, tint nWidth)
 Submatrix constructor.
CVector diag (tint nDiag) throw (cvmexception)
 Diagonal as l-value.
const CVector diag (tint nDiag) const throw (cvmexception)
 Diagonal (not l-value)
basic_cmatrixoperator= (const basic_cmatrix &m) throw (cvmexception)
 Assignment operator.
basic_cmatrixoperator= (basic_cmatrix &&m) throw (cvmexception)
 Move assignment operator.
basic_cmatrixassign (tint nRow, tint nCol, const basic_cmatrix &m) throw (cvmexception)
 Assignment to submatrix.
basic_cmatrixassign_real (const basic_rmatrix< TR > &mRe) throw (cvmexception)
 Assignment to real parts.
basic_cmatrixassign_imag (const basic_rmatrix< TR > &mIm) throw (cvmexception)
 Assignment to imaginary parts.
basic_cmatrixresize (tint nNewM, tint nNewN) throw (cvmexception)
 Changes dimensions.
bool operator== (const basic_cmatrix &m) const
 Matrix comparison.
bool operator!= (const basic_cmatrix &m) const
 Matrix comparison.
basic_cmatrixoperator<< (const basic_cmatrix &m) throw (cvmexception)
 Matrix replacement.
basic_cmatrix operator+ (const basic_cmatrix &m) const throw (cvmexception)
 Addition operator.
basic_cmatrix operator- (const basic_cmatrix &m) const throw (cvmexception)
 Subtraction operator.
basic_cmatrixsum (const basic_cmatrix &m1, const basic_cmatrix &m2) throw (cvmexception)
 Sum of matrices.
basic_cmatrixdiff (const basic_cmatrix &m1, const basic_cmatrix &m2) throw (cvmexception)
 Difference of matrices.
basic_cmatrixoperator+= (const basic_cmatrix &m) throw (cvmexception)
 Increment operator.
basic_cmatrixoperator-= (const basic_cmatrix &m) throw (cvmexception)
 Decrement operator.
basic_cmatrixtranspose (const basic_cmatrix &m) throw (cvmexception)
 Matrix transposition.
basic_cmatrixconj (const basic_cmatrix &m) throw (cvmexception)
 Matrix conjugation.
basic_cmatrix operator* (const basic_cmatrix &m) const throw (cvmexception)
 Matrix-matrix product.
basic_cmatrixmult (const basic_cmatrix &m1, const basic_cmatrix &m2) throw (cvmexception)
 Matrix-matrix product.
basic_cmatrixrank1update_u (const CVector &vCol, const CVector &vRow) throw (cvmexception)
 Rank-1 update (unconjugated)
basic_cmatrixrank1update_c (const CVector &vCol, const CVector &vRow) throw (cvmexception)
 Rank-1 update (conjugated)
basic_cmatrixsolve (const basic_scmatrix< TR, TC > &mA, const basic_cmatrix &mB, TR &dErr) throw (cvmexception)
 Linear solver.
basic_cmatrixsolve_tran (const basic_scmatrix< TR, TC > &mA, const basic_cmatrix &mB, TR &dErr) throw (cvmexception)
 Linear solver (transposed)
basic_cmatrixsolve_conj (const basic_scmatrix< TR, TC > &mA, const basic_cmatrix &mB, TR &dErr) throw (cvmexception)
 Linear solver (conjugated)
basic_cmatrixsolve (const basic_scmatrix< TR, TC > &mA, const basic_cmatrix &mB) throw (cvmexception)
 Linear solver.
basic_cmatrixsolve_tran (const basic_scmatrix< TR, TC > &mA, const basic_cmatrix &mB) throw (cvmexception)
 Linear solver (transposed)
basic_cmatrixsolve_conj (const basic_scmatrix< TR, TC > &mA, const basic_cmatrix &mB) throw (cvmexception)
 Linear solver (conjugated)
basic_cmatrixsolve_lu (const basic_scmatrix< TR, TC > &mA, const basic_scmatrix< TR, TC > &mLU, const tint *pPivots, const basic_cmatrix &mB, TR &dErr) throw (cvmexception)
 LU factorization based linear solver.
basic_cmatrixsolve_lu (const basic_scmatrix< TR, TC > &mA, const basic_scmatrix< TR, TC > &mLU, const tint *pPivots, const basic_cmatrix &mB) throw (cvmexception)
 LU factorization based linear solver.
RVector svd () const throw (cvmexception)
 Singular value decomposition.
RVector svd (basic_scmatrix< TR, TC > &mU, basic_scmatrix< TR, TC > &mVH) const throw (cvmexception)
 Singular value decomposition.
basic_cmatrix pinv (TR threshold=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Pseudo (generalized) inversion.
basic_cmatrixpinv (const basic_cmatrix &mA, TR threshold=basic_cvmMachSp< TR >()) throw (cvmexception)
 Pseudo (generalized) inversion.
basic_cmatrix gels (bool conjugate, const basic_cmatrix &mB, basic_cvector< TR, TC > &vErr) const throw (cvmexception)
 Overdetermined or underdetermined linear solver.
basic_cmatrixgels (bool conjugate, const basic_cmatrix &mA, const basic_cmatrix &mB, basic_cvector< TR, TC > &vErr) throw (cvmexception)
 Overdetermined or underdetermined linear solver.
basic_cvector< TR, TC > gels (bool conjugate, const basic_cvector< TR, TC > &vB, TC &dErr) const throw (cvmexception)
 Overdetermined or underdetermined linear solver.
basic_cmatrix gelsy (const basic_cmatrix &mB, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_cmatrixgelsy (const basic_cmatrix &mA, const basic_cmatrix &mB, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Linear least squares problem.
basic_cvector< TR, TC > gelsy (const basic_cvector< TR, TC > &vB, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_cmatrix gelss (const basic_cmatrix &mB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_cmatrixgelss (const basic_cmatrix &mA, const basic_cmatrix &mB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Linear least squares problem.
basic_cvector< TR, TC > gelss (const basic_cvector< TR, TC > &vB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_cmatrix gelsd (const basic_cmatrix &mB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) const throw (cvmexception)
 Linear least squares problem.
basic_cmatrixgelsd (const basic_cmatrix &mA, const basic_cmatrix &mB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception)
 Linear least squares problem.
basic_cvector< TR, TC > gelsd (const basic_cvector< TR, TC > &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_cmatrix< TR, TC > &mQ, basic_scmatrix< TR, TC > &mR) const throw (cvmexception)
 QR factorization ("economy" mode)
void qr (basic_scmatrix< TR, TC > &mQ, basic_cmatrix< TR, TC > &mR) const throw (cvmexception)
 QR factorization ("full" mode)
void lq (basic_scmatrix< TR, TC > &mL, basic_cmatrix< TR, TC > &mQ) const throw (cvmexception)
 LQ factorization ("economy" mode)
void lq (basic_cmatrix< TR, TC > &mL, basic_scmatrix< TR, TC > &mQ) const throw (cvmexception)
 LQ factorization ("full" mode)
void rq (basic_scmatrix< TR, TC > &mR, basic_cmatrix< TR, TC > &mQ) const throw (cvmexception)
 RQ factorization ("economy" mode)
void rq (basic_cmatrix< TR, TC > &mR, basic_scmatrix< TR, TC > &mQ) const throw (cvmexception)
 RQ factorization ("full" mode)
void ql (basic_cmatrix< TR, TC > &mQ, basic_scmatrix< TR, TC > &mL) const throw (cvmexception)
 QL factorization ("economy" mode)
void ql (basic_scmatrix< TR, TC > &mQ, basic_cmatrix< TR, TC > &mL) const throw (cvmexception)
 QL factorization ("full" mode)
basic_cmatrixgeru (TC alpha, const CVector &vCol, const CVector &vRow) throw (cvmexception)
 Rank-1 update matrix-vector operation (unconjugated)
basic_cmatrixgerc (TC alpha, const CVector &vCol, const CVector &vRow) throw (cvmexception)
 Rank-1 update matrix-vector operation (conjugated)
basic_cmatrixgemm (const basic_cmatrix &m1, bool bConj1, const basic_cmatrix &m2, bool bConj2, TC cAlpha, TC cBeta) throw (cvmexception)
 Generic matrix-matrix operation.
basic_cmatrixhemm (bool bLeft, const basic_schmatrix< TR, TC > &ms, const basic_cmatrix &m, TC cAlpha, TC cBeta) throw (cvmexception)
 Generic hermitian matrix-matrix operation.
TR norm2 () const override
 2-norm
- Public Member Functions inherited from Matrix< TR, TC >
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
TR norminf () const override
 Infinity norm.
- Public Member Functions inherited from basic_array< TR, TC >
 basic_array ()
 Default constructor.
 basic_array (tint nSize, bool bZeroMemory=true)
 Constructor.
 basic_array (TC *pd, tint nSize, tint nIncr=1)
 Constructor.
 basic_array (const TC *pd, tint nSize, tint nIncr=1)
 Constructor.
 basic_array (const TC *begin, const TC *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.
TC * get ()
 Pointer to data.
const TC * get () const
 Const pointer to data.
 operator TC * ()
 Type cast to pointer to data.
 operator const TC * () const
 Type cast to constant pointer to data.
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 assign (size_type n, const TC &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
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 TC &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 TC &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, TC >
typedef TC 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, TC >
 Matrix ()
 Default constructor.
 Matrix (tint nM, tint nN, tint nLD, bool bZeroMemory)
 Constructor.
 Matrix (TC *pd, tint nM, tint nN, tint nLD, tint nSize)
 Constructor.
 Matrix (const TC *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, TC >
 SqMatrix ()
 internal constructor
virtual ~SqMatrix ()
- Protected Attributes inherited from Matrix< TR, TC >
tint mm
 Number of rows.
tint mn
 Number of columns.
tint mld
 Leading dimension.

Detailed Description

template<typename TR, typename TC>
class basic_scmatrix< TR, TC >

End-user class encapsulating square matrix of complex numbers.

TR type stands for treal, TC type stands for tcomplex. Please use predefined scmatrix class in your applications.

See Also
Matrix

Definition at line 23460 of file cvm.h.

Constructor & Destructor Documentation

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( )
inline

Default constructor.

Creates empty square complex matrix. No memory gets allocated.

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

Definition at line 23493 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( tint  nDim)
inlineexplicit

Constructor.

Creates $n\times n$ scmatrix 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;
scmatrix m (4);
std::cout << m.msize() << std::endl
<< m.nsize() << std::endl
<< m.size() << std::endl << m;

prints

4
4
16
(0,0) (0,0) (0,0) (0,0)
(0,0) (0,0) (0,0) (0,0)
(0,0) (0,0) (0,0) (0,0)
(0,0) (0,0) (0,0) (0,0)
Parameters
[in]nDimNumber of rows and columns.

Definition at line 23523 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( TC *  pd,
tint  nDim 
)
inline

Constructor.

Creates $n\times n$ scmatrix object where $n$ is passed in nDim parameter. It throws cvmexception in case of non-positive size passed. 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).

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

Definition at line 23559 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( const TC *  pd,
tint  nDim 
)
inline

Constructor.

Creates $n\times n$ scmatrix object where $n$ is passed in nDim parameter. Constructor throws cvmexception in case of non-positive sizes passed. 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.,
1., 1., 1., 1., 1., 1., 1., 1., 1.};
scmatrix m ((const std::complex<double>*) a, 3);
m(1,1) = std::complex<double>(2.,3.);
std::cout << m << std::endl;
std::cout << a[0] << " " << a[1] << " " << a[2] << " "
<< a[3] << " " << a[4] << " " << a[5] << " " << std::endl;
prints
(2,3) (1,1) (1,1)
(1,1) (1,1) (1,1)
(1,1) (1,1) (1,1)
1 1 1 1 1 1
See Also
http://cvmlib.com/faq.htm
basic_cmatrix::basic_cmatrix(const TC*,tint,tint)
Parameters
[in]pdConst pointer to external array.
[in]nDimNumber of rows and columns.

Definition at line 23596 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( const basic_scmatrix< TR, TC > &  m)
inline

Copy constructor.

Creates scmatrix object as a copy of smatrix m. It throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
scmatrix m ((std::complex<double>*) a, 2);
scmatrix mc(m);
m(1,1) = std::complex<double>(7.77,7.77);
std::cout << m << std::endl << mc;
prints
(7.77,7.77) (5,6)
(3,4) (7,8)
(1,2) (5,6)
(3,4) (7,8)
Parameters
[in]mscmatrix to copy from.

Definition at line 23625 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( basic_scmatrix< TR, TC > &&  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 23648 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( const BaseCMatrix m)
inline

Constructor.

Creates scmatrix 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. Constructor throws cvmexception if this is not true or in case of memory allocation failure. Please note that this constructor is not explicit.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix m((std::complex<double>*) a, 2, 3);
std::cout << m << std::endl;
m.resize(3, 3);
scmatrix ms(m);
std::cout << ms;
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
(0,0) (0,0) (0,0)
Parameters
[in]mcmatrix to copy from.

Definition at line 23683 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( const CVector v)
inlineexplicit

Constructor.

Creates scmatrix 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., 6., 7., 8.};
cvector v((std::complex<double>*) a, 4);
scmatrix m(v);
std::cout << m;
prints
(1,2) (0,0) (0,0) (0,0)
(0,0) (3,4) (0,0) (0,0)
(0,0) (0,0) (5,6) (0,0)
(0,0) (0,0) (0,0) (7,8)
Parameters
[in]vcvector to copy main diagonal from.

Definition at line 23713 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( const basic_srmatrix< TR > &  m,
bool  bRealPart = true 
)
inlineexplicit

Constructor.

Creates cmatrix with the same dimensions as passed srmatrix m and copies matrix m to its real part if bRealPart is true or to its imaginary part otherwise. Constructor throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
const srmatrix m(a, 3);
scmatrix mr(m), mi(m, false);
std::cout << mr << std::endl << mi;
prints
(1,0) (4,0) (7,0)
(2,0) (5,0) (8,0)
(3,0) (6,0) (9,0)
(0,1) (0,4) (0,7)
(0,2) (0,5) (0,8)
(0,3) (0,6) (0,9)
Parameters
[in]msrmatrix to copy elements from.
[in]bRealParttrue to copy m to real part, false to copy to imaginary part.

Definition at line 23746 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( const TR *  pRe,
const TR *  pIm,
tint  nDim 
)
inline

Constructor.

Creates scmatrix object of dimension nDim and copies every element of arrays pointed to by pRe and pIm to real and imaginary part of the matrix created respectively. Use nullptr pointer to fill up appropriate part with zero values. Constructor throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double re[] = {1., 2., 3., 4.};
double im[] = {4., 3., 2., 1.};
scmatrix m(re, im, 2);
std::cout << m << std::endl;
re[0] = 7.777;
std::cout << m << std::endl;
const double rec[] = {1., 2., 3., 4.};
const scmatrix mc (rec, nullptr, 2);
std::cout << mc;
prints
(1,4) (3,2)
(2,3) (4,1)
(1,4) (3,2)
(2,3) (4,1)
(1,0) (3,0)
(2,0) (4,0)
Parameters
[in]pReConst pointer to external treal array to copy to real part.
[in]pImConst pointer to external treal array to copy to imaginary part.
[in]nDimMatrix dimension.

Definition at line 23793 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( const basic_srmatrix< TR > &  mRe,
const basic_srmatrix< TR > &  mIm 
)
inline

Constructor.

Creates scmatrix object of dimension mRe.msize() (if it differs from mIm.msize() then constructor throws cvmexception) and copies matrices mRe and mIm to real and imaginary part of the matrix created respectively. Constructor also throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
srmatrix mr(3), mi(3);
mr.set(1.);
mi.set(2.);
const scmatrix mc(mr, mi);
std::cout << mc;
prints
(1,2) (1,2) (1,2)
(1,2) (1,2) (1,2)
(1,2) (1,2) (1,2)
Parameters
[in]mResrmatrix to copy to real part.
[in]mImsrmatrix to copy to imaginary part.

Definition at line 23823 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix< TR, TC >::basic_scmatrix ( BaseCMatrix m,
tint  nRow,
tint  nCol,
tint  nDim 
)
inline

Submatrix constructor.

Creates scmatrix object as submatrix of matrix m. It means that the object created shares memory with some part of m. This part is defined by its upper left corner (parameters nRow and nCol, both are CVM0 based) and its dimension (parameter nDim).

Example:
using namespace cvm;
cmatrix m(4,5);
scmatrix subm(m,2,2,2);
subm.set(std::complex<double>(1.,2.));
std::cout << m;
prints
(0,0) (0,0) (0,0) (0,0) (0,0)
(0,0) (1,2) (1,2) (0,0) (0,0)
(0,0) (1,2) (1,2) (0,0) (0,0)
(0,0) (0,0) (0,0) (0,0) (0,0)
Parameters
[in]mParent cmatrix to attach to.
[in]nRowRow to start from (CVM0 based).
[in]nColColumn to start from (CVM0 based).
[in]nDimDimension of square submatrix.

Definition at line 23859 of file cvm.h.

Member Function Documentation

template<typename TR, typename TC>
type_proxy<TC, TR> basic_scmatrix< TR, TC >::operator() ( tint  nRow,
tint  nCol 
) throw (cvmexception)
inline

Reference to element (l-value)

Operator provides access to a particular element of calling matrix by its row and column index. Indexes passed are CVM0 based. It returns l-value in order to make possible write access to an element. Operator throws cvmexception if nRow or nCol is outside of boundaries.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
const cmatrix m ((std::complex<double>*) a, 2, 3);
scmatrix ms(2);
std::cout << m(1,1) << " "
<< m(2,3) << std::endl << std::endl;
ms(2,2) = std::complex<double>(7.77,7.77);
std::cout << ms;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1,2) (11,12)
(0,0) (0,0)
(0,0) (7.77,7.77)
See Also
http://cvmlib.com/faq.htm
Parameters
[in]nRowRow index (CVM0 based).
[in]nColColumn index (CVM0 based).
Returns
type_proxy Proxy to element (l-value).

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_scbmatrix< TR, TC >.

Definition at line 23865 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
TC basic_scmatrix< TR, TC >::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;
try {
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
const cmatrix m ((std::complex<double>*) 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,2) (11,12)
See Also
http://cvmlib.com/faq.htm
Parameters
[in]nRowRow index (CVM0 based).
[in]nColColumn index (CVM0 based).
Returns
TC tcomplex value.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 23872 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::operator() ( tint  nCol) throw (cvmexception)
inline

Column as l-value.

Operator provides access to nCol-th column (CVM0 based) of calling matrix by returning cvector sharing memory with it. Operator throws cvmexception if nCol is outside of boundaries.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
const cmatrix m ((std::complex<double>*) a, 2, 3);
scmatrix ms(2);
std::cout << m(2) << std::endl;
ms(2) = m(3);
std::cout << ms;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(5,6) (7,8)
(0,0) (9,10)
(0,0) (11,12)
Parameters
[in]nColIndex of column (CVM0 based).
Returns
cvector Column as l-value.

Reimplemented from basic_cmatrix< TR, TC >.

Definition at line 23880 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
const CVector basic_scmatrix< TR, TC >::operator() ( tint  nCol) const throw (cvmexception)
inline

Column as not l-value.

Operator creates cvector 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;
try {
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
const cmatrix m ((std::complex<double>*) a, 2, 3);
std::cout << m(2) << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(5,6) (7,8)
Parameters
[in]nColIndex of column (CVM0 based).
Returns
cvector Column value.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 23887 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::operator[] ( tint  nRow) throw (cvmexception)
inline

Row as l-value.

Operator provides access to nRow-th row (CVM0 based) of calling matrix by returning cvector sharing memory with it. 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., 7., 8., 9.};
const srmatrix m (a, 3);
srmatrix ms(3);
std::cout << m[2] << std::endl;
ms[2] = m[3];
std::cout << ms;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
2.00e+00 5.00e+00 8.00e+00
0.00e+00 0.00e+00 0.00e+00
3.00e+00 6.00e+00 9.00e+00
0.00e+00 0.00e+00 0.00e+00
Parameters
[in]nRowIndex of row (CVM0 based).
Returns
cvector Row as l-value.

Reimplemented from basic_cmatrix< TR, TC >.

Definition at line 23894 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
const CVector basic_scmatrix< TR, TC >::operator[] ( tint  nRow) const throw (cvmexception)
inline

Row as not l-value.

Operator creates cvector 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., 7., 8., 9.};
const srmatrix m (a, 3);
std::cout << m[2] << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
2.00e+00 5.00e+00 8.00e+00
Parameters
[in]nRowIndex of row (CVM0 based).
Returns
cvector Row value.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 23901 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
const basic_srmatrix<TR> basic_scmatrix< TR, TC >::real ( ) const
inline

Real part (not l-value)

Creates object of type const rmatrix as real part of calling matrix. Please note that, unlike cvector::real(), this function creates new object not sharing memory with real part of calling matrix, i.e. the matrix returned is not l-value.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix m((std::complex<double>*) a, 2, 3);
std::cout << m << std::endl << m.real();
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
1 5 9
3 7 11
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 23908 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
const basic_srmatrix<TR> basic_scmatrix< TR, TC >::imag ( ) const
inline

Imaginary part (not l-value)

Creates object of type const rmatrix as imaginary part of calling matrix. Please note that, unlike cvector::imag(), this function creates new object not sharing memory with imaginary part of calling matrix, i.e. the matrix returned is not l-value.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix m((std::complex<double>*) a, 2, 3);
std::cout << m << std::endl << m.imag();
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
2 6 10
4 8 12
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 23916 of file cvm.h.

Here is the call graph for this function:

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

Assignment operator.

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

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
const scmatrix m1((std::complex<double>*) a, 2);
scmatrix m2(2);
m2 = m1;
std::cout << m2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1,2) (5,6)
(3,4) (7,8)
Parameters
[in]mscmatrix to assign from.
Returns
Reference to changed calling matrix.

Definition at line 23952 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator= ( basic_scmatrix< TR, TC > &&  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 23972 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::assign ( const CVector v) throw (cvmexception)
inline

Vector (as array) assignment.

Sets every element of calling matrix to be equal to appropriate element of cvector 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.

Example:
using namespace cvm;
const double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
const cvector v((const std::complex<double>*) a,6);
cmatrix m(2, 3);
m.assign (v);
std::cout << m;
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
Parameters
[in]vcvector to assign.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_scbmatrix< TR, TC >.

Definition at line 23980 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::assign ( const TC *  pd)
inline

External array assignment.

Sets every element of calling 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.

Example:
using namespace cvm;
const double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix m(2, 3);
m.assign ((const std::complex<double>*) a);
std::cout << m;
prints
1.00e+000 3.00e+000 5.00e+000
2.00e+000 4.00e+000 6.00e+000
Parameters
[in]pdConst pointer to external array.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_scbmatrix< TR, TC >.

Definition at line 23988 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::assign ( tint  nRow,
tint  nCol,
const BaseCMatrix m 
) throw (cvmexception)
inline

Assignment to submatrix.

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

Example:
using namespace cvm;
scmatrix m1(5);
cmatrix m2(2,3);
m1.set(std::complex<double>(1.,1.));
m2.set(std::complex<double>(2.,2.));
m1.assign(2,3,m2);
std::cout << m1;
prints
(1,1) (1,1) (1,1) (1,1) (1,1)
(1,1) (1,1) (2,2) (2,2) (2,2)
(1,1) (1,1) (2,2) (2,2) (2,2)
(1,1) (1,1) (1,1) (1,1) (1,1)
(1,1) (1,1) (1,1) (1,1) (1,1)
Parameters
[in]nRowRow index (CVM0 based).
[in]nColColumn index (CVM0 based).
[in]mReference to cmatrix to assign.
Returns
Reference to changed calling matrix.

Definition at line 24025 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::set ( TC  c)
inline

Sets all elements to one value.

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

Example:
using namespace cvm;
cmatrix m(3, 4);
m.set(std::complex<double>(3.,4.));
std::cout << m;
prints
(3,4) (3,4) (3,4) (3,4)
(3,4) (3,4) (3,4) (3,4)
(3,4) (3,4) (3,4) (3,4)
Parameters
[in]cValue to set to.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_scbmatrix< TR, TC >.

Definition at line 24036 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::assign_real ( const basic_srmatrix< TR > &  mRe) throw (cvmexception)
inline

Assignment to real parts.

Sets real part of every element of calling matrix to value of appropriate element of srmatrix mRe and returns reference to the matrix changed. Function throws cvmexception in case of different dimensions of the operands.

Example:
using namespace cvm;
scmatrix mc(3);
srmatrix m(3);
m.set(1.);
mc.assign_real(m);
std::cout << mc;
prints
(1,0) (1,0) (1,0)
(1,0) (1,0) (1,0)
(1,0) (1,0) (1,0)
Parameters
[in]mResrmatrix to assign to real part.
Returns
Reference to changed calling matrix.

Definition at line 24066 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::assign_imag ( const basic_srmatrix< TR > &  mIm) throw (cvmexception)
inline

Assignment to imaginary parts.

Sets imaginary part of every element of calling matrix to value of appropriate element of srmatrix mRe and returns reference to the matrix changed. Function throws cvmexception in case of different dimensions of the operands.

Example:
using namespace cvm;
scmatrix mc(3);
srmatrix m(3);
m.set(1.);
mc.assign_imag(m);
std::cout << mc;
prints
(0,1) (0,1) (0,1)
(0,1) (0,1) (0,1)
(0,1) (0,1) (0,1)
Parameters
[in]mImsrmatrix to assign to imaginary part.
Returns
Reference to changed calling matrix.

Definition at line 24098 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::set_real ( TR  d)
inline

Sets all real parts to one value.

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

Example:
using namespace cvm;
cmatrix m(2,3);
m.set_real(1.);
std::cout << m;
prints
(1,0) (1,0) (1,0)
(1,0) (1,0) (1,0)
Parameters
[in]dValue to set to.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24107 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::set_imag ( TR  d)
inline

Sets all imaginary parts to one value.

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

Example:
using namespace cvm;
cmatrix m(2,3);
m.set_imag(1.);
std::cout << m;
prints
(0,1) (0,1) (0,1)
(0,1) (0,1) (0,1)
Parameters
[in]dValue to set to.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_scbmatrix< TR, TC >.

Definition at line 24114 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::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., 5., 6., 7., 8.};
scmatrix m((std::complex<double>*) 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,2) (5,6)
(3,4) (7,8)
(1,2) (5,6) (0,0)
(3,4) (7,8) (0,0)
(0,0) (0,0) (0,0)
Parameters
[in]nNewDimNew dimension.
Returns
Reference to changed calling matrix.

Reimplemented from basic_array< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24155 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator<< ( const basic_scmatrix< TR, TC > &  m) throw (cvmexception)
inline

Matrix replacement.

Destroys calling 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;
try {
scmatrix m(3);
scmatrix mc(1);
m(1,2) = 1.;
m(2,3) = 2.;
std::cout << m << std::endl << mc << std::endl;
mc << m;
std::cout << mc;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0,0) (1,0) (0,0)
(0,0) (0,0) (2,0)
(0,0) (0,0) (0,0)
(0,0)
(0,0) (1,0) (0,0)
(0,0) (0,0) (2,0)
(0,0) (0,0) (0,0)
See Also
operator =()
Parameters
[in]mscmatrix to replace by.
Returns
Reference to changed calling matrix.

Definition at line 24199 of file cvm.h.

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

Addition operator.

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

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
double b[] = {10., 20., 30., 40., 50., 60., 70., 80.};
scmatrix m1((std::complex<double>*) a, 2);
scmatrix m2((std::complex<double>*) b, 2);
std::cout << m1 + m2 << std::endl << m1 + m1;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(11,22) (55,66)
(33,44) (77,88)
(2,4) (10,12)
(6,8) (14,16)
See Also
sum()
Parameters
[in]mscmatrix to add to calling one.
Returns
Sum of matrices.

Definition at line 24240 of file cvm.h.

Here is the call graph for this function:

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

Subtraction operator.

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

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
double b[] = {10., 20., 30., 40., 50., 60., 70., 80.};
scmatrix m1((std::complex<double>*) a, 2);
scmatrix m2((std::complex<double>*) b, 2);
std::cout << m2 - m1 << std::endl << m1 - m1;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(9,18) (45,54)
(27,36) (63,72)
(0,0) (0,0)
(0,0) (0,0)
See Also
diff()
Parameters
[in]mscmatrix to subtract from calling one.
Returns
Difference of matrices.

Definition at line 24281 of file cvm.h.

Here is the call graph for this function:

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

Sum of matrices.

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

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
const scmatrix m1((std::complex<double>*)a, 3);
scmatrix m2(3);
scmatrix m(3);
m2.set(std::complex<double>(1.,1.));
std::cout << m.sum(m1, m2) << std::endl;
std::cout << m.sum(m, m2);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(2,3) (8,9) (14,15)
(4,5) (10,11) (16,17)
(6,7) (12,13) (18,19)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
(7,8) (13,14) (19,20)
See Also
operator +()
Parameters
[in]m1First scmatrix summand.
[in]m2Second scmatrix summand.
Returns
Reference to changed calling matrix.

Definition at line 24327 of file cvm.h.

Here is the call graph for this function:

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

Difference of matrices.

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

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
const scmatrix m1((std::complex<double>*)a, 3);
scmatrix m2(3);
scmatrix m(3);
m2.set(std::complex<double>(1.,1.));
std::cout << m.diff(m1, m2) << std::endl;
std::cout << m.diff(m, m2);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0,1) (6,7) (12,13)
(2,3) (8,9) (14,15)
(4,5) (10,11) (16,17)
(-1,0) (5,6) (11,12)
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
See Also
operator -()
Parameters
[in]m1First scmatrix subtrahend.
[in]m2Second scmatrix subtrahend.
Returns
Reference to changed calling matrix.

Definition at line 24373 of file cvm.h.

Here is the call graph for this function:

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

Increment operator.

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

Example:
using namespace cvm;
try {
scmatrix m1(3);
scmatrix m2(3);
m1.set(std::complex<double>(1.,2.));
m2.set(std::complex<double>(3.,4.));
m1 += m2;
std::cout << m1 << std::endl;
// well, you can do this too, but temporary object would be created
m2 += m2;
std::cout << m2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(4,6) (4,6) (4,6)
(4,6) (4,6) (4,6)
(4,6) (4,6) (4,6)
(6,8) (6,8) (6,8)
(6,8) (6,8) (6,8)
(6,8) (6,8) (6,8)
See Also
operator +()
sum()
Parameters
[in]mscmatrix to increment by.
Returns
Reference to changed calling matrix.

Definition at line 24422 of file cvm.h.

Here is the call graph for this function:

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

Decrement operator.

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

Example:
using namespace cvm;
try {
scmatrix m1(3);
scmatrix m2(3);
m1.set(std::complex<double>(1.,2.));
m2.set(std::complex<double>(3.,4.));
m1 -= m2;
std::cout << m1 << std::endl;
// well, you can do this too, but temporary object would be created
m2 -= m2;
std::cout << m2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-2,-2) (-2,-2) (-2,-2)
(-2,-2) (-2,-2) (-2,-2)
(-2,-2) (-2,-2) (-2,-2)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
See Also
operator -()
diff()
Parameters
[in]mscmatrix to decrement by.
Returns
Reference to changed calling matrix.

Definition at line 24470 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator- ( ) const
inline

Unary minus operator.

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

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
scmatrix m((std::complex<double>*) a, 2);
std::cout << -m;
prints
(-1,-2) (-5,-6)
(-3,-4) (-7,-8)
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24497 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator++ ( )
inline

Plus identity, prefix.

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

Example:
using namespace cvm;
scmatrix m(3);
m.set(std::complex<double>(1.,1.));
m++;
std::cout << m << std::endl;
std::cout << ++m;
prints
(2,1) (1,1) (1,1)
(1,1) (2,1) (1,1)
(1,1) (1,1) (2,1)
(3,1) (1,1) (1,1)
(1,1) (3,1) (1,1)
(1,1) (1,1) (3,1)
Returns
Reference to changed calling matrix.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24530 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator++ ( int  )
inline

Plus identity, postfix.

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

Example:
using namespace cvm;
scmatrix m(3);
m.set(std::complex<double>(1.,1.));
m++;
std::cout << m << std::endl;
std::cout << ++m;
prints
(2,1) (1,1) (1,1)
(1,1) (2,1) (1,1)
(1,1) (1,1) (2,1)
(3,1) (1,1) (1,1)
(1,1) (3,1) (1,1)
(1,1) (1,1) (3,1)
Returns
Reference to changed calling matrix.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24561 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator-- ( )
inline

Minus identity, prefix.

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

Example:
using namespace cvm;
scmatrix m(3);
m.set(std::complex<double>(1.,1.));
m--;
std::cout << m << std::endl;
std::cout << --m;
prints
(0,1) (1,1) (1,1)
(1,1) (0,1) (1,1)
(1,1) (1,1) (0,1)
(-1,1) (1,1) (1,1)
(1,1) (-1,1) (1,1)
(1,1) (1,1) (-1,1)
Returns
Reference to changed calling matrix.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24592 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator-- ( int  )
inline

Minus identity, postfix.

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

Example:
using namespace cvm;
scmatrix m(3);
m.set(std::complex<double>(1.,1.));
m--;
std::cout << m << std::endl;
std::cout << --m;
prints
(0,1) (1,1) (1,1)
(1,1) (0,1) (1,1)
(1,1) (1,1) (0,1)
(-1,1) (1,1) (1,1)
(1,1) (-1,1) (1,1)
(1,1) (1,1) (-1,1)
Returns
Reference to changed calling matrix.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24623 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator* ( TR  dMult) const
inline

Multiply by real number operator.

Creates object of type scmatrix as product of calling matrix and real 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.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
std::cout << m * 5.;
prints
(5,10) (35,40) (65,70)
(15,20) (45,50) (75,80)
(25,30) (55,60) (85,90)
See Also
operator *=()
Parameters
[in]dMultNumber to multiply by.
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24653 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator/ ( TR  dDiv) const throw (cvmexception)
inline

Divide by real number operator.

Creates object of type scmatrix as quotient of calling matrix and real 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;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
std::cout << m / 2.;
prints
(0.5,1) (3.5,4) (6.5,7)
(1.5,2) (4.5,5) (7.5,8)
(2.5,3) (5.5,6) (8.5,9)
See Also
operator /=()
Parameters
[in]dDivNumber to divide by.
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24686 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator* ( TC  cMult) const
inline

Multiply by complex number operator.

Creates object of type scmatrix as product of calling matrix and complex number cMult. It throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
std::cout << m * std::complex<double>(1.,1.);
prints
(-1,3) (-1,15) (-1,27)
(-1,7) (-1,19) (-1,31)
(-1,11) (-1,23) (-1,35)
See Also
operator *=()
Parameters
[in]cMultNumber to multiply by.
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24717 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator/ ( TC  cDiv) const throw (cvmexception)
inline

Divide by complex number operator.

Creates object of type scmatrix as quotient of calling matrix and complex number cDiv. It throws cvmexception if cDiv 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;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
std::cout << m / std::complex<double>(1.,1.);
prints
(1.5,0.5) (7.5,0.5) (13.5,0.5)
(3.5,0.5) (9.5,0.5) (15.5,0.5)
(5.5,0.5) (11.5,0.5) (17.5,0.5)
See Also
operator /=()
Parameters
[in]cDivNumber to divide by.
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24750 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator*= ( TR  dMult)
inline

Multiply by real number and assign.

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

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
m *= 5.;
std::cout << m;
prints
(5,10) (35,40) (65,70)
(15,20) (45,50) (75,80)
(25,30) (55,60) (85,90)
See Also
operator *(TR) const
Parameters
[in]dMultNumber to multiply by.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24781 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator/= ( TR  dDiv)
inline

Divide by real number and assign.

Divides calling square complex matrix by real 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;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
m /= 2.;
std::cout << m;
prints
(0.5,1) (3.5,4) (6.5,7)
(1.5,2) (4.5,5) (7.5,8)
(2.5,3) (5.5,6) (8.5,9)
See Also
operator /(TR) const
Parameters
[in]dDivNumber to divide by.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24813 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator*= ( TC  cMult)
inline

Multiply by complex number and assign.

Multiplies calling square complex matrix by complex number cMult and returns reference to the matrix changed.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
m *= std::complex<double>(2.,1.);
std::cout << m;
prints
(0,5) (6,23) (12,41)
(2,11) (8,29) (14,47)
(4,17) (10,35) (16,53)
See Also
operator *(TR) const
Parameters
[in]cMultNumber to multiply by.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_scbmatrix< TR, TC >.

Definition at line 24843 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator/= ( TC  cDiv)
inline

Divide by complex number and assign.

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

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
m /= std::complex<double>(2.,1.);
std::cout << m;
prints
(0.8,0.6) (4.4,1.8) (8,3)
(2,1) (5.6,2.2) (9.2,3.4)
(3.2,1.4) (6.8,2.6) (10.4,3.8)
See Also
operator /(TR) const
Parameters
[in]cDivNumber to divide by.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_scbmatrix< TR, TC >.

Definition at line 24875 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::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;
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix ma ((std::complex<double>*) a, 2, 3);
ma.normalize();
std::cout << ma << ma.norm() << std::endl;
prints
(0.0392232,0.0784465) (0.196116,0.235339) (0.353009,0.392232)
(0.11767,0.156893) (0.274563,0.313786) (0.431455,0.470679)
1
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24881 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator! ( ) const throw (cvmexception)
inline

Matrix transposition.

Creates object of type scmatrix as transposed calling matrix.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
scmatrix mc(3);
std::cout << m << std::endl << !m << std::endl ;
mc.transpose(m);
std::cout << mc << std::endl;
mc.transpose();
std::cout << mc;
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
(1,2) (3,4)
(5,6) (7,8)
(9,10) (11,12)
(1,2) (3,4)
(5,6) (7,8)
(9,10) (11,12)
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24923 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator~ ( ) const throw (cvmexception)
inline

Matrix conjugation.

Creates object of type scmatrix as hermitian conjugated calling matrix.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
scmatrix mc(3);
std::cout << m << std::endl << ~m << std::endl ;
mc.conj(m);
std::cout << mc << std::endl;
mc.conj();
std::cout << mc;
prints
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
(1,-2) (3,-4) (5,-6)
(7,-8) (9,-10) (11,-12)
(13,-14) (15,-16) (17,-18)
(1,-2) (3,-4) (5,-6)
(7,-8) (9,-10) (11,-12)
(13,-14) (15,-16) (17,-18)
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 24966 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::transpose ( const basic_scmatrix< TR, TC > &  m) throw (cvmexception)
inline

Matrix transposition.

Sets calling matrix to be equal to square complex matrix m transposed. Function throws cvmexception in case of not appropriate sizes of the operands.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
scmatrix mc(3);
std::cout << m << std::endl << !m << std::endl ;
mc.transpose(m);
std::cout << mc << std::endl;
mc.transpose();
std::cout << mc;
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
(1,2) (3,4)
(5,6) (7,8)
(9,10) (11,12)
(1,2) (3,4)
(5,6) (7,8)
(9,10) (11,12)
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
Parameters
[in]mscmatrix to transpose.
Returns
Reference to changed calling matrix.

Definition at line 25010 of file cvm.h.

Here is the caller graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::conj ( const basic_scmatrix< TR, TC > &  m) throw (cvmexception)
inline

Matrix conjugation.

Sets calling matrix to be equal to square complex matrix m hermitian conjugated. Function throws cvmexception in case of not appropriate sizes of the operands.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
scmatrix mc(3);
std::cout << m << std::endl << ~m << std::endl ;
mc.conj(m);
std::cout << mc << std::endl;
mc.conj();
std::cout << mc;
prints
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
(1,-2) (3,-4) (5,-6)
(7,-8) (9,-10) (11,-12)
(13,-14) (15,-16) (17,-18)
(1,-2) (3,-4) (5,-6)
(7,-8) (9,-10) (11,-12)
(13,-14) (15,-16) (17,-18)
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
Parameters
[in]mscmatrix to conjugate.
Returns
Reference to changed calling matrix.

Definition at line 25055 of file cvm.h.

Here is the caller graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::transpose ( ) throw (cvmexception)
inline

Matrix transposition (in-place)

Makes calling square complex matrix to be equal to transposed itself. Function throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
scmatrix mc(3);
std::cout << m << std::endl << !m << std::endl ;
mc.transpose(m);
std::cout << mc << std::endl;
mc.transpose();
std::cout << mc;
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
(1,2) (3,4)
(5,6) (7,8)
(9,10) (11,12)
(1,2) (3,4)
(5,6) (7,8)
(9,10) (11,12)
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 25098 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::conj ( ) throw (cvmexception)
inline

Matrix conjugation (in-place)

Makes calling square complex matrix to be equal to hermitian conjugated itself. Function throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
scmatrix m((std::complex<double>*) a, 3);
scmatrix mc(3);
std::cout << m << std::endl << ~m << std::endl ;
mc.conj(m);
std::cout << mc << std::endl;
mc.conj();
std::cout << mc;
prints
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
(1,-2) (3,-4) (5,-6)
(7,-8) (9,-10) (11,-12)
(13,-14) (15,-16) (17,-18)
(1,-2) (3,-4) (5,-6)
(7,-8) (9,-10) (11,-12)
(13,-14) (15,-16) (17,-18)
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 25142 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::operator* ( const CVector v) const throw (cvmexception)
inline

Matrix-vector product.

Creates object of type cvector 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_cvector::mult(const basic_cmatrix<TR,TC>&,const basic_cvector<TR,TC>&) to avoid new object creation.

Example:
using namespace cvm;
cmatrix m(2, 3);
cvector v(3);
m.set(std::complex<double>(1.,1.));
v.set(std::complex<double>(1.,1.));
std::cout << m * v;
prints
(0,6) (0,6)
See Also
basic_cvector::mult(const basic_cmatrix<TR,TC>&,const basic_cvector<TR,TC>&)
Parameters
[in]vcvector to compute product with.
Returns
Result object.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 25148 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::operator* ( const BaseCMatrix m) const throw (cvmexception)
inline

Matrix-matrix product.

Creates object of type cmatrix as product of calling square complex 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 {
scmatrix ms(3);
cmatrix m(3,2);
ms.set(std::complex<double>(1.,1.));
m.set(std::complex<double>(1.,1.));
std::cout << ms * m;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0,6) (0,6)
(0,6) (0,6)
(0,6) (0,6)
Parameters
[in]mcmatrix to compute product with.
Returns
Result object.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 25183 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::operator* ( const basic_scmatrix< TR, TC > &  m) const throw (cvmexception)
inline

Matrix-matrix product.

Creates object of type scmatrix as product of calling matrix and square 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 {
scmatrix m1(3), m2(3);
m1.set(std::complex<double>(1.,1.));
m2.set(std::complex<double>(1.,1.));
std::cout << m1 * m2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0,6) (0,6) (0,6)
(0,6) (0,6) (0,6)
(0,6) (0,6) (0,6)
Parameters
[in]mscmatrix to compute product with.
Returns
Result object.

Definition at line 25216 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::operator*= ( const basic_scmatrix< TR, TC > &  m) throw (cvmexception)
inline

Matrix-matrix product with assignment.

Sets calling matrix to be equal to product of itself and square complex matrix m and returns reference to the object it changes. Operator throws cvmexception in case of different dimensions of the operands.

Example:
using namespace cvm;
try {
scmatrix m1(3), m2(3);
m1.set(std::complex<double>(1.,2.));
m2.set(std::complex<double>(2.,1.));
m1 *= m2;
m2 *= m2;
std::cout << m1 << std::endl << m2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0,15) (0,15) (0,15)
(0,15) (0,15) (0,15)
(0,15) (0,15) (0,15)
(9,12) (9,12) (9,12)
(9,12) (9,12) (9,12)
(9,12) (9,12) (9,12)
Parameters
[in]mscmatrix to compute product with.
Returns
Reference to changed calling matrix.

Definition at line 25258 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::swap_rows ( tint  n1,
tint  n2 
) throw (cvmexception)
inline

Rows swap.

Swaps two rows of calling matrix and returns reference to the matrix changed. n1 and n2 are indexes of rows to be swapped, both are CVM0 based. Function throws cvmexception if one of the parameters is outside of boundaries.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix m ((std::complex<double>*)a, 3, 2);
std::cout << m << std::endl;
std::cout << m.swap_rows(2,3);
prints
(1,2) (7,8)
(3,4) (9,10)
(5,6) (11,12)
(1,2) (7,8)
(5,6) (11,12)
(3,4) (9,10)
Parameters
[in]n1Row index to swap.
[in]n2Row index to swap.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Definition at line 25266 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::swap_cols ( tint  n1,
tint  n2 
) throw (cvmexception)
inline

Columns swap.

Swaps two columnss of calling matrix and returns reference to the matrix changed. n1 and n2 are indexes of columns to be swapped, both are CVM0 based. Function throws cvmexception if one of the parameters is outside of boundaries.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix m ((std::complex<double>*)a, 2, 3);
std::cout << m << std::endl;
std::cout << m.swap_cols(2,3);
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
(1,2) (9,10) (5,6)
(3,4) (11,12) (7,8)
Parameters
[in]n1Column index to swap.
[in]n2Column index to swap.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Definition at line 25272 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::solve ( const CVector vB,
TR &  dErr 
) const throw (cvmexception)
inline

Linear solver.

Creates cvector object as solution $x$ of linear equation $A*x=b$ where calling matrix is square complex matrix $A$ and parameter vB is vector $b$. It also sets output parameter dErr to be equal to the norm of computation error. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve (ma, mb, dErr);
std::cout << mx << dErr
<< std::endl << ma * mx - mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve (vb, dErr);
std::cout << vx << dErr << std::endl << ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-6.25e-002,-2.71e-001) (-1.25e-001,+1.13e+000)
(+1.25e-001,+2.08e-001) (+2.50e-001,-2.50e-001)
(+6.25e-002,+6.25e-002) (+1.25e-001,+1.25e-001)
+1.45e-014
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(-2.22e-016,+4.44e-016) (+0.00e+000,+0.00e+000)
(+2.22e-016,+0.00e+000) (+0.00e+000,+0.00e+000)
(-1.25e-001,+1.13e+000) (+2.50e-001,-2.50e-001) (+1.25e-001,+1.25e-001)
+7.41e-015
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve(const CVector&)const
Parameters
[in]vBcvector $b$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 25339 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::solve_tran ( const CVector vB,
TR &  dErr 
) const throw (cvmexception)
inline

Linear solver (transposed)

Creates cvector object as solution $x$ of linear equation $A^T*x=b$ (which is equivalent to $x*A=b$) where calling matrix is square complex matrix $A$ and parameter vB is vector $b$. It also sets output parameter dErr to be equal to the norm of computation error. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve_tran (ma, mb, dErr);
std::cout << mx << dErr
<< std::endl << !ma * mx - mb
<< std::endl << !mx * ma - !mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve_tran (vb, dErr);
std::cout << vx << dErr << std::endl << vx * ma - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(+3.13e-002,-5.31e-001) (+9.38e-002,-9.38e-002)
(+6.25e-002,+6.25e-002) (+1.88e-001,+1.88e-001)
(+3.13e-002,+4.69e-001) (+9.38e-002,+2.40e-001)
+1.02e-014
(-2.22e-016,-2.22e-016) (+0.00e+000,+0.00e+000)
(-4.44e-016,-4.44e-016) (+0.00e+000,+0.00e+000)
(+8.88e-016,-8.88e-016) (+0.00e+000,+0.00e+000)
(-2.22e-016,-2.22e-016) (-4.44e-016,-4.44e-016) (+8.88e-016,-8.88e-016)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(+9.38e-002,-9.38e-002) (+1.88e-001,+1.88e-001) (+9.38e-002,+2.40e-001)
+1.02e-014
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve_tran(const CVector&)const
Parameters
[in]vBcvector $b$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 25408 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::solve_conj ( const CVector vB,
TR &  dErr 
) const throw (cvmexception)
inline

Linear solver (hermitian conjugated)

Creates cvector object as solution $x$ of linear equation $A^H*x=b$ where calling matrix is square complex matrix $A$ and parameter vB is vector $b$. It also sets output parameter dErr to be equal to the norm of computation error. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve_conj (ma, mb, dErr);
std::cout << mx << dErr
<< std::endl << ~ma * mx - mb
<< std::endl << ~mx * ma - ~mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve_conj (vb, dErr);
std::cout << vx << dErr << std::endl << ~ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-5.31e-001,+3.13e-002) (-9.38e-002,+9.38e-002)
(+6.25e-002,+6.25e-002) (+1.88e-001,+1.88e-001)
(+4.69e-001,+3.13e-002) (+2.40e-001,+9.38e-002)
+1.02e-014
(-2.22e-016,-2.22e-016) (+0.00e+000,+0.00e+000)
(-4.44e-016,-4.44e-016) (+0.00e+000,+0.00e+000)
(-8.88e-016,+8.88e-016) (+0.00e+000,+0.00e+000)
(-2.22e-016,+2.22e-016) (-4.44e-016,+4.44e-016) (-8.88e-016,-8.88e-016)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(-9.38e-002,+9.38e-002) (+1.88e-001,+1.88e-001) (+2.40e-001,+9.38e-002)
+1.02e-014
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve_conj(const CVector&)const
Parameters
[in]vBcvector $b$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 25477 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::solve ( const CVector vB) const throw (cvmexception)
inline

Linear solver.

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

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve (ma, mb);
std::cout << mx << std::endl << ma * mx - mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve (vb);
std::cout << vx << std::endl << ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-6.25e-002,-2.71e-001) (-1.25e-001,+1.13e+000)
(+1.25e-001,+2.08e-001) (+2.50e-001,-2.50e-001)
(+6.25e-002,+6.25e-002) (+1.25e-001,+1.25e-001)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(-2.22e-016,+4.44e-016) (+0.00e+000,+0.00e+000)
(+2.22e-016,+0.00e+000) (+0.00e+000,+0.00e+000)
(-1.25e-001,+1.13e+000) (+2.50e-001,-2.50e-001) (+1.25e-001,+1.25e-001)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve(const CVector&,TR&)const
Parameters
[in]vBcvector $b$.
Returns
Result object.

Definition at line 25536 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::solve_tran ( const CVector vB) const throw (cvmexception)
inline

Linear solver (transposed)

Creates cvector object as solution $x$ of linear equation $A^T*x=b$ (which is equivalent to $x*A=b$) where calling matrix is square complex matrix $A$ and parameter vB is vector $b$. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve_tran (ma, mb);
std::cout << mx
<< std::endl << !ma * mx - mb
<< std::endl << !mx * ma - !mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve_tran (vb);
std::cout << vx << std::endl << vx * ma - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(+3.13e-002,-5.31e-001) (+9.38e-002,-9.38e-002)
(+6.25e-002,+6.25e-002) (+1.88e-001,+1.88e-001)
(+3.13e-002,+4.69e-001) (+9.38e-002,+2.40e-001)
(-2.22e-016,-2.22e-016) (+0.00e+000,+0.00e+000)
(-4.44e-016,-4.44e-016) (+0.00e+000,+0.00e+000)
(+8.88e-016,-8.88e-016) (+0.00e+000,+0.00e+000)
(-2.22e-016,-2.22e-016) (-4.44e-016,-4.44e-016) (+8.88e-016,-8.88e-016)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(+9.38e-002,-9.38e-002) (+1.88e-001,+1.88e-001) (+9.38e-002,+2.40e-001)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve_tran(const CVector&,TR&)const
Parameters
[in]vBcvector $b$.
Returns
Result object.

Definition at line 25603 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::solve_conj ( const CVector vB) const throw (cvmexception)
inline

Linear solver (hermitian conjugated)

Creates cvector object as solution $x$ of linear equation $A^H*x=b$ where calling matrix is square complex matrix $A$ and parameter vB is vector $b$. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve_conj (ma, mb);
std::cout << mx
<< std::endl << ~ma * mx - mb
<< std::endl << ~mx * ma - ~mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve_conj (vb);
std::cout << vx << std::endl << ~ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-5.31e-001,+3.13e-002) (-9.38e-002,+9.38e-002)
(+6.25e-002,+6.25e-002) (+1.88e-001,+1.88e-001)
(+4.69e-001,+3.13e-002) (+2.40e-001,+9.38e-002)
(-2.22e-016,-2.22e-016) (+0.00e+000,+0.00e+000)
(-4.44e-016,-4.44e-016) (+0.00e+000,+0.00e+000)
(-8.88e-016,+8.88e-016) (+0.00e+000,+0.00e+000)
(-2.22e-016,+2.22e-016) (-4.44e-016,+4.44e-016) (-8.88e-016,-8.88e-016)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(-9.38e-002,+9.38e-002) (+1.88e-001,+1.88e-001) (+2.40e-001,+9.38e-002)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve_conj(const CVector&,TR&)const
Parameters
[in]vBcvector $b$.
Returns
Result object.

Definition at line 25670 of file cvm.h.

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::solve ( const BaseCMatrix mB,
TR &  dErr 
) const throw (cvmexception)
inline

Linear solver.

Creates cmatrix object as solution $X$ of matrix linear equation $A*X=B$ where calling square complex matrix is matrix $A$ and parameter mB is matrix $B$. It also sets output parameter dErr to be equal to the norm of computation error. Function throws cvmexception in case of inappropriate sizes of the operands or when the matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve (ma, mb, dErr);
std::cout << mx << dErr
<< std::endl << ma * mx - mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve (vb, dErr);
std::cout << vx << dErr << std::endl << ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-6.25e-002,-2.71e-001) (-1.25e-001,+1.13e+000)
(+1.25e-001,+2.08e-001) (+2.50e-001,-2.50e-001)
(+6.25e-002,+6.25e-002) (+1.25e-001,+1.25e-001)
+1.45e-014
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(-2.22e-016,+4.44e-016) (+0.00e+000,+0.00e+000)
(+2.22e-016,+0.00e+000) (+0.00e+000,+0.00e+000)
(-1.25e-001,+1.13e+000) (+2.50e-001,-2.50e-001) (+1.25e-001,+1.25e-001)
+7.41e-015
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve(const BaseCMatrix&)const
Parameters
[in]mBcmatrix $B$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 25735 of file cvm.h.

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::solve_tran ( const BaseCMatrix mB,
TR &  dErr 
) const throw (cvmexception)
inline

Linear solver (transposed)

Creates cmatrix object as solution $X$ of matrix linear equation $A^T*X=B$ (which is equivalent to $X^T*A=B^T$) where calling matrix is square complex matrix $A$ and parameter mB is matrix $B$. It also sets output parameter dErr to be equal to the norm of computation error. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve_tran (ma, mb, dErr);
std::cout << mx << dErr
<< std::endl << !ma * mx - mb
<< std::endl << !mx * ma - !mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve_tran (vb, dErr);
std::cout << vx << dErr << std::endl << vx * ma - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(+3.13e-002,-5.31e-001) (+9.38e-002,-9.38e-002)
(+6.25e-002,+6.25e-002) (+1.88e-001,+1.88e-001)
(+3.13e-002,+4.69e-001) (+9.38e-002,+2.40e-001)
+1.02e-014
(-2.22e-016,-2.22e-016) (+0.00e+000,+0.00e+000)
(-4.44e-016,-4.44e-016) (+0.00e+000,+0.00e+000)
(+8.88e-016,-8.88e-016) (+0.00e+000,+0.00e+000)
(-2.22e-016,-2.22e-016) (-4.44e-016,-4.44e-016) (+8.88e-016,-8.88e-016)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(+9.38e-002,-9.38e-002) (+1.88e-001,+1.88e-001) (+9.38e-002,+2.40e-001)
+1.02e-014
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve_tran(const BaseCMatrix&)const
Parameters
[in]mBcmatrix $B$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 25804 of file cvm.h.

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::solve_conj ( const BaseCMatrix mB,
TR &  dErr 
) const throw (cvmexception)
inline

Linear solver (hermitian conjugated)

Creates cmatrix object as solution $X$ of matrix linear equation $A^H*X=B$ (which is equivalent to $X^H*A=B^H$) where calling matrix is square complex matrix $A$ and parameter mB is matrix $B$. It also sets output parameter dErr to be equal to the norm of computation error. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve_conj (ma, mb, dErr);
std::cout << mx << dErr
<< std::endl << ~ma * mx - mb
<< std::endl << ~mx * ma - ~mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve_conj (vb, dErr);
std::cout << vx << dErr << std::endl << ~ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-5.31e-001,+3.13e-002) (-9.38e-002,+9.38e-002)
(+6.25e-002,+6.25e-002) (+1.88e-001,+1.88e-001)
(+4.69e-001,+3.13e-002) (+2.40e-001,+9.38e-002)
+1.02e-014
(-2.22e-016,-2.22e-016) (+0.00e+000,+0.00e+000)
(-4.44e-016,-4.44e-016) (+0.00e+000,+0.00e+000)
(-8.88e-016,+8.88e-016) (+0.00e+000,+0.00e+000)
(-2.22e-016,+2.22e-016) (-4.44e-016,+4.44e-016) (-8.88e-016,-8.88e-016)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(-9.38e-002,+9.38e-002) (+1.88e-001,+1.88e-001) (+2.40e-001,+9.38e-002)
+1.02e-014
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve_conj(const BaseCMatrix&)const
Parameters
[in]mBcmatrix $B$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 25873 of file cvm.h.

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::solve ( const BaseCMatrix mB) const throw (cvmexception)
inline

Linear solver.

Creates cmatrix object as solution $X$ of matrix linear equation $A*X=B$ where calling square complex matrix is matrix $A$ and parameter mB is matrix $B$. Function throws cvmexception in case of inappropriate sizes of the operands or when the matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve (ma, mb);
std::cout << mx << std::endl << ma * mx - mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve (vb);
std::cout << vx << std::endl << ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-6.25e-002,-2.71e-001) (-1.25e-001,+1.13e+000)
(+1.25e-001,+2.08e-001) (+2.50e-001,-2.50e-001)
(+6.25e-002,+6.25e-002) (+1.25e-001,+1.25e-001)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(-2.22e-016,+4.44e-016) (+0.00e+000,+0.00e+000)
(+2.22e-016,+0.00e+000) (+0.00e+000,+0.00e+000)
(-1.25e-001,+1.13e+000) (+2.50e-001,-2.50e-001) (+1.25e-001,+1.25e-001)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve(const BaseCMatrix&,TR&)const
Parameters
[in]mBcmatrix $B$.
Returns
Result object.

Definition at line 25932 of file cvm.h.

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::solve_tran ( const BaseCMatrix mB) const throw (cvmexception)
inline

Linear solver (transposed)

Creates cmatrix object as solution $X$ of matrix linear equation $A^T*X=B$ (which is equivalent to $X^T*A=B^T$) where calling matrix is square complex matrix $A$ and parameter mB is matrix $B$. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve_tran (ma, mb);
std::cout << mx
<< std::endl << !ma * mx - mb
<< std::endl << !mx * ma - !mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve_tran (vb);
std::cout << vx << std::endl << vx * ma - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(+3.13e-002,-5.31e-001) (+9.38e-002,-9.38e-002)
(+6.25e-002,+6.25e-002) (+1.88e-001,+1.88e-001)
(+3.13e-002,+4.69e-001) (+9.38e-002,+2.40e-001)
(-2.22e-016,-2.22e-016) (+0.00e+000,+0.00e+000)
(-4.44e-016,-4.44e-016) (+0.00e+000,+0.00e+000)
(+8.88e-016,-8.88e-016) (+0.00e+000,+0.00e+000)
(-2.22e-016,-2.22e-016) (-4.44e-016,-4.44e-016) (+8.88e-016,-8.88e-016)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(+9.38e-002,-9.38e-002) (+1.88e-001,+1.88e-001) (+9.38e-002,+2.40e-001)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve_tran(const BaseCMatrix&,TR&)const
Parameters
[in]mBcmatrix $B$.
Returns
Result object.

Definition at line 26000 of file cvm.h.

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::solve_conj ( const BaseCMatrix mB) const throw (cvmexception)
inline

Linear solver (hermitian conjugated)

Creates cmatrix object as solution $X$ of matrix linear equation $A^H*X=B$ (which is equivalent to $X^H*A=B^H$) where calling matrix is square complex matrix $A$ and parameter mB is matrix $B$. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
scmatrix ma(re, im, 3);
cmatrix mb(3,2);
cmatrix mx(3,2);
mb(1).set(std::complex<double>(1.,1.));
mb(1,2) = std::complex<double>(1.,1.);
mb(2,2) = std::complex<double>(2.,2.);
mb(3,2) = std::complex<double>(3.,3.);
mx.solve_conj (ma, mb);
std::cout << mx
<< std::endl << ~ma * mx - mb
<< std::endl << ~mx * ma - ~mb << std::endl;
cvector vb(3), vx(3);
vb = mb(2);
vx = ma.solve_conj (vb);
std::cout << vx << std::endl << ~ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-5.31e-001,+3.13e-002) (-9.38e-002,+9.38e-002)
(+6.25e-002,+6.25e-002) (+1.88e-001,+1.88e-001)
(+4.69e-001,+3.13e-002) (+2.40e-001,+9.38e-002)
(-2.22e-016,-2.22e-016) (+0.00e+000,+0.00e+000)
(-4.44e-016,-4.44e-016) (+0.00e+000,+0.00e+000)
(-8.88e-016,+8.88e-016) (+0.00e+000,+0.00e+000)
(-2.22e-016,+2.22e-016) (-4.44e-016,+4.44e-016) (-8.88e-016,-8.88e-016)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
(-9.38e-002,+9.38e-002) (+1.88e-001,+1.88e-001) (+2.40e-001,+9.38e-002)
(+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000) (+0.00e+000,+0.00e+000)
See Also
solve_conj(const BaseCMatrix&,TR&)const
Parameters
[in]mBcmatrix $B$.
Returns
Result object.

Definition at line 26068 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::operator% ( const CVector vB) const throw (cvmexception)
inline

Linear solver operator (transposed)

Creates cvector object as solution $x$ of linear equation $A^T*x=b$ (which is equivalent to $x*A=b$) where calling matrix is square complex 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 (7);
try {
double m[] = {1., -1., 1., 2., -2., 1., 3., -3.};
double b[] = {1., 2., 5., -3.};
scmatrix ma((std::complex<double>*) m, 2);
cvector vb((std::complex<double>*) b, 2);
cvector vx(2);
vx = ma % vb;
std::cout << vx * ma - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(+0.0000000e+000,+0.0000000e+000) (+0.0000000e+000,+4.4408921e-016)
Parameters
[in]vBcvector $b$.
Returns
Result object.

Definition at line 26108 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::operator/ ( const CVector vB) const throw (cvmexception)
inline

Linear solver operator.

Creates cvector object as solution $x$ of linear equation $A*x=b$ where calling matrix is square complex 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 (7);
try {
double m[] = {1., -1., 1., 2., -2., 1., 3., -3.};
double b[] = {1., 2., 5., -3.};
scmatrix ma((std::complex<double>*) m, 2);
cvector vb((std::complex<double>*) b, 2);
cvector vx(2);
vx = ma / vb;
std::cout << ma * vx - vb;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-6.6613381e-016,+4.4408921e-016) (+0.0000000e+000,+0.0000000e+000)
Parameters
[in]vBcvector $b$.
Returns
Result object.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 26146 of file cvm.h.

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::solve_lu ( const basic_scmatrix< TR, TC > &  mLU,
const tint pPivots,
const CVector vB,
TR &  dErr 
) const throw (cvmexception)
inline

LU factorization based linear solver.

Creates object of type cvector as solution $x$ of linear equation $A*x=b$ where calling matrix is square complex matrix $A$, parameter mLU is LU factorization (see low_up() ) of matrix $A$, parameter pPivots is an array of pivot numbers created while factorizing matrix $A$ and parameter vB is vector $b$. Function also sets output parameter dErr to be equal to the norm of computation error. This function is useful when you need to solve few linear equations of kind $A*x=b$ with the same matrix $A$ and different vectors $b$. In such case you save on matrix $A$ factorization since it's needed to be performed just one time. It also sets output parameter dErr to be equal to the norm of computation error and throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
scmatrix ma(3);
scmatrix mLU(3);
cmatrix mb1(3,2); cvector vb1(3);
cmatrix mb2(3,2); cvector vb2(3);
cmatrix mx1(3,2); cvector vx1(3);
cmatrix mx2(3,2); cvector vx2(3);
iarray nPivots(3);
double dErr = 0.;
ma.randomize_real(-1.1,3.); ma.randomize_imag(-3.7,3.);
mb1.randomize_real(-1.,3.); mb1.randomize_imag(-1.,3.);
vb1.randomize_real(-2.,3.); vb1.randomize_imag(-3.,1.);
mb2.randomize_real(-5.,1.); mb2.randomize_imag(-4.,1.);
vb2.randomize_real(-1.,6.); vb1.randomize_imag(-4.,4.);
mLU.low_up(ma, nPivots);
mx1 = ma.solve_lu (mLU, nPivots, mb1, dErr);
std::cout << mx1 << dErr << std::endl;
mx2 = ma.solve_lu (mLU, nPivots, mb2);
std::cout << mx2 << std::endl;;
std::cout << ma * mx1 - mb1 << std::endl << ma * mx2 - mb2;
vx1 = ma.solve_lu (mLU, nPivots, vb1, dErr);
std::cout << vx1 << dErr << std::endl;
vx2 = ma.solve_lu (mLU, nPivots, vb2);
std::cout << vx2 << std::endl;;
std::cout << ma * vx1 - vb1 << std::endl << ma * vx2 - vb2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-3.91e-001,-1.62e-001) (-3.17e-001,2.39e-001)
(-3.00e-001,-7.91e-001) (4.71e-001,-9.13e-001)
(-2.34e-001,1.09e+000) (1.10e-001,2.72e-001)
2.78e-015
(-2.60e-001,-5.48e-001) (-3.09e-002,-9.62e-001)
(8.77e-001,8.41e-001) (-6.02e-001,1.87e+000)
(4.20e-003,-9.72e-001) (6.18e-001,-5.64e-001)
(0.00e+000,-2.64e-016) (-1.11e-016,1.11e-016)
(0.00e+000,-2.22e-016) (2.22e-016,-4.44e-016)
(0.00e+000,0.00e+000) (-5.55e-017,0.00e+000)
(6.66e-016,-2.22e-016) (6.18e-016,0.00e+000)
(0.00e+000,1.11e-016) (0.00e+000,0.00e+000)
(0.00e+000,0.00e+000) (-4.44e-016,0.00e+000)
(2.61e-001,2.97e-001) (1.95e+000,-1.07e-001) (-5.51e-001,-1.03e-001)
1.96e-015
(1.26e-001,4.07e-001) (-4.82e-001,-1.14e-002) (2.59e-001,1.60e-001)
(1.11e-016,0.00e+000) (5.55e-017,0.00e+000) (1.11e-016,-2.22e-016)
(-1.11e-016,-7.61e-017) (-2.22e-016,-8.94e-017) (0.00e+000,4.07e-017)
See Also
low_up()
Parameters
[in]mLULU factorization of matrix $A$.
[in]pPivotspivots vector.
[in]vBcvector $b$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 26234 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::solve_lu ( const basic_scmatrix< TR, TC > &  mLU,
const tint pPivots,
const CVector vB 
) const throw (cvmexception)
inline

LU factorization based linear solver.

Creates object of type cvector as solution $x$ of linear equation $A*x=b$ where calling matrix is square complex matrix $A$, parameter mLU is LU factorization (see low_up() ) of matrix $A$, parameter pPivots is an array of pivot numbers created while factorizing matrix $A$ and parameter vB is vector $b$. Function also sets output parameter dErr to be equal to the norm of computation error. This function is useful when you need to solve few linear equations of kind $A*x=b$ with the same matrix $A$ and different vectors $b$. In such case you save on matrix $A$ factorization since it's needed to be performed just one time. It throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
scmatrix ma(3);
scmatrix mLU(3);
cmatrix mb1(3,2); cvector vb1(3);
cmatrix mb2(3,2); cvector vb2(3);
cmatrix mx1(3,2); cvector vx1(3);
cmatrix mx2(3,2); cvector vx2(3);
iarray nPivots(3);
double dErr = 0.;
ma.randomize_real(-1.1,3.); ma.randomize_imag(-3.7,3.);
mb1.randomize_real(-1.,3.); mb1.randomize_imag(-1.,3.);
vb1.randomize_real(-2.,3.); vb1.randomize_imag(-3.,1.);
mb2.randomize_real(-5.,1.); mb2.randomize_imag(-4.,1.);
vb2.randomize_real(-1.,6.); vb1.randomize_imag(-4.,4.);
mLU.low_up(ma, nPivots);
mx1 = ma.solve_lu (mLU, nPivots, mb1, dErr);
std::cout << mx1 << dErr << std::endl;
mx2 = ma.solve_lu (mLU, nPivots, mb2);
std::cout << mx2 << std::endl;;
std::cout << ma * mx1 - mb1 << std::endl << ma * mx2 - mb2;
vx1 = ma.solve_lu (mLU, nPivots, vb1, dErr);
std::cout << vx1 << dErr << std::endl;
vx2 = ma.solve_lu (mLU, nPivots, vb2);
std::cout << vx2 << std::endl;;
std::cout << ma * vx1 - vb1 << std::endl << ma * vx2 - vb2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-3.91e-001,-1.62e-001) (-3.17e-001,2.39e-001)
(-3.00e-001,-7.91e-001) (4.71e-001,-9.13e-001)
(-2.34e-001,1.09e+000) (1.10e-001,2.72e-001)
2.78e-015
(-2.60e-001,-5.48e-001) (-3.09e-002,-9.62e-001)
(8.77e-001,8.41e-001) (-6.02e-001,1.87e+000)
(4.20e-003,-9.72e-001) (6.18e-001,-5.64e-001)
(0.00e+000,-2.64e-016) (-1.11e-016,1.11e-016)
(0.00e+000,-2.22e-016) (2.22e-016,-4.44e-016)
(0.00e+000,0.00e+000) (-5.55e-017,0.00e+000)
(6.66e-016,-2.22e-016) (6.18e-016,0.00e+000)
(0.00e+000,1.11e-016) (0.00e+000,0.00e+000)
(0.00e+000,0.00e+000) (-4.44e-016,0.00e+000)
(2.61e-001,2.97e-001) (1.95e+000,-1.07e-001) (-5.51e-001,-1.03e-001)
1.96e-015
(1.26e-001,4.07e-001) (-4.82e-001,-1.14e-002) (2.59e-001,1.60e-001)
(1.11e-016,0.00e+000) (5.55e-017,0.00e+000) (1.11e-016,-2.22e-016)
(-1.11e-016,-7.61e-017) (-2.22e-016,-8.94e-017) (0.00e+000,4.07e-017)
See Also
low_up()
Parameters
[in]mLULU factorization of matrix $A$.
[in]pPivotspivots vector.
[in]vBcvector $b$.
Returns
Result object.

Definition at line 26326 of file cvm.h.

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::solve_lu ( const basic_scmatrix< TR, TC > &  mLU,
const tint pPivots,
const BaseCMatrix mB,
TR &  dErr 
) const throw (cvmexception)
inline

LU factorization based linear solver.

Creates object of type cmatrix as solution $X$ of matrix linear equation $A*X=B$ where calling matrix is square complex matrix $A$, parameter mLU is LU factorization (see low_up() ) of matrix $A$, parameter pPivots is an array of pivot numbers created while factorizing matrix $A$ and parameter mB is matrix $B$. This function is useful when you need to solve few linear equations of kind $A*X=B$ with the same matrix $A$ and different matrices $B$. In such case you save on matrix $A$ factorization since it's needed to be performed just one time. Function also sets output parameter dErr to be equal to the norm of computation error and throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
scmatrix ma(3);
scmatrix mLU(3);
cmatrix mb1(3,2); cvector vb1(3);
cmatrix mb2(3,2); cvector vb2(3);
cmatrix mx1(3,2); cvector vx1(3);
cmatrix mx2(3,2); cvector vx2(3);
iarray nPivots(3);
double dErr = 0.;
ma.randomize_real(-1.1,3.); ma.randomize_imag(-3.7,3.);
mb1.randomize_real(-1.,3.); mb1.randomize_imag(-1.,3.);
vb1.randomize_real(-2.,3.); vb1.randomize_imag(-3.,1.);
mb2.randomize_real(-5.,1.); mb2.randomize_imag(-4.,1.);
vb2.randomize_real(-1.,6.); vb1.randomize_imag(-4.,4.);
mLU.low_up(ma, nPivots);
mx1 = ma.solve_lu (mLU, nPivots, mb1, dErr);
std::cout << mx1 << dErr << std::endl;
mx2 = ma.solve_lu (mLU, nPivots, mb2);
std::cout << mx2 << std::endl;;
std::cout << ma * mx1 - mb1 << std::endl << ma * mx2 - mb2;
vx1 = ma.solve_lu (mLU, nPivots, vb1, dErr);
std::cout << vx1 << dErr << std::endl;
vx2 = ma.solve_lu (mLU, nPivots, vb2);
std::cout << vx2 << std::endl;;
std::cout << ma * vx1 - vb1 << std::endl << ma * vx2 - vb2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-3.91e-001,-1.62e-001) (-3.17e-001,2.39e-001)
(-3.00e-001,-7.91e-001) (4.71e-001,-9.13e-001)
(-2.34e-001,1.09e+000) (1.10e-001,2.72e-001)
2.78e-015
(-2.60e-001,-5.48e-001) (-3.09e-002,-9.62e-001)
(8.77e-001,8.41e-001) (-6.02e-001,1.87e+000)
(4.20e-003,-9.72e-001) (6.18e-001,-5.64e-001)
(0.00e+000,-2.64e-016) (-1.11e-016,1.11e-016)
(0.00e+000,-2.22e-016) (2.22e-016,-4.44e-016)
(0.00e+000,0.00e+000) (-5.55e-017,0.00e+000)
(6.66e-016,-2.22e-016) (6.18e-016,0.00e+000)
(0.00e+000,1.11e-016) (0.00e+000,0.00e+000)
(0.00e+000,0.00e+000) (-4.44e-016,0.00e+000)
(2.61e-001,2.97e-001) (1.95e+000,-1.07e-001) (-5.51e-001,-1.03e-001)
1.96e-015
(1.26e-001,4.07e-001) (-4.82e-001,-1.14e-002) (2.59e-001,1.60e-001)
(1.11e-016,0.00e+000) (5.55e-017,0.00e+000) (1.11e-016,-2.22e-016)
(-1.11e-016,-7.61e-017) (-2.22e-016,-8.94e-017) (0.00e+000,4.07e-017)
See Also
low_up()
Parameters
[in]mLULU factorization of matrix $A$.
[in]pPivotspivots vector.
[in]mBcmatrix $B$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 26415 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
BaseCMatrix basic_scmatrix< TR, TC >::solve_lu ( const basic_scmatrix< TR, TC > &  mLU,
const tint pPivots,
const BaseCMatrix mB 
) const throw (cvmexception)
inline

LU factorization based linear solver.

Creates object of type cmatrix as solution $X$ of matrix linear equation $A*X=B$ where calling matrix is square complex matrix $A$, parameter mLU is LU factorization (see low_up() ) of matrix $A$, parameter pPivots is an array of pivot numbers created while factorizing matrix $A$ and parameter mB is matrix $B$. This function is useful when you need to solve few linear equations of kind $A*X=B$ with the same matrix $A$ and different matrices $B$. In such case you save on matrix $A$ factorization since it's needed to be performed just one time. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix $A$ is close to singular.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
scmatrix ma(3);
scmatrix mLU(3);
cmatrix mb1(3,2); cvector vb1(3);
cmatrix mb2(3,2); cvector vb2(3);
cmatrix mx1(3,2); cvector vx1(3);
cmatrix mx2(3,2); cvector vx2(3);
iarray nPivots(3);
double dErr = 0.;
ma.randomize_real(-1.1,3.); ma.randomize_imag(-3.7,3.);
mb1.randomize_real(-1.,3.); mb1.randomize_imag(-1.,3.);
vb1.randomize_real(-2.,3.); vb1.randomize_imag(-3.,1.);
mb2.randomize_real(-5.,1.); mb2.randomize_imag(-4.,1.);
vb2.randomize_real(-1.,6.); vb1.randomize_imag(-4.,4.);
mLU.low_up(ma, nPivots);
mx1 = ma.solve_lu (mLU, nPivots, mb1, dErr);
std::cout << mx1 << dErr << std::endl;
mx2 = ma.solve_lu (mLU, nPivots, mb2);
std::cout << mx2 << std::endl;;
std::cout << ma * mx1 - mb1 << std::endl << ma * mx2 - mb2;
vx1 = ma.solve_lu (mLU, nPivots, vb1, dErr);
std::cout << vx1 << dErr << std::endl;
vx2 = ma.solve_lu (mLU, nPivots, vb2);
std::cout << vx2 << std::endl;;
std::cout << ma * vx1 - vb1 << std::endl << ma * vx2 - vb2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-3.91e-001,-1.62e-001) (-3.17e-001,2.39e-001)
(-3.00e-001,-7.91e-001) (4.71e-001,-9.13e-001)
(-2.34e-001,1.09e+000) (1.10e-001,2.72e-001)
2.78e-015
(-2.60e-001,-5.48e-001) (-3.09e-002,-9.62e-001)
(8.77e-001,8.41e-001) (-6.02e-001,1.87e+000)
(4.20e-003,-9.72e-001) (6.18e-001,-5.64e-001)
(0.00e+000,-2.64e-016) (-1.11e-016,1.11e-016)
(0.00e+000,-2.22e-016) (2.22e-016,-4.44e-016)
(0.00e+000,0.00e+000) (-5.55e-017,0.00e+000)
(6.66e-016,-2.22e-016) (6.18e-016,0.00e+000)
(0.00e+000,1.11e-016) (0.00e+000,0.00e+000)
(0.00e+000,0.00e+000) (-4.44e-016,0.00e+000)
(2.61e-001,2.97e-001) (1.95e+000,-1.07e-001) (-5.51e-001,-1.03e-001)
1.96e-015
(1.26e-001,4.07e-001) (-4.82e-001,-1.14e-002) (2.59e-001,1.60e-001)
(1.11e-016,0.00e+000) (5.55e-017,0.00e+000) (1.11e-016,-2.22e-016)
(-1.11e-016,-7.61e-017) (-2.22e-016,-8.94e-017) (0.00e+000,4.07e-017)
See Also
low_up()
Parameters
[in]mLULU factorization of matrix $A$.
[in]pPivotspivots vector.
[in]mBcmatrix $B$.
Returns
Result object.

Definition at line 26506 of file cvm.h.

template<typename TR, typename TC>
TC basic_scmatrix< TR, TC >::det ( ) const throw (cvmexception)
inline

Matrix determinant.

Returns determinant of calling matrix. It uses the LU factorization internally and may throw the same exceptions as the factorizer.

Example:
using namespace cvm;
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {-1., 2., -3., -4., 5., -6., 7., -8., 9.};
const scmatrix m(re, im, 3);
std::cout << m << std::endl << m.det() << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1,-1) (4,-4) (7,7)
(2,2) (5,5) (8,-8)
(3,-3) (6,-6) (9,9)
(-192,-192)
See Also
low_up()
Returns
Determinant value.

Definition at line 26541 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::low_up ( const basic_scmatrix< TR, TC > &  m,
tint nPivots 
) throw (cvmexception)
inline

Low-up (LU) factorization.

Compute LU factorization of square complex matrix $A$ as

\[ A=PLU \]

where $P$ is permutation matrix, $L$ is lower triangular matrix with unit diagonal elements and $U$ is upper triangular matrix. Function stores result as the matrix $L$ without main diagonal combined with $U$. Function returns pivot indices as array of integers (it should support at least msize() elements) pointed to by nPivots so $i$-th row was interchanged with nPivots[ $i$]-th row. This version sets calling matrix to be equal to matrix m's LU factorization. Function throws cvmexception in case of inappropriate sizes of the operands or when the matrix to be factorized is close to singular. It is recommended to use iarray for pivot values.

Example:
using namespace cvm;
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.1};
scmatrix m(re, im, 3);
scmatrix mLU(3), mLo(3), mUp(3);
iarray naPivots(3);
mLU.low_up (m, naPivots);
mLo.identity ();
mLo.diag(-2) = mLU.diag(-2);
mLo.diag(-1) = mLU.diag(-1);
mUp.diag(0) = mLU.diag(0);
mUp.diag(1) = mLU.diag(1);
mUp.diag(2) = mLU.diag(2);
std::cout << mLo << std::endl << mUp
<< std::endl << naPivots << std::endl;
mLU = mLo * mUp;
for (int i = 3; i >= 1; i--) {
mLU.swap_rows (i, naPivots[i]);
}
std::cout << mLU << std::endl << m - mLU;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1,0) (0,0) (0,0)
(0.333333,0) (1,0) (0,0)
(0.666667,0) (0.5,0) (1,0)
(3,3) (6,6) (9,9.1)
(0,0) (2,2) (4,3.96667)
(0,0) (0,0) (-1.11022e-016,-0.05)
3 3 3
(1,1) (4,4) (7,7)
(2,2) (5,5) (8,8)
(3,3) (6,6) (9,9.1)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
Parameters
[in]mscmatrix to compute LU factorization for.
[out]nPivotsArray of pivot indices.
Returns
Reference to changed calling matrix.

Definition at line 26622 of file cvm.h.

Here is the caller graph for this function:

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::low_up ( tint nPivots) const throw (cvmexception)
inline

Low-up (LU) factorization.

Compute LU factorization of square complex matrix $A$ as

\[ A=PLU \]

where $P$ is permutation matrix, $L$ is lower triangular matrix with unit diagonal elements and $U$ is upper triangular matrix. Function stores result as the matrix $L$ without main diagonal combined with $U$. Function returns pivot indices as array of integers (it should support at least msize() elements) pointed to by nPivots so $i$-th row was interchanged with nPivots[ $i$]-th row. This version creates object of type srmatrix as calling matrix LU factorization. Function throws cvmexception in case of inappropriate sizes of the operands or when the matrix to be factorized is close to singular. It is recommended to use iarray for pivot values.

Example:
using namespace cvm;
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.1};
scmatrix m(re, im, 3);
scmatrix mLU(3), mLo(3), mUp(3);
iarray naPivots(3);
mLU = m.low_up(naPivots);
mLo.identity ();
mLo.diag(-2) = mLU.diag(-2);
mLo.diag(-1) = mLU.diag(-1);
mUp.diag(0) = mLU.diag(0);
mUp.diag(1) = mLU.diag(1);
mUp.diag(2) = mLU.diag(2);
std::cout << mLo << std::endl << mUp
<< std::endl << naPivots << std::endl;
mLU = mLo * mUp;
for (int i = 3; i >= 1; i--) {
mLU.swap_rows (i, naPivots[i]);
}
std::cout << mLU << std::endl << m - mLU;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1,0) (0,0) (0,0)
(0.333333,0) (1,0) (0,0)
(0.666667,0) (0.5,0) (1,0)
(3,3) (6,6) (9,9.1)
(0,0) (2,2) (4,3.96667)
(0,0) (0,0) (-1.11022e-016,-0.05)
3 3 3
(1,1) (4,4) (7,7)
(2,2) (5,5) (8,8)
(3,3) (6,6) (9,9.1)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
Parameters
[out]nPivotsArray of pivot indices.
Returns
Result object.

Reimplemented in basic_scbmatrix< TR, TC >.

Definition at line 26704 of file cvm.h.

template<typename TR, typename TC>
TR basic_scmatrix< TR, TC >::cond ( ) const throw (cvmexception)
inline

Condition number reciprocal.

Returns condition number reciprocal of calling matrix $A$ in the infinity-norm

\[ \kappa_\infty=\|A\|_\infty \|A^{-1}\|_\infty. \]

Less value returned means that matrix $A$ is closer to singular. Zero value returned means estimation underflow or that matrix $A$ is singular. The condition number is used for error analysis of systems of linear equations. Function throws cvmexception in case of LAPACK subroutines failure.

Example:
using namespace cvm;
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
scmatrix m(re, im, 3);
std::cout << m.cond() << std::endl
<< m.det() << std::endl << std::endl;
m(3,3) = std::complex<double>(9.,10.);
std::cout << m.cond() << std::endl << m.det() << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
1.54198e-018
(1.33227e-015,-1.33227e-015)
0.0050679
(6,-1.33227e-015)
See Also
basic_array::norminf()
Returns
Result value.

Definition at line 26753 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::inv ( const basic_scmatrix< TR, TC > &  m) throw (cvmexception)
inline

Matrix inversion.

This version sets calling matrix to be equal to square complex 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 (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {1., 2., 3., 4., 5., 6., 7., 8., 10.};
scmatrix m(re, im, 3);
scmatrix mi(3);
mi.inv (m);
std::cout << mi << std::endl << mi * m - eye_complex(3);
std::cout << std::endl << mi.inv() * mi - eye_complex(3);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-8.33e-001,-1.67e-001) (6.67e-001,1.33e+000) (4.81e-016,-1.00e+000)
(3.33e-001,1.67e+000) (-1.67e-001,-3.83e+000) (-5.37e-016,2.00e+000)
(2.22e-016,-1.00e+000) (-4.44e-016,2.00e+000) (2.22e-016,-1.00e+000)
(-1.11e-016,1.11e-016) (0.00e+000,2.22e-016) (8.33e-017,1.26e-015)
(4.44e-016,-5.00e-016) (0.00e+000,7.77e-016) (7.22e-016,-1.15e-015)
(-1.11e-016,1.11e-016) (2.22e-016,-6.66e-016) (0.00e+000,1.11e-016)
(4.44e-016,4.44e-016) (-1.18e-015,1.33e-015) (6.66e-016,-7.77e-016)
(-6.85e-016,8.88e-016) (1.33e-015,3.16e-030) (-8.33e-016,-1.77e-030)
(-5.09e-016,6.66e-016) (7.96e-016,-1.78e-015) (-4.44e-016,1.11e-016)
Parameters
[in]mscmatrix to invert.
Returns
Reference to changed calling matrix.

Definition at line 26802 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::inv ( ) const throw (cvmexception)
inline

Matrix inversion.

This version creates scmatrix object equal to calling 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 (2);
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {1., 2., 3., 4., 5., 6., 7., 8., 10.};
scmatrix m(re, im, 3);
scmatrix mi(3);
mi.inv (m);
std::cout << mi << std::endl << mi * m - eye_complex(3);
std::cout << std::endl << mi.inv() * mi - eye_complex(3);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-8.33e-001,-1.67e-001) (6.67e-001,1.33e+000) (4.81e-016,-1.00e+000)
(3.33e-001,1.67e+000) (-1.67e-001,-3.83e+000) (-5.37e-016,2.00e+000)
(2.22e-016,-1.00e+000) (-4.44e-016,2.00e+000) (2.22e-016,-1.00e+000)
(-1.11e-016,1.11e-016) (0.00e+000,2.22e-016) (8.33e-017,1.26e-015)
(4.44e-016,-5.00e-016) (0.00e+000,7.77e-016) (7.22e-016,-1.15e-015)
(-1.11e-016,1.11e-016) (2.22e-016,-6.66e-016) (0.00e+000,1.11e-016)
(4.44e-016,4.44e-016) (-1.18e-015,1.33e-015) (6.66e-016,-7.77e-016)
(-6.85e-016,8.88e-016) (1.33e-015,3.16e-030) (-8.33e-016,-1.77e-030)
(-5.09e-016,6.66e-016) (7.96e-016,-1.78e-015) (-4.44e-016,1.11e-016)
Returns
Result object.

Reimplemented in basic_schmatrix< TR, TC >.

Definition at line 26849 of file cvm.h.

Here is the call graph for this function:

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

Matrix exponent.

Computes exponent of square complex 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 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. Functions throw 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);
try {
scmatrix m(2);
m(1,1) = std::complex<double>(-49.,1.);
m(1,2) = std::complex<double>(24.,1.);
m(2,1) = std::complex<double>(-64.,1.);
m(2,2) = std::complex<double>(31.,1.);
m.exp(m);
std::cout << m(1,1) << std::endl << " "
<< m(1,2) << std::endl;
std::cout << m(2,1) << std::endl << " "
<< m(2,2) << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-4.508497580069049e-001,7.900659666738140e-001)
(3.199576050797298e-001,-6.081804753523605e-001)
(-7.584316151930286e-001,1.666747485117659e+000)
(5.295040786046933e-001,-1.278050361026203e+000)
Matlab output:
Column 1
-4.508497580070262e-001 +7.900659666739607e-001i
-7.584316151932523e-001 +1.666747485117982e+000i
Column 2
3.199576050798204e-001 -6.081804753524764e-001i
5.295040786048589e-001 -1.278050361026457e+000i
Parameters
[in]mscmatrix to compute exponent for.
[in]tolComputation tolerance.
Returns
Reference to changed calling matrix.

Definition at line 26927 of file cvm.h.

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

Matrix exponent.

Computes exponent of square 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 scmatrix as exponent of calling 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. Functions throw 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);
try {
scmatrix m(2);
m(1,1) = std::complex<double>(-49.,1.);
m(1,2) = std::complex<double>(24.,1.);
m(2,1) = std::complex<double>(-64.,1.);
m(2,2) = std::complex<double>(31.,1.);
m = m.exp();
std::cout << m(1,1) << std::endl << " "
<< m(1,2) << std::endl;
std::cout << m(2,1) << std::endl << " "
<< m(2,2) << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-4.508497580070061e-001,7.900659666739228e-001)
(3.199576050798058e-001,-6.081804753524478e-001)
(-7.584316151932173e-001,1.666747485117903e+000)
(5.295040786048336e-001,-1.278050361026397e+000)
Matlab output:
Column 1
-4.508497580070262e-001 +7.900659666739607e-001i
-7.584316151932523e-001 +1.666747485117982e+000i
Column 2
3.199576050798204e-001 -6.081804753524764e-001i
5.295040786048589e-001 -1.278050361026457e+000i
Parameters
[in]tolComputation tolerance.
Returns
Result object.

Reimplemented in basic_schmatrix< TR, TC >.

Definition at line 27002 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::polynom ( const basic_scmatrix< TR, TC > &  m,
const CVector v 
) throw (cvmexception)
inline

Matrix polynomial.

Computes 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 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 (15);
try {
const double re[] = {2.2, 1.3, 1.1, -0.9, 0.2,
-0.45, 45., -30., 10., 3., 0.};
const double im[] = {0.5, -2, 0, 1, 3,
-3., 30., 0., -9., 0., 1.};
const cvector v(re, im, 11);
scmatrix m(2), mp(2);
m(1,1) = std::complex<double>(0.1, -0.2);
m(1,2) = std::complex<double>(0.1, -0.2);
m(2,1) = std::complex<double>(0.5, -0.6);
m(2,2) = std::complex<double>(0.3, -0.4);
mp.polynom (m, v);
std::cout << mp(1,1) << std::endl << " "
<< mp(1,2) << std::endl;
std::cout << mp(2,1) << std::endl << " "
<< mp(2,2) << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(2.485652665600000e+000,3.791263308800001e+000)
(2.817786176000004e-001,2.301942860800001e+000)
(-8.835069888000001e-001,8.052028620800002e+000)
(1.903009862400001e+000,6.666306188800002e+000)
Matlab output:
Column 1
2.485652665600000e+000 +3.791263308800001e+000i
-8.835069887999991e-001 +8.052028620800002e+000i
Column 2
2.817786176000000e-001 +2.301942860800001e+000i
1.903009862399999e+000 +6.666306188800003e+000i
Parameters
[in]mscmatrix to compute polynomial for.
[in]vVector of coefficients.
Returns
Reference to changed calling matrix.

Definition at line 27088 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix basic_scmatrix< TR, TC >::polynom ( const CVector v) const
inline

Matrix polynomial.

Computes 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 srmatrix as the polynomial of calling 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 (15);
try {
const double re[] = {2.2, 1.3, 1.1, -0.9, 0.2,
-0.45, 45., -30., 10., 3., 0.};
const double im[] = {0.5, -2, 0, 1, 3,
-3., 30., 0., -9., 0., 1.};
const cvector v(re, im, 11);
scmatrix m(2), mp(2);
m(1,1) = std::complex<double>(0.1, -0.2);
m(1,2) = std::complex<double>(0.1, -0.2);
m(2,1) = std::complex<double>(0.5, -0.6);
m(2,2) = std::complex<double>(0.3, -0.4);
mp = m.polynom (v);
std::cout << mp(1,1) << std::endl << " "
<< mp(1,2) << std::endl;
std::cout << mp(2,1) << std::endl << " "
<< mp(2,2) << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(2.485652665600000e+000,3.791263308800001e+000)
(2.817786176000004e-001,2.301942860800001e+000)
(-8.835069888000001e-001,8.052028620800002e+000)
(1.903009862400001e+000,6.666306188800002e+000)
Matlab output:
Column 1
2.485652665600000e+000 +3.791263308800001e+000i
-8.835069887999991e-001 +8.052028620800002e+000i
Column 2
2.817786176000000e-001 +2.301942860800001e+000i
1.903009862399999e+000 +6.666306188800003e+000i
Parameters
[in]vVector of coefficients.
Returns
Result object.

Definition at line 27175 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::eig ( basic_scmatrix< TR, TC > &  mEigVect,
bool  bRightVect = true 
) const throw (cvmexception)
inline

Eigenvalues and eigenvectors.

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

\[ Az = \lambda z. \]

Some eigenvalues may be complex even for real matrix $A$. Moreover, if real nonsymmetric matrix has a complex eigenvalue $a+bi$ corresponding to an eigenvector $z$, then $a-bi$ is also an eigenvalue. The eigenvalue $a-bi$ corresponds to the eigenvector whose elements are complex conjugate to the elements of $z$. Function sets output parameter mEigVect to be equal to square matrix containing eigenvectors as columns. Function also computes "left" eigenvectors if parameter bRightVect is set to false. Left eigencectors satisfy

\[ z^HA = \lambda z^H. \]

Function throws cvmexception in case of inappropriate calling object sizes or in case of convergence error.

Example:
using namespace cvm;
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {1., 2., 3., 4., 5., 6., 7., 8., 10.};
scmatrix m(re, im, 3);
scmatrix me(3);
cvector vl(3);
vl = m.eig (me);
std::cout << vl << std::endl;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
std::cout << m * me(1) - me(1) * vl(1);
std::cout << m * me(2) - me(2) * vl(2);
std::cout << m * me(3) - me(3) * vl(3);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(16.1096,16.7004) (-1.09351,-0.88358) (-0.0161248,0.183218)
(-9.44e-016,-3.55e-015) (-1.11e-016,-1.07e-014) (2.66e-015,-1.42e-014)
(-5.55e-016,-4.44e-016) (-1.80e-015,9.44e-016) (-2.00e-015,7.22e-016)
(9.92e-016,1.24e-015) (1.05e-015,2.78e-017) (1.64e-015,9.30e-016)
See Also
cvector::eig()
Parameters
[out]mEigVectEigenvectors of mA.
[in]bRightVecttrue (default) to compute right eigenvectors.
Returns
Result object.

Definition at line 27242 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_scmatrix< TR, TC >::eig ( ) const throw (cvmexception)
inline

Eigenvalues.

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

\[ Az = \lambda z. \]

Some eigenvalues may be complex even for real matrix $A$. Moreover, if real nonsymmetric matrix has a complex eigenvalue $a+bi$ corresponding to an eigenvector $z$, then $a-bi$ is also an eigenvalue. The eigenvalue $a-bi$ corresponds to the eigenvector whose elements are complex conjugate to the elements of $z$. Function throws cvmexception in case of in caso of memory allocation failure or convergence error.

Example:
using namespace cvm;
try {
double re[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
double im[] = {1., 2., 3., 4., 5., 6., 7., 8., 10.};
scmatrix m(re, im, 3);
std::cout << m.eig();
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(16.1096,16.7004) (-1.09351,-0.88358) (-0.0161248,0.183218)
See Also
cvector::eig()
Returns
Result object.

Reimplemented in basic_schmatrix< TR, TC >.

Definition at line 27286 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::cholesky ( const basic_schmatrix< TR, TC > &  m) throw (cvmexception)
inline

Cholesky factorization.

Forms the Cholesky factorization of hermitian positive-definite complex matrix $A$ defined as

\[ A=U^T U, \]

where $U$ is upper triangular matrix. It utilizes one of ZPOTRF routines of the LAPACK library. Function sets calling matrix to be equal to the factorization of hermitian positive-definite matrix m. Function throws cvmexception in case of inappropriate sizes of the operands or in case of convergence error.

Example:
using namespace cvm;
try {
double r[] = {1., 2., 1., 2., 15., -1., 1., -1., 20.};
double i[] = {0., -1., 2., 1., 0., 3., -2., -3., 0.};
const schmatrix m(r, i, 3);
scmatrix c(3);
c.cholesky(m);
std::cout << c << std::endl;
std::cout << ~c * c - m;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
(1,0) (2,1) (1,-2)
(0,-0) (3.16228,0) (-0.316228,0.632456)
(0,0) (-0,0) (3.80789,0)
(0,0) (0,0) (0,0)
(0,0) (1.77636e-015,0) (0,0)
(0,0) (0,0) (0,0)
See Also
http://www.netlib.org/lapack
Parameters
[in]mschmatrix to factorize.
Returns
Reference to changed calling matrix.

Definition at line 27338 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::bunch_kaufman ( const basic_schmatrix< TR, TC > &  m,
tint nPivots 
) throw (cvmexception)
inline

Bunch-Kaufman factorization.

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

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

where $A$ is the input matrix passed in parameter m, $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 ZHETRF routines of the LAPACK library. Function sets calling matrix to be equal to the factorization of symmetric positive-definite matrix m. Function throws cvmexception in case of inappropriate sizes of the operands or in case of convergence error. Function is mostly designed to be used for subsequent calls of ZHETRS, ZHECON and ZHETRI 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
Parameters
[in]mschmatrix to factorize.
[out]nPivotsPivot indices array.
Returns
Reference to changed calling matrix.

Definition at line 27378 of file cvm.h.

template<typename TR, typename TC>
void basic_scmatrix< TR, TC >::qr ( basic_scmatrix< TR, TC > &  mQ,
basic_scmatrix< TR, TC > &  mR 
) const throw (cvmexception)
inline

QR factorization.

Computes QR factorization as

\[ A=QR \]

where $A$ is calling square complex matrix, orthogonal matrix $Q$ and upper triangular matrix $R$ are mQ and mR respectively. Function throws cvmexception in case if inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
treal ai[] = {1., -1., 2., -2., 3., -3., 4., -4., 5.};
const cvm::scmatrix m(ar, ai, 3);
cvm::scmatrix q(3), r(3);
m.qr(q,r);
std::cout << (eye_complex(3) - ~q * q).norm()
<< " " << (m - q * r).norm() << std::endl;
prints
+3.7957075e-16 +1.9641850e-15
Parameters
[out]mQscmatrix $Q$.
[out]mRscmatrix $R$.

Definition at line 27414 of file cvm.h.

template<typename TR, typename TC>
void basic_scmatrix< TR, TC >::lq ( basic_scmatrix< TR, TC > &  mL,
basic_scmatrix< TR, TC > &  mQ 
) const throw (cvmexception)
inline

LQ factorization.

Computes LQ factorization as

\[ A=LQ \]

where $A$ is calling square complex matrix, lower triangular matrix $L$ and orthogonal matrix $Q$ are mL and mQ respectively. Function throws cvmexception in case if inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
treal ai[] = {1., -1., 2., -2., 3., -3., 4., -4., 5.};
const cvm::scmatrix m(ar, ai, 3);
cvm::scmatrix l(3), q(3);
m.lq(l,q);
std::cout << (eye_complex(3) - ~q * q).norm()
<< " " << (m - l * q).norm() << std::endl;
prints
+3.5331153e-016 +3.0526086e-015
Parameters
[out]mLscmatrix $L$.
[out]mQscmatrix $Q$.

Definition at line 27446 of file cvm.h.

template<typename TR, typename TC>
void basic_scmatrix< TR, TC >::ql ( basic_scmatrix< TR, TC > &  mQ,
basic_scmatrix< TR, TC > &  mL 
) const throw (cvmexception)
inline

QL factorization.

Computes QL factorization as

\[ A=QL \]

where $A$ is calling square complex matrix, orthogonal matrix $Q$ and lower triangular matrix $L$ are mQ and mL respectively. Function throws cvmexception in case if inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
treal ai[] = {1., -1., 2., -2., 3., -3., 4., -4., 5.};
const cvm::scmatrix m(ar, ai, 3);
cvm::scmatrix q(3), l(3);
m.ql(q,l);
std::cout << (eye_complex(3) - ~q * q).norm()
<< " " << (m - q * l).norm() << std::endl;
prints
+8.8904536e-016 +4.5789129e-015
Parameters
[out]mQscmatrix $Q$.
[out]mLscmatrix $L$.

Definition at line 27478 of file cvm.h.

template<typename TR, typename TC>
void basic_scmatrix< TR, TC >::rq ( basic_scmatrix< TR, TC > &  mR,
basic_scmatrix< TR, TC > &  mQ 
) const throw (cvmexception)
inline

RQ factorization.

Computes RQ factorization as

\[ A=RQ \]

where $A$ is calling square complex matrix, upper triangular matrix $R$ and orthogonal matrix $Q$ are mR and mQ respectively. Function throws cvmexception in case if inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
treal ai[] = {1., -1., 2., -2., 3., -3., 4., -4., 5.};
const cvm::scmatrix m(ar, ai, 3);
cvm::scmatrix r(3), q(3);
m.rq(r,q);
std::cout << (eye_complex(3) - ~q * q).norm()
<< " " << (m - r * q).norm() << std::endl;
prints
+3.3357248e-016 +3.4488467e-015
Parameters
[out]mRscmatrix $R$.
[out]mQscmatrix $Q$.

Definition at line 27510 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::identity ( )
inline

Identity matrix.

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

Example:
using namespace cvm;
scmatrix m(3);
m.randomize_real(0.,3.);
m.randomize_imag(-1.,2.);
std::cout << m << std::endl;
std::cout << m.identity();
prints
(1.31162,-0.52501) (2.8612,-0.531144) (1.31849,0.547838)
(1.19929,1.48253) (0.535417,0.41316) (0.459883,1.7019)
(0.415937,-0.491134) (2.0969,-0.218024) (0.545305,1.17866)
(1,0) (0,0) (0,0)
(0,0) (1,0) (0,0)
(0,0) (0,0) (1,0)
Returns
Reference to changed calling matrix.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 27539 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::vanish ( )
inline

Set matrix to zero.

Sets every element of calling square complex 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;
scmatrix m(3);
m.randomize_real(0.,3.);
m.randomize_imag(-1.,2.);
std::cout << m << std::endl;
std::cout << m.vanish();
prints
(1.34834,-0.758385) (0.837825,-0.225532) (0.367687,0.791833)
(2.23698,-0.183142) (2.6878,0.741111) (0.495865,0.698904)
(0.584124,0.00491348) (1.31574,0.687643) (0.482131,1.66482)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 27573 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::randomize_real ( TR  dFrom,
TR  dTo 
)
inline

Randomizer (real part)

Fills real part of calling complex matrix with pseudo-random numbers distributed between dFrom and dTo. It returns reference to the matrix changed.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (3);
cmatrix m(2,3);
m.randomize_real(-1., 2.);
std::cout << m;
prints
(1.090e+00,0.000e+00) (-6.375e-01,0.000e+00) (1.248e+00,0.000e+00)
(-1.272e-01,0.000e+00) (-8.557e-01,0.000e+00) (4.848e-01,0.000e+00)
Parameters
[in]dFromFirst limit.
[in]dToSecond limit.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 27579 of file cvm.h.

template<typename TR, typename TC>
basic_scmatrix& basic_scmatrix< TR, TC >::randomize_imag ( TR  dFrom,
TR  dTo 
)
inline

Randomizer (imaginary part)

Fills imaginary part of calling complex matrix with pseudo-random numbers distributed between dFrom and dTo. It returns reference to the matrix changed.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (3);
cmatrix m(2,3);
m.randomize_imag(-1., 2.);
std::cout << m;
prints
(0.000e+00,1.113e+00) (0.000e+00,6.615e-01) (0.000e+00,1.017e+00)
(0.000e+00,-3.397e-01) (0.000e+00,1.577e+00) (0.000e+00,8.071e-01)
Parameters
[in]dFromFirst limit.
[in]dToSecond limit.
Returns
Reference to changed calling matrix.

Reimplemented from basic_cmatrix< TR, TC >.

Reimplemented in basic_schmatrix< TR, TC >, and basic_scbmatrix< TR, TC >.

Definition at line 27585 of file cvm.h.


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