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 | Friends | List of all members
basic_cmatrix< TR, TC > Class Template Reference

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

#include <cvm.h>

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

Public Member Functions

 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.
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.
CVector operator[] (tint nRow) throw (cvmexception)
 Row as l-value.
const CVector operator() (tint nCol) const throw (cvmexception)
 Column as not l-value.
const CVector operator[] (tint nRow) const throw (cvmexception)
 Row as not l-value.
CVector diag (tint nDiag) throw (cvmexception)
 Diagonal as l-value.
const CVector diag (tint nDiag) const throw (cvmexception)
 Diagonal (not l-value)
const basic_rmatrix< TR > real () const
 Real part (not l-value)
const basic_rmatrix< TR > imag () const
 Imaginary part (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 (const CVector &v) throw (cvmexception)
 Vector (as array) assignment.
basic_cmatrixassign (const TC *pd)
 External array assignment.
basic_cmatrixassign (tint nRow, tint nCol, const basic_cmatrix &m) throw (cvmexception)
 Assignment to submatrix.
basic_cmatrixset (TC c)
 Sets all elements to one value.
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_cmatrixset_real (TR d)
 Sets all real parts to one value.
basic_cmatrixset_imag (TR d)
 Sets all imaginary parts to one value.
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_cmatrix operator- () const
 Unary minus operator.
basic_cmatrix operator* (TR dMult) const
 Multiply by real number operator.
basic_cmatrix operator/ (TR dDiv) const throw (cvmexception)
 Divide by real number operator.
basic_cmatrix operator* (TC cMult) const
 Multiply by complex number operator.
basic_cmatrix operator/ (TC cDiv) const throw (cvmexception)
 Divide by complex number operator.
basic_cmatrixoperator*= (TR dMult)
 Multiply by real number and assign.
basic_cmatrixoperator/= (TR dDiv)
 Divide by real number and assign.
basic_cmatrixoperator*= (TC cMult)
 Multiply by complex number and assign.
basic_cmatrixoperator/= (TC cDiv)
 Divide by complex number and assign.
basic_cmatrixnormalize ()
 Matrix normalizer.
basic_cmatrix operator! () const throw (cvmexception)
 Matrix transposition.
basic_cmatrix operator~ () const throw (cvmexception)
 Matrix conjugation.
basic_cmatrixtranspose (const basic_cmatrix &m) throw (cvmexception)
 Matrix transposition.
basic_cmatrixconj (const basic_cmatrix &m) throw (cvmexception)
 Matrix conjugation.
basic_cmatrixtranspose () throw (cvmexception)
 Matrix transposition (in-place)
basic_cmatrixconj () throw (cvmexception)
 Matrix conjugation (in-place)
CVector operator* (const CVector &v) const throw (cvmexception)
 Matrix-vector product.
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_cmatrixswap_rows (tint n1, tint n2) throw (cvmexception)
 Rows swap.
basic_cmatrixswap_cols (tint n1, tint n2) throw (cvmexception)
 Columns swap.
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.
basic_cmatrixvanish ()
 Set matrix to zero.
basic_cmatrixrandomize_real (TR dFrom, TR dTo)
 Randomizer (real part)
basic_cmatrixrandomize_imag (TR dFrom, TR dTo)
 Randomizer (imaginary part)
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.
basic_arrayresize (tint nNewSize) throw (cvmexception)
 Changes size of array.
tint incr () const
 Increment between elements.
tint indofmax () const
 Index of element with maximum module.
tint indofmin () const
 Index of element with minimum module.
virtual TR norm () const
 Euclidean norm.
iterator begin ()
 (STL) iterator to begin
const_iterator begin () const
 (STL) const iterator to begin
iterator end ()
 (STL) iterator to end
const_iterator end () const
 (STL) const iterator to end
reverse_iterator rbegin ()
 (STL) iterator to begin reversed
const_reverse_iterator rbegin () const
 (STL) const iterator to begin reversed
reverse_iterator rend ()
 (STL) iterator to end reversed
const_reverse_iterator rend () const
 (STL) const iterator to end reversed
size_type max_size () const
 (STL) maximum possible size of array
size_type capacity () const
 (STL) current capacity of array, equal to size()
bool empty () const
 (STL) is array empty
reference front ()
 (STL) reference to first element
const_reference front () const
 (STL) const reference to first element
reference back ()
 (STL) reference to last element
const_reference back () const
 (STL) const reference to last element
void 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

Friends

class basic_cvector< TR, TC >

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 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_cmatrix< TR, TC >

End-user class encapsulating matrix of complex numbers.

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

See Also
Matrix

Definition at line 18389 of file cvm.h.

Constructor & Destructor Documentation

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

Default constructor.

Creates empty matrix. No memory gets allocated.

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

Definition at line 18421 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix< TR, TC >::basic_cmatrix ( tint  nM,
tint  nN 
)
inline

Constructor.

Creates $m\times n$ cmatrix object where $m$ is passed in nM parameter (number of rows) and $n$ is passed in nN (number of columns). Constructor sets all elements to zero. It throws cvmexception in case of non-positive sizes passed or memory allocation failure.

Example:
using namespace cvm;
cmatrix m (3, 4);
std::cout << m.msize() << std::endl
<< m.nsize() << std::endl
<< m.size() << std::endl << m;
prints
3
4
12
(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]nMNumber of rows.
[in]nNNumber of columns.

Definition at line 18452 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix< TR, TC >::basic_cmatrix ( TC *  pd,
tint  nM,
tint  nN 
)
inline

Constructor.

Creates $m\times n$ cmatrix object where $m$ is passed in nM parameter (number of rows) and $n$ is passed in nN (number of columns). It throws cvmexception in case of non-positive sizes 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[] = {5., 5., 5., 5., 5., 5.,
5., 5., 5., 5., 5., 5.};
cmatrix m ((std::complex<double>*) a, 2, 3);
m(1,1) = std::complex<double>(1.,2.);
std::cout << m << std::endl;
std::cout << a[0] << " " << a[1] << " "
<< a[2] << " " << a[3] << std::endl;
prints
(1,2) (5,5) (5,5)
(5,5) (5,5) (5,5)
1 2 5 5
See Also
http://cvmlib.com/faq.htm
basic_cvector::basic_cvector(TC*,tint,tint)
Parameters
[in]pdPointer to array to share memory with.
[in]nMNumber of rows.
[in]nNNumber of columns.

Definition at line 18489 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix< TR, TC >::basic_cmatrix ( const TC *  pd,
tint  nM,
tint  nN 
)
inline

Constructor.

Creates $m\times n$ cmatrix object where $m$ is passed in nM parameter (number of rows) and $n$ is passed in nN (number of columns). 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 nM*nN elements total.

Example:
using namespace cvm;
const double a[] = {5., 5., 5., 5., 5., 5.,
5., 5., 5., 5., 5., 5.};
cmatrix m ((const std::complex<double>*) a, 2, 3);
m(1,1) = std::complex<double>(1.,2.);
std::cout << m << std::endl;
std::cout << a[0] << " " << a[1] << " "
<< a[2] << " " << a[3] << std::endl;
prints
(1,2) (5,5) (5,5)
(5,5) (5,5) (5,5)
5 5 5 5
See Also
http://cvmlib.com/faq.htm
basic_cvector::basic_cvector(const TC*,tint,tint)
Parameters
[in]pdConst pointer to external array.
[in]nMNumber of rows.
[in]nNNumber of columns.

Definition at line 18527 of file cvm.h.

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

Copy constructor.

Creates cmatrix object as a copy of matrix m. 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.};
cmatrix m ((std::complex<double>*) a, 2, 3);
cmatrix 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) (9,10)
(3,4) (7,8) (11,12)
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
Parameters
[in]mrmatrix to copy from.

Definition at line 18557 of file cvm.h.

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

template<typename TR, typename TC>
basic_cmatrix< TR, TC >::basic_cmatrix ( const CVector v,
bool  bBeColumn = true 
)
inlineexplicit

Constructor.

Creates cmatrix object containing v.size() rows and 1 column if bBeColumn is true or 1 row and v.size() columns otherwise. After that it copies elements of vector v to the matrix created. Constructor throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
cvector v(3);
v(1) = std::complex<double>(1.,2.);
v(2) = std::complex<double>(2.,3.);
v(3) = std::complex<double>(3.,4.);
cmatrix mc (v);
cmatrix mr (v, false);
std::cout << mc << std::endl << mr;
prints
(1,2)
(2,3)
(3,4)
(1,2) (2,3) (3,4)
Parameters
[in]vcvector to copy elements from.
[in]bBeColumnTrue to create column matrix.

Definition at line 18615 of file cvm.h.

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

Constructor.

Creates cmatrix object with m.msize() rows and m.nsize() columns 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.};
const rmatrix m (a, 2, 3);
cmatrix mr(m), mi(m, false);
std::cout << mr << std::endl << mi;
prints
(1,0) (3,0) (5,0)
(2,0) (4,0) (6,0)
(0,1) (0,3) (0,5)
(0,2) (0,4) (0,6)
Parameters
[in]mrmatrix to copy elements from.
[in]bRealParttrue to copy m to real part, false to copy to imaginary part.

Definition at line 18645 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix< TR, TC >::basic_cmatrix ( const TR *  pRe,
const TR *  pIm,
tint  nM,
tint  nN 
)
inline

Constructor.

Creates cmatrix object of size nM by nN 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., 5., 6.};
double im[] = {6., 5., 4., 3., 2., 1.};
cmatrix m (re, im, 3, 2);
std::cout << m << std::endl;
re[1] = 7.77;
std::cout << m << std::endl;
const double re2[] = {1., 2., 3., 4.};
const cmatrix m2 (re2, nullptr, 2, 2);
std::cout << m2;
prints
(1,6) (4,3)
(2,5) (5,2)
(3,4) (6,1)
(1,6) (4,3)
(2,5) (5,2)
(3,4) (6,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]nMNumber of rows.
[in]nNNumber of columns.

Definition at line 18695 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix< TR, TC >::basic_cmatrix ( const basic_rmatrix< TR > &  mRe,
const basic_rmatrix< TR > &  mIm 
)
inline

Constructor.

Creates cmatrix object of size mRe.msize() by mRe.nsize() (if one of these sizes differs from appropriate size of matrix mIm 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;
rmatrix mr(3,3), mi(3,3);
mr(1,1) = 1.;
mr(2,2) = 2.;
mr(3,3) = 3.;
mi(1,3) = 6.;
mi(2,2) = 5.;
mi(3,1) = 4.;
const cmatrix mc(mr, mi);
std::cout << mc;
prints
(1,0) (0,0) (0,6)
(0,0) (2,5) (0,0)
(0,4) (0,0) (3,0)
Parameters
[in]mRermatrix to copy to real part.
[in]mImrmatrix to copy to imaginary part.

Definition at line 18731 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix< TR, TC >::basic_cmatrix ( basic_cmatrix< TR, TC > &  m,
tint  nRow,
tint  nCol,
tint  nHeight,
tint  nWidth 
)
inline

Submatrix constructor.

Creates cmatrix object as submatrix of matrix m. It means that the matrix 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 height and width (parameters nHeight and nWidth).

Example:
using namespace cvm;
cmatrix m(4,5);
cmatrix subm(m, 2, 2, 2, 2);
subm.set(std::complex<double>(1.,1.));
std::cout << m;
prints
(0,0) (0,0) (0,0) (0,0) (0,0)
(0,0) (1,1) (1,1) (0,0) (0,0)
(0,0) (1,1) (1,1) (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]nHeightNumber of submatrix's rows.
[in]nWidthNumber of submatrix's columns.

Definition at line 18769 of file cvm.h.

Member Function Documentation

template<typename TR, typename TC>
type_proxy<TC, TR> basic_cmatrix< 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 in basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 18811 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
TC basic_cmatrix< 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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 18846 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_cmatrix< 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_array< TR, TC >.

Reimplemented in basic_scmatrix< TR, TC >.

Definition at line 18887 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_cmatrix< 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_array< TR, TC >.

Reimplemented in basic_scmatrix< TR, TC >.

Definition at line 18927 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
const CVector basic_cmatrix< 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_array< TR, TC >.

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

Definition at line 18958 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
const CVector basic_cmatrix< 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_array< TR, TC >.

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

Definition at line 18990 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_cmatrix< TR, TC >::diag ( tint  nDiag) throw (cvmexception)
inline

Diagonal as l-value.

Operator provides access to nDiag-th diagonal of calling matrix (here nDiag=0 for main diagonal, nDiag<0 for lower diagonals and nDiag>0 for upper ones) by returning cvector sharing memory with it. Operator throws cvmexception if nDiag is outside of boundaries.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
cmatrix m (2, 3);
const scmatrix ms((std::complex<double>*)a, 3);
m.diag(-1).set(std::complex<double>(1.,1.));
m.diag(0).set(std::complex<double>(2.,2.));
m.diag(1).set(std::complex<double>(3.,3.));
m.diag(2).set(std::complex<double>(4.,4.));
std::cout << m << std::endl;
std::cout << ms << std::endl;
std::cout << ms.diag(0) << ms.diag(1);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(2,2) (3,3) (4,4)
(1,1) (2,2) (3,3)
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
(1,2) (9,10) (17,18)
(7,8) (15,16)
Parameters
[in]nDiagIndex of diagonal (0 for main diagonal, negative for lower, positive for upper one).
Returns
cvector Diagonal as l-value.

Definition at line 19039 of file cvm.h.

Here is the caller graph for this function:

template<typename TR, typename TC>
const CVector basic_cmatrix< TR, TC >::diag ( tint  nDiag) const throw (cvmexception)
inline

Diagonal (not l-value)

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

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16., 17., 18.};
const scmatrix ms((std::complex<double>*)a, 3);
std::cout << ms << std::endl;
std::cout << ms.diag(0) << ms.diag(1);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1,2) (7,8) (13,14)
(3,4) (9,10) (15,16)
(5,6) (11,12) (17,18)
(1,2) (9,10) (17,18)
(7,8) (15,16)
Parameters
[in]nDiagIndex of diagonal (0 for main diagonal, negative for lower, positive for upper one).
Returns
cvector Diagonal value.

