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 | Protected Attributes | Friends | List of all members
basic_srbmatrix< TR > Class Template Reference

End-user class encapsulating band square matrix of real numbers. More...

#include <cvm.h>

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

Public Member Functions

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

Protected Attributes

BaseSRMatrix mSM
 Temporary storage for square matrix enclosing band one (if needed)
- Protected Attributes inherited from BandMatrix< TR, TR >
tint mkl
 Number of sub-diagonals.
tint mku
 Number of super-diagonals.

Friends

class basic_scbmatrix< TR, TC >

Additional Inherited Members

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

Detailed Description

template<typename TR>
class basic_srbmatrix< TR >

End-user class encapsulating band square matrix of real numbers.

TR type stands for treal. Please use predefined srbmatrix class in your applications. Band storage can be described as follows (cited from MKL manual): an $m$ by $n$ band matrix with $k_l$ sub-diagonals and $k_u$ super-diagonals is stored compactly in a two-dimensional array with $k_l+k_u+1$ rows and $n$ columns. Columns of the matrix are stored in the corresponding columns of the array, and diagonals of the matrix are stored in rows of the array}. This way of storage can be illustrated as follows (referenced elements are shown as $*$, not referenced as $-$, zeros are not stored):

\[\begin{aligned} m=n=3, k_l=0, k_u=0&:\ \begin{bmatrix} * & 0 & 0 \\ 0 & * & 0 \\ 0 & 0 & * \end{bmatrix}\\ m=n=4, k_l=1, k_u=0&:\ \begin{bmatrix} * & 0 & 0 & 0 \\ * & * & 0 & 0 \\ 0 & * & * & 0 \\ 0 & 0 & * & * \\ & & & - \end{bmatrix}\\ m=n=6, k_l=1, k_u=2&:\ \begin{bmatrix} - & & & & & \\ - & - & & & & \\ * & * & * & 0 & 0 & 0 \\ * & * & * & * & 0 & 0 \\ 0 & * & * & * & * & 0 \\ 0 & 0 & * & * & * & * \\ 0 & 0 & 0 & * & * & * \\ 0 & 0 & 0 & 0 & * & * \\ & & & & & - \end{bmatrix} \end{aligned}\]

CVM library implements square band matrices only, therefore $m=n$ is satisfied for them.

See Also
BandMatrix

Definition at line 28309 of file cvm.h.

Constructor & Destructor Documentation

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

Default constructor.

Creates empty square band matrix. No memory gets allocated.

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

Definition at line 28349 of file cvm.h.

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

Diagonal band matrix constructor.

Creates $n\times n$ srbmatrix object where dimension $n$ is passed in nDim parameter. The matrix created is diagonal, i.e. $k_l=k_u=0$. Constructor throws cvmexception in case of non-positive size passed or memory allocation failure.

Example:
using namespace cvm;
srbmatrix m(4);
std::cout << m.msize() << " " << m.nsize() << " " << m.size();
std::cout << " " << m.lsize() << " " << m.usize() << std::endl;
m.set(1.);
std::cout << m;
prints
4 4 4 0 0
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
Parameters
[in]nDimNumber of rows and columns.

Definition at line 28379 of file cvm.h.

template<typename TR>
basic_srbmatrix< TR >::basic_srbmatrix ( tint  nDim,
tint  nKL,
tint  nKU 
)
inline

Band matrix constructor.

Creates srbmatrix object of dimension passed in nDim parameter. The matrix created has nKL sub-diagonals and nKU super-diagonals. Constructor throws cvmexception in case of non-positive size or negative number of sub-diagonals or super-diagonals passed or in case of memory allocation failure. Example:

using namespace cvm;
srbmatrix m(5,1,1);
m.set(1.);
std::cout << m << std::endl
<< m.msize() << " " << m.nsize() << " " << m.size()
<< " " << m.lsize() << " " << m.usize() << std::endl;

prints

1 1 0 0 0
1 1 1 0 0
0 1 1 1 0
0 0 1 1 1
0 0 0 1 1
5 5 15 1 1
Parameters
[in]nDimNumber of rows and columns.
[in]nKLNumber of lower sub-diagonals.
[in]nKUNumber of upper super-diagonals.

