#include <vector.hh>
Public Types | |
typedef T | value_type |
Remember the storage type. | |
typedef value_type & | reference |
Reference to an object. | |
typedef const value_type & | const_reference |
Const reference to an object. | |
typedef std::size_t | size_type |
Type used for array indices. | |
typedef std::ptrdiff_t | difference_type |
Difference type. | |
Public Member Functions | |
Vector () | |
make empty vector | |
Vector (size_type _n) | |
Make vector vector of given size. | |
Vector (size_type _n, const T &_t) | |
Make vector of given size with initialization. | |
Vector (const Vector &v) | |
Make vector from given vector. | |
Vector & | operator= (const Vector &v) |
Assign vector from given vector. | |
Vector & | operator= (const T &t) |
Assign vector from a scalar. | |
Vector< T > | sub (size_type i, size_type m) |
Subvector extraction. | |
void | resize (size_type _n) |
Reallocate the vector to a new size. | |
void | resize (size_type _n, const T &_t) |
Reallocate the vector to a new size with initialization. | |
reference | operator[] (size_type i) |
Component access (read/write version). | |
const_reference | operator[] (size_type i) const |
Component access (read-only version). | |
size_type | size () const |
Get number of components of the vector. | |
int | iwidth () const |
get index field width for pretty-printing | |
int | width () const |
get data field width for pretty-printing | |
int | precision () const |
get data precision for pretty-printing | |
void | iwidth (int i) const |
set index field width for pretty-printing | |
void | width (int i) const |
set data field width for pretty-printing | |
void | precision (int i) const |
set data precision for pretty-printing | |
iterator | begin () |
begin iterator | |
iterator | end () |
end iterator | |
iterator | rbegin () |
begin iterator | |
iterator | rend () |
end iterator | |
const_iterator | begin () const |
const begin iterator | |
const_iterator | end () const |
const end iterator | |
const_iterator | rbegin () const |
const begin iterator | |
const_iterator | rend () const |
const end iterator | |
Vector & | operator+= (const Vector &y) |
Addition assignment. | |
Vector & | operator-= (const Vector &y) |
Subtraction assignment. | |
Vector & | operator*= (const T &s) |
Scalar multiplication assignment. | |
Vector & | operator/= (const T &s) |
Scalar division assignment. | |
void | update (const T &a, const Vector &y) |
Scaled update of a vector. | |
T | operator* (const Vector &y) |
Scalar multiplication of two vectors. | |
Classes | |
class | const_iterator |
const random access iterator More... | |
class | iterator |
random access iterator More... |
Provides a dynamic vector class with arbitrary component type.
Vector is implemented as a handle to a dynamically allocated array. Copy and assignement operators have reference semantics. In order to make a true copy the function "copy" can be used.
Here is a list of features:
hdnum::Vector< T >::Vector | ( | size_type | _n | ) | [inline] |
Make vector vector of given size.
[in] | _n | number of elements in the vector |
hdnum::Vector< T >::Vector | ( | size_type | _n, | |
const T & | _t | |||
) | [inline] |
Make vector of given size with initialization.
[in] | _n | number of elements in the vector |
[in] | _t | value to inititialize each element of the vector |
hdnum::Vector< T >::Vector | ( | const Vector< T > & | v | ) | [inline] |
Make vector from given vector.
[in] | v | another vector |
Vector& hdnum::Vector< T >::operator= | ( | const Vector< T > & | v | ) | [inline] |
Assign vector from given vector.
[in] | v | another vector |
Vector& hdnum::Vector< T >::operator= | ( | const T & | t | ) | [inline] |
Assign vector from a scalar.
[in] | t | value to assign to all components of the vector |
Vector<T> hdnum::Vector< T >::sub | ( | size_type | i, | |
size_type | m | |||
) | [inline] |
Subvector extraction.
Returns a new vector that references a (contiguous) subset of the components of the given vector.
[in] | i | first index of the new vector |
[in] | n | size of the new vector, i.e. it has components [i,i+m-1] |
void hdnum::Vector< T >::resize | ( | size_type | _n | ) | [inline] |
Reallocate the vector to a new size.
[in] | _n | size of the new vector |
void hdnum::Vector< T >::resize | ( | size_type | _n, | |
const T & | _t | |||
) | [inline] |
Reallocate the vector to a new size with initialization.
[in] | _n | size of the new vector |
[in] | _t | initialization value for the components |
reference hdnum::Vector< T >::operator[] | ( | size_type | i | ) | [inline] |
Component access (read/write version).
[in] | i | component index |
const_reference hdnum::Vector< T >::operator[] | ( | size_type | i | ) | const [inline] |
Component access (read-only version).
[in] | i | component index |
Vector& hdnum::Vector< T >::operator+= | ( | const Vector< T > & | y | ) | [inline] |
Addition assignment.
Implements x += y vector addition
[in] | y | another vector |
Vector& hdnum::Vector< T >::operator-= | ( | const Vector< T > & | y | ) | [inline] |
Subtraction assignment.
Implements x -= y vector subtraction
[in] | y | another vector |
Vector& hdnum::Vector< T >::operator*= | ( | const T & | s | ) | [inline] |
Scalar multiplication assignment.
Implements x *= s where s is a scalar
[in] | s | scalar value to multiply with vector scalar multiplication |
Vector& hdnum::Vector< T >::operator/= | ( | const T & | s | ) | [inline] |
Scalar division assignment.
Implements x /= s where s is a scalar
[in] | s | scalar value to divide with |
void hdnum::Vector< T >::update | ( | const T & | a, | |
const Vector< T > & | y | |||
) | [inline] |
Scaled update of a vector.
Implements x += a*y where a is a scalar and y a vector
[in] | a | scalar value to multiply with |
[in] | y | another vector |
T hdnum::Vector< T >::operator* | ( | const Vector< T > & | y | ) | [inline] |
Scalar multiplication of two vectors.
Implements x*y where x,y are vectors
[in] | y | another vector |