#include <vector.h>
Public Types | |
| typedef C | value_type |
| typedef value_type * | pointer |
| typedef const value_type * | const_pointer |
| typedef value_type * | iterator |
| typedef const value_type * | const_iterator |
| typedef value_type & | reference |
| typedef const value_type & | const_reference |
| typedef size_t | size_type |
Public Member Functions | |
| Vector () | |
| Vector (const size_type s, const bool initialize=true) | |
| Vector (const size_type s, const char *str) | |
| Vector (const Vector< C > &v) | |
| virtual | ~Vector () |
| size_type | size () const |
| size_type | memory_consumption () const |
| bool | empty () const |
| void | resize (const size_type s, const bool initialize=true) |
| const C | operator[] (const size_type i) const |
| const C | operator() (const size_type i) const |
| C & | operator[] (const size_type i) |
| C & | operator() (const size_type i) |
| const_iterator | begin () const |
| iterator | begin () |
| const_iterator | end () const |
| iterator | end () |
| Vector< C > & | operator= (const C c) |
| Vector< C > & | operator= (const Vector< C > &v) |
| void | swap (Vector< C > &v) |
| template<class C2 > | |
| bool | operator== (const Vector< C2 > &v) const |
| template<class C2 > | |
| bool | operator!= (const Vector< C2 > &v) const |
| template<class C2 > | |
| bool | operator< (const Vector< C2 > &v) const |
| template<class C2 > | |
| void | add (const Vector< C2 > &v) |
| template<class C2 > | |
| void | add (const C2 s, const Vector< C2 > &v) |
| template<class C2 > | |
| void | sadd (const C s, const Vector< C2 > &v) |
| void | scale (const C s) |
| template<class C2 > | |
| Vector< C > & | operator+= (const Vector< C2 > &v) |
| template<class C2 > | |
| void | subtract (const Vector< C2 > &v) |
| template<class C2 > | |
| Vector< C > & | operator-= (const Vector< C2 > &v) |
| template<class C2 > | |
| const C | inner_product (const Vector< C2 > &v) const |
| Vector< C > & | operator*= (const C c) |
| Vector< C > & | operator/= (const C c) |
| template<class C2 > | |
| const C | operator* (const Vector< C2 > &v) const |
| void | compress (const double eta=1e-15) |
| double | wrmsqr_norm (const double atol, const double rtol, const Vector< C > &v, const Vector< C > &w) const |
Protected Attributes | |
| C * | values_ |
| size_type | size_ |
This class models finite, densely populated vectors x = (x_0, ... ,x_{n-1}) with entries from an arbitrary (scalar) class C, designed for numerical computations. The signature parallels that of std::vector.
A Vector<C> has essentially the same functionality as an Array1D<C>. However, we deliberately don't use inheritance here in order to really provide a raw class with maximum performance.
| typedef const value_type* MathTL::Vector< C >::const_iterator |
const iterator type (cf. STL containers)
| typedef const value_type* MathTL::Vector< C >::const_pointer |
const pointer type (cf. STL containers)
| typedef const value_type& MathTL::Vector< C >::const_reference |
const reference type (cf. STL containers)
| typedef value_type* MathTL::Vector< C >::iterator |
iterator type (cf. STL containers)
| typedef value_type* MathTL::Vector< C >::pointer |
pointer type (cf. STL containers)
| typedef value_type& MathTL::Vector< C >::reference |
reference type (cf. STL containers)
| typedef size_t MathTL::Vector< C >::size_type |
type of indexes and size type (cf. STL containers)
| typedef C MathTL::Vector< C >::value_type |
value type (cf. STL containers)
| MathTL::Vector< C >::Vector | ( | ) | [inline] |
default constructor: yields a 0-dimensional vector
| MathTL::Vector< C >::Vector | ( | const size_type | s, |
| const bool | initialize = true |
||
| ) | [inline, explicit] |
Construct a vector of size s. It is possible to choose whether the vector will be initialized by zeros or not. For the initialization we use a constructor of the form C(0), which is available for the builtin types. The default behaviour is to indeed initialize the vector.
| MathTL::Vector< C >::Vector | ( | const size_type | s, |
| const char * | str | ||
| ) |
Construct a vector from a string holding its entries, separated by a blank.
| s | dimension |
| str | input string |
| MathTL::Vector< C >::Vector | ( | const Vector< C > & | v | ) | [inline] |
copy constructor
| MathTL::Vector< C >::~Vector | ( | ) | [inline, virtual] |
release allocated memory
in place summation *this += v
| void MathTL::Vector< C >::add | ( | const C2 | s, |
| const Vector< C2 > & | v | ||
| ) |
in place summation *this += s*v
| Vector< C >::const_iterator MathTL::Vector< C >::begin | ( | ) | const [inline] |
read-only iterator access to first element (cf. STL containers)
| Vector< C >::iterator MathTL::Vector< C >::begin | ( | ) | [inline] |
read-write iterator access to first element (cf. STL containers)
| void MathTL::Vector< C >::compress | ( | const double | eta = 1e-15 | ) |
set all values with modulus strictly less than eta to zero (fabs<C> should exist)
| bool MathTL::Vector< C >::empty | ( | ) | const [inline] |
return true if dimension is zero
| Vector< C >::const_iterator MathTL::Vector< C >::end | ( | ) | const [inline] |
read-only iterator access to the element behind the last one (cf. STL containers)
| Vector< C >::iterator MathTL::Vector< C >::end | ( | ) | [inline] |
read-only iterator access to the element behind the last one (cf. STL containers)
| const C MathTL::Vector< C >::inner_product | ( | const Vector< C2 > & | v | ) | const |
inner product
| Vector< C >::size_type MathTL::Vector< C >::memory_consumption | ( | ) | const [inline] |
(estimate for the) memory consumption in bytes
| bool MathTL::Vector< C >::operator!= | ( | const Vector< C2 > & | v | ) | const [inline] |
non-equality test
| const C MathTL::Vector< C >::operator() | ( | const size_type | i | ) | const [inline] |
Matlab style read-only access to the i-th vector component
| C & MathTL::Vector< C >::operator() | ( | const size_type | i | ) | [inline] |
Matlab style read-write access to the i-th vector component
| const C MathTL::Vector< C >::operator* | ( | const Vector< C2 > & | v | ) | const |
inner product
| Vector< C > & MathTL::Vector< C >::operator*= | ( | const C | c | ) |
in place multiplication with a scalar
Reimplemented in MathTL::Polynomial< C >.
| Vector< C > & MathTL::Vector< C >::operator+= | ( | const Vector< C2 > & | v | ) | [inline] |
in place summation
| Vector< C > & MathTL::Vector< C >::operator-= | ( | const Vector< C2 > & | v | ) | [inline] |
in place subtraction
| Vector< C > & MathTL::Vector< C >::operator/= | ( | const C | c | ) |
in place division by a (nontrivial) scalar
| bool MathTL::Vector< C >::operator< | ( | const Vector< C2 > & | v | ) | const [inline] |
lexicographical order
| Vector< C > & MathTL::Vector< C >::operator= | ( | const C | c | ) | [inline] |
assignment of a constant value to each component
Reimplemented in MathTL::Polynomial< C >.
| Vector< C > & MathTL::Vector< C >::operator= | ( | const Vector< C > & | v | ) |
assignment from another vector (may change the dimension)
| bool MathTL::Vector< C >::operator== | ( | const Vector< C2 > & | v | ) | const |
equality test with another vector
| const C MathTL::Vector< C >::operator[] | ( | const size_type | i | ) | const [inline] |
C style read-only access to the i-th vector component
| C & MathTL::Vector< C >::operator[] | ( | const size_type | i | ) | [inline] |
C style read-write access to the i-th vector component
| void MathTL::Vector< C >::resize | ( | const size_type | s, |
| const bool | initialize = true |
||
| ) |
resize vector, initialize with C(0) if desired
| void MathTL::Vector< C >::sadd | ( | const C | s, |
| const Vector< C2 > & | v | ||
| ) |
in place summation *this = s*(*this) + v (AXPY level 1 BLAS routine)
| void MathTL::Vector< C >::scale | ( | const C | s | ) |
in place scaling *this *= s
Reimplemented in MathTL::Polynomial< C >.
| Vector< C >::size_type MathTL::Vector< C >::size | ( | ) | const [inline] |
size/dimension of the vector
in place subtraction *this -= v
| void MathTL::Vector< C >::swap | ( | Vector< C > & | v | ) | [inline] |
swap components of two vectors
| double MathTL::Vector< C >::wrmsqr_norm | ( | const double | atol, |
| const double | rtol, | ||
| const Vector< C > & | v, | ||
| const Vector< C > & | w | ||
| ) | const |
weighted root mean square norm ||x||_{v,w} = (1/n * sum_i |x_i|^2 / (atol+max(|v_i|,|w_i|)*rtol)^2)^{1/2}
(this has to be modeled as a member function, since partial specialization of template functions is not allowed in C++)
size_type MathTL::Vector< C >::size_ [protected] |
size/dimension of the vector
C* MathTL::Vector< C >::values_ [protected] |
internal storage is just a pointer to a C array
1.7.6.1