Definition at line 28415 of file cvm.h.

template<typename TR>
basic_srbmatrix< TR >::basic_srbmatrix ( TR *  pd,
tint  nDim,
tint  nKL,
tint  nKU 
)
inline

Constructor.

Creates $n\times n$ srbmatrix object where $n$ is passed in nDim parameter. The matrix created has nKL sub-diagonals and nKU super-diagonals. Constructor throws cvmexception in case of non-positive size or negative number of sub-diagonals or super-diagonals passed or in case of memory allocation failure. Unlike others, this constructor does not allocate memory. It just shares memory with array pointed to by pd (for matrices nIncr=1 is always satisfied).

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
srbmatrix ml(a,4,1,0);
srbmatrix mu(a,4,0,1);
ml(2,1) = 9.;
std::cout << ml << std::endl << mu << std::endl;
std::cout << a[0] << " " << a[1] << " " << a[2] << " "
<< a[3] << " " << a[4] << " " << a[5] << " " << std::endl;
prints
1 0 0 0
9 3 0 0
0 4 5 0
0 0 6 7
9 3 0 0
0 4 5 0
0 0 6 7
0 0 0 8
1 9 3 4 5 6
See Also
http://cvmlib.com/faq.htm
basic_rmatrix::basic_rmatrix(TR*,tint,tint)
Parameters
[in]pdPointer to array to share memory with.
[in]nDimNumber of rows and columns.
[in]nKLNumber of lower sub-diagonals.
[in]nKUNumber of upper super-diagonals.

Definition at line 28464 of file cvm.h.

template<typename TR>
basic_srbmatrix< TR >::basic_srbmatrix ( const TR *  pd,
tint  nDim,
tint  nKL,
tint  nKU 
)
inline

Constructor.

Creates $n\times n$ srbmatrix object where $n$ is passed in nDim parameter. The matrix created has nKL sub-diagonals and nKU super-diagonals. Constructor throws cvmexception in case of non-positive size or negative number of sub-diagonals or super-diagonals passed or in case of memory allocation failure. Then constructor copies $(k_l + k_u + 1)*n$ elements of array pd to the matrix according to band storage.

Example:
using namespace cvm;
const double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
srbmatrix ml(a,4,1,0);
srbmatrix mu(a,4,0,1);
ml(2,1) = 9.;
std::cout << ml << std::endl << mu << std::endl;
std::cout << a[0] << " " << a[1] << " " << a[2] << " "
<< a[3] << " " << a[4] << " " << a[5] << " " << std::endl;
prints
1 0 0 0
9 3 0 0
0 4 5 0
0 0 6 7
2 3 0 0
0 4 5 0
0 0 6 7
0 0 0 8
1 2 3 4 5 6
See Also
http://cvmlib.com/faq.htm
basic_rmatrix::basic_rmatrix(TR*,tint,tint)
Parameters
[in]pdPointer to array to share memory with.
[in]nDimNumber of rows and columns.
[in]nKLNumber of lower sub-diagonals.
[in]nKUNumber of upper super-diagonals.

Definition at line 28513 of file cvm.h.

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

Copy constructor.

Creates srbmatrix object as a copy of band 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.};
srbmatrix m(a,4,1,0);
srbmatrix mc(m);
m(1,1) = 7.77;
std::cout << m << std::endl << mc;
prints
7.77 0 0 0
2 3 0 0
0 4 5 0
0 0 6 7
1 0 0 0
2 3 0 0
0 4 5 0
0 0 6 7
Parameters
[in]msrbmatrix to copy from.

Definition at line 28548 of file cvm.h.

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

Move constructor.

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

rvector a(b + c);

or this

rvector a = b + c;

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

Parameters
[in]mrvalue reference to other matrix.

Definition at line 28572 of file cvm.h.

template<typename TR>
basic_srbmatrix< TR >::basic_srbmatrix ( const BaseRMatrix m,
tint  nKL,
tint  nKU 
)
inline

Constructor.