Reimplemented in basic_schmatrix< TR, TC >.

Definition at line 19076 of file cvm.h.

template<typename TR, typename TC>
const basic_rmatrix<TR> basic_cmatrix< 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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 19104 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
const basic_rmatrix<TR> basic_cmatrix< 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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 19135 of file cvm.h.

Here is the call graph for this function:

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

Assignment operator.

Sets every element of calling cmatrix to be equal to appropriate element of matrix 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., 9., 10., 11., 12.};
const cmatrix m1((std::complex<double>*) a, 2, 3);
cmatrix m2(2, 3);
m2 = m1;
std::cout << m2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
Parameters
[in]mcmatrix to assign from.
Returns
Reference to changed calling matrix.

Definition at line 19172 of file cvm.h.

Here is the call graph for this function:

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

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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 in basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 19224 of file cvm.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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_array< TR, TC >.

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

Definition at line 19256 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::assign ( tint  nRow,
tint  nCol,
const basic_cmatrix< TR, TC > &  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;
rmatrix m1(4,5);
rmatrix m2(2,2);
m1.set(1.);
m2.set(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) (1,1)
(1,1) (1,1) (2,2) (2,2) (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 matrix to assign.
Returns
Reference to changed calling matrix.

Definition at line 19292 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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_array< TR, TC >.

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

Definition at line 19323 of file cvm.h.

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

Assignment to real parts.

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

Example:
using namespace cvm;
rmatrix m (2,3);
cmatrix mc(2,3);
m.randomize (0., 1.);
std::cout << mc;
prints
(0.126835,0) (0.57271,0) (0.28312,0)
(0.784417,0) (0.541673,0) (0.663869,0)
Parameters
[in]mRermatrix to assign to real part.
Returns
Reference to changed calling matrix.

Definition at line 19352 of file cvm.h.

Here is the call graph for this function:

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

Assignment to imaginary parts.

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

Example:
using namespace cvm;
rmatrix m (2,3);
cmatrix mc(2,3);
m.randomize (0., 1.);
std::cout << mc;
prints
(0,0.13831) (0,0.267373) (0,0.482345)
(0,0.50618) (0,0.992401) (0,0.444777)
Parameters
[in]mImrmatrix to assign to imaginary part.
Returns
Reference to changed calling matrix.

Definition at line 19383 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 19411 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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 in basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 19437 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::resize ( tint  nNewM,
tint  nNewN 
) throw (cvmexception)
inline

Changes dimensions.

Changes dimensions of calling matrix to to nNewM by nNewN 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., 9., 10., 11., 12.};
cmatrix m((std::complex<double>*) a, 2, 3);
std::cout << m << std::endl;
m.resize (2, 2);
std::cout << m << std::endl;
m.resize (3, 3);
std::cout << m;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1,2) (5,6) (9,10)
(3,4) (7,8) (11,12)
(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]nNewMNew number of rows.
[in]nNewNNew number of columns.
Returns
Reference to changed calling matrix.

Definition at line 19485 of file cvm.h.

Here is the caller graph for this function:

template<typename TR, typename TC>
bool basic_cmatrix< TR, TC >::operator== ( const basic_cmatrix< TR, TC > &  m) const
inline

Matrix comparison.

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

Example:
using namespace cvm;
cmatrix m1(2, 3);
cmatrix m2(2, 3);
m1.set_real(1.);
m2.set_real(1.);
std::cout << (m1 == m2) << std::endl;
prints
1
See Also
operator !=()
Parameters
[in]mcmatrix to compare to.
Returns
bool Result of comparison.

Definition at line 19516 of file cvm.h.

Here is the call graph for this function:

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

Matrix comparison.

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

Example:
using namespace cvm;
cmatrix m1(2, 3);
cmatrix m2(2, 3);
m1.set_real(1.);
m2.set_real(1.);
std::cout << (m1 != m2) << std::endl;
prints
0
See Also
operator ==()
Parameters
[in]mcmatrix to compare to.
Returns
bool Result of comparison.

Definition at line 19545 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::operator<< ( const basic_cmatrix< 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 {
cmatrix m(2,3);
cmatrix mc(1,1);
m(1,2) = std::complex<double>(1.,2.);
m(2,3) = std::complex<double>(2.,4.);
std::cout << m << mc << std::endl;
mc << m;
std::cout << mc;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0,0) (1,2) (0,0)
(0,0) (0,0) (2,4)
(0,0)
(0,0) (1,2) (0,0)
(0,0) (0,0) (2,4)
See Also
operator =()
Parameters
[in]mcmatrix to replace by.
Returns
Reference to changed calling matrix.

Definition at line 19584 of file cvm.h.

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

Addition operator.

Creates object of type cmatrix 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., 9., 10., 11., 12.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
cmatrix mb (2, 3);
mb.set (std::complex<double>(1.,1.));
std::cout << ma + mb << std::endl;
std::cout << ma + ma;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(2,3) (6,7) (10,11)
(4,5) (8,9) (12,13)
(2,4) (10,12) (18,20)
(6,8) (14,16) (22,24)
See Also
sum()
Parameters
[in]mcmatrix to add to calling one.
Returns
Result object as sum of matrices.

Definition at line 19627 of file cvm.h.

Here is the call graph for this function:

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

Subtraction operator.

Creates object of type cmatrix 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., 9., 10., 11., 12.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
cmatrix mb (2, 3);
mb.set (std::complex<double>(1.,1.));
std::cout << ma - mb << std::endl;
std::cout << ma - ma;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0,1) (4,5) (8,9)
(2,3) (6,7) (10,11)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
See Also
diff()
Parameters
[in]mcmatrix to subtract from calling one.
Returns
Result object as difference of matrices.

Definition at line 19671 of file cvm.h.

Here is the call graph for this function:

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

Sum of matrices.

Assigns sum of 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.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
cmatrix mb (2, 3);
cmatrix m (2, 3);
mb.set (std::complex<double>(1.,1.));
std::cout << m.sum(ma, mb) << std::endl;
std::cout << m.sum(m, mb);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(2,3) (6,7) (10,11)
(4,5) (8,9) (12,13)
(3,4) (7,8) (11,12)
(5,6) (9,10) (13,14)
See Also
operator +()
Parameters
[in]m1First cmatrix summand.
[in]m2Second cmatrix summand.
Returns
Reference to changed calling matrix.

Definition at line 19717 of file cvm.h.

Here is the call graph for this function:

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

Difference of matrices.

Assigns difference of 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.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
cmatrix mb (2, 3);
cmatrix m (2, 3);
mb.set (std::complex<double>(1.,1.));
std::cout << m.diff(ma, mb) << std::endl;
std::cout << m.diff(m, mb);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0,1) (4,5) (8,9)
(2,3) (6,7) (10,11)
(-1,0) (3,4) (7,8)
(1,2) (5,6) (9,10)
See Also
operator -()
Parameters
[in]m1First cmatrix subtrahend.
[in]m2Second cmatrix subtrahend.
Returns
Reference to changed calling matrix.

Definition at line 19764 of file cvm.h.

Here is the call graph for this function:

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

Increment operator.

Adds matrix 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 {
cmatrix m1(2, 3);
cmatrix m2(2, 3);
m1.set(std::complex<double>(1.,1.));
m2.set(std::complex<double>(2.,2.));
m1 += m2;
std::cout << m1 << std::endl;
// well, you can do this too, but temporary object would be created
m2 += m2;
std::cout << m2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(3,3) (3,3) (3,3)
(3,3) (3,3) (3,3)
(4,4) (4,4) (4,4)
(4,4) (4,4) (4,4)
See Also
operator +()
sum()
Parameters
[in]mcmatrix to increment by.
Returns
Reference to changed calling matrix.

Definition at line 19811 of file cvm.h.

Here is the call graph for this function:

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

Decrement operator.

Subtracts matrix 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 {
cmatrix m1(2, 3);
cmatrix m2(2, 3);
m1.set(std::complex<double>(1.,1.));
m2.set(std::complex<double>(2.,2.));
m1 -= m2;
std::cout << m1 << std::endl;
// well, you can do this too, but temporary object would be created
m2 -= m2;
std::cout << m2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-1,-1) (-1,-1) (-1,-1)
(-1,-1) (-1,-1) (-1,-1)
(0,0) (0,0) (0,0)
(0,0) (0,0) (0,0)
See Also
operator -()
diff()
Parameters
[in]mcmatrix to decrement by.
Returns
Reference to changed calling matrix.

Definition at line 19856 of file cvm.h.

Here is the call graph for this function:

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

Unary minus operator.

Creates object of type cmatrix 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., 9., 10., 11., 12.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
std::cout << - ma;
prints
(-1,-2) (-5,-6) (-9,-10)
(-3,-4) (-7,-8) (-11,-12)
Returns
Result object.

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

Definition at line 19885 of file cvm.h.

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

Multiply by real number operator.

Creates object of type cmatrix 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.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
std::cout << ma * 5.;
prints
(5,10) (25,30) (45,50)
(15,20) (35,40) (55,60)
See Also
operator *=()
Parameters
[in]dMultNumber to multiply by.
Returns
Result object.

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

Definition at line 19916 of file cvm.h.

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

Divide by real number operator.

Creates object of type cmatrix 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;
try {
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
std::cout << ma / 4.;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0.25,0.5) (1.25,1.5) (2.25,2.5)
(0.75,1) (1.75,2) (2.75,3)
See Also
operator /=()
Parameters
[in]dDivNumber to divide by.
Returns
Result object.

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

Definition at line 19953 of file cvm.h.

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

Multiply by complex number operator.

Creates object of type cmatrix 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.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
std::cout << ma * std::complex<double>(5.,2.);
prints
(1,12) (13,40) (25,68)
(7,26) (19,54) (31,82)
See Also
operator *=()
Parameters
[in]cMultNumber to multiply by.
Returns
Result object.

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

Definition at line 19983 of file cvm.h.

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

Divide by complex number operator.

Creates object of type cmatrix 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;
try {
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
const cmatrix ma ((std::complex<double>*) a, 2, 3);
std::cout << ma / std::complex<double>(4.,2.);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0.4,0.3) (1.6,0.7) (2.8,1.1)
(1,0.5) (2.2,0.9) (3.4,1.3)
See Also
operator /=()
Parameters
[in]cDivNumber to divide by.
Returns
Result object.

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

Definition at line 20020 of file cvm.h.

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

Multiply by real number and assign.

Multiplies calling 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.};
cmatrix ma ((std::complex<double>*) a, 2, 3);
ma *= 2.;
std::cout << ma;
prints
(2,4) (10,12) (18,20)
(6,8) (14,16) (22,24)
See Also
operator *(TR) const
Parameters
[in]dMultNumber to multiply by.
Returns
Reference to changed calling matrix.

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

Definition at line 20050 of file cvm.h.

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

Divide by real number and assign.

Divides calling 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;
try {
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix ma ((std::complex<double>*) a, 2, 3);
ma /= 2.;
std::cout << ma;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0.5,1) (2.5,3) (4.5,5)
(1.5,2) (3.5,4) (5.5,6)
See Also
operator /(TR) const
Parameters
[in]dDivNumber to divide by.
Returns
Reference to changed calling matrix.

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

Definition at line 20086 of file cvm.h.

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

Multiply by complex number and assign.

