Basic Geometry, Numerical Algorithms and Interfaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Types | Public Member Functions | Private Attributes | List of all members
SVector< N, Type > Class Template Reference

Detailed Description

template<uint N, class Type = Real>
class SVector< N, Type >

Fixed size vector.

A constant size (stack-allocated) array which is mainly used for geometry and the corresponding linear algebra work. SVector defines some typedefs and memeber functions which make it more compatible with STL algorithms than the conventional data structure for geoemtric points (struct {float x,y,z};).

Operators are defined in the naive way, i.e. using temporaries, because testing showed that expresseion templates (using PETE) did not provide any improvements, neither with gcc-3.2 nor icc-8.0, perhaps because of the "named return value" optimization which helps to avoid temporaries.

#include <svector.h>

Public Types

typedef Eigen::Matrix< Type,
int(N), 1 > 
 for interfacing with the Eigen library

Public Member Functions

 SVector ()
 default: zero vector
 SVector (const Type &x)
 construction, initialization
template<typename ConvertibleType >
 SVector (std::initializer_list< ConvertibleType > list)
 list initialization, uses std::copy to convert type
 SVector (const Type &x1, const Type &x2)
 element-wise construction for dimension 2
 SVector (const Type &x1, const Type &x2, const Type &x3)
 element-wise construction for dimension 3
 SVector (const Type &x1, const Type &x2, const Type &x3, const Type &x4)
 element-wise construction for dimension 4
template<class OtherType >
 SVector (const SVector< N, OtherType > &a)
 type conversion
template<class OtherType >
 SVector (const SVector< N-1, OtherType > &a, OtherType last)
 SVector (const Type *x)
 initialized construction
 SVector (const std::string &s)
 construction using a string, e.g of the form "0.5 0.6 1.2"
 SVector (const SVector< N, Type > &x)
 copy construction
SVector< N, Type > & operator= (const SVector< N, Type > &src)
template<typename SrcType >
SVector< N, Type > & operator= (const SVector< N, SrcType > &src)
 conversion assignment
SVector< N, Type > & operator= (const Type &x)
 assignment from a scalar
Type * pointer ()
 data pointer
const Type * pointer () const
 data pointer
void assign (const Type *ptr)
 assign from pointer
reference operator[] (uint i)
 mutable access[]
const_reference operator[] (uint i) const
 const access[]
reference operator() (uint i)
 mutable access()
const_reference operator() (uint i) const
 const access()
bool operator== (const SVector< N, Type > &rhs) const
 equality element by element
bool operator!= (const SVector< N, Type > &rhs) const
 at least one element different
iterator begin ()
 mutable start pointer
const_iterator begin () const
 const start pointer
iterator end ()
 one-past-end pointer
const_iterator end () const
 one-past-end pointer
const_reference front () const
 first value (const)
reference front ()
 first value (mutable)
const_reference back () const
 last value (const)
reference back ()
 last value (mutable)
uint size () const
 number of entries
SVector< N, Type > operator- () const
 unary minus
const SVector< N, Type > normalized () const
 returns a new vector, normalized to length = 1.
void clear ()
 overwrite with zero
EigenMap mmap ()
 create a mutable map object for interfacing with Eigen
ConstEigenMap cmap () const
 create a mutable map object for interfacing with Eigen

Private Attributes

Type data [N]
 static array

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