LTL  2.0.x
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | Related Functions | List of all members
ltl::FVector< T, N, S > Class Template Reference

Vector whose length is known at compile time. More...

Inherits ltl::FVMemory< T, N, S >.

Public Types

enum  { static_size = 1 }
 Used by expression engine to decide which loops to unroll. More...
 
typedef T value_type
 STL-compatible type definitions. More...
 
typedef FVIter< T, N, S > iterator
 
typedef FVIterConst< T, N, S > const_iterator
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef std::size_t size_type
 
typedef std::ptrdiff_t difference_type
 

Public Member Functions

 FVector ()
 default constructor More...
 
 ~FVector ()
 destructor More...
 
 FVector (const FVector< T, N, S > &other)
 copy constructor More...
 
 FVector (T *const a)
 
 FVector (const T t)
 fill with value t. More...
 
template<class Expr >
 FVector (const FVExprNode< Expr, N > &e)
 construct from expression More...
 
ListInitializationSwitch
< FVector< T, N, S > > 
operator= (T x)
 Initialize with list of values or single value. More...
 
iterator begin ()
 return an iterator pointing to the first element. More...
 
const_iterator begin () const
 return a const iterator pointing to the first element. More...
 
iterator end ()
 return an iterator pointing past the last element. More...
 
const_iterator end () const
 return a const iterator pointing past the last element. More...
 
void fill (const T x)
 fill with value x. More...
 
template<class T2 , int S2>
void swap (FVector< T2, N, S2 > &other)
 swap values with other. More...
 
T * data ()
 Return a pointer to the data. More...
 
T * data () const
 Return a const pointer to the data. More...
 
template<class Expr >
FVector< T, N, S > & operator= (const FVExprNode< Expr, N > &e)
 operatorX= for expression rhs. More...
 
template<class Expr >
FVector< T, N, S > & operator+= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator-= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator*= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator/= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator%= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator^= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator&= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator|= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator<<= (const FVExprNode< Expr, N > &e)
 
template<class Expr >
FVector< T, N, S > & operator>>= (const FVExprNode< Expr, N > &e)
 
template<class T2 , int S2>
FVector< T, N, S > & operator= (const FVector< T2, N, S2 > &v)
 operatorX for FVector rhs. More...
 