Multiplies calling 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.};
cmatrix ma ((std::complex<double>*) a, 2, 3);
ma *= std::complex<double>(2.,1.);
std::cout << ma;
prints
(0,5) (4,17) (8,29)
(2,11) (6,23) (10,35)
See Also
operator *(TR) const
Parameters
[in]cMultNumber to multiply by.
Returns
Reference to changed calling matrix.

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

Definition at line 20115 of file cvm.h.

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

Divide by complex number and assign.

Divides calling 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;
try {
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix ma ((std::complex<double>*) a, 2, 3);
ma /= std::complex<double>(2.,1.);
std::cout << ma;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(0.8,0.6) (3.2,1.4) (5.6,2.2)
(2,1) (4.4,1.8) (6.8,2.6)
See Also
operator /(TR) const
Parameters
[in]cDivNumber to divide by.
Returns
Reference to changed calling matrix.

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

Definition at line 20151 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 20181 of file cvm.h.

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

Matrix transposition.

Creates object of type cmatrix as transposed calling matrix.

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);
cmatrix mc(3,2);
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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 20222 of file cvm.h.

Here is the call graph for this function:

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

Matrix conjugation.

Creates object of type cmatrix as hermitian conjugated calling matrix.

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);
cmatrix mc(3,2);
std::cout << m << std::endl << ~m << std::endl ;
mc.conj(m);
std::cout << mc << std::endl;
mc.conj();
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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 20264 of file cvm.h.

Here is the call graph for this function:

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

Matrix transposition.

Sets calling matrix to be equal to 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.};
cmatrix m((std::complex<double>*) a, 2, 3);
cmatrix mc(3,2);
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]mcmatrix to transpose.
Returns
Reference to changed calling matrix.

Definition at line 20309 of file cvm.h.

Here is the call graph for this function:

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

Matrix conjugation.

Sets calling matrix to be equal to matrix m 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.};
cmatrix m((std::complex<double>*) a, 2, 3);
cmatrix mc(3,2);
std::cout << m << std::endl << ~m << std::endl ;
mc.conj(m);
std::cout << mc << std::endl;
mc.conj();
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]mcmatrix to conjugate.
Returns
Reference to changed calling matrix.

Definition at line 20359 of file cvm.h.

Here is the call graph for this function:

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

Matrix transposition (in-place)

Makes calling 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.};
cmatrix m((std::complex<double>*) a, 2, 3);
cmatrix mc(3,2);
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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 20402 of file cvm.h.

Here is the call graph for this function:

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

Matrix conjugation (in-place)

Makes calling matrix to be equal to 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.};
cmatrix m((std::complex<double>*) a, 2, 3);
cmatrix mc(3,2);
std::cout << m << std::endl << ~m << std::endl ;
mc.conj(m);
std::cout << mc << std::endl;
mc.conj();
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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 20446 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
CVector basic_cmatrix< 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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 20478 of file cvm.h.

Here is the call graph for this function:

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

Matrix-matrix product.

Creates object of type cmatrix as product of calling 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;
cmatrix m1(2, 3);
cmatrix m2(3, 2);
m1.set(std::complex<double>(1.,1.));
m2.set(std::complex<double>(1.,1.));
std::cout << m1 * m2;
prints
(0,6) (0,6)
(0,6) (0,6)
Parameters
[in]mcmatrix to compute product with.
Returns
Result object.

Definition at line 20510 of file cvm.h.

Here is the call graph for this function:

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

Matrix-matrix product.

Sets calling matrix to be equal to product of matrix m1 by matrix m2 and returns reference to the matrix changed. Function throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix m1(2, 3);
cmatrix m2(3, 2);
scmatrix m(2);
m1.set(std::complex<double>(1.,1.));
m2.set(std::complex<double>(1.,1.));
m.mult(m1, m2);
std::cout << m;
prints
(0,6) (0,6)
(0,6) (0,6)
Parameters
[in]m1cmatrix multiplicand.
[in]m2cmatrix multiplier.
Returns
Reference to changed calling matrix.

Definition at line 20544 of file cvm.h.

Here is the caller graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::rank1update_u ( const CVector vCol,
const CVector vRow 
) throw (cvmexception)
inline

Rank-1 update (unconjugated)

Sets calling matrix to rank-1 update (unconjugated) of vector vCol and vector vRow. The rank-1 update of vector-column $x$ of size $m$ and vector-row $y$ of size $n$ is defined as $m\times n$ matrix

\[\begin{pmatrix} x_1 y_1 & x_1 y_2 & \cdots & x_1 y_n \\ x_2 y_1 & x_2 y_2 & \cdots & x_2 y_n \\ \hdotsfor{4} \\ x_m y_1 & x_m y_2 & \cdots & x_m y_n \end{pmatrix} = \begin{pmatrix} x_1 \\ x_2 \\ \vdots \\ x_m \end{pmatrix} \begin{pmatrix} y_1 & y_2 & \cdots & y_n \end{pmatrix}.\]

Function throws cvmexception if number of rows of calling matrix is not equal to vCol.size() or number of columns is not equal to vRow.size().

Example:
using namespace cvm;
cvector vc(3), vr(2);
cmatrix m(3, 2);
vc.set(std::complex<double>(1.,1.));
vr.set(std::complex<double>(1.,1.));
std::cout << m.rank1update_u (vc, vr);
prints
(0,2) (0,2)
(0,2) (0,2)
(0,2) (0,2)
See Also
rank1update_c()
Parameters
[in]vColcvector column.
[in]vRowcvector row.
Returns
Reference to changed calling matrix.

Definition at line 20593 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::rank1update_c ( const CVector vCol,
const CVector vRow 
) throw (cvmexception)
inline

Rank-1 update (conjugated)

Sets calling matrix to rank-1 update (conjugated) of vector vCol and vector vRow. The rank-1 update of vector-column $x$ of size $m$ and vector-row $y$ of size $n$ is defined as $m\times n$ matrix

\[\begin{pmatrix} x_1 y_1^* & x_1 y_2^* & \cdots & x_1 y_n^* \\ x_2 y_1^* & x_2 y_2^* & \cdots & x_2 y_n^* \\ \hdotsfor{4} \\ x_m y_1^* & x_m y_2^* & \cdots & x_m y_n^* \end{pmatrix} = \begin{pmatrix} x_1 \\ x_2 \\ \vdots \\ x_m \end{pmatrix} \begin{pmatrix} y_1^* & y_2^* & \hdots & y_n^* \end{pmatrix},\]

where $y_i^*$ is $i$-th complex conjugated element of $y$. Function throws cvmexception if number of rows of calling matrix is not equal to vCol.size() or number of columns is not equal to vRow.size().

Example:
using namespace cvm;
cvector vc(3), vr(2);
cmatrix m(3, 2);
vc.set(std::complex<double>(1.,1.));
vr.set(std::complex<double>(1.,1.));
std::cout << m.rank1update_c (vc, vr);
prints
(2,0) (2,0)
(2,0) (2,0)
(2,0) (2,0)
See Also
rank1update_u()
Parameters
[in]vColcvector column.
[in]vRowcvector row.
Returns
Reference to changed calling matrix.

Definition at line 20648 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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 in basic_scmatrix< TR, TC >.

Definition at line 20688 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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 in basic_scmatrix< TR, TC >.

Definition at line 20721 of file cvm.h.

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

Linear solver.

