TooN::Vector< Size, Precision, Base > Class Template Reference
[Linear Algebra]

#include <TooN/toon.h>

List of all members.

Public Types

typedef Base::template VLayout
< Size, Precision >
::PointerType 
PointerType

Public Member Functions

Comparison

template<int Size2, class Precision2 , class Base2 >
bool operator!= (const Vector< Size2, Precision2, Base2 > &rhs)
 Test for inequality with another vector.
template<int Size2, class Precision2 , class Base2 >
bool operator== (const Vector< Size2, Precision2, Base2 > &rhs)
 Test for equality with another vector.
Operators on the vector

Vectoroperator*= (const Precision &rhs)
 multiply this vector by a constant
template<class Op >
Vectoroperator+= (const Operator< Op > &op)
template<int Size2, class Precision2 , class Base2 >
Vectoroperator+= (const Vector< Size2, Precision2, Base2 > &rhs)
 add another vector onto this one
template<int Size2, class Precision2 , class Base2 >
Vectoroperator-= (const Vector< Size2, Precision2, Base2 > &rhs)
 subtract another vector from this one
template<class Op >
Vectoroperator-= (const Operator< Op > &op)
Vectoroperator/= (const Precision &rhs)
 divide this vector by a constant
Assignment

template<class Op >
Vectoroperator= (const Operator< Op > &op)
template<int Size2, typename Precision2 , typename Base2 >
Vector< Size, Precision, Base > & operator= (const Vector< Size2, Precision2, Base2 > &from)
Vectoroperator= (const Vector &from)
Misc

Vectorref ()
 return me as a non const reference - useful for temporaries
Constructors

template<int Size2, typename Precision2 , typename Base2 >
 Vector (const Vector< Size2, Precision2, Base2 > &from)
 constructor from arbitrary vector
template<class Op >
 Vector (const Operator< Op > &op)
 Vector (PointerType data_in, int size_in, int stride_in, Internal::Slicing)
 internal constructor
 Vector (PointerType data, int size_in)
 Vector (PointerType data)
 Vector (int size_in)
 Vector ()

Detailed Description

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
class TooN::Vector< Size, Precision, Base >

A vector. Support is provided for all the usual vector operations:

See individual member function documentation for examples of usage.

Statically- and dynamically-sized vectors

The library provides classes for both statically- and dynamically-sized vectors. If you know what dimension of vector you're going to use (e.g. 3 to represent a point in 3D space), it's more efficient to statically sized vectors. The size of static vectors is determined at compile time; that of dynamically-sized vectors at run-time.

To create a 3-dimensional vector, use:

Vector<3> v;

and to create a vector of some other dimensionality just replace 3 with the positive integer of your choice, or some expression which the compiler can evaluate to an integer at compile time.

The preferred way of initialising a vector is to use makeVector. The makeVector function constructs a static vector initialised to the size and the contents of the comma-separated list of argments. The makeVector vectors are real Vectors and so can be used anywhere where a vector is needed, not just in initialisations. For example

// Create a vector initialised to [1 2 3];
Vector<3> v = makeVector(1, 2, 3);
// Calculate the dot product with the vector [4 0 6]
double dot = v * makeVector(4, 0, 6);

Because the make_Vector syntax creates actual vectors, compile-time checking is done to ensure that all vectors defined in this way have the correct number of elements.

Dynamically-sized vectors

To create a dynamically sized vector, use:

Vector<> v(size);

where size is an integer which will be evaluated at run time.

Vector<> is actually a synonym for Vector<Dynamic> which is Vector<-1> being a template specialisation of Vector<N> with a special implementation that allows the size to be determined at runtime.

Row vectors and column vectors

This library makes no distinction between row vectors and column vectors. Vectors that appear on the left of a multiplication are treated as row vectors while those that appear on the right are treated as column vectors (thus v1*v2 means the dot product). This means that sometimes you have to be careful to include prarentheses since it is possible to write obscure stuff like

Vector<4> v4 = v1 * v2 * v3;

which in the absence of any extra parentheses means 'compute the dot product between v1 and v2 and then multiply v3 by this scalar and assign to v4'.

If the row-column distinction is important, then vectors can be turned into matrices with one row or column by using as_row() or as_col():

double d[3] = {1,2,3};
Vector<3> v(d);
Matrix<3,3> M = v.as_col() * v.as_row(); // creates a symmetric rank 1 matrix from v 

Definition at line 128 of file vector.hh.


Member Typedef Documentation

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
typedef Base::template VLayout<Size, Precision>::PointerType TooN::Vector< Size, Precision, Base >::PointerType

Definition at line 131 of file vector.hh.


Constructor & Destructor Documentation

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
TooN::Vector< Size, Precision, Base >::Vector (  )  [inline]