Creates srbmatrix object as a copy of sliced matrix m, i.e. it copies main diagonal, nKL sub-diagonals and nKU super-diagonals of matrix m. It's assumed that $m\times n$ matrix m must have equal sizes, i.e. $m = n$ is satisfied. Constructor throws cvmexception if this is not true or in case of memory allocation failure.

Example:
using namespace cvm;
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.,
10., 11., 12., 13., 14., 15., 16.};
srmatrix m(a,4);
srbmatrix mb(m,1,2);
std::cout << m << std::endl << mb;
prints
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
1 5 9 0
2 6 10 14
0 7 11 15
0 0 12 16
Parameters
[in]mrmatrix to copy diagonal and subdiagonals from.
[in]nKLNumber of lower sub-diagonals.
[in]nKUNumber of upper super-diagonals.

Definition at line 28611 of file cvm.h.

Here is the call graph for this function:

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

Constructor.

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

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

Definition at line 28643 of file cvm.h.

Here is the call graph for this function:

Member Function Documentation

template<typename TR>
type_proxy<TR,TR> basic_srbmatrix< TR >::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;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
try {
double a[] = {1., 2., 3., 4., 5., 6.};
const rmatrix m (a, 2, 3);
rmatrix ms(m);
std::cout << m(1,1) << " " << m(2,3) << std::endl << std::endl;
ms(2,2) = 7.77;
std::cout << ms;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
1.00e+00 6.00e+00
1.00e+00 3.00e+00 5.00e+00
2.00e+00 7.77e+00 6.00e+00
See Also
http://cvmlib.com/faq.htm
Parameters
[in]nRowRow index (CVM0 based).
[in]nColColumn index (CVM0 based).
Returns
type_proxy Proxy to element (l-value).

Reimplemented from basic_srmatrix< TR >.

Definition at line 28650 of file cvm.h.

Here is the call graph for this function:

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

Value of element (not l-value)

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 28657 of file cvm.h.

Here is the call graph for this function:

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

Column as not l-value.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 28665 of file cvm.h.

Here is the call graph for this function:

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

Row as not l-value.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 28672 of file cvm.h.

Here is the call graph for this function:

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

Assignment operator.

Sets every element of calling srbmatrix 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.};
const srbmatrix m1(a,4,1,0);
srbmatrix m2(4,1,0);
m2 = m1;
std::cout << m2;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
1 0 0 0
2 3 0 0
0 4 5 0
0 0 6 7
Parameters
[in]msrbmatrix to assign from.
Returns
Reference to changed calling matrix.

Definition at line 28710 of file cvm.h.

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

Move assignment operator.

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

a = b + c;

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

Parameters
[in]mrvalue reference to other matrix.

Definition at line 28730 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
basic_srbmatrix& basic_srbmatrix< TR >::assign ( const RVector v) throw (cvmexception)
inline

Vector (as array) assignment.

Sets every element of calling matrix to be equal to appropriate element of rvector v as an array. Assignment is performed according to matrix storage (by columns). It's assumed that vector passed is long enough to fill calling matrix. Function throws cvmexception otherwise.

Example:
try {
const double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
const rvector v(a,8);
rmatrix m(2,3);
std::cout << v << std::endl;
m.assign(v);
std::cout << m;
} catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
1 2 3 4 5 6 7 8
1 3 5
2 4 6
Parameters
[in]vrvector to assign.
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 28738 of file cvm.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TR>
basic_srbmatrix& basic_srbmatrix< TR >::assign ( const TR *  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;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (2);
const double a[] = {1., 2., 3., 4., 5., 6.};
rmatrix m(2, 3);
m.assign(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_srmatrix< TR >.

Definition at line 28746 of file cvm.h.

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

Sets all elements to one value.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 28753 of file cvm.h.

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

Changes dimension.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 28759 of file cvm.h.

template<typename TR>
basic_srbmatrix& basic_srbmatrix< TR >::resize_lu ( tint  nNewKL,
tint  nNewKU 
) throw (cvmexception)
inline

Changes number of sub- and super-diagonals.

Changes number of sub- and super-diagonals of calling band matrix to nNewKL and nNewKU respectively and returns reference to the matrix changed. In case of increasing of the numbers, calling matrix is filled up with zeroes. Function throws cvmexception in case of negative number passed or memory allocation failure.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
srbmatrix m(a,4,1,0);
std::cout << m << std::endl;
m.resize_lu (0,1);
m.diag(1).set(9.);
std::cout << m;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
1 0 0 0
2 3 0 0
0 4 5 0
0 0 6 7
1 9 0 0
0 3 9 0
0 0 5 9
0 0 0 7
Parameters
[in]nNewKLNew number of lower sub-diagonals.
[in]nNewKUNew number of upper super-diagonals.
Returns
Reference to changed calling matrix.

Definition at line 28803 of file cvm.h.

Here is the caller graph for this function:

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

Band matrix comparison.

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

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

Definition at line 28843 of file cvm.h.

Here is the call graph for this function:

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

Band matrix comparison.

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

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

Definition at line 28880 of file cvm.h.

Here is the call graph for this function:

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

Matrix replacement.

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

Example:
using namespace cvm;
try {
srbmatrix m(3,1,0);
srmatrix mc(1);
m(2,1) = 1.;
m(2,2) = 2.;
std::cout << m << std::endl << mc << std::endl;
mc << m;
std::cout << mc;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
0 0 0
1 2 0
0 0 0
0
0 0 0
1 2 0
0 0 0
See Also
operator =()
Parameters
[in]msrbmatrix to replace by.
Returns
Reference to changed calling matrix.

Definition at line 28922 of file cvm.h.

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

Addition operator.

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

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (1);
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
double b[] = {10., 20., 30., 40., 50., 60., 70., 80.};
srbmatrix m1(a,4,1,0);
srbmatrix m2(b,4,1,0);
std::cout << m1 + m2 << std::endl << m1 + m1;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
1.1e+01 0.0e+00 0.0e+00 0.0e+00
2.2e+01 3.3e+01 0.0e+00 0.0e+00
0.0e+00 4.4e+01 5.5e+01 0.0e+00
0.0e+00 0.0e+00 6.6e+01 7.7e+01
2.0e+00 0.0e+00 0.0e+00 0.0e+00
4.0e+00 6.0e+00 0.0e+00 0.0e+00
0.0e+00 8.0e+00 1.0e+01 0.0e+00
0.0e+00 0.0e+00 1.2e+01 1.4e+01
See Also
sum()
Parameters
[in]msrbmatrix to add to calling one.
Returns
Sum of matrices.

Definition at line 28973 of file cvm.h.

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

Subtraction operator.

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

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (1);
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
double b[] = {10., 20., 30., 40., 50., 60., 70., 80.};
srbmatrix m1(a,4,1,0);
srbmatrix m2(b,4,1,0);
std::cout << m2 - m1 << std::endl << m1 - m1;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
9.0e+00 0.0e+00 0.0e+00 0.0e+00
1.8e+01 2.7e+01 0.0e+00 0.0e+00
0.0e+00 3.6e+01 4.5e+01 0.0e+00
0.0e+00 0.0e+00 5.4e+01 6.3e+01
0.0e+00 0.0e+00 0.0e+00 0.0e+00
0.0e+00 0.0e+00 0.0e+00 0.0e+00
0.0e+00 0.0e+00 0.0e+00 0.0e+00
0.0e+00 0.0e+00 0.0e+00 0.0e+00
See Also
diff()
Parameters
[in]msrbmatrix to subtract from calling one.
Returns
Difference of matrices.

Definition at line 29020 of file cvm.h.

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

Sum of matrices.

Assigns sum of square band 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.};
const srbmatrix m1(a,3,1,0);
srbmatrix m2(3,1,0);
srbmatrix m(3,1,0);
m2.set(1.);
std::cout << m1 << std::endl << m2 << std::endl;
std::cout << m.sum(m1, m2) << std::endl;
std::cout << m.sum(m, m2);
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
1 0 0
2 3 0
0 4 5
1 0 0
1 1 0
0 1 1
2 0 0
3 4 0
0 5 6
3 0 0
4 5 0
0 6 7
See Also
operator +()
Parameters
[in]m1First srbmatrix summand.
[in]m2Second srbmatrix summand.
Returns
Reference to changed calling matrix.

Definition at line 29074 of file cvm.h.

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

Difference of matrices.

Assigns difference of square band 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.};
const srbmatrix m1(a,3,1,0);
srbmatrix m2(3,1,0);
srbmatrix m(3,1,0);
m2.set(1.);
std::cout << m1 << std::endl << m2 << std::endl;
std::cout << m.diff(m1, m2) << std::endl;
std::cout << m.diff(m, m2);
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
1 0 0
2 3 0
0 4 5
1 0 0
1 1 0
0 1 1
0 0 0
1 2 0
0 3 4
-1 0 0
0 1 0
0 2 3
See Also
operator -()
Parameters
[in]m1First srbmatrix subtrahend.
[in]m2Second srbmatrix subtrahend.
Returns
Reference to changed calling matrix.

Definition at line 29128 of file cvm.h.

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

Increment operator.

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

Definition at line 29179 of file cvm.h.

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

Decrement operator.

Subtracts srbmatrix 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 {
srbmatrix m1(4,0,1);
srbmatrix m2(4,0,1);
m1.set(1.);
m2.set(4.);
m2 -= m1;
std::cout << m2 << 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 0 0
0 3 3 0
0 0 3 3
0 0 0 3
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
See Also
operator -()
diff()
Parameters
[in]msrbmatrix to decrement by.
Returns
Reference to changed calling matrix.

Definition at line 29229 of file cvm.h.

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

Unary minus operator.

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

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific |
std::ios::left |
std::ios::showpos);
std::cout.precision (1);
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
srbmatrix m(a,4,1,0);
std::cout << -m;
prints
-1.0e+00 +0.0e+00 +0.0e+00 +0.0e+00
-2.0e+00 -3.0e+00 +0.0e+00 +0.0e+00
+0.0e+00 -4.0e+00 -5.0e+00 +0.0e+00
+0.0e+00 +0.0e+00 -6.0e+00 -7.0e+00
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 29262 of file cvm.h.

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

Plus identity, prefix.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29297 of file cvm.h.

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

Plus identity, postfix.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29330 of file cvm.h.

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

Minus identity, prefix.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29363 of file cvm.h.

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

Minus identity, postfix.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29396 of file cvm.h.

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

Multiply by number operator.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29402 of file cvm.h.

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

Divide by number operator.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29409 of file cvm.h.

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

Multiply by number and assign.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29416 of file cvm.h.

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

Divide by number and assign.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29422 of file cvm.h.

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

Matrix normalizer.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29428 of file cvm.h.

template<typename TR>
basic_srbmatrix basic_srbmatrix< TR >::operator~ ( ) const throw (cvmexception)
inline

Matrix transposition.

Creates object of type srmatrix as transposed calling matrix.

Example:
using namespace cvm;
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 9.};
srmatrix m(a,3);
srmatrix mt(3);
std::cout << ~m << std::endl ;
mt.transpose(m);
std::cout << mt << std::endl;
mt.transpose();
std::cout << mt;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
1 2 3
4 5 6
7 8 9
1 2 3
4 5 6
7 8 9
1 4 7
2 5 8
3 6 9
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 29435 of file cvm.h.