Sets calling matrix to be equal to solution $X$ of matrix linear equation $A*X=B$ where parameter mA is square complex matrix $A$ and parameter mB is complex matrix $B$. Function returns reference to the matrix changed. 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 (4);
scmatrix ma(3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
ma.randomize_real(0.,10.); ma.randomize_imag(0.,10.);
mb.randomize_real(0.,10.); mb.randomize_imag(0.,10.);
mx.solve (ma, mb, dErr);
std::cout << mx << std::endl << ma * mx - mb
<< dErr << std::endl;
prints
(+3.2103e-001,+2.8598e-002) (+1.1907e+000,-1.1101e+000)
(+3.7451e-001,+4.2471e-001) (-2.3858e-001,+3.3028e-001)
(+3.0085e-001,-3.0427e-001) (-7.6874e-001,+4.1100e-001)
(+4.4409e-016,+0.0000e+000) (-8.8818e-016,+1.3323e-015)
(+7.7716e-016,-8.8818e-016) (+0.0000e+000,+1.7764e-015)
(+0.0000e+000,-8.8818e-016) (-1.7764e-015,+8.8818e-016)
+5.4774e-015
See Also
solve(const basic_scmatrix<TR,TC>&,const basic_cmatrix<TR,TC>&)
Parameters
[in]mAscmatrix $A$.
[in]mBcmatrix $B$.
[out]dErrNorm of computation error.
Returns
Reference to changed calling matrix.

Definition at line 20770 of file cvm.h.

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

Linear solver (transposed)

Sets calling matrix to be equal to solution $X$ of matrix linear equation $A^T*X=B$ (which is equivalent to $X^T*A=B^T$) where parameter mA is square complex matrix $A$ and parameter mB is complex matrix $B$. Function returns reference to the matrix changed. 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 (3);
scmatrix ma(3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
ma.randomize_real(0.,10.); ma.randomize_imag(0.,10.);
mb.randomize_real(0.,10.); mb.randomize_imag(0.,10.);
mx.solve_tran (ma, mb, dErr);
std::cout << !ma * mx - mb << dErr << std::endl;
std::cout << !mx * ma - !mb << std::endl;
prints
(+6.661e-016,+1.776e-015) (+0.000e+000,+5.690e-016)
(-1.776e-015,-1.776e-015) (-8.882e-016,-8.882e-016)
(-2.665e-015,+1.776e-015) (+0.000e+000,-1.110e-015)
+7.079e-015
(+6.661e-016,+1.776e-015) (-1.776e-015,-1.776e-015) (-1.776e-015,+1.776e-015)
(+0.000e+000,+5.690e-016) (-8.882e-016,-8.882e-016) (+0.000e+000,-1.554e-015)
See Also
solve_tran(const basic_scmatrix<TR,TC>&,const basic_cmatrix<TR,TC>&)
Parameters
[in]mAscmatrix $A$.
[in]mBcmatrix $B$.
[out]dErrNorm of computation error.
Returns
Reference to changed calling matrix.

Definition at line 20818 of file cvm.h.

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

Linear solver (conjugated)

Sets calling matrix to be equal to solution $X$ of matrix linear equation $A^H*X=B$ (which is equivalent to $X^H*A=B^H$) where parameter mA is square complex matrix $A$ and parameter mB is complex matrix $B$. Function returns reference to the matrix changed. 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 (3);
scmatrix ma(3);
cmatrix mb(3,2);
cmatrix mx(3,2);
double dErr;
ma.randomize_real(0.,10.); ma.randomize_imag(0.,10.);
mb.randomize_real(0.,10.); mb.randomize_imag(0.,10.);
mx.solve_conj (ma, mb, dErr);
std::cout << ~ma * mx - mb << dErr << std::endl;
std::cout << ~mx * ma - ~mb << std::endl;
prints
(+7.105e-015,-1.776e-015) (+1.332e-015,+8.882e-016)
(+1.776e-015,-8.882e-016) (+8.882e-016,-8.882e-016)
(+0.000e+000,-6.661e-016) (-1.776e-015,-2.665e-015)
+1.169e-014
(+7.105e-015,+1.776e-015) (+1.776e-015,+8.882e-016) (-2.665e-015,+6.661e-016)
(+1.332e-015,-8.882e-016) (+8.882e-016,+8.882e-016) (-1.776e-015,+2.665e-015)
See Also
solve_conj(const basic_scmatrix<TR,TC>&,const basic_cmatrix<TR,TC>&)
Parameters
[in]mAscmatrix $A$.
[in]mBcmatrix $B$.
[out]dErrNorm of computation error.
Returns
Reference to changed calling matrix.

Definition at line 20866 of file cvm.h.

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

Linear solver.

Sets calling matrix to be equal to solution $X$ of matrix linear equation $A*X=B$ where parameter mA is square complex matrix $A$ and parameter mB is complex matrix $B$. Function returns reference to the matrix changed. 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 (4);
scmatrix ma(3);
cmatrix mb(3,2);
cmatrix mx(3,2);
ma.randomize_real(0.,10.); ma.randomize_imag(0.,10.);
mb.randomize_real(0.,10.); mb.randomize_imag(0.,10.);
mx.solve (ma, mb);
std::cout << mx << std::endl << ma * mx - mb;
prints
(+3.2103e-001,+2.8598e-002) (+1.1907e+000,-1.1101e+000)
(+3.7451e-001,+4.2471e-001) (-2.3858e-001,+3.3028e-001)
(+3.0085e-001,-3.0427e-001) (-7.6874e-001,+4.1100e-001)
(+4.4409e-016,+0.0000e+000) (-8.8818e-016,+1.3323e-015)
(+7.7716e-016,-8.8818e-016) (+0.0000e+000,+1.7764e-015)
(+0.0000e+000,-8.8818e-016) (-1.7764e-015,+8.8818e-016)
See Also
solve(const basic_scmatrix<TR,TC>&,const basic_cmatrix<TR,TC>&,TR&)
Parameters
[in]mAscmatrix $A$.
[in]mBcmatrix $B$.
Returns
Reference to changed calling matrix.

Definition at line 20908 of file cvm.h.

Here is the call graph for this function:

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

Linear solver (transposed)

Sets calling matrix to be equal to solution $X$ of matrix linear equation $A^T*X=B$ (which is equivalent to $X^T*A=B^T$) where parameter mA is square complex matrix $A$ and parameter mB is complex matrix $B$. Function returns reference to the matrix changed. 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 (3);
scmatrix ma(3);
cmatrix mb(3,2);
cmatrix mx(3,2);
ma.randomize_real(0.,10.); ma.randomize_imag(0.,10.);
mb.randomize_real(0.,10.); mb.randomize_imag(0.,10.);
mx.solve_tran (ma, mb);
std::cout << !ma * mx - mb << std::endl;
std::cout << !mx * ma - !mb << std::endl;
prints
(+6.661e-016,+1.776e-015) (+0.000e+000,+5.690e-016)
(-1.776e-015,-1.776e-015) (-8.882e-016,-8.882e-016)
(-2.665e-015,+1.776e-015) (+0.000e+000,-1.110e-015)
(+6.661e-016,+1.776e-015) (-1.776e-015,-1.776e-015) (-1.776e-015,+1.776e-015)
(+0.000e+000,+5.690e-016) (-8.882e-016,-8.882e-016) (+0.000e+000,-1.554e-015)
See Also
solve_tran(const basic_scmatrix<TR,TC>&,const basic_cmatrix<TR,TC>&,TR&)
Parameters
[in]mAscmatrix $A$.
[in]mBcmatrix $B$.
Returns
Reference to changed calling matrix.

Definition at line 20955 of file cvm.h.

Here is the call graph for this function:

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

Linear solver (conjugated)

Sets calling matrix to be equal to solution $X$ of matrix linear equation $A^H*X=B$ (which is equivalent to $X^H*A=B^H$) where parameter mA is square complex matrix $A$ and parameter mB is complex matrix $B$. Function returns reference to the matrix changed. 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 (3);
scmatrix ma(3);
cmatrix mb(3,2);
cmatrix mx(3,2);
ma.randomize_real(0.,10.); ma.randomize_imag(0.,10.);
mb.randomize_real(0.,10.); mb.randomize_imag(0.,10.);
mx.solve_conj (ma, mb);
std::cout << ~ma * mx - mb << std::endl;
std::cout << ~mx * ma - ~mb << std::endl;
prints
(+7.105e-015,-1.776e-015) (+1.332e-015,+8.882e-016)
(+1.776e-015,-8.882e-016) (+8.882e-016,-8.882e-016)
(+0.000e+000,-6.661e-016) (-1.776e-015,-2.665e-015)
(+7.105e-015,+1.776e-015) (+1.776e-015,+8.882e-016) (-2.665e-015,+6.661e-016)
(+1.332e-015,-8.882e-016) (+8.882e-016,+8.882e-016) (-1.776e-015,+2.665e-015)
See Also
solve_conj(const basic_scmatrix<TR,TC>&,const basic_cmatrix<TR,TC>&,TR&)
Parameters
[in]mAscmatrix $A$.
[in]mBcmatrix $B$.
Returns
Reference to changed calling matrix.

Definition at line 21002 of file cvm.h.

Here is the call graph for this function:

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

LU factorization based linear solver.

Sets calling matrix to be equal to solution $X$ of matrix linear equation $A*X=B$ where parameter mA is square complex matrix $A$, parameter mLU is LU factorization (see srmatrix::low_up() ) of matrix $A$, parameter pPivots is an array of pivot numbers created while factorizing matrix $A$ and parameter mB is complex matrix $B$. Function returns reference to the matrix changed. It 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 matrices $B$. In such case you save on matrix $A$ factorization since it's needed to be performed just one time. 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 (4);
try {
scmatrix ma(3);
scmatrix mLU(3);
cmatrix mb1(3,2);
cmatrix mb2(3,2);
cmatrix mx1(3,2);
cmatrix mx2(3,2);
iarray nPivots(3);
double dErr = 0.;
ma.randomize_real(0.,10.); ma.randomize_imag(0.,10.);
mb1.randomize_real(0.,10.); mb1.randomize_imag(0.,10.);
mb2.randomize_real(0.,10.); mb2.randomize_imag(0.,10.);
mLU.low_up(ma, nPivots);
std::cout << mx1.solve_lu (ma, mLU, nPivots, mb1, dErr);
std::cout << dErr << std::endl;
std::cout << mx2.solve_lu (ma, mLU, nPivots, mb2) << std::endl;
std::cout << ma * mx1 - mb1 << std::endl << ma * mx2 - mb2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(4.2888e-01,8.2409e-02) (-1.1261e-01,-5.7778e-01)
(5.8052e-01,3.2179e-01) (2.5811e-01,-3.8609e-02)
(-3.1499e-02,-7.0014e-01) (1.2652e+00,4.5309e-01)
5.2931e-15
(3.0153e-01,-5.6606e-01) (-1.6308e-01,1.8217e-01)
(7.4971e-01,-1.1305e-01) (5.2187e-01,2.3441e-01)
(-1.9916e-01,1.4493e+00) (9.1046e-02,3.5242e-01)
(0.0000e+00,-8.8818e-16) (0.0000e+00,-8.8818e-16)
(-4.4409e-16,0.0000e+00) (0.0000e+00,-8.8818e-16)
(0.0000e+00,0.0000e+00) (0.0000e+00,0.0000e+00)
(-8.8818e-16,8.8818e-16) (-8.8818e-16,-1.7764e-15)
(0.0000e+00,0.0000e+00) (2.2204e-16,-8.8818e-16)
(4.4409e-16,-8.8818e-16) (1.3878e-17,-4.4409e-16)
See Also
srmatrix::low_up()
Parameters
[in]mAscmatrix $A$.
[in]mLULU factorization of matrix $A$.
[in]pPivotspivots vector.
[in]mBcmatrix $B$.
[out]dErrNorm of computation error.
Returns
Reference to changed calling matrix.

Definition at line 21077 of file cvm.h.

Here is the call graph for this function:

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

LU factorization based linear solver.

Sets calling matrix to be equal to solution $X$ of matrix linear equation $A*X=B$ where parameter mA is square complex matrix $A$, parameter mLU is LU factorization (see srmatrix::low_up() ) of matrix $A$, parameter pPivots is an array of pivot numbers created while factorizing matrix $A$ and parameter mB is complex matrix $B$. Function returns reference to the matrix changed. 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. 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 (4);
try {
scmatrix ma(3);
scmatrix mLU(3);
cmatrix mb1(3,2);
cmatrix mb2(3,2);
cmatrix mx1(3,2);
cmatrix mx2(3,2);
iarray nPivots(3);
ma.randomize_real(0.,10.); ma.randomize_imag(0.,10.);
mb1.randomize_real(0.,10.); mb1.randomize_imag(0.,10.);
mb2.randomize_real(0.,10.); mb2.randomize_imag(0.,10.);
mLU.low_up(ma, nPivots);
std::cout << mx1.solve_lu (ma, mLU, nPivots, mb1);
std::cout << std::endl;
std::cout << mx2.solve_lu (ma, mLU, nPivots, mb2) << std::endl;
std::cout << ma * mx1 - mb1 << std::endl << ma * mx2 - mb2;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(4.2888e-01,8.2409e-02) (-1.1261e-01,-5.7778e-01)
(5.8052e-01,3.2179e-01) (2.5811e-01,-3.8609e-02)
(-3.1499e-02,-7.0014e-01) (1.2652e+00,4.5309e-01)
(3.0153e-01,-5.6606e-01) (-1.6308e-01,1.8217e-01)
(7.4971e-01,-1.1305e-01) (5.2187e-01,2.3441e-01)
(-1.9916e-01,1.4493e+00) (9.1046e-02,3.5242e-01)
(0.0000e+00,-8.8818e-16) (0.0000e+00,-8.8818e-16)
(-4.4409e-16,0.0000e+00) (0.0000e+00,-8.8818e-16)
(0.0000e+00,0.0000e+00) (0.0000e+00,0.0000e+00)
(-8.8818e-16,8.8818e-16) (-8.8818e-16,-1.7764e-15)
(0.0000e+00,0.0000e+00) (2.2204e-16,-8.8818e-16)
(4.4409e-16,-8.8818e-16) (1.3878e-17,-4.4409e-16)
See Also
srmatrix::low_up()
Parameters
[in]mAscmatrix $A$.
[in]mLULU factorization of matrix $A$.
[in]pPivotspivots vector.
[in]mBcmatrix $B$.
Returns
Reference to changed calling matrix.

Definition at line 21154 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
RVector basic_cmatrix< TR, TC >::svd ( ) const throw (cvmexception)
inline

Singular value decomposition.

Creates rvector of singular values

\[ \sigma_1\ge\sigma_2\ge\dots\ge\sigma_{\min(m,n)}\ge 0 \]

of $m\times n$ complex matrix $A$ (calling matrix). These values are the main diagonal of matrix $\Sigma$ of the singular value decomposition

\[ A=U\Sigma V^H \]

where $U$ and $V$ are orthogonal for real $A$ and unitary for complex $A$. $V^H$ is transposed $V$ for real one and hermitian conjugated $V$ for complex one. First $\min(m, n)$ columns of matrices $U$ and $V$ are left and right singular vectors of $A$ respectively. Singular values and singular vectors satisfy

\[ Av_i=\sigma_i u_i\ \ \text{ and }\ \ A^Hu_i=\sigma_i v_i \]

where $u_i$ and $v_i$ are $i$-th columns of $U$ and $V$ respectively. Function throws cvmexception in case of convergence error.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (3);
try {
double m[] = {1., -1., 1., 2., -2., 1.,
3., -2., 1., 0., -2., 1.};
cmatrix mA((std::complex<double>*) m, 2, 3);
cmatrix mSigma(2,3);
rvector v(2);
scmatrix mU(2), mVH(3);
v = mA.svd(mU, mVH);
mSigma.diag(0) = cvector(v);
std::cout << mU << std::endl;
std::cout << mVH << std::endl;
std::cout << mSigma << std::endl;
std::cout << (mA * ~mVH - mU * mSigma).norm() << std::endl;
std::cout << (~mA * mU - ~(mSigma * mVH)).norm() << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-4.861e-01,0.000e+00) (8.739e-01,0.000e+00)
(7.956e-01,-3.616e-01) (4.425e-01,-2.012e-01)
(-7.590e-02,4.474e-01) (7.488e-01,-1.820e-01) (-4.474e-01,1.327e-02)
(8.084e-01,1.878e-01) (-1.576e-02,5.238e-01) (-1.878e-01,3.558e-02)
(1.065e-01,3.065e-01) (3.597e-01,4.669e-02) (8.727e-01,4.012e-02)
(5.452e+00,0.000e+00) (0.000e+00,0.000e+00) (0.000e+00,0.000e+00)
(0.000e+00,0.000e+00) (1.131e+00,0.000e+00) (0.000e+00,0.000e+00)
1.357e-15
1.267e-15
Returns
Result object (singular values in decreasing order).

Definition at line 21227 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
RVector basic_cmatrix< TR, TC >::svd ( basic_scmatrix< TR, TC > &  mU,
basic_scmatrix< TR, TC > &  mVH 
) const throw (cvmexception)
inline

Singular value decomposition.

Creates rvector of singular values

\[ \sigma_1\ge\sigma_2\ge\dots\ge\sigma_{\min(m,n)}\ge 0 \]

of $m\times n$ complex matrix $A$ (calling matrix). These values are the main diagonal of matrix $\Sigma$ of the singular value decomposition

\[ A=U\Sigma V^H \]

where $U$ and $V$ are orthogonal for real $A$ and unitary for complex $A$. $V^H$ is transposed $V$ for real one and hermitian conjugated $V$ for complex one. First $\min(m, n)$ columns of matrices $U$ and $V$ are left and right singular vectors of $A$ respectively. Singular values and singular vectors satisfy

\[ Av_i=\sigma_i u_i\ \ \text{ and }\ \ A^Hu_i=\sigma_i v_i \]

where $u_i$ and $v_i$ are $i$-th columns of $U$ and $V$ respectively. Function sets output parameter mU to be equal to square matrix $U$ of size $m\times m$ and mVH to be equal to square matrix $V^H$ of size $n\times n$. Function throws cvmexception in case of inappropriate calling object size (it must be equal to $\min(m,n)$), matrix mU size (must be $m\times m$), matrix mVH size (must be $n\times n$) or in case of convergence error.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (3);
try {
double m[] = {1., -1., 1., 2., -2., 1.,
3., -2., 1., 0., -2., 1.};
cmatrix mA((std::complex<double>*) m, 2, 3);
cmatrix mSigma(2,3);
rvector v(2);
scmatrix mU(2), mVH(3);
v = mA.svd(mU, mVH);
mSigma.diag(0) = cvector(v);
std::cout << mU << std::endl;
std::cout << mVH << std::endl;
std::cout << mSigma << std::endl;
std::cout << (mA * ~mVH - mU * mSigma).norm() << std::endl;
std::cout << (~mA * mU - ~(mSigma * mVH)).norm() << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(-4.861e-01,0.000e+00) (8.739e-01,0.000e+00)
(7.956e-01,-3.616e-01) (4.425e-01,-2.012e-01)
(-7.590e-02,4.474e-01) (7.488e-01,-1.820e-01) (-4.474e-01,1.327e-02)
(8.084e-01,1.878e-01) (-1.576e-02,5.238e-01) (-1.878e-01,3.558e-02)
(1.065e-01,3.065e-01) (3.597e-01,4.669e-02) (8.727e-01,4.012e-02)
(5.452e+00,0.000e+00) (0.000e+00,0.000e+00) (0.000e+00,0.000e+00)
(0.000e+00,0.000e+00) (1.131e+00,0.000e+00) (0.000e+00,0.000e+00)
1.357e-15
1.267e-15
Parameters
[out]mUscmatrix $U$.
[out]mVHscmatrix $V^H$.
Returns
Result object (singular values in decreasing order).

Definition at line 21305 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix basic_cmatrix< TR, TC >::pinv ( TR  threshold = basic_cvmMachSp<TR>()) const throw (cvmexception)
inline

Pseudo (generalized) inversion.

Creates object of type cmatrix as pseudo inverted calling matrix. Matrix pseudo inversion (aka Moore-Penrose generalized inversion) definition: $n\times m$ matrix $A^{+}$ is pseudo inversion of $m\times n$ matrix $A$ if the following two equations are satisfied:

\[ AA^{+}A=A,\\ A^{+}=QA^H=A^HP \]

where $Q$ and $P$ are some matrices. To compute the pseudo inversion, we use singular value decomposition

\[ A = U\Sigma V^H \]

of matrix $A$, thus

\[ A^{+} = V\Sigma^{-1}U^{H}, \]

where $\Sigma^{-1}$ is diagonal $n\times m$ matrix having inverted diagonal values of matrix $\Sigma$ if they are greater than some threshold, and zeros otherwise. The threshold parameter sets minimum distinguishable from zero singular value to be used to compute the pseudo inversion. All values equal or less than the threshold are treated as zeros. Function throws cvmexception in case of memory allocation failure.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (7);
try {
cmatrix mA(2,3);
mA(1,1) = tcomplex(1.,2.); mA(1,2) = tcomplex(-1.,3.);
mA(1,3) = tcomplex(0.,-1.);
mA(2,1) = tcomplex(1.,-2.); mA(2,2) = tcomplex(1.,-4.);
mA(2,3) = tcomplex(1.,0.);
cmatrix mX = mA.pinv();
std::cout << mX << (mA * mX * mA - mA).norm2() << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(+3.2407407e-01,-1.1111111e-01) (+2.5925926e-01,-1.8518519e-02)
(-1.3888889e-01,-2.7777778e-02) (-5.5555556e-02,+1.6666667e-01)
(+1.4814815e-01,+2.3148148e-01) (+1.6666667e-01,+1.4814815e-01)
+3.3217718e-15
See Also
svd()
Parameters
[in]thresholdAlgorithm threshold.
Returns
Result object.

Definition at line 21368 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::pinv ( const basic_cmatrix< TR, TC > &  mA,
TR  threshold = basic_cvmMachSp<TR>() 
) throw (cvmexception)
inline

Pseudo (generalized) inversion.

Sets calling matrix to be equal to complex matrix mA pseudo inverted. Matrix pseudo inversion (aka Moore-Penrose generalized inversion) definition: $n\times m$ matrix $A^{+}$ is pseudo inversion of $m\times n$ matrix $A$ if the following two equations are satisfied:

\[ AA^{+}A=A,\\ A^{+}=QA^H=A^HP \]

where $Q$ and $P$ are some matrices. To compute the pseudo inversion, we use singular value decomposition

\[ A = U\Sigma V^H \]

of matrix $A$, thus

\[ A^{+} = V\Sigma^{-1}U^{H}, \]

where $\Sigma^{-1}$ is diagonal $n\times m$ matrix having inverted diagonal values of matrix $\Sigma$ if they are greater than some threshold, and zeros otherwise. The threshold parameter sets minimum distinguishable from zero singular value to be used to compute the pseudo inversion. All values equal or less than the threshold are treated as zeros. Function throws cvmexception in case of not appropriate sizes of the operands.

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (3);
try {
cmatrix mA(2,3), mX(3,2);
mA(1,1) = tcomplex(1.,2.); mA(1,2) = tcomplex(-1.,3.);
mA(1,3) = tcomplex(0.,-1.);
mA(2,1) = tcomplex(1.,-2.); mA(2,2) = tcomplex(1.,-4.);
mA(2,3) = tcomplex(1.,0.);
mX.pinv(mA);
std::cout << mX << (mA * mX * mA - mA).norm2() << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(+3.241e-001,-1.111e-001) (+2.593e-001,-1.852e-002)
(-1.389e-001,-2.778e-002) (-5.556e-002,+1.667e-001)
(+1.481e-001,+2.315e-001) (+1.667e-001,+1.481e-001)
+3.322e-015
See Also
svd()
Parameters
[in]mAMatrix to pseudo invert.
[in]thresholdAlgorithm threshold.
Returns
Reference to changed calling matrix.

Definition at line 21432 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix basic_cmatrix< TR, TC >::gels ( bool  conjugate,
const basic_cmatrix< TR, TC > &  mB,
basic_cvector< TR, TC > &  vErr 
) const throw (cvmexception)
inline

Overdetermined or underdetermined linear solver.

Creates object of type cmatrix as a solution of overdetermined or underdetermined linear systems

\[ A*x=b \]

for $m\times n$ complex matrix $A$ (or its conjugated one) where $b$ is a vector of length $k$ combined to

\[ A*X=B \]

for multiple vectors $b$ stored as columns of $k\times l$ matrix $B$ where $k=m$ in non-conjugated case and $k=n$ otherwise. The algorithm uses QR or LQ factorization of $A$. It is assumed that $A$ has full rank, infinity returned otherwise. Internally function uses ZGELS LAPACK routines. If $m>n$ and conjugate=false or $m<n$ and conjugate=true, then the system is overdetermined, thus the algorithm tries to find the least squares solution $x$ of the problem

\[ \|A*x-b\|_2\to\min\quad\text{or}\quad\|A^H*x-b\|_2\to\min\ \]

respectively. Real number dErr (or vector vErr for multiple vector $b$ case) returns residual sum of squares. The system is underdetermined otherwise, and the algorithm finds its minimum norm solution. In this case bErr is set to zero. In both cases the solution computed satisfies $\newcommand{\pinv}{\operatorname{pinv}} x=\pinv(A)*b$, but this algorithm is faster than pseudo inversion. Function throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(7, 5);
cmatrix b(7, 2);
cmatrix bt(5, 2);
cvector bv(5);
cvector vErr(2);
tcomplex dErr;
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bt.randomize_real(-10., 10.);
bt.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gels(false, b, vErr);
cvector vt = a.gels(true, bv, dErr);
cmatrix xt(7,2);
xt.gels(true, a, bt, vErr);
std::cout << (a.pinv()*b - x).norm() << std::endl;
std::cout << (~a.pinv()*bv - vt).norm() << std::endl;
std::cout << (~a.pinv()*bt - xt).norm() << std::endl;
prints
+1.3258216e-015
+1.0696705e-015
+1.1685394e-015
See Also
pinv()
Parameters
[in]conjugateTrue to compute for transposed matrix $A$ (calling matrix).
[in]mBcmatrix $B$.
[out]vErrNorms of computation errors.
Returns
Result object.

Definition at line 21508 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::gels ( bool  conjugate,
const basic_cmatrix< TR, TC > &  mA,
const basic_cmatrix< TR, TC > &  mB,
basic_cvector< TR, TC > &  vErr 
) throw (cvmexception)
inline

Overdetermined or underdetermined linear solver.

Sets calling matrix to a solution of overdetermined or underdetermined linear systems

\[ A*x=b \]

for $m\times n$ complex matrix $A$ (or conjuated one, parameter mA) where $b$ is a vector of length $k$ combined to

\[ A*X=B \]

for multiple vectors $b$ stored as columns of $k\times l$ matrix $B$ where $k=m$ in non-conjugated case and $k=n$ otherwise. The algorithm uses QR or LQ factorization of $A$. It is assumed that $A$ has full rank, infinity returned otherwise. Internally function uses ZGELS LAPACK routines. If $m>n$ and transpose=false or $m<n$ and transpose=true, then the system is overdetermined, thus the algorithm tries to find the least squares solution $x$ of the problem

\[ \|A*x-b\|_2\to\min\quad\text{or}\quad\|A^H*x-b\|_2\to\min\ \]

respectively. Real number dErr (or vector vErr for multiple vector $b$ case) returns residual sum of squares. The system is underdetermined otherwise, and the algorithm finds its minimum norm solution. In this case bErr is set to zero. In both cases the solution computed satisfies $\newcommand{\pinv}{\operatorname{pinv}} x=\pinv(A)*b$, but this algorithm is faster than pseudo inversion. Function throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(7, 5);
cmatrix b(7, 2);
cmatrix bt(5, 2);
cvector bv(5);
cvector vErr(2);
tcomplex dErr;
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bt.randomize_real(-10., 10.);
bt.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gels(false, b, vErr);
cvector vt = a.gels(true, bv, dErr);
cmatrix xt(7,2);
xt.gels(true, a, bt, vErr);
std::cout << (a.pinv()*b - x).norm() << std::endl;
std::cout << (~a.pinv()*bv - vt).norm() << std::endl;
std::cout << (~a.pinv()*bt - xt).norm() << std::endl;
prints
+1.3258216e-015
+1.0696705e-015
+1.1685394e-015
See Also
pinv()
Parameters
[in]conjugateTrue to compute for conjugated matrix $A$ (calling matrix).
[in]mAcmatrix $A$.
[in]mBcmatrix $B$.
[out]vErrNorms of computation errors.
Returns
Reference to changed calling matrix.

Definition at line 21587 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cvector<TR,TC> basic_cmatrix< TR, TC >::gels ( bool  conjugate,
const basic_cvector< TR, TC > &  vB,
TC &  dErr 
) const throw (cvmexception)
inline

Overdetermined or underdetermined linear solver.

Creates object of type cvector as a solution of overdetermined or underdetermined linear system

\[ A*x=b \]

for $m\times n$ complex matrix $A$ (or conjugated one) where $b$ is a vector of length $k$ where $k=m$ in non-transposed case and $k=n$ otherwise. The algorithm uses QR or LQ factorization of $A$. It is assumed that $A$ has full rank, infinity returned otherwise. Internally function uses ZGELS LAPACK routines. If $m>n$ and transpose=false or $m<n$ and transpose=true, then the system is overdetermined, thus the algorithm tries to find the least squares solution $x$ of the problem

\[ \|A*x-b\|_2\to\min\quad\text{or}\quad\|A^H*x-b\|_2\to\min\ \]

respectively. Real number dErr returns residual sum of squares. The system is underdetermined otherwise, and the algorithm finds its minimum norm solution. In this case bErr is set to zero. In both cases the solution computed satisfies $\newcommand{\pinv}{\operatorname{pinv}} x=\pinv(A)*b$, but this algorithm is faster than pseudo inversion. Function throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(7, 5);
cmatrix b(7, 2);
cmatrix bt(5, 2);
cvector bv(5);
cvector vErr(2);
tcomplex dErr;
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bt.randomize_real(-10., 10.);
bt.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gels(false, b, vErr);
cvector vt = a.gels(true, bv, dErr);
cmatrix xt(7,2);
xt.gels(true, a, bt, vErr);
std::cout << (a.pinv()*b - x).norm() << std::endl;
std::cout << (~a.pinv()*bv - vt).norm() << std::endl;
std::cout << (~a.pinv()*bt - xt).norm() << std::endl;
prints
+1.3258216e-015
+1.0696705e-015
+1.1685394e-015
See Also
pinv()
Parameters
[in]conjugateTrue to compute for conjugated matrix $A$ (calling matrix).
[in]vBcvector $b$.
[out]dErrNorm of computation error.
Returns
Result object.

Definition at line 21664 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix basic_cmatrix< TR, TC >::gelsy ( const basic_cmatrix< TR, TC > &  mB,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) const throw (cvmexception)
inline

Linear least squares problem.

Function creates cmatrix object with the minimum-norm solutions to linear least squares problems

\[ \|A*x-b\|_2\to\min \]

using complete orthogonal factorization of $m\times n$ calling complex matrix $A$. Here $b$ is a vector of length $m$. Multiple vectors $b$ are stored as columns of $m\times l$ matrix $B$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelsy(b, rank);
cvector xv = a.gelsy(bv, rank);
cmatrix x2(5,2);
x2.gelsy(a, b, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*x2 - b).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+8.9701623e-015
+6.9342294e-015
+8.9701623e-015
+4 +4
See Also
gelss()
gelsd()
cvector::gelsy()
rank()
Parameters
[in]mBcmatrix $B$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Result object.

Definition at line 21732 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::gelsy ( const basic_cmatrix< TR, TC > &  mA,
const basic_cmatrix< TR, TC > &  mB,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) throw (cvmexception)
inline

Linear least squares problem.

Function sets calling matrix to the minimum-norm solutions to linear least squares problems

\[ \|A*x-b\|_2\to\min \]

using complete orthogonal factorization of $m\times n$ complex matrix $A$ (parameter mA). Here $b$ is a vector of length $m$. Multiple vectors $b$ are stored as columns of $m\times l$ matrix $B$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. Matrix $A$ is passed as argument mA. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelsy(b, rank);
cvector xv = a.gelsy(bv, rank);
cmatrix x2(5,2);
x2.gelsy(a, b, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*x2 - b).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+8.9701623e-015
+6.9342294e-015
+8.9701623e-015
+4 +4
See Also
gelss()
gelsd()
cvector::gelsy()
rank()
Parameters
[in]mAcmatrix $A$.
[in]mBcmatrix $B$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Reference to changed calling matrix.

Definition at line 21799 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cvector<TR,TC> basic_cmatrix< TR, TC >::gelsy ( const basic_cvector< TR, TC > &  vB,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) const throw (cvmexception)
inline

Linear least squares problem.

Function creates cvector object with the minimum-norm solution to linear least squares problem

\[ \|A*x-b\|_2\to\min \]

using complete orthogonal factorization of $m\times n$ calling complex matrix $A$. Here $b$ is a vector of length $m$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. Matrix $A$ is passed as argument mA. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelsy(b, rank);
cvector xv = a.gelsy(bv, rank);
cmatrix x2(5,2);
x2.gelsy(a, b, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*x2 - b).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+8.9701623e-015
+6.9342294e-015
+8.9701623e-015
+4 +4
See Also
gelss()
gelsd()
cvector::gelsy()
rank()
Parameters
[in]vBcvector $b$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Result object.

Definition at line 21865 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix basic_cmatrix< TR, TC >::gelss ( const basic_cmatrix< TR, TC > &  mB,
basic_rvector< TR > &  sv,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) const throw (cvmexception)
inline

Linear least squares problem.

Function creates cmatrix object with the minimum-norm solutions to linear least squares problems

\[ \|A*x-b\|_2\to\min \]

using singular value decomposition of $m\times n$ calling complex matrix $A$. Here $b$ is a vector of length $m$. Multiple vectors $b$ are stored as columns of $m\times l$ matrix $B$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. Function also computes singular values of $A$ in decreasing order and returns them in sv output parameter having $\min(m,n)$ size. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
rvector sv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelss(b, sv, rank);
cvector xv = a.gelss(bv, sv, rank);
cmatrix xt(5,2);
xt.gelss(a, b, sv, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*xt - b).norm() << std::endl;
std::cout << (sv - a.svd()).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+2.3444861e-013
+4.6335022e-014
+2.3444861e-013
+1.1234667e-014
+4 +4
See Also
gelsy()
gelsd()
cvector::gelss()
rank()
Parameters
[in]mBcmatrix $B$.
[out]svSingular values of $A$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Result object.

Definition at line 21938 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::gelss ( const basic_cmatrix< TR, TC > &  mA,
const basic_cmatrix< TR, TC > &  mB,
basic_rvector< TR > &  sv,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) throw (cvmexception)
inline

Linear least squares problem.

Function sets calling matrix to the minimum-norm solutions to linear least squares problems

\[ \|A*x-b\|_2\to\min \]

using singular value decomposition of $m\times n$ complex matrix $A$ (parameter mA). Here $b$ is a vector of length $m$. Multiple vectors $b$ are stored as columns of $m\times l$ matrix $B$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. Matrix $A$ is passed as argument mA. Function also computes singular values of $A$ in decreasing order and returns them in sv output parameter having $\min(m,n)$ size. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
rvector sv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelss(b, sv, rank);
cvector xv = a.gelss(bv, sv, rank);
cmatrix xt(5,2);
xt.gelss(a, b, sv, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*xt - b).norm() << std::endl;
std::cout << (sv - a.svd()).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+2.3444861e-013
+4.6335022e-014
+2.3444861e-013
+1.1234667e-014
+4 +4
See Also
gelsy()
gelsd()
cvector::gelss()
rank()
Parameters
[in]mAcmatrix $A$.
[in]mBcmatrix $B$.
[out]svSingular values of $A$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Reference to changed calling matrix.

Definition at line 22007 of file cvm.h.

template<typename TR, typename TC>
basic_cvector<TR,TC> basic_cmatrix< TR, TC >::gelss ( const basic_cvector< TR, TC > &  vB,
basic_rvector< TR > &  sv,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) const throw (cvmexception)
inline

Linear least squares problem.

Function creates cvector object with the minimum-norm solution to linear least squares problem

\[ \|A*x-b\|_2\to\min \]

using singular value decomposition of $m\times n$ calling complex matrix $A$. Here $b$ is a vector of length $m$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. Matrix $A$ is passed as argument mA. Function also computes singular values of $A$ in decreasing order and returns them in sv output parameter having $\min(m,n)$ size. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
rvector sv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelss(b, sv, rank);
cvector xv = a.gelss(bv, sv, rank);
cmatrix xt(5,2);
xt.gelss(a, b, sv, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*xt - b).norm() << std::endl;
std::cout << (sv - a.svd()).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+2.3444861e-013
+4.6335022e-014
+2.3444861e-013
+1.1234667e-014
+4 +4
See Also
gelsy()
gelsd()
cvector::gelss()
rank()
Parameters
[in]vBcvector $b$.
[out]svSingular values of $A$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Result object.

Definition at line 22075 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix basic_cmatrix< TR, TC >::gelsd ( const basic_cmatrix< TR, TC > &  mB,
basic_rvector< TR > &  sv,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) const throw (cvmexception)
inline

Linear least squares problem.

Function creates cmatrix object with the minimum-norm solutions to linear least squares problems

\[ \|A*x-b\|_2\to\min \]

using singular value decomposition of $m\times n$ calling complex matrix $A$ and divide and conquer method. Here $b$ is a vector of length $m$. Multiple vectors $b$ are stored as columns of $m\times l$ matrix $B$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. Function also computes singular values of $A$ in decreasing order and returns them in sv output parameter having $\min(m,n)$ size. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
rvector sv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelsd(b, sv, rank);
cvector xv = a.gelsd(bv, sv, rank);
cmatrix xt(5,2);
xt.gelsd(a, b, sv, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*xt - b).norm() << std::endl;
std::cout << (sv - a.svd()).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+1.2865301e-014
+1.2824878e-014
+1.2865301e-014
+1.2809491e-014
+4 +4
See Also
gelsy()
gelss()
cvector::gelss()
rank()
Parameters
[in]mBcmatrix $B$.
[out]svSingular values of $A$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Result object.

Definition at line 22142 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::gelsd ( const basic_cmatrix< TR, TC > &  mA,
const basic_cmatrix< TR, TC > &  mB,
basic_rvector< TR > &  sv,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) throw (cvmexception)
inline

Linear least squares problem.

Function sets calling complex matrix to the minimum-norm solutions to linear least squares problems

\[ \|A*x-b\|_2\to\min \]

using singular value decomposition of $m\times n$ complex matrix $A$ (parameter mA) and divide and conquer method. Here $b$ is a vector of length $m$. Multiple vectors $b$ are stored as columns of $m\times l$ matrix $B$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. Matrix $A$ is passed as argument mA. Function also computes singular values of $A$ in decreasing order and returns them in sv output parameter having $\min(m,n)$ size. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
rvector sv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelsd(b, sv, rank);
cvector xv = a.gelsd(bv, sv, rank);
cmatrix xt(5,2);
xt.gelsd(a, b, sv, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*xt - b).norm() << std::endl;
std::cout << (sv - a.svd()).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+1.2865301e-014
+1.2824878e-014
+1.2865301e-014
+1.2809491e-014
+4 +4
See Also
gelsy()
gelss()
cvector::gelss()
rank()
Parameters
[in]mAcmatrix $A$.
[in]mBcmatrix $B$.
[out]svSingular values of $A$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Reference to changed calling matrix.

Definition at line 22211 of file cvm.h.

template<typename TR, typename TC>
basic_cvector<TR,TC> basic_cmatrix< TR, TC >::gelsd ( const basic_cvector< TR, TC > &  vB,
basic_rvector< TR > &  sv,
tint rank,
TR  tol = basic_cvmMachSp<TR>() 
) const throw (cvmexception)
inline

Linear least squares problem.

Function creates cvector object with the minimum-norm solution to linear least squares problem

\[ \|A*x-b\|_2\to\min \]

using singular value decomposition of $m\times n$ calling complex matrix $A$ and divide and conquer method. Here $b$ is a vector of length $m$. Matrix $A$ may be rank-deficient, function returns its effective rank in rank output parameter using tol tolerance. Internally function uses ZGELSY LAPACK routines, see more details about the algorithm in those routines' documentation. Matrix $A$ is passed as argument mA. Function also computes singular values of $A$ in decreasing order and returns them in sv output parameter having $\min(m,n)$ size. It throws cvmexception in case of inappropriate sizes of the operands.

Example:
using namespace cvm;
cmatrix a(4, 5);
cmatrix b(4, 2);
cvector bv(4);
rvector sv(4);
a.randomize_real(-10., 10.);
a.randomize_imag(-10., 10.);
b.randomize_real(-10., 10.);
b.randomize_imag(-10., 10.);
bv.randomize_real(-10., 10.);
bv.randomize_imag(-10., 10.);
cmatrix x = a.gelsd(b, sv, rank);
cvector xv = a.gelsd(bv, sv, rank);
cmatrix xt(5,2);
xt.gelsd(a, b, sv, rank);
std::cout << (a*x - b).norm() << std::endl;
std::cout << (a*xv - bv).norm() << std::endl;
std::cout << (a*xt - b).norm() << std::endl;
std::cout << (sv - a.svd()).norm() << std::endl;
std::cout << rank << " " << a.rank() << std::endl;
prints
+1.2865301e-014
+1.2824878e-014
+1.2865301e-014
+1.2809491e-014
+4 +4
See Also
gelsy()
gelss()
cvector::gelss()
rank()
Parameters
[in]vBcvector $b$.
[out]svSingular values of $A$.
[out]rankRank of matrix $A$.
[in]tolRank computation tolerance.
Returns
Result object.

Definition at line 22279 of file cvm.h.

template<typename TR, typename TC>
tint basic_cmatrix< TR, TC >::rank ( TR  tol = basic_cvmMachSp<TR>()) const throw (cvmexception)
inline

Matrix rank.

Returns rank of calling complex matrix as number of singular values with normalized absolute value greater than or equal to parameter tol (this is the largest relative spacing by default). Function throws cvmexception in case of convergence error.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6.,
7., 8., 9., 10., 11., 12.};
cmatrix m(a, nullptr, 3, 4);
std::cout << m << m.rank() << std::endl;
m(3,4) = std::complex<double>(0.,1.);
std::cout << m.rank() << std::endl;
prints
(1,0) (4,0) (7,0) (10,0)
(2,0) (5,0) (8,0) (11,0)
(3,0) (6,0) (9,0) (12,0)
2
3
See Also
rvector::svd()
cvector::normalize()
cvmMachSp()
Parameters
[in]tolRank computation tolerance.
Returns
tint Rank as integer.

Definition at line 22316 of file cvm.h.

Here is the call graph for this function:

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

QR factorization ("economy" mode)

Computes QR factorization as

\[ M=QR \]

where $M$ is calling matrix, orthogonal matrix $Q$ and upper triangular (trapezoidal) matrix $R$ are mQ and mR output parameters respectively. This version implements so-called "economy" algorithm which for given $m\times n$ matrix $M$ computes $m\times n$ matrix $Q$ and $n\times n$ matrix $R$. See also full version. Function throws cvmexception in case if inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6.};
treal ai[] = {1., -1., 2., -2., 3., -3.};
const cvm::cmatrix mh(ar, ai, 2, 3);
const cvm::cmatrix mv(ar, ai, 3, 2);
cvm::scmatrix s2(2), s3(3);
cvm::cmatrix h(2,3), v(3,2);
mh.qr(h,s3);
std::cout << (eye_complex(2)-~cmatrix(h,1,1,2,2)*cmatrix(h,1,1,2,2)).norm()
<< " " << (mh - h * s3).norm() << std::endl;
mh.qr(s2,h);
std::cout << (eye_complex(2) - ~s2 * s2).norm()
<< " " << (mh - s2 * h).norm() << std::endl;
mv.qr(v,s2);
std::cout << (eye_complex(2) - ~v * v).norm()
<< " " << (mv - v * s2).norm() << std::endl;
mv.qr(s3,v);
std::cout << (eye_complex(3) - ~s3 * s3).norm()
<< " " << (mv - s3 * v).norm() << std::endl;
prints
+2.5145832e-16 +1.3506446e-15
+2.5145832e-16 +1.3506446e-15
+2.5367068e-16 +1.4432899e-15
+3.8435519e-16 +1.4432899e-15
Parameters
[out]mQcmatrix $Q$.
[out]mRscmatrix $R$.

Definition at line 22377 of file cvm.h.

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

QR factorization ("full" mode)

Computes QR factorization as

\[ M=QR \]

where $M$ is calling matrix, orthogonal matrix $Q$ and upper triangular (trapezoidal) matrix $R$ are mQ and mR output parameters respectively. This version implements so-called "full" algorithm which for given $m\times n$ matrix $M$ computes $m\times m$ matrix $Q$ and $m\times n$ matrix $R$. See also economy version. Function throws cvmexception in case if inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6.};
treal ai[] = {1., -1., 2., -2., 3., -3.};
const cvm::cmatrix mh(ar, ai, 2, 3);
const cvm::cmatrix mv(ar, ai, 3, 2);
cvm::scmatrix s2(2), s3(3);
cvm::cmatrix h(2,3), v(3,2);
mh.qr(h,s3);
std::cout << (eye_complex(2)-~cmatrix(h,1,1,2,2)*cmatrix(h,1,1,2,2)).norm()
<< " " << (mh - h * s3).norm() << std::endl;
mh.qr(s2,h);
std::cout << (eye_complex(2) - ~s2 * s2).norm()
<< " " << (mh - s2 * h).norm() << std::endl;
mv.qr(v,s2);
std::cout << (eye_complex(2) - ~v * v).norm()
<< " " << (mv - v * s2).norm() << std::endl;
mv.qr(s3,v);
std::cout << (eye_complex(3) - ~s3 * s3).norm()
<< " " << (mv - s3 * v).norm() << std::endl;
prints
+2.5145832e-16 +1.3506446e-15
+2.5145832e-16 +1.3506446e-15
+2.5367068e-16 +1.4432899e-15
+3.8435519e-16 +1.4432899e-15
Parameters
[out]mQscmatrix $Q$.
[out]mRcmatrix $R$.

Definition at line 22429 of file cvm.h.

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

LQ factorization ("economy" mode)

Computes LQ factorization as

\[ M=LQ \]

where $M$ is calling matrix, lower triangular (trapezoidal) matrix $L$ and orthogonal matrix $Q$ are mL and mQ output parameters respectively. This version implements so-called "economy" algorithm which for given $m\times n$ matrix $M$ computes $m\times m$ matrix $L$ and $m\times n$ matrix $Q$. See also full version. Function throws cvmexception in case of inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6.};
treal ai[] = {1., -1., 2., -2., 3., -3.};
const cvm::cmatrix mh(ar, ai, 2, 3);
const cvm::cmatrix mv(ar, ai, 3, 2);
cvm::scmatrix s2(2), s3(3);
cvm::cmatrix h(2,3), v(3,2);
mh.lq(s2,h);
std::cout << (eye_complex(2) - h * ~h).norm() << " " << (mh - s2 * h)
.norm() << std::endl;
mv.lq(s3,v);
std::cout << (eye_complex(2) - ~cmatrix(v,1,1,2,2) * cmatrix(v,1,1,2,2))
.norm() << " " << (mv - s3 * v).norm() << std::endl;
mh.lq(h,s3);
std::cout << (eye_complex(3) - s3 * ~s3).norm() << " " << (mh - h * s3)
.norm() << std::endl;
mv.lq(v,s2);
std::cout << (eye_complex(2) - s2 * ~s2).norm() << " " << (mv - v * s2)
.norm() << std::endl;
prints
+1.3374617e-015 +7.4806297e-015
+6.6728929e-016 +2.9205408e-015
+1.4349634e-015 +7.4806297e-015
+6.7217793e-016 +2.9205408e-015
Parameters
[out]mLscmatrix $L$.
[out]mQcmatrix $Q$.

Definition at line 22481 of file cvm.h.

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

LQ factorization ("full" mode)

Computes LQ factorization as

\[ M=LQ \]

where $M$ is calling matrix, lower triangular (trapezoidal) matrix $L$ and orthogonal matrix $Q$ are mL and mQ output parameters respectively. This version implements so-called "full" algorithm which for given $m\times n$ matrix $M$ computes $m\times n$ matrix $L$ and $n\times n$ matrix $Q$. See also economy version. Function throws cvmexception in case of inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6.};
treal ai[] = {1., -1., 2., -2., 3., -3.};
const cvm::cmatrix mh(ar, ai, 2, 3);
const cvm::cmatrix mv(ar, ai, 3, 2);
cvm::scmatrix s2(2), s3(3);
cvm::cmatrix h(2,3), v(3,2);
mh.lq(s2,h);
std::cout << (eye_complex(2) - h * ~h).norm() << " " << (mh - s2 * h)
.norm() << std::endl;
mv.lq(s3,v);
std::cout << (eye_complex(2) - ~cmatrix(v,1,1,2,2) * cmatrix(v,1,1,2,2))
.norm() << " " << (mv - s3 * v).norm() << std::endl;
mh.lq(h,s3);
std::cout << (eye_complex(3) - s3 * ~s3).norm() << " " << (mh - h * s3)
.norm() << std::endl;
mv.lq(v,s2);
std::cout << (eye_complex(2) - s2 * ~s2).norm() << " " << (mv - v * s2)
.norm() << std::endl;
prints
+1.3374617e-015 +7.4806297e-015
+6.6728929e-016 +2.9205408e-015
+1.4349634e-015 +7.4806297e-015
+6.7217793e-016 +2.9205408e-015
Parameters
[out]mLcmatrix $L$.
[out]mQscmatrix $Q$.

Definition at line 22532 of file cvm.h.

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

RQ factorization ("economy" mode)

Computes RQ factorization as

\[ M=RQ \]

where $M$ is calling matrix, upper triangular matrix $R$ and orthogonal matrix $Q$ are mR and mQ output parameters respectively. This version implements so-called "economy" algorithm which for given $m\times n$ matrix $M$ computes $m\times m$ matrix $R$ and $m\times n$ matrix $Q$. See also full version. Following this definition the implementation assumes that $m\le n$ is satisfied and throws cvmexception otherwise. Function also throws cvmexception in case of inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6.};
treal ai[] = {1., -1., 2., -2., 3., -3.};
const cvm::cmatrix mh(ar, ai, 2, 3);
const cvm::cmatrix mv(ar, ai, 3, 2);
cvm::scmatrix s2(2), s3(3);
cvm::cmatrix h(2,3), v(3,2);
mh.rq(h,s3);
std::cout << (eye_complex(2) - cmatrix(s3,2,1,2,3) * ~cmatrix(s3,2,1,2,3))
.norm() << " " << (mh - h * s3).norm() << std::endl;
mh.rq(s2,h);
std::cout << (eye_complex(2) - h * ~h).norm()
<< " " << (mh - s2 * h).norm() << std::endl;
prints
+3.1898416e-016 +2.2342807e-015
+3.1898416e-016 +2.2342807e-015
Parameters
[out]mRscmatrix $R$.
[out]mQcmatrix $Q$.

Definition at line 22578 of file cvm.h.

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

RQ factorization ("full" mode)

Computes RQ factorization as

\[ M=RQ \]

where $M$ is calling matrix, upper triangular matrix $R$ and orthogonal matrix $Q$ are mR and mQ output parameters respectively. This version implements so-called "full" algorithm which for given $m\times n$ matrix $M$ computes $m\times n$ matrix $R$ and $n\times n$ matrix $Q$. See also economy version. Following this definition the implementation assumes that $m\le n$ is satisfied and throws cvmexception otherwise. Function also throws cvmexception in case of inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6.};
treal ai[] = {1., -1., 2., -2., 3., -3.};
const cvm::cmatrix mh(ar, ai, 2, 3);
const cvm::cmatrix mv(ar, ai, 3, 2);
cvm::scmatrix s2(2), s3(3);
cvm::cmatrix h(2,3), v(3,2);
mh.rq(h,s3);
std::cout << (eye_complex(2) - cmatrix(s3,2,1,2,3) * ~cmatrix(s3,2,1,2,3))
.norm() << " " << (mh - h * s3).norm() << std::endl;
mh.rq(s2,h);
std::cout << (eye_complex(2) - h * ~h).norm()
<< " " << (mh - s2 * h).norm() << std::endl;
prints
+3.1898416e-016 +2.2342807e-015
+3.1898416e-016 +2.2342807e-015
Parameters
[out]mRcmatrix $R$.
[out]mQscmatrix $Q$.

Definition at line 22623 of file cvm.h.

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

QL factorization ("economy" mode)

Computes QL factorization as

\[ M=QL \]

where $M$ is calling matrix, orthogonal matrix $Q$ and lower triangular matrix $L$ are mQ and mL output parameters respectively. This version implements so-called "economy" algorithm which for given $m\times n$ matrix $M$ computes $m\times n$ matrix $Q$ and $n\times n$ matrix $L$. See also full version. Following this definition the implementation assumes that $m\ge n$ is satisfied and throws cvmexception otherwise. Function also throws cvmexception in case of inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6.};
treal ai[] = {1., -1., 2., -2., 3., -3.};
const cvm::cmatrix mv(ar, ai, 3, 2);
cvm::scmatrix s2(2), s3(3);
cvm::cmatrix v(3,2);
mv.ql(v,s2);
std::cout << (eye_complex(2) - ~v * v).norm()
<< " " << (mv - v * s2).norm() << std::endl;
mv.ql(s3,v);
std::cout << (eye_complex(2) - ~cmatrix(s3,1,2,3,2) * cmatrix(s3,1,2,3,2))
.norm() << " " << (mv - s3 * v).norm() << std::endl;
prints
+1.1857187e-016 +9.4857497e-016
+1.1857187e-016 +9.4857497e-016
Parameters
[out]mQcmatrix $Q$.
[out]mLscmatrix $L$.

