|
Heidelberg Educational Numerics Library Version 0.27 (from 15 March 2021)
|
Class with mathematical vector operations. More...
#include <vector.hh>
Public Types | |
| typedef std::size_t | size_type |
| Type used for array indices. | |
Public Member Functions | |
| Vector () | |
| default constructor, also inherited from the STL vector default constructor | |
| Vector (const size_t size, const REAL defaultvalue_=0) | |
| another constructor, with arguments, setting the default value for all entries of the vector of given size | |
| Vector (const std::initializer_list< REAL > &v) | |
| constructor from initializer list | |
| Vector & | operator= (const REAL value) |
| Assign all values of the Vector from one scalar value: x = value. | |
| Vector | sub (size_type i, size_type m) |
| Subvector extraction. | |
| Vector & | operator*= (const REAL value) |
| Multiplication by a scalar value (x *= value) | |
| Vector & | operator/= (const REAL value) |
| Division by a scalar value (x /= value) | |
| Vector & | operator+= (const Vector &y) |
| Add another vector (x += y) | |
| Vector & | operator-= (const Vector &y) |
| Subtract another vector (x -= y) | |
| Vector & | update (const REAL alpha, const Vector &y) |
| Update vector by addition of a scaled vector (x += a y ) | |
| REAL | operator* (Vector &x) const |
| Inner product with another vector. | |
| Vector | operator+ (Vector &x) const |
| Adding two vectors x+y. | |
| Vector | operator- (Vector &x) const |
| vector subtraction x-y | |
| REAL | two_norm_2 () const |
| Square of the Euclidean norm. | |
| REAL | two_norm () const |
| Euclidean norm of a vector. | |
| bool | scientific () const |
| pretty-print output property: true = scientific, false = fixed point representation | |
| void | scientific (bool b) const |
| scientific(true) is the default, scientific(false) switches to the fixed point representation | |
| std::size_t | iwidth () const |
| get index field width for pretty-printing | |
| std::size_t | width () const |
| get data field width for pretty-printing | |
| std::size_t | precision () const |
| get data precision for pretty-printing | |
| void | iwidth (std::size_t i) const |
| set index field width for pretty-printing | |
| void | width (std::size_t i) const |
| set data field width for pretty-printing | |
| void | precision (std::size_t i) const |
| set data precision for pretty-printing | |
Related Symbols | |
(Note that these are not member symbols.) | |
| template<typename REAL > | |
| std::ostream & | operator<< (std::ostream &os, const Vector< REAL > &x) |
| Output operator for Vector. | |
| template<typename REAL > | |
| void | gnuplot (const std::string &fname, const Vector< REAL > x) |
| Output contents of a Vector x to a text file named fname. | |
| template<typename REAL > | |
| void | readVectorFromFile (const std::string &filename, Vector< REAL > &vector) |
| Read vector from a text file. | |
| template<class REAL > | |
| void | fill (Vector< REAL > &x, const REAL &t, const REAL &dt) |
| Fill vector, with entries starting at t, consecutively shifted by dt. | |
| template<class REAL > | |
| void | unitvector (Vector< REAL > &x, std::size_t j) |
| Defines j-th unitvector (j=0,...,n-1) where n = length of the vector. | |
Inner product with another vector.
Example:
Output:
x= [ 0] 12.0000000 [ 1] 3.0000000 y= [ 0] 4.0000000 [ 1] -1.0000000 s = x*y = 45.0000000
Adding two vectors x+y.
Example:
Output:
x= [ 0] 12.0000000 [ 1] 3.0000000 y= [ 0] 4.0000000 [ 1] -1.0000000 x+y = [ 0] 16.0000000 [ 1] 2.0000000
vector subtraction x-y
Example:
Output:
x= [ 0] 12.0000000 [ 1] 3.0000000 y= [ 0] 4.0000000 [ 1] -1.0000000 x-y = [ 0] 8.0000000 [ 1] 4.0000000
Assign all values of the Vector from one scalar value: x = value.
| [in] | value | constant value which should be assigned |
Example:
Output:
x= [ 0] 1.2340000e+00 [ 1] 1.2340000e+00 [ 2] 1.2340000e+00 [ 3] 1.2340000e+00
scientific(true) is the default, scientific(false) switches to the fixed point representation
Example:
Output:
x= [ 0] 2.0000000e+00 [ 1] 2.0000000e+00 [ 2] 1.0000000e+00 x= [ 0] 2.0000000 [ 1] 2.0000000 [ 2] 1.0000000
Subvector extraction.
Returns a new vector that is a subset of the components of the given vector.
| [in] | i | first index of the new vector |
| [in] | m | size of the new vector, i.e. it has components [i,i+m-1] |
|
inline |
Euclidean norm of a vector.
Example:
Output:
x= [ 0] 2.0000000 [ 1] 2.0000000 [ 2] 1.0000000 euclidean norm of x = 3.0000000
Fill vector, with entries starting at t, consecutively shifted by dt.
Example:
Output:
x= [ 0] 2.0100000 [ 1] 2.1100000 [ 2] 2.2100000 [ 3] 2.3100000 [ 4] 2.4100000
Output contents of a Vector x to a text file named fname.
Example:
Output:
Contents of 'test.dat': 0 0.0000000 1 0.0000000 2 0.0000000 3 1.0000000 4 0.0000000
Output operator for Vector.
Example:
Output:
x= [ 0] 2.0000000e+00 [ 1] 2.0000000e+00 [ 2] 1.0000000e+00
Read vector from a text file.
| [in] | filename | name of the text file |
| [in,out] | vector | reference to a Vector |
Example:
Output:
Contents of "x.dat": 1.0 2.0 3.0 would give: x= [ 0] 1.0000000e+00 [ 1] 2.0000000e+00 [ 2] 3.0000000e+00
Defines j-th unitvector (j=0,...,n-1) where n = length of the vector.
Example:
Output:
x= [ 0] 0.0000000 [ 1] 0.0000000 [ 2] 0.0000000 [ 3] 1.0000000 [ 4] 0.0000000