Here is the call graph for this function:

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

Matrix transposition.

Sets calling square band matrix to be equal to square band 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.};
srbmatrix m (a,4,1,0);
srbmatrix mt(4,0,1);
std::cout << ~m << std::endl ;
mt.transpose(m);
std::cout << mt << std::endl;
mt.transpose();
std::cout << mt;
prints
1 2 0 0
0 3 4 0
0 0 5 6
0 0 0 7
1 2 0 0
0 3 4 0
0 0 5 6
0 0 0 7
1 0 0 0
2 3 0 0
0 4 5 0
0 0 6 7
Parameters
[in]msrbmatrix to transpose.
Returns
Reference to changed calling matrix.

Definition at line 29478 of file cvm.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename TR>
basic_srbmatrix& basic_srbmatrix< TR >::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;
try {
double a[] = {1., 2., 3., 4., 5., 6.};
rmatrix m(a,2,3);
std::cout << m << std::endl;
std::cout << m.transpose();
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
1 3 5
2 4 6
1 2
3 4
5 6
Returns
Reference to changed calling matrix.

Reimplemented from basic_srmatrix< TR >.

Definition at line 29487 of file cvm.h.

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

Matrix-vector product.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29493 of file cvm.h.

Here is the call graph for this function:

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

Matrix-matrix product.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29502 of file cvm.h.

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

Matrix-matrix product.

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

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

Definition at line 29539 of file cvm.h.

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

Matrix-matrix product.

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

Example:
using namespace cvm;
try {
srbmatrix m1(7,1,0);
srbmatrix m2(7,1,1);
m1.set(1.);
m2.set(1.);
std::cout << m1 * m2;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
1 1 0 0 0 0 0
2 2 1 0 0 0 0
1 2 2 1 0 0 0
0 1 2 2 1 0 0
0 0 1 2 2 1 0
0 0 0 1 2 2 1
0 0 0 0 1 2 2
Parameters
[in]msrbmatrix to compute product with.
Returns
Result object.

Definition at line 29579 of file cvm.h.

Here is the call graph for this function:

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

Linear solver operator.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29590 of file cvm.h.

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

Low-up (LU) factorization.

Compute LU factorization of square band matrix $A$ as

\[ A=PLU \]

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

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::left);
std::cout.precision (4);
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8.};
srbmatrix ma(a,4,1,0);
srbmatrix mLU(4,1,0);
rmatrix mb1(4,2); rvector vb1(4);
rmatrix mb2(4,2); rvector vb2(4);
rmatrix mx1(4,2); rvector vx1(4);
rmatrix mx2(4,2); rvector vx2(4);
iarray nPivots(4);
double dErr = 0.;
mb1.randomize(-1.,3.); vb1.randomize(-2.,4.);
mb2.randomize(-2.,5.); vb2.randomize(-3.,1.);
mLU.low_up(ma, nPivots);
mx1 = ma.solve_lu (mLU, nPivots, mb1, dErr);
std::cout << mx1 << dErr << std::endl << std::endl;
mx2 = ma.solve_lu (mLU, nPivots, mb2);
std::cout << mx2 << std::endl;;
std::cout << ma * mx1 - mb1 << std::endl << ma * mx2 - mb2;
vx1 = ma.solve_lu (mLU, nPivots, vb1, dErr);
std::cout << vx1 << dErr << std::endl;
vx2 = ma.solve_lu (mLU, nPivots, vb2);
std::cout << vx2 << std::endl;;
std::cout << ma * vx1 - vb1 << std::endl << ma * vx2 - vb2;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
7.6327e-02 -4.7386e-01
-2.9523e-01 9.7577e-01
1.7288e-01 -3.5093e-01
1.0595e-01 4.7363e-01
1.1832e-15
3.1963e+00 4.8622e+00
-4.9904e-01 -2.6575e+00
8.2183e-01 2.3294e+00
-6.1693e-01 -1.8015e+00
0.0000e+00 0.0000e+00
0.0000e+00 -2.2204e-16
0.0000e+00 -4.4409e-16
0.0000e+00 0.0000e+00
0.0000e+00 0.0000e+00
8.8818e-16 0.0000e+00
0.0000e+00 -4.4409e-16
-4.4409e-16 4.4409e-16
7.8933e-01 7.0543e-01 -1.6338e-02 -2.6206e-01
1.4832e-15
-1.5505e+00 5.8987e-01 -8.4977e-01 7.3059e-01
0.0000e+00 0.0000e+00 0.0000e+00 0.0000e+00
-2.2204e-16 0.0000e+00 0.0000e+00 4.4409e-16
Parameters
[in]msrbmatrix to compute LU factorization for.
[out]nPivotsArray of pivot indices.
Returns
Reference to changed calling matrix.