Definition at line 22668 of file cvm.h.

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

QL factorization ("full" mode)

Computes QL factorization as

\[ M=QL \]

where $M$ is calling matrix, orthogonal matrix $Q$ and lower triangular matrix $L$ are mQ and mL output parameters respectively. This version implements so-called "full" algorithm which for given $m\times n$ matrix $M$ computes $m\times m$ matrix $Q$ and $m\times n$ matrix $L$. See also economy version. Following this definition the implementation assumes that $m\ge n$ is satisfied and throws cvmexception otherwise. Function also throws cvmexception in case of inappropriate sizes of the operands passed.

Example:
using namespace cvm;
treal ar[] = {1., 2., 3., 4., 5., 6.};
treal ai[] = {1., -1., 2., -2., 3., -3.};
const cvm::cmatrix mv(ar, ai, 3, 2);
cvm::scmatrix s2(2), s3(3);
cvm::cmatrix v(3,2);
mv.ql(v,s2);
std::cout << (eye_complex(2) - ~v * v).norm()
<< " " << (mv - v * s2).norm() << std::endl;
mv.ql(s3,v);
std::cout << (eye_complex(2) - ~cmatrix(s3,1,2,3,2) * cmatrix(s3,1,2,3,2))
.norm() << " " << (mv - s3 * v).norm() << std::endl;
prints
+1.1857187e-016 +9.4857497e-016
+1.1857187e-016 +9.4857497e-016
Parameters
[out]mQscmatrix $Q$.
[out]mLcmatrix $L$.

