MathTL
 All Classes Functions Variables Typedefs Enumerations
Public Types | Public Member Functions | Protected Attributes
MathTL::Vector< C > Class Template Reference

#include <vector.h>

Inheritance diagram for MathTL::Vector< C >:
MathTL::Polynomial< C >

List of all members.

Public Types

typedef C value_type
typedef value_typepointer
typedef const value_typeconst_pointer
typedef value_typeiterator
typedef const value_typeconst_iterator
typedef value_typereference
typedef const value_typeconst_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_

Detailed Description

template<class C>
class MathTL::Vector< C >

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.


Member Typedef Documentation

template<class C>
typedef const value_type* MathTL::Vector< C >::const_iterator

const iterator type (cf. STL containers)

template<class C>
typedef const value_type* MathTL::Vector< C >::const_pointer

const pointer type (cf. STL containers)

template<class C>
typedef const value_type& MathTL::Vector< C >::const_reference

const reference type (cf. STL containers)

template<class C>
typedef value_type* MathTL::Vector< C >::iterator

iterator type (cf. STL containers)

template<class C>
typedef value_type* MathTL::Vector< C >::pointer

pointer type (cf. STL containers)

template<class C>
typedef value_type& MathTL::Vector< C >::reference

reference type (cf. STL containers)

template<class C>
typedef size_t MathTL::Vector< C >::size_type

type of indexes and size type (cf. STL containers)

template<class C>
typedef C MathTL::Vector< C >::value_type

value type (cf. STL containers)


Constructor & Destructor Documentation

template<class C >
MathTL::Vector< C >::Vector ( ) [inline]

default constructor: yields a 0-dimensional vector

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

template<class C >
MathTL::Vector< C >::Vector ( const size_type  s,
const char *  str 
)

Construct a vector from a string holding its entries, separated by a blank.

Parameters:
sdimension
strinput string
template<class C>
MathTL::Vector< C >::Vector ( const Vector< C > &  v) [inline]

copy constructor

template<class C >
MathTL::Vector< C >::~Vector ( ) [inline, virtual]

release allocated memory


Member Function Documentation

template<class C >
template<class C2 >
void MathTL::Vector< C >::add ( const Vector< C2 > &  v)

in place summation *this += v

template<class C >
template<class C2 >
void MathTL::Vector< C >::add ( const C2  s,
const Vector< C2 > &  v 
)

in place summation *this += s*v

template<class C >
Vector< C >::const_iterator MathTL::Vector< C >::begin ( ) const [inline]

read-only iterator access to first element (cf. STL containers)

template<class C >
Vector< C >::iterator MathTL::Vector< C >::begin ( ) [inline]

read-write iterator access to first element (cf. STL containers)

template<class C >
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)

template<class C >
bool MathTL::Vector< C >::empty ( ) const [inline]

return true if dimension is zero

template<class C >
Vector< C >::const_iterator MathTL::Vector< C >::end ( ) const [inline]

read-only iterator access to the element behind the last one (cf. STL containers)

template<class C >
Vector< C >::iterator MathTL::Vector< C >::end ( ) [inline]

read-only iterator access to the element behind the last one (cf. STL containers)

template<class C >
template<class C2 >
const C MathTL::Vector< C >::inner_product ( const Vector< C2 > &  v) const

inner product

template<class C >
Vector< C >::size_type MathTL::Vector< C >::memory_consumption ( ) const [inline]

(estimate for the) memory consumption in bytes

template<class C >
template<class C2 >
bool MathTL::Vector< C >::operator!= ( const Vector< C2 > &  v) const [inline]

non-equality test

template<class C >
const C MathTL::Vector< C >::operator() ( const size_type  i) const [inline]

Matlab style read-only access to the i-th vector component

template<class C >
C & MathTL::Vector< C >::operator() ( const size_type  i) [inline]

Matlab style read-write access to the i-th vector component

template<class C >
template<class C2 >
const C MathTL::Vector< C >::operator* ( const Vector< C2 > &  v) const

inner product

template<class C>
Vector< C > & MathTL::Vector< C >::operator*= ( const C  c)

in place multiplication with a scalar

Reimplemented in MathTL::Polynomial< C >.

template<class C >
template<class C2 >
Vector< C > & MathTL::Vector< C >::operator+= ( const Vector< C2 > &  v) [inline]

in place summation

template<class C >
template<class C2 >
Vector< C > & MathTL::Vector< C >::operator-= ( const Vector< C2 > &  v) [inline]

in place subtraction

template<class C>
Vector< C > & MathTL::Vector< C >::operator/= ( const C  c)

in place division by a (nontrivial) scalar

template<class C >
template<class C2 >
bool MathTL::Vector< C >::operator< ( const Vector< C2 > &  v) const [inline]

lexicographical order

template<class C>
Vector< C > & MathTL::Vector< C >::operator= ( const C  c) [inline]

assignment of a constant value to each component

Reimplemented in MathTL::Polynomial< C >.

template<class C>
Vector< C > & MathTL::Vector< C >::operator= ( const Vector< C > &  v)

assignment from another vector (may change the dimension)

template<class C >
template<class C2 >
bool MathTL::Vector< C >::operator== ( const Vector< C2 > &  v) const

equality test with another vector

template<class C >
const C MathTL::Vector< C >::operator[] ( const size_type  i) const [inline]

C style read-only access to the i-th vector component

template<class C >
C & MathTL::Vector< C >::operator[] ( const size_type  i) [inline]

C style read-write access to the i-th vector component

template<class C >
void MathTL::Vector< C >::resize ( const size_type  s,
const bool  initialize = true 
)

resize vector, initialize with C(0) if desired

template<class C>
template<class C2 >
void MathTL::Vector< C >::sadd ( const C  s,
const Vector< C2 > &  v 
)

in place summation *this = s*(*this) + v (AXPY level 1 BLAS routine)

template<class C>
void MathTL::Vector< C >::scale ( const C  s)

in place scaling *this *= s

Reimplemented in MathTL::Polynomial< C >.

template<class C >
Vector< C >::size_type MathTL::Vector< C >::size ( ) const [inline]

size/dimension of the vector

template<class C >
template<class C2 >
void MathTL::Vector< C >::subtract ( const Vector< C2 > &  v)

in place subtraction *this -= v

template<class C>
void MathTL::Vector< C >::swap ( Vector< C > &  v) [inline]

swap components of two vectors

template<class C>
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++)


Member Data Documentation

template<class C>
size_type MathTL::Vector< C >::size_ [protected]

size/dimension of the vector

template<class C>
C* MathTL::Vector< C >::values_ [protected]

internal storage is just a pointer to a C array


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Enumerations