FVector< T, N, S > & operator= (const FVector< T, N, S > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator+= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator-= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator*= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator/= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator%= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator^= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator&= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator|= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator<<= (const FVector< T2, N, S2 > &v)
 
template<class T2 , int S2>
FVector< T, N, S > & operator>>= (const FVector< T2, N, S2 > &v)
 
FVector< T, N, S > & operator+= (const T t)
 operatorX= for scalar rhs. More...
 
FVector< T, N, S > & operator-= (const T t)
 
FVector< T, N, S > & operator*= (const T t)
 
FVector< T, N, S > & operator/= (const T t)
 
FVector< T, N, S > & operator%= (const T t)
 
FVector< T, N, S > & operator^= (const T t)
 
FVector< T, N, S > & operator&= (const T t)
 
FVector< T, N, S > & operator|= (const T t)
 
FVector< T, N, S > & operator<<= (const T t)
 
FVector< T, N, S > & operator>>= (const T t)
 
operator[] (const int i) const
 Access elements with zero-based index i. More...
 
T & operator[] (const int i)
 Access elements with zero-based index i. More...
 
operator() (const int i) const
 Access elements with one-based index i. More...
 
T & operator() (const int i)
 Access elements with one-based index i. More...
 

Static Public Member Functions

static int length ()
 return length of vector. More...
 
static int minIndex ()
 lowest possible index, always one. More...
 
static int maxIndex ()
 highest possible index, always N. More...
 
static size_type size ()
 STL return the length of the vector. More...
 
static bool empty ()
 STL empty(). Always false. More...
 
static size_type max_size ()
 STL: Maximum capacity. Always ==size() More...
 

Protected Attributes

T * __data_
 points to first element of data block for 0-based access More...
 

Friends

class FVIter< T, N, S >
 
class FVIterConst< T, N, S >
 
class ListInitializationSwitch< FVector< T, N, S > >
 

Related Functions

(Note that these are not member functions.)

template<class T , int N, int S>
ostream & operator<< (ostream &os, const FVector< T, N, S > &x)
 
template<class T , int N, int S>
istream & operator>> (istream &is, FVector< T, N, S > &x)
 

Detailed Description

template<class T, int N, int S>
class ltl::FVector< T, N, S >

Vector whose length is known at compile time.

Can either have its own memory region or reference foreign memory, for example when representing a column-vector of a matrix

The template parameter S is a 'stride' for the foreign memory: when we reference a column vector we need a stride of M (if the matrix is MxN). Memory handling is encapsulated in the class FVMemory. To make life easier for the compiler/optimizer, there is a specialization of FVMemory with no stride at all and an own new embedded block of memory. This is indicated by S=0, which is also the default case.

FVector does not require more memory than is necessary to store the N elements of the vector if S=0. If S>0, the size is exactly sizeof(T*).

FVector provides operator() for 1-based access and operator[] for 0-based access. A full expression-templated engine for evaluating expressions involving ltl::FVectors is provided, as well as dot products between ltl::FVector and ltl::FMatrix objects, and scalar-valued reductions.

STL-compatible iterators and types.

Member Typedef Documentation

template<class T, int N, int S>
typedef T ltl::FVector< T, N, S >::value_type

STL-compatible type definitions.

template<class T, int N, int S>
typedef FVIter<T,N,S> ltl::FVector< T, N, S >::iterator
template<class T, int N, int S>
typedef FVIterConst<T,N,S> ltl::FVector< T, N, S >::const_iterator
template<class T, int N, int S>
typedef T* ltl::FVector< T, N, S >::pointer
template<class T, int N, int S>
typedef const T* ltl::FVector< T, N, S >::const_pointer
template<class T, int N, int S>
typedef T& ltl::FVector< T, N, S >::reference
template<class T, int N, int S>
typedef const T& ltl::FVector< T, N, S >::const_reference
template<class T, int N, int S>
typedef std::size_t ltl::FVector< T, N, S >::size_type
template<class T, int N, int S>
typedef std::ptrdiff_t ltl::FVector< T, N, S >::difference_type

Member Enumeration Documentation

template<class T, int N, int S>
anonymous enum

Used by expression engine to decide which loops to unroll.

Enumerator
static_size 

Constructor & Destructor Documentation

template<class T, int N, int S>
ltl::FVector< T, N, S >::FVector ( )
inline

default constructor

template<class T, int N, int S>
ltl::FVector< T, N, S >::~FVector ( )
inline

destructor

template<class T, int N, int S>
ltl::FVector< T, N, S >::FVector ( const FVector< T, N, S > &  other)

copy constructor

template<class T, int N, int S>
ltl::FVector< T, N, S >::FVector ( T *const  a)

constructor taking a pointer to foreign memory. If S==0, copy, else reference the foreign memory.

template<class T, int N, int S>
ltl::FVector< T, N, S >::FVector ( const T  t)

fill with value t.

template<class T, int N, int S>
template<class Expr >
ltl::FVector< T, N, S >::FVector ( const FVExprNode< Expr, N > &  e)

construct from expression

Member Function Documentation

template<class T, int N, int S>
static size_type ltl::FVector< T, N, S >::size ( )
inlinestatic

STL return the length of the vector.

Functions needed for STL container conformance

template<class T, int N, int S>
static bool ltl::FVector< T, N, S >::empty ( )
inlinestatic

STL empty(). Always false.

template<class T, int N, int S>
static size_type ltl::FVector< T, N, S >::max_size ( )
inlinestatic

STL: Maximum capacity. Always ==size()

template<class T, int N, int S>
ListInitializationSwitch< FVector<T,N,S> > ltl::FVector< T, N, S >::operator= ( x)
inline

Initialize with list of values or single value.

Assign values through initialization list. A bit more comlicated since we have to discriminate between A = 3; and A = 1, 2, 3, 4; which is done using ListInitializationSwitch which either calls ListInitializer or FVector::fill().

template<class T, int N, int S>
static int ltl::FVector< T, N, S >::length ( )
inlinestatic

return length of vector.

operator[] and operator() inherited from FVMemory

template<class T, int N, int S>
static int ltl::FVector< T, N, S >::minIndex ( )
inlinestatic

lowest possible index, always one.

Referenced by ltl::FVector< T, N, S >::operator>>().

template<class T, int N, int S>
static int ltl::FVector< T, N, S >::maxIndex ( )
inlinestatic

highest possible index, always N.

Referenced by ltl::FVector< T, N, S >::operator>>().

template<class T, int N, int S>
iterator ltl::FVector< T, N, S >::begin ( )
inline

return an iterator pointing to the first element.

template<class T, int N, int S>
const_iterator ltl::FVector< T, N, S >::begin ( ) const
inline

return a const iterator pointing to the first element.

template<class T, int N, int S>
iterator ltl::FVector< T, N, S >::end ( )
inline

return an iterator pointing past the last element.

template<class T, int N, int S>
const_iterator ltl::FVector< T, N, S >::end ( ) const
inline

return a const iterator pointing past the last element.

template<class T, int N, int S>
void ltl::FVector< T, N, S >::fill ( const T  x)

fill with value x.

template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator= ( const FVExprNode< Expr, N > &  e)

operatorX= for expression rhs.

template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator+= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator-= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator*= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator/= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator%= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator^= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator&= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator|= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator<<= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class Expr >
FVector<T,N,S>& ltl::FVector< T, N, S >::operator>>= ( const FVExprNode< Expr, N > &  e)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator= ( const FVector< T2, N, S2 > &  v)

operatorX for FVector rhs.

template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator= ( const FVector< T, N, S > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator+= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator-= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator*= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator/= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator%= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator^= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator&= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator|= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator<<= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
template<class T2 , int S2>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator>>= ( const FVector< T2, N, S2 > &  v)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator+= ( const T  t)

operatorX= for scalar rhs.

template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator-= ( const T  t)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator*= ( const T  t)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator/= ( const T  t)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator%= ( const T  t)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator^= ( const T  t)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator&= ( const T  t)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator|= ( const T  t)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator<<= ( const T  t)
template<class T, int N, int S>
FVector<T,N,S>& ltl::FVector< T, N, S >::operator>>= ( const T  t)
template<class T, int N, int S>
template<class T2 , int S2>
void ltl::FVector< T, N, S >::swap ( FVector< T2, N, S2 > &  other)

swap values with other.

template<class T, int N, int S>
T ltl::FVMemory< T, N, S >::operator[] ( const int  i) const
inlineinherited

Access elements with zero-based index i.

template<class T, int N, int S>
T& ltl::FVMemory< T, N, S >::operator[] ( const int  i)
inlineinherited

Access elements with zero-based index i.

template<class T, int N, int S>
T ltl::FVMemory< T, N, S >::operator() ( const int  i) const
inlineinherited

Access elements with one-based index i.

template<class T, int N, int S>
T& ltl::FVMemory< T, N, S >::operator() ( const int  i)
inlineinherited

Access elements with one-based index i.

template<class T, int N, int S>
T* ltl::FVMemory< T, N, S >::data ( )
inlineinherited

Return a pointer to the data.

template<class T, int N, int S>
T* ltl::FVMemory< T, N, S >::data ( ) const
inlineinherited

Return a const pointer to the data.

Friends And Related Function Documentation

template<class T, int N, int S>
friend class FVIter< T, N, S >
friend
template<class T, int N, int S>
friend class FVIterConst< T, N, S >
friend
template<class T, int N, int S>
friend class ListInitializationSwitch< FVector< T, N, S > >
friend
template<class T , int N, int S>
ostream & operator<< ( ostream &  os,
const FVector< T, N, S > &  x 
)
related

Write ltl::FVector to ascii stream. Compatible with opertor>>.

template<class T , int N, int S>
istream & operator>> ( istream &  is,
FVector< T, N, S > &  x 
)
related

Read ltl::FVector from ascii stream. Compatible with operator<<.

References ltl::FVector< T, N, S >::maxIndex(), and ltl::FVector< T, N, S >::minIndex().

Member Data Documentation

template<class T, int N, int S>
T* ltl::FVMemory< T, N, S >::__data_
protectedinherited