Definition at line 22712 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::geru ( TC  alpha,
const CVector vCol,
const CVector vRow 
) throw (cvmexception)
inline

Rank-1 update matrix-vector operation (unconjugated)

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

\[ M=\alpha\,\begin{pmatrix} x_1 \\ x_2 \\ \vdots \\ x_m \end{pmatrix} \begin{pmatrix} y_1 & y_2 & \cdots & y_n \end{pmatrix} + M, \]

where $\alpha$ is complex number (parameter dAlpha), $M$ is calling matrix and $x$ and $y$ are complex vectors (parameters vCol and vRow respectively). Function returns reference to the matrix changed and throws cvmexception in case of inappropriate sizes of the operands. Function is not applicable to objects of the classes scbmatrix and schmatrix (i.e. cvmexception would be thrown).

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (5);
std::complex<double> alpha = std::complex<double>(1.2,4.11);
cmatrix m(3,2);
cvector vc(3);
cvector vr(2);
m.randomize_real(-1., 2.); m.randomize_imag(-3., 2.);
vc.randomize_real(-1., 3.); vc.randomize_imag(1., 3.);
vr.randomize_real(0., 2.); vr.randomize_imag(-1., 2.);
std::cout << m + vc.rank1update_u(vr) * alpha << std::endl;
std::cout << m.geru(alpha, vc, vr);
prints
(2.88144e+00,3.54299e+00) (-8.14760e+00,-1.03789e+00)
(6.33361e-01,3.35209e+00) (-4.81787e+00,-8.53964e+00)
(5.44811e-01,1.37156e+00) (-5.97006e+00,-5.00794e+00)
(2.88144e+00,3.54299e+00) (-8.14760e+00,-1.03789e+00)
(6.33361e-01,3.35209e+00) (-4.81787e+00,-8.53964e+00)
(5.44811e-01,1.37156e+00) (-5.97006e+00,-5.00794e+00)
See Also
http://www.netlib.org/blas
rank1update_u()
basic_cvector<TR,TC>::rank1update_u()
Parameters
[in]alphaMultiplier $\alpha$.
[in]vColcvector $x$.
[in]vRowcvector $y$.
Returns
Reference to changed calling matrix.

