Public Member Functions

apf::Vector< N > Class Template Reference

template-generic vector of N doubles More...

List of all members.

Public Member Functions

 Vector ()
 mandatory
 Vector (double const *v)
 construct from array
Vector< N > operator+ (Vector< N > const &b) const
 add two vectors
Vector< N > & operator+= (Vector< N > const &b)
 add a vector to this vector
Vector< N > operator- (Vector< N > const &b) const
 subtract two vectors
Vector< N > operator* (double s) const
 multiply a vector times a scalar
Vector< N > operator/ (double s) const
 divide a vector by a scalar
double operator* (Vector< N > const &b) const
 vector dot product
double getLength () const
 get the vector magnitude
Vector< N > normalize () const
 divide the vector by its magnitude
void zero ()
 zero the vector

Detailed Description

template<std::size_t N>
class apf::Vector< N >

template-generic vector of N doubles

this class implements a linear algebra vector whose size is known at compile time. It is intended to be used for small, dense vectors whose operations benefit from the optimization offered by templates and inline methods because they are so small that the overhead of function calls and conditionals is high.

For vectors sized at runtime, see apf::DynamicVector. For sparse structures or parallel vectors, look outside of APF.

apf::Vector objects should be used in a functional programming style, i.e. treated as immutable values for the most part, then we expect the compiler to optimize the assignments into faster code.


Member Function Documentation

template<std::size_t N>
Vector<N> apf::Vector< N >::operator* ( double  s  )  const [inline]

multiply a vector times a scalar

currently there is no scalar-times-vector operator, so do be sure to put scalar on the right hand side.

template<std::size_t N>
double apf::Vector< N >::operator* ( Vector< N > const &  b  )  const [inline]

vector dot product

We chose the default vector-vector multiplication operator to be the dot product. So far this seems to have been a good choice

template<std::size_t N>
Vector<N> apf::Vector< N >::operator/ ( double  s  )  const [inline]

divide a vector by a scalar

equivalent to scaling by 1/s


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines