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.
|
End-user class encapsulating vector of real numbers. More...
#include <cvm.h>
Public Member Functions | |
basic_rvector () | |
Default constructor. | |
basic_rvector (tint nSize) | |
Constructor. | |
basic_rvector (std::initializer_list< TR > list) | |
Constructor. | |
basic_rvector (tint nSize, TR d) | |
Constructor. | |
basic_rvector (TR *pd, tint nSize, tint nIncr=1) | |
Constructor. | |
basic_rvector (const TR *pd, tint nSize, tint nIncr=1) | |
Constructor. | |
basic_rvector (const basic_rvector &v) | |
Copy constructor. | |
basic_rvector (basic_rvector &&a) noexcept | |
Move constructor. | |
basic_rvector & | operator= (const basic_rvector &v) throw (cvmexception) |
Assignment operator. | |
basic_rvector & | operator= (basic_rvector &&a) throw (cvmexception) |
Move assignment operator. | |
basic_rvector & | assign (const TR *pd, tint nIncr=1) |
External array assignment. | |
basic_rvector & | assign (tint n, const TR *pd, tint nIncr=1) |
External array assignment (to tail) | |
basic_rvector & | assign (tint n, const TR *pd, tint nSize, tint nIncr) |
External array assignment (range) | |
basic_rvector & | assign (tint n, const basic_rvector &v) throw (cvmexception) |
Subvector assignment. | |
basic_rvector & | set (TR d) |
Sets all elements to one value. | |
basic_rvector & | resize (tint nNewSize) throw (cvmexception) |
Changes size of vector. | |
bool | operator== (const basic_rvector &v) const |
Vector comparison. | |
bool | operator!= (const basic_rvector &v) const |
Vector comparison. | |
basic_rvector & | operator<< (const basic_rvector &v) throw (cvmexception) |
Vector replacement. | |
basic_rvector | operator+ (const basic_rvector &v) const throw (cvmexception) |
Addition operator. | |
basic_rvector | operator- (const basic_rvector &v) const throw (cvmexception) |
Subtraction operator. | |
basic_rvector & | sum (const basic_rvector &v1, const basic_rvector &v2) throw (cvmexception) |
Sum of vectors. | |
basic_rvector & | diff (const basic_rvector &v1, const basic_rvector &v2) throw (cvmexception) |
Difference of vectors. | |
basic_rvector & | operator+= (const basic_rvector &v) throw (cvmexception) |
Increment operator. | |
basic_rvector & | operator-= (const basic_rvector &v) throw (cvmexception) |
Decrement operator. | |
basic_rvector | operator- () const throw (cvmexception) |
Unary minus operator. | |
basic_rvector | operator* (TR dMult) const throw (cvmexception) |
Multiply by number operator. | |
basic_rvector | operator/ (TR dDiv) const throw (cvmexception) |
Divide by number operator. | |
basic_rvector & | operator*= (TR dMult) |
Multiply by number and assign. | |
basic_rvector & | operator/= (TR dDiv) throw (cvmexception) |
Divide by number and assign. | |
basic_rvector & | normalize () |
Vector normalizer. | |
TR | operator* (const basic_rvector &v) const throw (cvmexception) |
Scalar product. | |
basic_rvector | operator* (const basic_rmatrix< TR > &m) const throw (cvmexception) |
Vector-matrix product. | |
basic_rvector & | mult (const basic_rvector &v, const basic_rmatrix< TR > &m) throw (cvmexception) |
Vector-matrix product. | |
basic_rvector & | mult (const basic_rmatrix< TR > &m, const basic_rvector &v) throw (cvmexception) |
Matrix-vector product. | |
basic_rmatrix< TR > | rank1update (const basic_rvector &v) const |
Rank-1 update. | |
basic_rvector & | solve (const basic_srmatrix< TR > &mA, const basic_rvector &vB, TR &dErr) throw (cvmexception) |
Linear solver. | |
basic_rvector & | solve_tran (const basic_srmatrix< TR > &mA, const basic_rvector &vB, TR &dErr) throw (cvmexception) |
Linear solver (transposed) | |
basic_rvector & | solve (const basic_srmatrix< TR > &mA, const basic_rvector &vB) throw (cvmexception) |
Linear solver. | |
basic_rvector & | solve_tran (const basic_srmatrix< TR > &mA, const basic_rvector &vB) throw (cvmexception) |
Linear solver (transposed) | |
basic_rvector | operator/ (const basic_srmatrix< TR > &mA) const throw (cvmexception) |
Linear solver operator (transposed) | |
basic_rvector | operator% (const basic_srmatrix< TR > &mA) const throw (cvmexception) |
Linear solver operator. | |
basic_rvector & | solve_lu (const basic_srmatrix< TR > &mA, const basic_srmatrix< TR > &mLU, const tint *pPivots, const basic_rvector &vB, TR &dErr) throw (cvmexception) |
LU factorization based linear solver. | |
basic_rvector & | solve_lu (const basic_srmatrix< TR > &mA, const basic_srmatrix< TR > &mLU, const tint *pPivots, const basic_rvector &vB) throw (cvmexception) |
LU factorization based linear solver. | |
basic_rvector & | gels (bool transpose, const basic_rmatrix< TR > &mA, const basic_rvector &vB, TR &dErr) throw (cvmexception) |
Overdetermined or underdetermined linear solver. | |
basic_rvector & | gelsy (const basic_rmatrix< TR > &mA, const basic_rvector &vB, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception) |
Linear least squares problem. | |
basic_rvector & | gelss (const basic_rmatrix< TR > &mA, const basic_rvector &vB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception) |
Linear least squares problem. | |
basic_rvector & | gelsd (const basic_rmatrix< TR > &mA, const basic_rvector &vB, basic_rvector< TR > &sv, tint &rank, TR tol=basic_cvmMachSp< TR >()) throw (cvmexception) |
Linear least squares problem. | |
basic_rvector & | svd (const basic_rmatrix< TR > &mA) throw (cvmexception) |
Singular value decomposition. | |
basic_rvector & | svd (const basic_cmatrix< TR, TC > &mA) throw (cvmexception) |
Singular value decomposition. | |
basic_rvector & | svd (const basic_rmatrix< TR > &mA, basic_srmatrix< TR > &mU, basic_srmatrix< TR > &mVH) throw (cvmexception) |
Singular value decomposition. | |
basic_rvector & | svd (const basic_cmatrix< TR, TC > &mA, basic_scmatrix< TR, TC > &mU, basic_scmatrix< TR, TC > &mVH) throw (cvmexception) |
Singular value decomposition. | |
basic_rvector & | eig (const basic_srsmatrix< TR > &mA) throw (cvmexception) |
Eigenvalues. | |
basic_rvector & | eig (const basic_srsmatrix< TR > &mA, basic_srmatrix< TR > &mEigVect) throw (cvmexception) |
Eigenvalues. | |
basic_rvector & | eig (const basic_schmatrix< TR, TC > &mA) throw (cvmexception) |
Eigenvalues. | |
basic_rvector & | eig (const basic_schmatrix< TR, TC > &mA, basic_scmatrix< TR, TC > &mEigVect) throw (cvmexception) |
Eigenvalues. | |
basic_rvector & | gemv (bool bLeft, const basic_rmatrix< TR > &m, TR dAlpha, const basic_rvector &v, TR dBeta) throw (cvmexception) |
Generic matrix-vector operation. | |
basic_rvector & | gbmv (bool bLeft, const basic_srbmatrix< TR > &m, TR dAlpha, const basic_rvector &v, TR dBeta) throw (cvmexception) |
Generic band matrix-vector operation. | |
basic_rvector & | randomize (TR dFrom, TR dTo) |
Randomizer. | |
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_array & | operator= (const basic_array &a) throw (cvmexception) |
Assignment operator. | |
basic_array & | operator= (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 | |
TR & | operator() (tint n) throw (cvmexception) |
Reference to element (l-value) | |
TR | operator() (tint n) const throw (cvmexception) |
Value of element (not l-value) | |
TR & | operator[] (tint n) throw (cvmexception) |
Reference to element (l-value) | |
TR | operator[] (tint n) const throw (cvmexception) |
Value of element (not l-value) | |
basic_array & | assign (const TR *p) |
Assignment from external array. | |
void | assign (size_type n, const TR &val) throw (cvmexception) |
(STL) assigns given value to n-th element (0-based) | |
void | assign (const_iterator begin, const_iterator end) throw (cvmexception) |
(STL) assigns begin-end iteartor range to array | |
tint | incr () const |
Increment between elements. | |
tint | indofmax () const |
Index of element with maximum module. | |
tint | indofmin () const |
Index of element with minimum module. | |
virtual TR | norm () const |
Euclidean norm. | |
virtual TR | norminf () const |
Infinity norm. | |
virtual TR | norm1 () const |
1-norm | |
virtual TR | norm2 () const |
2-norm | |
iterator | begin () |
(STL) iterator to begin | |
const_iterator | begin () const |
(STL) const iterator to begin | |
iterator | end () |
(STL) iterator to end | |
const_iterator | end () const |
(STL) const iterator to end | |
reverse_iterator | rbegin () |
(STL) iterator to begin reversed | |
const_reverse_iterator | rbegin () const |
(STL) const iterator to begin reversed | |
reverse_iterator | rend () |
(STL) iterator to end reversed | |
const_reverse_iterator | rend () const |
(STL) const iterator to end reversed | |
size_type | max_size () const |
(STL) maximum possible size of array | |
size_type | capacity () const |
(STL) current capacity of array, equal to size() | |
bool | empty () const |
(STL) is array empty | |
reference | front () |
(STL) reference to first element | |
const_reference | front () const |
(STL) const reference to first element | |
reference | back () |
(STL) reference to last element | |
const_reference | back () const |
(STL) const reference to last element | |
void | clear () |
(STL) clears array, dealocates memory and sets size() to zero | |
void | swap (basic_array &v) throw (cvmexception) |
(STL) swaps array values, throws cvmexception if sizes are different | |
reference | at (size_type n) throw (cvmexception) |
(STL) returns reference to n-th element of array (0-based), throws cvmexception if n is out of boundaries | |
const_reference | at (size_type n) const throw (cvmexception) |
(STL) returns const reference to n-th element of array (0-based), throws cvmexception if n is out of boundaries | |
void | push_back (const TR &x) throw (cvmexception) |
(STL) pushes new value to the end of array | |
void | pop_back () throw (cvmexception) |
(STL) removes last element from array | |
iterator | insert (iterator position, const TR &x) throw (cvmexception) |
(STL) inserts element to given position in array | |
iterator | erase (iterator position) throw (cvmexception) |
(STL) removes element from given position in array |
Additional Inherited Members | |
Public Types inherited from basic_array< TR, TR > | |
typedef TR | value_type |
STL-specific value type definition. | |
typedef value_type * | pointer |
STL-specific value pointer definition. | |
typedef value_type * | iterator |
STL-specific iterator definition. | |
typedef const value_type * | const_iterator |
STL-specific const iterator definition. | |
typedef const value_type * | const_pointer |
STL-specific const pointer definition. | |
typedef value_type & | reference |
STL-specific reference definition. | |
typedef const value_type & | const_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 Attributes inherited from basic_array< TR, TR > | |
tint | msz |
Number of elements of type TC allocated. | |
tint | mincr |
Increment (distance) between elements (default is 1, i.e. elements follow each other) | |
std::shared_ptr< TR > | mp |
native data pointer | |
TR * | mpf |
Foreign data pointer. |
End-user class encapsulating vector of real numbers.
TR
type stands for treal. Please use predefined rvector class in your applications.
|
inline |
Default constructor.
Creates zero size rvector. No memory gets allocated.
|
inlineexplicit |
Constructor.
Creates rvector object of given size. It throws cvmexception in case of non-positive size passed or memory allocation failure.
[in] | nSize | Size of rvector (must be positive). |
|
inline |
Constructor.
Creates rvector object and fills it with values provided in the initializer list. This constructor is available only if your compiler supports initializer lists (GCC 4.4 and higher, MS Visual Studio 2013 and higher, Apple LLVM 5.0 and higher).
[in] | list | Initializer list as shown above. |
|
inline |
Constructor.
Creates rvector object of given size and fills it with given number. It throws cvmexception in case of non-positive size passed or memory allocation failure.
|
inline |
Constructor.
Creates rvector object of given size with given increment between elements (default is 1). It throws cvmexception in case of non-positive size passed. Unlike others, this constructor does not allocate memory. It just shares memory with array pointed to by pd
using distance between elements equal to nIncr
. It is intented to make possible the following syntax:
And for example this code...
will also call this constructor and memory will be shared.
If you need the code like this with memory allocation, use the following:
[in] | pd | Pointer to array to share memory with. |
[in] | nSize | Size of rvector (must be positive). |
[in] | nIncr | Increment between elements, default is 1 (one after another). |
|
inline |
Constructor.
Creates rvector of nSize
elements with increment 1 in between. This is const version, it allocates memory and copies every nIncr-th
element (deep copy) from external array pointed to by pd
parameter. It copies nSize
elements total.
[in] | pd | Const pointer to external array. |
[in] | nSize | Number of array elements. |
[in] | nIncr | Increment between external array elements. |
|
inline |
Copy constructor.
Creates rvector object of size equal to size of vector v
and sets every element of created vector to be equal to appropriate element of v
. Constructor throws cvmexception in case of memory allocation failure.
[in] | v | Vector to copy from. |
Definition at line 3570 of file cvm.h.
|
inline |
Move constructor.
Implements move semantics introduced in new C++ standard. Moves data ownership from other array to newly created object. It's usually executed implicitly in cases like this:
or this
Here temporary result of calling b.operator+(c)
will not be destroyed but rather moved to newly created object a
.
[in] | a | rvalue reference to other array. |
|
inline |
Assignment operator.
Sets every element of calling rvector to be equal to appropriate element of vector v
and returns reference to the vector changed. Operator throws cvmexception in case of different vector sizes.
[in] | v | rvector to assign from. |
Definition at line 3616 of file cvm.h.
|
inline |
Move assignment operator.
Implements move semantics introduced in new C++ standard. Moves data ownership from other array to calling object. It's usually executed implicitly in cases like this:
Here temporary result of calling b.operator+(c)
will not be destroyed but rather moved to calling object a
.
[in] | a | rvalue reference to other array. |
Definition at line 3626 of file cvm.h.
|
inline |
External array assignment.
Sets every element of calling vector to be equal to every nIncr-th
element of array pointed to by parameter pd
and returns reference to the vector changed. It's assumed that array passed is long enough to fill calling vector.
[in] | pd | Const pointer to external array. |
[in] | nIncr | Increment between elements in external array. |
Definition at line 3664 of file cvm.h.
|
inline |
External array assignment (to tail)
Sets every element of calling vector, starting from CVM0 based n-th
one till the end, to be equal to every nIncr-th
element of array pointed to by parameter pd
and returns reference to the vector changed.
[in] | n | Start rvector index to assign from. |
[in] | pd | Const pointer to external array. |
[in] | nIncr | Increment between elements in external array. |
Definition at line 3701 of file cvm.h.
|
inline |
External array assignment (range)
Sets every element of calling vector, starting from CVM0 based n-th
one, up to nSize
total, to be equal to every nIncr-th
element of array pointed to by parameter pd
and returns reference to the vector changed. If n+nSize
goes beyond rvector boundaries assignment stops at the last element.
[in] | n | Start rvector index to assign from. |
[in] | pd | Const pointer to external array. |
[in] | nSize | Maximum number of elements to be assigned. |
[in] | nIncr | Increment between elements in external array. |
Definition at line 3742 of file cvm.h.
|
inline |
Subvector assignment.
Sets every element of calling vector's sub-vector beginning with CVM0 based index n
to vector v
and returns reference to the vector changed. Function throws cvmexception if n
is not positive or v.size()+n-1
is greater than calling vector's size.
[in] | n | Start rvector index to assign from. |
[in] | v | Const reference to vector. |
Definition at line 3780 of file cvm.h.
|
inline |
Sets all elements to one value.
Sets every element of calling vector to be equal to parameter d
and returns reference to the vector changed.
[in] | d | Value to set to. |
Reimplemented from basic_array< TR, TR >.
|
inline |
Changes size of vector.
Changes size of calling vector to be equal to nNewSize
and returns reference to the vector changed. In case of increasing of its size, the vector is filled up with zeroes. Function throws cvmexception in case of negative size passed or memory allocation failure.
[in] | nNewSize | New size. |
Reimplemented from basic_array< TR, TR >.
|
inline |
Vector comparison.
Operator compares calling vector with vector v
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.
[in] | v | rvector to compare to. |
Definition at line 3887 of file cvm.h.
|
inline |
Vector comparison.
Operator compares calling vector with vector v
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.
[in] | v | rvector to compare to. |
Definition at line 3920 of file cvm.h.
|
inline |
Vector replacement.
Destroys calling vector, creates a new one as a copy of v
and returns reference to the vector changed. Operator throws cvmexception in case of memory allocation failure.
[in] | v | rvector to replace by. |
Definition at line 3961 of file cvm.h.
|
inline |
Addition operator.
Creates object of type rvector as sum of calling vector and vector v
. Operator throws cvmexception in case of different sizes of the operands or memory allocation failure.
[in] | v | rvector to add to calling one. |
Definition at line 4005 of file cvm.h.
|
inline |
Subtraction operator.
Creates object of type rvector as difference of calling vector and vector v
. It throws cvmexception in case of different sizes of the operands or memory allocation failure.
[in] | v | rvector to subtract from calling one. |
Definition at line 4049 of file cvm.h.
|
inline |
Sum of vectors.
Assigns sum of vectors v1
and v2
to calling vector and returns reference to the vector changed. It throws cvmexception in case of different sizes of the operands.
Definition at line 4094 of file cvm.h.
|
inline |
Difference of vectors.
Assigns difference of vectors v1
and v2
to calling vector and returns reference to the vector changed. It throws cvmexception in case of different sizes of the operands.
Definition at line 4139 of file cvm.h.
|
inline |
Increment operator.
Adds vector v
to calling vector and returns reference to the vector changed. It throws cvmexception in case of different sizes of the operands.
[in] | v | rvector to increment by. |
Definition at line 4186 of file cvm.h.
|
inline |
Decrement operator.
Subtracts vector v
from calling vector and returns reference to the vector changed. It throws cvmexception in case of different sizes of the operands.
[in] | v | rvector to decrement by. |
Definition at line 4232 of file cvm.h.
|
inline |
Unary minus operator.
Creates object of type rvector as calling vector multiplied by -1
. It throws cvmexception in case of memory allocation failure.
|
inline |
Multiply by number operator.
Creates object of type rvector as product of calling vector and number dMult
. It throws cvmexception in case of memory allocation failure.
[in] | dMult | Number to multiply by. |
|
inline |
Divide by number operator.
Creates object of type rvector as quotient of calling vector 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.
[in] | dDiv | Number to divide by. |
|
inline |
Multiply by number and assign.
Multiplies calling vector by number dMult
and returns reference to the vector changed.
[in] | dMult | Number to multiply by. |
|
inline |
Divide by number and assign.
Divides calling vector by number dDiv
and returns reference to the vector changed. It throws cvmexception if dDiv
has absolute value equal or less than cvmMachMin() (the smallest normalized positive number).
[in] | dDiv | Number to divide by. |
|
inline |
Vector normalizer.
Normalizes calling vector 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.
Definition at line 4436 of file cvm.h.
|
inline |
Scalar product.
Scalar product of calling vector and vector v
. It throws cvmexception if the operands have different sizes.
[in] | v | rvector to compute scalar product with. |
Definition at line 4473 of file cvm.h.
|
inline |
Vector-matrix product.
Creates object of type rvector
as product of calling vector and matrix m
. Use mult() function to avoid new object creation. Operator throws cvmexception if calling vector's size differs from number of rows in matrix m
.
[in] | m | rmatrix to multiply calling vector by. |
Definition at line 4512 of file cvm.h.
|
inline |
Vector-matrix product.
Sets calling vector to be equal to product of vector v
by matrix m
and returns reference to the object changed.
Definition at line 4551 of file cvm.h.
|
inline |
Matrix-vector product.
Sets calling vector to be equal to product of matrix m
by vector v
by and returns reference to the object changed.
Definition at line 4590 of file cvm.h.
|
inline |
Rank-1 update.
Creates object of type rmatrix as rank-1 update of calling vector and vector v
. The rank-1 update of vector-column of size and vector-row of size is defined as matrix
[in] | v | rvector to compute rank-1 update with. |
Definition at line 4641 of file cvm.h.
|
inline |
Linear solver.
Sets calling vector to be equal to solution of linear equation where parameter mA
is square matrix and parameter vB
is vector . Function returns reference to the vector 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 objects or when matrix is close to singular.
Definition at line 4695 of file cvm.h.
|
inline |
Linear solver (transposed)
Sets calling vector to be equal to solution of linear equation (which is equivalent to ) where parameter mA
is square matrix and parameter vB
is vector . Function returns reference to the vector 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 objects or when matrix is close to ingular.
Definition at line 4746 of file cvm.h.
|
inline |
Linear solver.
Sets calling vector to be equal to solution of linear equation where parameter mA
is square matrix and parameter vB
is vector . Function returns reference to the vector changed. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix is close to singular.
Definition at line 4791 of file cvm.h.
|
inline |
Linear solver (transposed)
Sets calling vector to be equal to solution of linear equation (which is equivalent to ) where parameter mA
is square matrix and parameter vB
is vector . Function returns reference to the vector changed. Function throws cvmexception in case of inappropriate sizes of the objects or when matrix is close to singular.
Definition at line 4840 of file cvm.h.
|
inline |
Linear solver operator (transposed)
Returns solution of linear equation (which is equivalent to ) where parameter mA
is square matrix and calling vector is . This operator throws cvmexception in case of inappropriate sizes of the objects or when matrix is close to singular.
[in] | mA | srmatrix . |
|
inline |
Linear solver operator.
Returns solution of linear equation where parameter mA
is square matrix and calling vector is . This operator throws cvmexception in case of inappropriate sizes of the objects or when matrix is close to singular.
[in] | mA | srmatrix . |
|
inline |
LU factorization based linear solver.
Sets calling vector to be equal to solution of linear equation where parameter mA
is square matrix , parameter mLU
is LU factorization (see srmatrix::low_up() ) of matrix , parameter pPivots
is an array of pivot numbers created while factorizing matrix and parameter vB
is vector . Function returns reference to the vector 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 with the same matrix and different vectors . In such case you save on matrix factorization since it's needed to be performed just one time. Throws cvmexception in case of inappropriate sizes of the objects or when matrix is close to singular.
[in] | mA | srmatrix . |
[in] | mLU | LU factorization of matrix . |
[in] | pPivots | pivots vector. |
[in] | vB | rvector . |
[out] | dErr | Norm of computation error. |
Definition at line 4991 of file cvm.h.
|
inline |
LU factorization based linear solver.
Sets calling vector to be equal to solution of linear equation where parameter mA
is square matrix , parameter mLU
is LU factorization (see srmatrix::low_up() ) of matrix , parameter pPivots
is an array of pivot numbers created while factorizing matrix and parameter vB
is vector . Function returns reference to the vector changed. This function is useful when you need to solve few linear equations of kind with the same matrix and different vectors . In such case you save on matrix factorization since it's needed to be performed just one time. Throws cvmexception in case of inappropriate sizes of the objects or when matrix is close to singular.
[in] | mA | srmatrix . |
[in] | mLU | LU factorization of matrix . |
[in] | pPivots | pivots vector. |
[in] | vB | rvector . |
Definition at line 5056 of file cvm.h.
|
inline |
Overdetermined or underdetermined linear solver.
Solves overdetermined or underdetermined linear system
for matrix (or transposed one) where is a vector of length and in non-transposed case and otherwise. The algorithm uses QR or LQ factorization of . It is assumed that has full rank, infinity returned otherwise. Internally function uses DGELS
LAPACK routines. If and transpose=false
or and transpose=true
, then the system is overdetermined, thus the algorithm tries to find the least squares solution of the problem
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 , but this algorithm is faster than pseudo inversion. Function sets calling object to be the solution and returns reference to it. It throws cvmexception in case of inappropriate sizes of the operands.
[in] | transpose | True to compute for transposed matrix . |
[in] | mA | rmatrix . |
[in] | vB | rvector . |
[out] | dErr | Norm of computation error. |
Definition at line 5117 of file cvm.h.
|
inline |
Linear least squares problem.
Computes minimum-norm solution to linear least squares problem
using complete orthogonal factorization of matrix . Here is a vector of length . Matrix may be rank-deficient, function returns its effective rank in rank
output parameter using tol
tolerance. Internally function uses DGELSY
LAPACK routines, see more details about the algorithm in those routines' documentation. Matrix is passed as argument mA
. Function sets calling object to be the solution and returns reference to it. It throws cvmexception in case of inappropriate sizes of the operands.
[in] | mA | rmatrix . |
[in] | vB | rvector . |
[out] | rank | Rank of matrix . |
[in] | tol | Rank computation tolerance. |
Definition at line 5178 of file cvm.h.
|
inline |
Linear least squares problem.
Computes minimum-norm solution to linear least squares problem
using singular value decomposition of matrix . Here is a vector of length . Matrix may be rank-deficient, function returns its effective rank in rank
output parameter using tol
tolerance. This function also computes singular values of in decreasing order and returns them in sv
output parameter having size. Internally function uses DGELSS
LAPACK routines, see more details about the algorithm in that routine's documentation. Matrix is passed as argument mA
. Function sets calling object to be the solution and returns reference to it. It throws cvmexception in case of inappropriate sizes of the operands.
[in] | mA | rmatrix . |
[in] | vB | rvector . |
[out] | sv | Singular values of matrix . |
[out] | rank | Rank of matrix . |
[in] | tol | Rank computation tolerance. |
|
inline |
Linear least squares problem.
Computes minimum-norm solution to linear least squares problem
using singular value decomposition of matrix and divide and conquer method. Here is a vector of length . Matrix may be rank-deficient, function returns its effective rank in rank
output parameter using tol
tolerance. This function also computes singular values of in decreasing order and returns them in sv
output parameter having size. Internally function uses DGELSD
LAPACK routines, see more details about the algorithm in that routine's documentation. Matrix is passed as argument mA
. Function sets calling object to be the solution and returns reference to it. It throws cvmexception in case of inappropriate sizes of the operands.
[in] | mA | rmatrix . |
[in] | vB | rvector . |
[out] | sv | Singular values of matrix . |
[out] | rank | Rank of matrix . |
[in] | tol | Rank computation tolerance. |
|
inline |
Singular value decomposition.
Sets calling vector to be equal to singular values
of real matrix (parameter mA
). These values are the main diagonal of matrix of the singular value decomposition
where and are orthogonal for real and unitary for complex . is transposed for real one and hermitian conjugated for complex one. First columns of matrices and are left and right singular vectors of respectively. Singular values and singular vectors satisfy
where and are -th columns of and respectively. Function returns reference to the object it changes and throws cvmexception in case of inappropriate calling object size (it must be equal to ) or in case of convergence error.
[in] | mA | rmatrix . |
|
inline |
Singular value decomposition.
Sets calling vector to be equal to singular values
of complex matrix (parameter mA
). These values are the main diagonal of matrix of the singular value decomposition
where and are orthogonal for real and unitary for complex . is transposed for real one and hermitian conjugated for complex one. First columns of matrices and are left and right singular vectors of respectively. Singular values and singular vectors satisfy
where and are -th columns of and respectively. Function returns reference to the object it changes and throws cvmexception in case of inappropriate calling object size (it must be equal to ) or in case of convergence error.
[in] | mA | cmatrix . |
|
inline |
Singular value decomposition.
Sets calling vector to be equal to singular values
of real matrix (parameter mA
). These values are the main diagonal of matrix of the singular value decomposition
where and are orthogonal for real and unitary for complex . is transposed for real one and hermitian conjugated for complex one. First columns of matrices and are left and right singular vectors of respectively. Singular values and singular vectors satisfy
where and are -th columns of and respectively. Function sets output parameter mU
to be equal to square matrix of size and mVH
to be equal to square matrix of size . Function returns reference to the object it changes and throws cvmexception in case of inappropriate calling object size (it must be equal to ), matrix mU
size (must be ), matrix mVH
size (must be ) or in case of convergence error.
|
inline |
Singular value decomposition.
Sets calling vector to be equal to singular values
of complex matrix (parameter mA
). These values are the main diagonal of matrix of the singular value decomposition
where and are orthogonal for real and unitary for complex . is transposed for real one and hermitian conjugated for complex one. First columns of matrices and are left and right singular vectors of respectively. Singular values and singular vectors satisfy
where and are -th columns of and respectively. Function sets output parameter mU
to be equal to square matrix of size and mVH
to be equal to square matrix of size . Function returns reference to the object it changes and throws cvmexception in case of inappropriate calling object size (it must be equal to ), matrix mU
size (must be ), matrix mVH
size (must be ) or in case of convergence error.
|
inline |
Eigenvalues.
Solves symmetric eigenvalue problem and sets calling vector to be equal to eigenvalues of symmetric matrix mA
. The symmetric eigenvalue problem is defined as follows: given symmetric or Hermitian matrix , find the eigenvalues and the corresponding eigenvectors that satisfy the equation
All eigenvalues are real not only for real symmetric but also for complex Hermitian matrices , and there exists an orthogonal system of eigenvectors. If is symmetric or Hermitian positive-definite matrix, all eigenvalues are positive. Function returns reference to the vector changed and throws cvmexception in case of inappropriate calling object sizes or in case of convergence error.
[in] | mA | srsmatrix . |
Definition at line 5706 of file cvm.h.
|
inline |
Eigenvalues.
Solves symmetric eigenvalue problem and sets calling vector to be equal to eigenvalues of symmetric matrix mA
. The symmetric eigenvalue problem is defined as follows: given symmetric or Hermitian matrix , find the eigenvalues and the corresponding eigenvectors that satisfy the equation
All eigenvalues are real not only for real symmetric but also for complex Hermitian matrices , and there exists an orthogonal system of eigenvectors. If is symmetric or Hermitian positive-definite matrix, all eigenvalues are positive. Function returns reference to the vector changed and throws cvmexception in case of inappropriate calling object sizes or in case of convergence error. It sets output parameter mEigVect
to be equal to square matrix containing eigenvectors as columns.
Definition at line 5786 of file cvm.h.
|
inline |
Eigenvalues.
Solves symmetric eigenvalue problem and sets calling vector to be equal to eigenvalues of hermitian matrix mA
. The symmetric eigenvalue problem is defined as follows: given symmetric or Hermitian matrix , find the eigenvalues and the corresponding eigenvectors that satisfy the equation
All eigenvalues are real not only for real symmetric but also for complex Hermitian matrices , and there exists an orthogonal system of eigenvectors. If is symmetric or Hermitian positive-definite matrix, all eigenvalues are positive. Function returns reference to the vector changed and throws cvmexception in case of inappropriate calling object sizes or in case of convergence error.
[in] | mA | schmatrix . |
Definition at line 5866 of file cvm.h.
|
inline |
Eigenvalues.
Solves symmetric eigenvalue problem and sets calling vector to be equal to eigenvalues of hermitian matrix mA
. The symmetric eigenvalue problem is defined as follows: given symmetric or Hermitian matrix , find the eigenvalues and the corresponding eigenvectors that satisfy the equation
All eigenvalues are real not only for real symmetric but also for complex Hermitian matrices , and there exists an orthogonal system of eigenvectors. If is symmetric or Hermitian positive-definite matrix, all eigenvalues are positive. Function returns reference to the vector changed and throws cvmexception in case of inappropriate calling object sizes or in case of convergence error. It sets output parameter mEigVect
to be equal to square matrix containing eigenvectors as columns. Example:
prints
Definition at line 5946 of file cvm.h.
|
inline |
Generic matrix-vector operation.
Calls one of DGEMV
routines of the BLAS Library performing matrix-vector operation defined as
where and are real numbers (parameters dAlpha
and dBeta
), is matrix (parameter m
) and and are vectors (parameter v
and calling vector respectively). First operation is performed if bLeft
passed is false
and second one otherwise. Function returns reference to the vector changed and throws cvmexception in case of inappropriate sizes of the operands.
[in] | bLeft | Is left-sided multiplication. |
[in] | m | rmatrix . |
[in] | dAlpha | Number . |
[in] | v | rvector . |
[in] | dBeta | Number . |
Definition at line 6008 of file cvm.h.
|
inline |
Generic band matrix-vector operation.
Calls one of DGBMV
routines of the BLAS Library performing matrix-vector operation defined as
where and are real numbers (parameters dAlpha
and dBeta
), is band matrix (parameter m
) and and are vectors (parameter v
and calling vector respectively). First operation is performed if bLeft
passed is false
and second one otherwise. Function returns reference to the vector changed and throws cvmexception in case of inappropriate sizes of the operands.
[in] | bLeft | Is left-sided multiplication. |
[in] | m | srbmatrix . |
[in] | dAlpha | Number . |
[in] | v | rvector . |
[in] | dBeta | Number . |
Definition at line 6068 of file cvm.h.
|
inline |
Fills calling vector with pseudo-random numbers distributed between dFrom
and dTo
. Function returns reference to the vector changed.
[in] | dFrom | First limit. |
[in] | dTo | Second limit. |
Definition at line 6099 of file cvm.h.