Definition at line 22773 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::gerc ( TC  alpha,
const CVector vCol,
const CVector vRow 
) throw (cvmexception)
inline

Rank-1 update matrix-vector operation (conjugated)

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

\[ M=\alpha\,\begin{pmatrix} x_1 \\ x_2 \\ \vdots \\ x_m \end{pmatrix} \begin{pmatrix} y_1^* & y_2^* & \cdots & y_n^* \end{pmatrix} + M, \]

where $\alpha$ is complex number (parameter dAlpha), $M$ is calling matrix and $x$ and $y$ are complex vectors (parameters vCol and vRow respectively). Function returns reference to the matrix changed and throws cvmexception in case of inappropriate sizes of the operands. Function is not applicable to objects of the classes scbmatrix and schmatrix (i.e. cvmexception would be thrown).

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (5);
std::complex<double> alpha = std::complex<double>(1.2,4.11);
cmatrix m(3,2);
cvector vc(3);
cvector vr(2);
m.randomize_real(-1., 2.); m.randomize_imag(-3., 2.);
vc.randomize_real(-1., 3.); vc.randomize_imag(1., 3.);
vr.randomize_real(0., 2.); vr.randomize_imag(-1., 2.);
std::cout << m + vc.rank1update_c(vr) * alpha << std::endl;
std::cout << m.gerc(alpha, vc, vr);
prints
(1.27138e+01,1.58049e+01) (1.00616e+01,2.21197e+01)
(1.93326e+01,1.41763e+01) (1.74769e+01,2.49013e+01)
(8.09961e+00,1.36259e+01) (5.86738e+00,1.97800e+01)
(1.27138e+01,1.58049e+01) (1.00616e+01,2.21197e+01)
(1.93326e+01,1.41763e+01) (1.74769e+01,2.49013e+01)
(8.09961e+00,1.36259e+01) (5.86738e+00,1.97800e+01)
See Also
http://www.netlib.org/blas
rank1update_c()
basic_cvector<TR,TC>::rank1update_c()
Parameters
[in]alphaMultiplier $\alpha$.
[in]vColcvector $x$.
[in]vRowcvector $y$.
Returns
Reference to changed calling matrix.

Definition at line 22839 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::gemm ( const basic_cmatrix< TR, TC > &  m1,
bool  bConj1,
const basic_cmatrix< TR, TC > &  m2,
bool  bConj2,
TC  cAlpha,
TC  cBeta 
) throw (cvmexception)
inline

Generic matrix-matrix operation.

Calls one of ZGEMM routines of the BLAS library performing matrix-matrix operation defined as

\[ M=\alpha\,\mathcal{T}(M_1)\cdot\mathcal{T}(M_2) + \beta M, \]

where $\alpha$ and $\beta$ are complex numbers (parameters dAlpha and dBeta), $M$ is calling matrix and $M_1$ and $M_2$ are matrices (parameters m1 and m2 respectively). Function $\mathcal{T}(M_i)$ conjugatess matrix $M_i$ if appropriate boolean parameter bConj* is equal to true and does nothing otherwise. Function returns reference to the matrix changed and throws cvmexception in case of inappropriate sizes of the operands. Function is not applicable to objects of the classes srbmatrix and srsmatrix (i.e. exception of type cvmexception would be thrown).

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (3);
try {
std::complex<double> alpha = std::complex<double>(1.1,2.1);
std::complex<double> beta = std::complex<double>(0.71,0.12);
cmatrix m1(4,3); cmatrix m2(4,3);
cmatrix m(3,3);
m.randomize_real(-1., 2.); m.randomize_imag(1., 3.);
m1.randomize_real(-1., 3.); m1.randomize_imag(-2., 4.);
m2.randomize_real(0., 2.); m2.randomize_imag(-3., 2.);
std::cout << ~m1 * m2 * alpha + m * beta << std::endl;
std::cout << m.gemm(m1, true, m2, false, alpha, beta);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(3.225e+01,3.611e+01) (2.042e+01,1.206e+01) (5.065e+01,-2.261e+01)
(3.009e+01,3.665e+00) (2.167e+01,-3.327e+00) (4.305e+01,-1.960e+01)
(1.156e+01,-4.966e+00) (4.067e+00,-1.181e+01) (1.121e+01,-2.684e+01)
(3.225e+01,3.611e+01) (2.042e+01,1.206e+01) (5.065e+01,-2.261e+01)
(3.009e+01,3.665e+00) (2.167e+01,-3.327e+00) (4.305e+01,-1.960e+01)
(1.156e+01,-4.966e+00) (4.067e+00,-1.181e+01) (1.121e+01,-2.684e+01)
See Also
http://www.netlib.org/blas
Parameters
[in]m1cmatrix $M_1$.
[in]bConj1Conjugate cmatrix $M_1$.
[in]m2cmatrix $M_2$.
[in]bConj2Conjugate cmatrix $M_2$.
[in]cAlphaMultiplier $\alpha$.
[in]cBetaMultiplier $\beta$.
Returns
Reference to changed calling matrix.

Definition at line 22908 of file cvm.h.

Here is the call graph for this function:

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< TR, TC >::hemm ( bool  bLeft,
const basic_schmatrix< TR, TC > &  ms,
const basic_cmatrix< TR, TC > &  m,
TC  cAlpha,
TC  cBeta 
) throw (cvmexception)
inline

Generic hermitian matrix-matrix operation.

Calls one of ZHEMM routines of the BLAS library performing one of matrix-matrix operations defined as

\[ M=\alpha\,M_s\cdot M_1 + \beta M\quad\text{or}\quad M=\alpha\,M_1\cdot M_s + \beta M, \]

where $\alpha$ and $\beta$ are complex numbers (parameters cAlpha and cBeta), $M$ is calling matrix, $M_s$ is hermitian matrix and $M_1$ is complex matrix (parameters ms and m respectively). First operation is performed if bLeft passed is true and second one otherwise. Function returns reference to the matrix changed and throws cvmexception in case of inappropriate sizes of the operands. Function is not applicable to objects of the class scbmatrix (i.e. cvmexception would be thrown).

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (3);
try {
std::complex<double> alpha = std::complex<double>(1.3,0.21);
std::complex<double> beta = std::complex<double>(0.5,-0.1);
cmatrix m1(2,3);
cmatrix m2(3,2);
schmatrix ms(2);
cmatrix m(2,3);
m.randomize_real(-1., 2.); m.randomize_imag(1., 3.);
m1.randomize_real(-1., 3.); m1.randomize_imag(1., 2.);
m2.randomize_real(0., 2.); m2.randomize_imag(-3., -1.);
ms.randomize_real(-3., 1.); ms.randomize_imag(-1.3, 4.);
std::cout << ms * m1 * alpha + m * beta << std::endl;
std::cout << m.hemm (true, ms, m1, alpha, beta) << std::endl;
m.resize(3,2);
m.randomize_real(-1.4, 1.3); m.randomize_imag(1.1, 3.);
std::cout << m2 * ms * alpha + m * beta << std::endl;
std::cout << m.hemm (false, ms, m2, alpha, beta);
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
(1.096e+00,-7.692e+00) (-7.923e+00,-3.909e+00) (-1.324e+01,-5.264e+00)
(2.415e+00,1.240e+00) (4.384e-01,-1.771e+00) (7.495e-01,-2.740e+00)
(1.096e+00,-7.692e+00) (-7.923e+00,-3.909e+00) (-1.324e+01,-5.264e+00)
(2.415e+00,1.240e+00) (4.384e-01,-1.771e+00) (7.495e-01,-2.740e+00)
(-5.007e+00,1.010e+01) (2.341e+00,3.248e+00)
(-8.753e+00,7.854e+00) (3.152e+00,4.491e+00)
(-9.162e+00,6.401e+00) (-1.168e+00,3.973e+00)
(-5.007e+00,1.010e+01) (2.341e+00,3.248e+00)
(-8.753e+00,7.854e+00) (3.152e+00,4.491e+00)
(-9.162e+00,6.401e+00) (-1.168e+00,3.973e+00)
See Also
http://www.netlib.org/blas
Parameters
[in]bLeftPerfoem left-side operation.
[in]msschmatrix $M_s$.
[in]mcmatrix $M_1$.
[in]cAlphaMultiplier $\alpha$.
[in]cBetaMultiplier $\beta$.
Returns
Reference to changed calling matrix.

Definition at line 22990 of file cvm.h.

Here is the call graph for this function:

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

Set matrix to zero.

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

Example:
using namespace cvm;
cmatrix m(4, 3);
m.randomize_real(0.,1.);
m.randomize_imag(1.,2.);
std::cout << m << std::endl;
std::cout << m.vanish ();
prints
(0.851527,1.16376) (0.557512,1.90188) (0.0343638,1.52068)
(0.478042,1.29106) (0.561724,1.19764) (0.320994,1.35804)
(0.264534,1.40986) (0.113468,1.75137) (0.37727,1.54994)
(0.521409,1.83035) (0.559465,1.35072) (0.809198,1.12537)
(0,0) (0,0) (0,0)
(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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 23030 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 23059 of file cvm.h.

template<typename TR, typename TC>
basic_cmatrix& basic_cmatrix< 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 in basic_schmatrix< TR, TC >, basic_scbmatrix< TR, TC >, and basic_scmatrix< TR, TC >.

Definition at line 23088 of file cvm.h.

template<typename TR, typename TC>
TR basic_cmatrix< TR, TC >::norm2 ( ) const
inlineoverridevirtual

2-norm

2-norm of calling array that for vectors is defined as

\[ {\|x\|}_2={\|x\|}_E=\left(\sum_{i=1}^{n} |x_i|^2\right)^{1/2} \]

and for matrices as

\[ {\|A\|}_2=\max_i\sigma_i = \left(\max_{|x|=1}\, (Ax\cdot Ax)\right)^{1/2}, \]

where $\sigma_i$ is $i$-th singular value of $m\times n$ matrix $A,\ i=1,\dots,\min(m,n)$.

Example:
using namespace cvm;
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (12);
double a[] = {1., 2., 3., -4., 5., -6.};
const rvector v (a, 3);
const rmatrix m (a, 2, 3);
std::cout << v << v.norm2 () << std::endl << std::endl;
std::cout << m << m.norm2 () << std::endl;
prints
+1.000000000000e+000 +2.000000000000e+000 +3.000000000000e+000
+3.741657386774e+000
+1.000000000000e+000 +3.000000000000e+000 +5.000000000000e+000
+2.000000000000e+000 -4.000000000000e+000 -6.000000000000e+000
+9.319612060784e+000
Returns
treal Norm value

Reimplemented from basic_array< TR, TC >.

Definition at line 23095 of file cvm.h.

Here is the call graph for this function:

Friends And Related Function Documentation

template<typename TR, typename TC>
friend class basic_cvector< TR, TC >
friend

Definition at line 18396 of file cvm.h.


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