Public Types | Public Member Functions | Data Fields | Static Public Attributes
T2DVector< T > Class Template Reference

a 2D vector More...

#include <mia/2d/vector.hh>

Public Types

typedef T value_type
 typedef for generic access to the element type More...
 

Public Member Functions

void fill (T v)
 fill all the elements with the given value More...
 
norm () const
 
norm2 () const
 
bool operator!= (const T2DVector &a) const
 not equal operator More...
 
T2DVectoroperator*= (double a)
 in place multiplication with a scalar More...
 
T2DVectoroperator*= (const T2DVector &a)
 in place element wise multiplication of two 2D vectors More...
 
T2DVectoroperator+= (const T2DVector &a)
 in place addition More...
 
T2DVectoroperator-= (const T2DVector &a)
 in place subtraction More...
 
T2DVectoroperator/= (const T2DVector &a)
 in place element wise division of two 2D vectors More...
 
T2DVectoroperator/= (double a)
 in place division by a scalar More...
 
bool operator== (const T2DVector &a) const
 Equal operator. More...
 
T & operator[] (int i)
 
const T & operator[] (int i) const
 
void print (std::ostream &os) const
 print the vector to a stream with special formatting More...
 
double product () const
 
void read (std::istream &is)
 read the properly formatted 2D vector from a stream More...
 
size_t size () const
 returns the size of this vector, always 2 More...
 
 T2DVector ()
 
 T2DVector (int dim)
 
 T2DVector (T _x, T _y)
 
template<typename In >
 T2DVector (const T2DVector< In > &in)
 

Data Fields

x
 first element More...
 
y
 second element More...
 

Static Public Attributes

static const T2DVector< T > _0 = T2DVector<T>(0,0)
 a static for the value <0,0>. More...
 
static const T2DVector< T > _1 = T2DVector<T>(1,1)
 a static for the value <1,1>. More...
 

Detailed Description

template<class T>
class T2DVector< T >

a 2D vector

A 2D vector that provides the usual set of operations required to handle such objects.

Template Parameters
typeof the elements

Definition at line 45 of file 2d/vector.hh.

Member Typedef Documentation

template<class T>
typedef T T2DVector< T >::value_type

typedef for generic access to the element type

Definition at line 49 of file 2d/vector.hh.

Constructor & Destructor Documentation

template<class T>
T2DVector< T >::T2DVector ( )
inline

Definition at line 63 of file 2d/vector.hh.

template<class T>
T2DVector< T >::T2DVector ( int  dim)
inlineexplicit

this constructor is required for some generic code It is explicit to avoid some problems with automatic assigment

Definition at line 68 of file 2d/vector.hh.

template<class T>
T2DVector< T >::T2DVector ( _x,
_y 
)
inline

Contruct the vector with the according elements

Parameters
_x
_y

Definition at line 77 of file 2d/vector.hh.

template<class T>
template<typename In >
T2DVector< T >::T2DVector ( const T2DVector< In > &  in)
inline

Automatically convert a 2D vector from another element type

Definition at line 84 of file 2d/vector.hh.

Member Function Documentation

template<class T>
void T2DVector< T >::fill ( v)
inline

fill all the elements with the given value

Definition at line 182 of file 2d/vector.hh.

template<class T>
T T2DVector< T >::norm ( ) const
inline
Returns
norm of the vector

Definition at line 99 of file 2d/vector.hh.

template<class T>
T T2DVector< T >::norm2 ( ) const
inline
Returns
square norm of the vector

Definition at line 94 of file 2d/vector.hh.

Referenced by T2DVector< T2DVector< T > >::norm().

template<class T>
bool T2DVector< T >::operator!= ( const T2DVector< T > &  a) const
inline

not equal operator

Definition at line 192 of file 2d/vector.hh.

template<class T>
T2DVector& T2DVector< T >::operator*= ( double  a)
inline

in place multiplication with a scalar

Definition at line 123 of file 2d/vector.hh.

template<class T>
T2DVector& T2DVector< T >::operator*= ( const T2DVector< T > &  a)
inline

in place element wise multiplication of two 2D vectors

Definition at line 129 of file 2d/vector.hh.

template<class T>
T2DVector& T2DVector< T >::operator+= ( const T2DVector< T > &  a)
inline

in place addition

Definition at line 111 of file 2d/vector.hh.

template<class T>
T2DVector& T2DVector< T >::operator-= ( const T2DVector< T > &  a)
inline

in place subtraction

Definition at line 117 of file 2d/vector.hh.

template<class T>
T2DVector& T2DVector< T >::operator/= ( const T2DVector< T > &  a)
inline

in place element wise division of two 2D vectors

Definition at line 135 of file 2d/vector.hh.

template<class T>
T2DVector& T2DVector< T >::operator/= ( double  a)
inline

in place division by a scalar

Definition at line 143 of file 2d/vector.hh.

template<class T>
bool T2DVector< T >::operator== ( const T2DVector< T > &  a) const
inline

Equal operator.

Definition at line 187 of file 2d/vector.hh.

template<class T>
T& T2DVector< T >::operator[] ( int  i)
inline

Array access operator for some generic code One should have a look how expensive this function is

Definition at line 158 of file 2d/vector.hh.

template<class T>
const T& T2DVector< T >::operator[] ( int  i) const
inline

Array access operator for some generic code One should have a look how expensive this function is

Definition at line 171 of file 2d/vector.hh.

template<class T>
void T2DVector< T >::print ( std::ostream &  os) const
inline

print the vector to a stream with special formatting

Definition at line 197 of file 2d/vector.hh.

Referenced by operator<<().

template<class T>
double T2DVector< T >::product ( ) const
inline
Returns
product of the elements of the vector

Definition at line 104 of file 2d/vector.hh.

template<class T>
void T2DVector< T >::read ( std::istream &  is)
inline

read the properly formatted 2D vector from a stream

Definition at line 202 of file 2d/vector.hh.

Referenced by operator>>().

template<class T>
size_t T2DVector< T >::size ( ) const
inline

returns the size of this vector, always 2

Definition at line 151 of file 2d/vector.hh.

Field Documentation

template<class T>
const T2DVector< T > T2DVector< T >::_0 = T2DVector<T>(0,0)
static

a static for the value <0,0>.

Definition at line 61 of file 2d/vector.hh.

template<class T>
const T2DVector< T > T2DVector< T >::_1 = T2DVector<T>(1,1)
static

a static for the value <1,1>.

Definition at line 58 of file 2d/vector.hh.

template<class T>
T T2DVector< T >::x
template<class T>
T T2DVector< T >::y

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