Abstract array of numbers with increment between them. Root object for all library classes.
More...
Public Member Functions |
| 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 | 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 | 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
|
template<typename TR, typename TC>
class basic_array< TR, TC >
Abstract array of numbers with increment between them. Root object for all library classes.
This abstract class encapsulates BLAS/LAPACK aware array of numbers. It implements increment bewteen elements (default increment is 1, i.e. elements follow each other). TR
type stands for treal and TC
stands for tcomplex for complex number classes and treal otherwise.
This class contains array-specific member functions inherited in other classes. It can be used as a standalone class too. It also provides STL-compatible functions and type definitions, so itself and derived classes can be used in the same way as std::vector<T>
.
Definition at line 1818 of file cvm.h.
template<typename TR, typename TC>
Reference to element (l-value)
Returns reference to array's element by its index (CVM0 based).
- Example:
using namespace cvm;
try {
v[1] = 1.;
v(2) = 2.;
std::cout << v;
double a[] = {1., 2., 3., 4.};
std::cout << vc(1) << " " << vc[2] << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
- Parameters
-
[in] | n | Index of element to return reference to. |
- Returns
- TC&
Reimplemented in basic_scmatrix< TR, TC >, basic_cmatrix< TR, TC >, basic_srmatrix< TR >, and basic_rmatrix< TR >.
Definition at line 2356 of file cvm.h.
template<typename TR, typename TC>
Value of element (not l-value)
Returns value of array's element by its index (CVM0 based).
- Example:
using namespace cvm;
try {
v[1] = 1.;
v(2) = 2.;
std::cout << v;
double a[] = {1., 2., 3., 4.};
std::cout << vc(1) << " " << vc[2] << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
- Parameters
-
[in] | n | Index of element to return value for. |
- Returns
- TC
Reimplemented in basic_schmatrix< TR, TC >, basic_srsmatrix< TR >, basic_scbmatrix< TR, TC >, basic_srbmatrix< TR >, basic_scmatrix< TR, TC >, basic_cmatrix< TR, TC >, basic_srmatrix< TR >, and basic_rmatrix< TR >.
Definition at line 2390 of file cvm.h.
template<typename TR, typename TC>
Reference to element (l-value)
Returns reference to array's element by its index (CVM0 based).
- Example:
using namespace cvm;
try {
v[1] = 1.;
v(2) = 2.;
std::cout << v;
double a[] = {1., 2., 3., 4.};
std::cout << vc(1) << " " << vc[2] << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
- Parameters
-
[in] | n | Index of element to return reference to. |
- Returns
- TC&
Reimplemented in basic_scmatrix< TR, TC >, basic_cmatrix< TR, TC >, basic_srmatrix< TR >, and basic_rmatrix< TR >.
Definition at line 2424 of file cvm.h.
template<typename TR, typename TC>
Value of element (not l-value)
Returns value of array's element by its index (CVM0 based).
- Example:
using namespace cvm;
try {
v[1] = 1.;
v(2) = 2.;
std::cout << v;
double a[] = {1., 2., 3., 4.};
std::cout << vc(1) << " " << vc[2] << std::endl;
}
catch (std::exception& e) {
std::cout << "Exception: " << e.what () << std::endl;
}
prints
- Parameters
-
[in] | n | Index of element to return value for. |
- Returns
- TC&
Reimplemented in basic_schmatrix< TR, TC >, basic_srsmatrix< TR >, basic_scbmatrix< TR, TC >, basic_srbmatrix< TR >, basic_scmatrix< TR, TC >, basic_cmatrix< TR, TC >, basic_srmatrix< TR >, and basic_rmatrix< TR >.
Definition at line 2458 of file cvm.h.
template<typename TR, typename TC>
Changes size of array.
In case of size increase fills new elements with zeros.
- Example:
using namespace cvm;
try {
const int a[] = {1, 2, 3, 4};
std::cout << v;
v.resize(2);
std::cout << v;
v.resize(4);
std::cout << v;
}
catch (std::exception& e) {
std::cout << "Exception " << e.what () << std::endl;
}
prints
- Parameters
-
- Returns
- Reference to changed calling array.
Reimplemented in basic_schmatrix< TR, TC >, basic_srsmatrix< TR >, basic_scbmatrix< TR, TC >, basic_srbmatrix< TR >, basic_scmatrix< TR, TC >, basic_srmatrix< TR >, basic_cvector< TR, TC >, and basic_rvector< TR >.
Definition at line 2545 of file cvm.h.
template<typename TR, typename TC>
1-norm
1-norm of calling array that for vectors is defined as
and for matrices as
- 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.};
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 in basic_scbmatrix< TR, TC >, basic_srbmatrix< TR >, Matrix< TR, TC >, and Matrix< TR, TR >.
Definition at line 2752 of file cvm.h.
template<typename TR, typename TC>
(STL) pushes new value to the end of array
Increases array's size() by one, throws cvmexception in case of memory allocation failure. It's provided for every class of the library to be compatible with STL algorithms and methods. Since CVM doesn't pre-allocate memory for extra storage, these functions will require memory reallocation every time they are being executed and may slow down your application.
- Example:
using namespace cvm;
a.push_back(77);
std::cout << a;
a.pop_back();
std::cout << a;
prints
- Parameters
-
[in] | x | Const reference to value to push. |
Definition at line 2953 of file cvm.h.