Definition at line 29686 of file cvm.h.

Here is the caller graph for this function:

template<typename TR>
basic_srbmatrix basic_srbmatrix< TR >::low_up ( tint nPivots) const throw (cvmexception)
inline

Low-up (LU) factorization.

Compute LU factorization of square matrix $A$ as

\[ A=PLU \]

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

Example:
using namespace cvm;
std::cout.setf (std::ios::scientific | std::ios::showpos);
std::cout.precision (3);
try {
double a[] = {1., 2., 3., 4., 5., 6., 7., 8., 10.};
srmatrix m(a, 3);
srmatrix mLU(3), mLo(3), mUp(3);
iarray naPivots(3);
mLU = m.low_up (naPivots);
mLo.identity ();
mLo.diag(-2) = mLU.diag(-2);
mLo.diag(-1) = mLU.diag(-1);
mUp.diag(0) = mLU.diag(0);
mUp.diag(1) = mLU.diag(1);
mUp.diag(2) = mLU.diag(2);
std::cout << mLo << std::endl << mUp
<< std::endl << naPivots << std::endl;
mLU = mLo * mUp;
for (int i = 3; i >= 1; i--) {
mLU.swap_rows (i, naPivots[i]);
}
std::cout << mLU;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
+1.000e+000 +0.000e+000 +0.000e+000
+3.333e-001 +1.000e+000 +0.000e+000
+6.667e-001 +5.000e-001 +1.000e+000
+3.000e+000 +6.000e+000 +1.000e+001
+0.000e+000 +2.000e+000 +3.667e+000
+0.000e+000 +0.000e+000 -5.000e-001
+3 +3 +3
+1.000e+000 +4.000e+000 +7.000e+000
+2.000e+000 +5.000e+000 +8.000e+000
+3.000e+000 +6.000e+000 +1.000e+001
Parameters
[out]nPivotsArray of pivot indices.
Returns
Result object.

Reimplemented from basic_srmatrix< TR >.

Definition at line 29693 of file cvm.h.

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

Identity matrix.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29700 of file cvm.h.

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

Set matrix to zero.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29707 of file cvm.h.

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

Randomizer.

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

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

Reimplemented from basic_srmatrix< TR >.

Definition at line 29713 of file cvm.h.

template<typename TR>
TR basic_srbmatrix< TR >::norm ( ) const
inlineoverridevirtual

Euclidean norm.

Euclidean norm of calling array that for vectors is defined as

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

and for matrices as

\[ {\|A\|}_E=\left(\sum_{i=1}^{m}\sum_{j=1}^{n} |a_{ij}|^2\right)^{1/2}, \]

Example:
using namespace cvm;
std::cout.setf (ios::scientific | 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.norm () << std::endl << std::endl;
std::cout << m << m.norm () << 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.539392014169e+000
Returns
treal Norm value

Reimplemented from basic_array< TR, TR >.

Definition at line 29720 of file cvm.h.

Here is the call graph for this function:

template<typename TR>
TR basic_srbmatrix< TR >::norm1 ( ) const
inlineoverridevirtual

1-norm

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

\[ {\|x\|}_1=\sum_{i=1}^{n} |x_i| \]

and for matrices as

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

Example:
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.norm1 () << std::endl << std::endl;
std::cout << m << m.norm1 () << std::endl;
prints
+1.000000000000e+000 +2.000000000000e+000 +3.000000000000e+000
+6.000000000000e+000
+1.000000000000e+000 +3.000000000000e+000 +5.000000000000e+000
+2.000000000000e+000 -4.000000000000e+000 -6.000000000000e+000
+1.100000000000e+001
Returns
treal Norm value

Reimplemented from Matrix< TR, TR >.

Definition at line 29739 of file cvm.h.

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

Infinity norm.

Infinity norm of calling array that for vectors is defined as

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

and for matrices as

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

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

Reimplemented from Matrix< TR, TR >.

Definition at line 29744 of file cvm.h.

Here is the caller graph for this function:

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

Definition at line 29752 of file cvm.h.

Friends And Related Function Documentation

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

Definition at line 28320 of file cvm.h.

Member Data Documentation

template<typename TR>
BaseSRMatrix basic_srbmatrix< TR >::mSM
mutableprotected

Temporary storage for square matrix enclosing band one (if needed)

Definition at line 28323 of file cvm.h.


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