Default constructor for vectors. For fixed-sized vectors, this does nothing, i.e. does not guarantee to initialise the vector to any particular values. For dynamically sized vectors, this sets the vector to have a length of 0 which renders the vector useless because vectors can't be resized

Definition at line 144 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
TooN::Vector< Size, Precision, Base >::Vector ( int  size_in  )  [inline, explicit]

Constructor for dynamically-size vectors. This can also be used for statically sized vectors in which case the argument is ignored. The values of the vector are uninitialised

Definition at line 149 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
TooN::Vector< Size, Precision, Base >::Vector ( PointerType  data  )  [inline, explicit]

Constructor used when constructing a vector which references other data, e.g.

 double[] d = {1,2,3};
 Vector<3,double,Reference> v(d);

Definition at line 157 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
TooN::Vector< Size, Precision, Base >::Vector ( PointerType  data,
int  size_in 
) [inline]

Constructor used when constructing a dynamic vector which references other data, e.g.

 double[] d = {1,2,3};
 Vector<Dynamic,double,Reference> v(d,3);

Definition at line 166 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
TooN::Vector< Size, Precision, Base >::Vector ( PointerType  data_in,
int  size_in,
int  stride_in,
Internal::Slicing   
) [inline]

internal constructor

Definition at line 169 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<class Op >
TooN::Vector< Size, Precision, Base >::Vector ( const Operator< Op > &  op  )  [inline]

construction from Operator object

This is used to implement return value optimisation for vectors created from the product of a matrix and a vector, or another object like Ones

Definition at line 180 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<int Size2, typename Precision2 , typename Base2 >
TooN::Vector< Size, Precision, Base >::Vector ( const Vector< Size2, Precision2, Base2 > &  from  )  [inline]

constructor from arbitrary vector

Definition at line 197 of file vector.hh.


Member Function Documentation

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<int Size2, class Precision2 , class Base2 >
bool TooN::Vector< Size, Precision, Base >::operator!= ( const Vector< Size2, Precision2, Base2 > &  rhs  )  [inline]

Test for inequality with another vector.

Definition at line 345 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
Vector& TooN::Vector< Size, Precision, Base >::operator*= ( const Precision &  rhs  )  [inline]

multiply this vector by a constant

Definition at line 283 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<class Op >
Vector& TooN::Vector< Size, Precision, Base >::operator+= ( const Operator< Op > &  op  )  [inline]

add an Operator object onto this vector

this is used to handle cases such as:

 Vector<3> v;
 v+=Ones

Definition at line 306 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<int Size2, class Precision2 , class Base2 >
Vector& TooN::Vector< Size, Precision, Base >::operator+= ( const Vector< Size2, Precision2, Base2 > &  rhs  )  [inline]

add another vector onto this one

Definition at line 291 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<int Size2, class Precision2 , class Base2 >
Vector& TooN::Vector< Size, Precision, Base >::operator-= ( const Vector< Size2, Precision2, Base2 > &  rhs  )  [inline]

subtract another vector from this one

Definition at line 321 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<class Op >
Vector& TooN::Vector< Size, Precision, Base >::operator-= ( const Operator< Op > &  op  )  [inline]

Definition at line 313 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
Vector& TooN::Vector< Size, Precision, Base >::operator/= ( const Precision &  rhs  )  [inline]

divide this vector by a constant

Definition at line 276 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<class Op >
Vector& TooN::Vector< Size, Precision, Base >::operator= ( const Operator< Op > &  op  )  [inline]

assignment from an Operator object Assignment from sized operators causes a resize of Resizable Vectors. Assignment from unsized operators dows not.

Definition at line 265 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<int Size2, typename Precision2 , typename Base2 >
Vector<Size,Precision,Base >& TooN::Vector< Size, Precision, Base >::operator= ( const Vector< Size2, Precision2, Base2 > &  from  )  [inline]

operator = another Vector A size mismatch is a fatal error, unless the destination is resizable.

Definition at line 250 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
Vector& TooN::Vector< Size, Precision, Base >::operator= ( const Vector< Size, Precision, Base > &  from  )  [inline]

operator = from copy A size mismatch is a fatal error, unless the destination is resizable.

Definition at line 236 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
template<int Size2, class Precision2 , class Base2 >
bool TooN::Vector< Size, Precision, Base >::operator== ( const Vector< Size2, Precision2, Base2 > &  rhs  )  [inline]

Test for equality with another vector.

Definition at line 335 of file vector.hh.

template<int Size = Dynamic, typename Precision = DefaultPrecision, typename Base = Internal::VBase>
Vector& TooN::Vector< Size, Precision, Base >::ref (  )  [inline]

return me as a non const reference - useful for temporaries

Definition at line 359 of file vector.hh.


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


libtoon
Author(s): Florian Weisshardt
autogenerated on Fri Jan 11 10:09:50 2013