hdnum::Vector< T > Class Template Reference

A flexible vector class. More...

#include <vector.hh>

List of all members.

Public Types

typedef T value_type
 Remember the storage type.
typedef value_typereference
 Reference to an object.
typedef const value_typeconst_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.
Vectoroperator= (const Vector &v)
 Assign vector from given vector.
Vectoroperator= (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
Vectoroperator+= (const Vector &y)
 Addition assignment.
Vectoroperator-= (const Vector &y)
 Subtraction assignment.
Vectoroperator*= (const T &s)
 Scalar multiplication assignment.
Vectoroperator/= (const T &s)
 Scalar division assignment.
void update (const T &a, const Vector &y)
 Scaled update of a vector.
operator* (const Vector &y)
 Scalar multiplication of two vectors.

Classes

class  const_iterator
 const random access iterator More...
class  iterator
 random access iterator More...


Detailed Description

template<class T>
class hdnum::Vector< T >

A flexible vector class.

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:


Constructor & Destructor Documentation

template<class T>
hdnum::Vector< T >::Vector ( size_type  _n  )  [inline]

Make vector vector of given size.

Parameters:
[in] _n number of elements in the vector

template<class T>
hdnum::Vector< T >::Vector ( size_type  _n,
const T &  _t 
) [inline]

Make vector of given size with initialization.

Parameters:
[in] _n number of elements in the vector
[in] _t value to inititialize each element of the vector

template<class T>
hdnum::Vector< T >::Vector ( const Vector< T > &  v  )  [inline]

Make vector from given vector.

Warning:
Copy constructor of Vector has reference semantics! That means a vector constructed from a given vector actually references the same data.
Parameters:
[in] v another vector


Member Function Documentation

template<class T>
Vector& hdnum::Vector< T >::operator= ( const Vector< T > &  v  )  [inline]

Assign vector from given vector.

Warning:
Assignment of Vector has reference semantics! That means a vector assigned from a given vector actually references the same data.
Parameters:
[in] v another vector

template<class T>
Vector& hdnum::Vector< T >::operator= ( const T &  t  )  [inline]

Assign vector from a scalar.

Parameters:
[in] t value to assign to all components of the vector

template<class T>
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.

Parameters:
[in] i first index of the new vector
[in] n size of the new vector, i.e. it has components [i,i+m-1]

template<class T>
void hdnum::Vector< T >::resize ( size_type  _n  )  [inline]

Reallocate the vector to a new size.

Warning:
All data of the vector is lost!
Parameters:
[in] _n size of the new vector

template<class T>
void hdnum::Vector< T >::resize ( size_type  _n,
const T &  _t 
) [inline]

Reallocate the vector to a new size with initialization.

Warning:
All data of the vector is lost!
Parameters:
[in] _n size of the new vector
[in] _t initialization value for the components

template<class T>
reference hdnum::Vector< T >::operator[] ( size_type  i  )  [inline]

Component access (read/write version).

Parameters:
[in] i component index

template<class T>
const_reference hdnum::Vector< T >::operator[] ( size_type  i  )  const [inline]

Component access (read-only version).

Parameters:
[in] i component index

template<class T>
Vector& hdnum::Vector< T >::operator+= ( const Vector< T > &  y  )  [inline]

Addition assignment.

Implements x += y vector addition

Parameters:
[in] y another vector

template<class T>
Vector& hdnum::Vector< T >::operator-= ( const Vector< T > &  y  )  [inline]

Subtraction assignment.

Implements x -= y vector subtraction

Parameters:
[in] y another vector

template<class T>
Vector& hdnum::Vector< T >::operator*= ( const T &  s  )  [inline]

Scalar multiplication assignment.

Implements x *= s where s is a scalar

Parameters:
[in] s scalar value to multiply with vector scalar multiplication

template<class T>
Vector& hdnum::Vector< T >::operator/= ( const T &  s  )  [inline]

Scalar division assignment.

Implements x /= s where s is a scalar

Parameters:
[in] s scalar value to divide with

template<class T>
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

Parameters:
[in] a scalar value to multiply with
[in] y another vector

template<class T>
T hdnum::Vector< T >::operator* ( const Vector< T > &  y  )  [inline]

Scalar multiplication of two vectors.

Implements x*y where x,y are vectors

Parameters:
[in] y another vector


The documentation for this class was generated from the following file:

Generated on Thu Nov 5 11:47:02 2009 for Heidelberg Educational Numerics Library by  doxygen 1.5.5