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.
|
Generalized matrix class (not end-user) More...
#include <cvm.h>
Public Member Functions | |
tint | msize () const |
Number of rows. | |
tint | nsize () const |
Number of columns. | |
tint | ld () const |
Leading dimension. | |
tint | rowofmax () const |
Row with maximum element. | |
tint | rowofmin () const |
Row with minimum element. | |
tint | colofmax () const |
Column with maximum element. | |
tint | colofmin () const |
Column with minimum element. | |
TR | norm1 () const override |
1-norm | |
TR | norminf () const override |
Infinity norm. | |
Public Member Functions inherited from basic_array< TR, TC > | |
basic_array () | |
Default constructor. | |
basic_array (tint nSize, bool bZeroMemory=true) | |
Constructor. | |
basic_array (TC *pd, tint nSize, tint nIncr=1) | |
Constructor. | |
basic_array (const TC *pd, tint nSize, tint nIncr=1) | |
Constructor. | |
basic_array (const TC *begin, const TC *end) | |
Constructor. | |
basic_array (const basic_array &a) | |
Copy constructor. | |
basic_array (basic_array &&a) noexcept | |
Move constructor. | |
basic_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. | |
TC * | get () |
Pointer to data. | |
const TC * | get () const |
Const pointer to data. | |
operator TC * () | |
Type cast to pointer to data. | |
operator const TC * () const | |
Type cast to constant pointer to data. | |
TC & | operator() (tint n) throw (cvmexception) |
Reference to element (l-value) | |
TC | operator() (tint n) const throw (cvmexception) |
Value of element (not l-value) | |
TC & | operator[] (tint n) throw (cvmexception) |
Reference to element (l-value) | |
TC | operator[] (tint n) const throw (cvmexception) |
Value of element (not l-value) | |
basic_array & | assign (const TC *p) |
Assignment from external array. | |
basic_array & | set (TC x) |
Sets all elements to one value. | |
basic_array & | resize (tint nNewSize) throw (cvmexception) |
Changes size of array. | |
tint | incr () const |
Increment between elements. | |
tint | indofmax () const |
Index of element with maximum module. | |
tint | indofmin () const |
Index of element with minimum module. | |
virtual TR | norm () const |
Euclidean norm. | |
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 | assign (size_type n, const TC &val) throw (cvmexception) |
(STL) assigns given value to n-th element (0-based) | |
void | assign (const_iterator begin, const_iterator end) throw (cvmexception) |
(STL) assigns begin-end iteartor range to array | |
void | clear () |
(STL) clears array, dealocates memory and sets size() to zero | |
void | swap (basic_array &v) throw (cvmexception) |
(STL) swaps array values, throws cvmexception if sizes are different | |
reference | at (size_type n) throw (cvmexception) |
(STL) returns reference to n-th element of array (0-based), throws cvmexception if n is out of boundaries | |
const_reference | at (size_type n) const throw (cvmexception) |
(STL) returns const reference to n-th element of array (0-based), throws cvmexception if n is out of boundaries | |
void | push_back (const TC &x) throw (cvmexception) |
(STL) pushes new value to the end of array | |
void | pop_back () throw (cvmexception) |
(STL) removes last element from array | |
iterator | insert (iterator position, const TC &x) throw (cvmexception) |
(STL) inserts element to given position in array | |
iterator | erase (iterator position) throw (cvmexception) |
(STL) removes element from given position in array |
Protected Member Functions | |
Matrix () | |
Default constructor. | |
Matrix (tint nM, tint nN, tint nLD, bool bZeroMemory) | |
Constructor. | |
Matrix (TC *pd, tint nM, tint nN, tint nLD, tint nSize) | |
Constructor. | |
Matrix (const TC *pd, tint nM, tint nN, tint nLD, tint nSize) | |
Constructor. | |
Matrix (const BaseArray &v, bool bBeColumn) | |
Constructor. | |
Matrix (Matrix &&m) noexcept | |
Move constructor. | |
Matrix & | operator= (Matrix &&m) throw (cvmexception) |
Move assignment operator. |
Protected Attributes | |
tint | mm |
Number of rows. | |
tint | mn |
Number of columns. | |
tint | mld |
Leading dimension. | |
Protected Attributes inherited from basic_array< TR, TC > | |
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< TC > | mp |
native data pointer | |
TC * | mpf |
Foreign data pointer. |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Matrix< TR, TC > &mOut) |
Writes Matrix to output stream. | |
std::istream & | operator>> (std::istream &is, Matrix< TR, TC > &mIn) |
Reads Matrix from input stream. |
Additional Inherited Members | |
Public Types inherited from basic_array< TR, TC > | |
typedef TC | 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. |
Generalized matrix class (not end-user)
TR
type stands for treal, TC
type stands for tcomplex. Please use inherited matrix classes. This one provides some member functions which are common for all matrices.
|
inlineprotected |
Constructor.
Creates Matrix of nM
by nN
size with nLD
leading dimension. Assigns zero to all elements if bZeroMemory
is true
.
[in] | nM | Number of rows. |
[in] | nN | Number of columns. |
[in] | nLD | Leading dimension. |
[in] | bZeroMemory | True if all elements should be set to zero. |
|
inlineprotected |
Constructor.
Creates Matrix of nM
by nN
size with nLD
leading dimension and nSize
array size. This is non-const version, it shares memory (shallow copy) with array pointed to by pd
parameter.
[in] | pd | Non-const pointer to external array. |
[in] | nM | Number of rows. |
[in] | nN | Number of columns. |
[in] | nLD | Leading dimension. |
[in] | nSize | Number of array elements. |
|
inlineprotected |
Constructor.
Creates Matrix of nM
by nN
size with nLD
leading dimension and nSize
array size. This is const version, it allocates memory and copies every element (deep copy) from external array pointed to by pd
parameter. It copies nSize
elements total.
[in] | pd | Const pointer to external array. |
[in] | nM | Number of rows. |
[in] | nN | Number of columns. |
[in] | nLD | Leading dimension. |
[in] | nSize | Number of array elements. |
|
inlineprotected |
Constructor.
Creates Matrix of 1
by N
size if bBeColumn
is false and N
by 1
otherwise. Here N
is size of array v
passed as the first parameter. Copies all elements of v
to the matrix created.
[in] | v | basic_array to copy elements from. |
[in] | bBeColumn | True to create column matrix. |
|
inlineprotected |
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:
or this
Here temporary result of calling b.operator+(c)
will not be destroyed but rather moved to newly created object a
.
[in] | m | rvalue reference to other matrix. |
|
inlineprotected |
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:
Here temporary result of calling b.operator+(c)
will not be destroyed but rather moved to calling object a
.
[in] | m | rvalue reference to other matrix. |
Definition at line 10066 of file cvm.h.
Leading dimension.
Returns leading dimension of calling matrix. Leading dimension is equal to number of rows for every matrix except submatrices. For submatrices it's equal to number of rows of parent matrix.
Definition at line 10138 of file cvm.h.
Row with maximum element.
Returns CVM0 based number of calling matrix row where the element with the maximum absolute value is located.
Row with minimum element.
Returns CVM0 based number of calling matrix row where the element with the minimum absolute value is located.
Column with maximum element.
Returns CVM0 based number of calling matrix column where the element with the maximum absolute value is located.
Column with minimum element.
Returns CVM0 based number of calling matrix column where the element with the minimum absolute value is located.
|
inlineoverridevirtual |
1-norm
1-norm of calling array that for vectors is defined as
and for matrices as
Reimplemented from basic_array< TR, TC >.
Reimplemented in basic_scbmatrix< TR, TC >, and basic_srbmatrix< TR >.
Definition at line 10250 of file cvm.h.
|
inlineoverridevirtual |
Infinity norm.
Infinity norm of calling array that for vectors is defined as
and for matrices as
Reimplemented from basic_array< TR, TC >.
Reimplemented in basic_schmatrix< TR, TC >, basic_srsmatrix< TR >, basic_scbmatrix< TR, TC >, and basic_srbmatrix< TR >.
Definition at line 10271 of file cvm.h.
|
friend |
Writes Matrix to output stream.
Operator writes matrix (row by row) referenced by parameter mOut
into os
stream.
[out] | os | Stream to write to. |
[in] | mOut | Matrix to write from. |
|
friend |
Reads Matrix from input stream.
Operator fills calling Matrix (row by row) referenced by parameter mIn
with numbers from is
stream.
[in] | is | Stream to read from. |
[out] | mIn | Matrix to write to. |