Imagine++
Public Member Functions | Static Public Member Functions | Friends | List of all members
Imagine::FVector< T, dim > Class Template Reference

Vector of fixed size. More...

#include "Imagine/Common.h"

Inheritance diagram for Imagine::FVector< T, dim >:
Imagine::FArray< T, dim >

Public Member Functions

 FVector ()
 Empty constructor. More...
 
 FVector (const T &v)
 Constructor with constant value. More...
 
template<typename T2 >
 FVector (const T2 t[dim])
 Constructor from C array. More...
 
template<typename T2 >
 FVector (const FArray< T2, dim > &a)
 Copy constructor. More...
 
 FVector (T x, T y)
 2D alias. More...
 
 FVector (T x, T y, T z)
 3D alias. More...
 
FVectorfill (const T &v)
 Filling. More...
 
FVectornormalize ()
 Euclidean in-place normalization. More...
 
operator* (const FVector &v) const
 Scalar product. More...
 
FVector operator* (T s) const
 Scalar multiplication. More...
 
FVectoroperator*= (T s)
 Scalar in place multiplication. More...
 
FVector operator+ (const FVector &v) const
 Addition. More...
 
FVector operator+ (T s) const
 Scalar Addition. More...
 
FVectoroperator+= (const FVector &v)
 In place Addition. More...
 
FVectoroperator+= (T s)
 Scalar in place Addition. More...
 
FVector operator- (const FVector &v) const
 Substraction. More...
 
FVector operator- (T s) const
 Scalar Substraction. More...
 
FVector operator- () const
 Opposite. More...
 
FVectoroperator-= (const FVector &v)
 In place Substraction. More...
 
FVectoroperator-= (T s)
 Scalar in place substractrion. More...
 
FVector operator/ (T s) const
 Scalar division. More...
 
FVectoroperator/= (T s)
 Scalar in place division. More...
 
template<typename T2 >
FVectoroperator= (const FArray< T2, dim > &b)
 Assignment. More...
 
operator^ (const FVector< T, 2 > &v) const
 2D cross product. More...
 
FVector< T, 3 > operator^ (const FVector< T, 3 > &v) const
 3D cross product. More...
 
const T & x () const
 Read alias. More...
 
T & x ()
 Write alias. More...
 
const T & y () const
 Read alias. More...
 
T & y ()
 Write alias. More...
 
const T & z () const
 Read alias. More...
 
T & z ()
 Write alias. More...
 
- Public Member Functions inherited from Imagine::FArray< T, dim >
 FArray ()
 Empty constructor. More...
 
 FArray (const T &v)
 Constructor with constant value. More...
 
 FArray (const T2 t[S])
 Constructor from C array. More...
 
 FArray (const FArray< T2, S > &a)
 Copy constructor. More...
 
 FArray (T v0, T v1)
 2D alias. More...
 
 FArray (T v0, T v1, T v2)
 3D alias. More...
 
 FArray (T v0, T v1, T v2, T v3)
 4D alias. More...
 
iterator begin ()
 Begin iterator. More...
 
const_iterator begin () const
 Begin const iterator. More...
 
FArraycopy (const T2 t[S])
 C array of different type copy. More...
 
FArraycopy (const FArray< T2, S > &b)
 Copy. More...
 
const T * data () const
 Data pointer (read). More...
 
T * data ()
 Data pointer (write). More...
 
bool empty () const
 Is empty. More...
 
iterator end ()
 End iterator. More...
 
const_iterator end () const
 End const iterator. More...
 
FArrayfill (const T &v)
 Filling. More...
 
bool operator!= (const FArray &b) const
 Inequality test. More...
 
FArrayoperator= (const FArray< T2, S > &b)
 Assignment. More...
 
bool operator== (const FArray &b) const
 Equality test. More...
 
const T & operator[] (int i) const
 Read access. More...
 
T & operator[] (int i)
 Write access. More...
 
int size () const
 Size. More...
 

Static Public Member Functions

static FVector Zero ()
 Zero vector Vector with constant 0 value. More...
 

Friends

double dist (const FVector &a, const FVector &b)
 Distance. More...
 
FVector div (const FVector &v, const FVector &w)
 Pointwise division. More...
 
double doubleNorm (const FVector &v)
 Double Euclidean norm. More...
 
double doubleNorm1 (const FVector &v)
 Double L1-norm. More...
 
double doubleNorm2 (const FVector &v)
 Double squared Euclidean norm. More...
 
FVector exp (const FVector &a)
 Pointwise exp exps of each coordinate. More...
 
int intL1Dist (const FVector &a, const FVector &b)
 Integer L1-distance. More...
 
int intNorm1 (const FVector &v)
 Integer L1-norm. More...
 
int intNorm2 (const FVector &v)
 Integer squared Euclidean norm. More...
 
double L1Dist (const FVector &a, const FVector &b)
 Double L1-distance. More...
 
FVector log (const FVector &a)
 Pointwise log logs of each coordinate. More...
 
maxNorm (const FVector &v)
 Maximum norm. More...
 
FVector mult (const FVector &v, const FVector &w)
 Pointwise multiplication. More...
 
norm (const FVector &v)
 Euclidean norm. More...
 
norm2 (const FVector &v)
 Squared Euclidean norm. More...
 
FVector normalized (const FVector &v)
 Euclidean normalization. More...
 
FVector operator* (T s, const FVector &v)
 Scalar multiplication. More...
 
FVector operator+ (T s, const FVector &v)
 Scalar addition. More...
 
FVector operator- (T s, const FVector &v)
 Scalar substraction. More...
 
FVector pmax (const FVector &a, const FVector &b)
 Pointwise max. More...
 
FVector pmin (const FVector &a, const FVector &b)
 Pointwise min. More...
 
FVector sqrt (const FVector &a)
 Pointwise square root Square roots of each coordinate. More...
 
double squaredDist (const FVector &a, const FVector &b)
 Squared distance. More...
 
sum (const FVector &v)
 Sum of coordinates. More...
 

Additional Inherited Members

- Public Types inherited from Imagine::FArray< T, dim >
typedef const T * const_iterator
 Const iterator type.
 
typedef T * iterator
 Iterator type.
 
- Protected Attributes inherited from Imagine::FArray< T, dim >
_data [S]
 internal storage.
 

Detailed Description

template<typename T, int dim>
class Imagine::FVector< T, dim >

Fixed size vectors.

Parameters
Tvalue type
dimsize
Examples:
Common/test/test.cpp, Graphics/test/example.cpp, Graphics/test/particles.cpp, Graphics/test/test.cpp, Images/test/test.cpp, and LinAlg/test/test.cpp.

Constructor & Destructor Documentation

◆ FVector() [1/6]

template<typename T, int dim>
Imagine::FVector< T, dim >::FVector ( )
inline

Constructs an uninitialized vector of dim variables of type T

FVector<double,3> a; // uninitialized

◆ FVector() [2/6]

template<typename T, int dim>
Imagine::FVector< T, dim >::FVector ( const T &  v)
inlineexplicit

Constructs a vector of dim variables of type T, each initialized to v

Parameters
vvalue used for initialization
FVector<double,3> b(1.5); // filled with constant value

◆ FVector() [3/6]

template<typename T, int dim>
template<typename T2 >
Imagine::FVector< T, dim >::FVector ( const T2  t[dim])
inline

Constructs from a C array (with a possibly different type)

Parameters
tC array used for initialization
Template Parameters
T2value type of a
double tt[]={1,2,3}; // filled from C array
FVector<double,3> c(tt); // (copying array into fresh memory)

◆ FVector() [4/6]

template<typename T, int dim>
template<typename T2 >
Imagine::FVector< T, dim >::FVector ( const FArray< T2, dim > &  a)
inline

Constructs from another FArray (with a possibly different type)

Parameters
aFArray to be copied (has to be of the same size)
Template Parameters
T2value type of a
FVector<double,3> dd(c); // copy constructor
FVector<int,3> di(c); // copy from different type

◆ FVector() [5/6]

template<typename T, int dim>
Imagine::FVector< T, dim >::FVector ( x,
y 
)
inline

Short constructor for 2D FVector

Parameters
xvalue for index 0 coordinate
yvalue for index 1 coordinate
FVector<double,2> e(1.5,2.5); // alias for 2D case

◆ FVector() [6/6]

template<typename T, int dim>
Imagine::FVector< T, dim >::FVector ( x,
y,
z 
)
inline

Short constructor for 3D FVector

Parameters
xvalue for index 0 coordinate
yvalue for index 1 coordinate
zvalue for index 2 coordinate
FVector<double,3> f(1.5,2.5,3.5); // alias for 3D case

Member Function Documentation

◆ fill()

template<typename T, int dim>
FVector& Imagine::FVector< T, dim >::fill ( const T &  v)
inline

Fills with constant value

Parameters
vvalue to be copied to each element
Returns
self reference
a.fill(1.3); // Fills with constant value

◆ normalize()

template<typename T, int dim>
FVector& Imagine::FVector< T, dim >::normalize ( )
inline

In-place normalization using Euclidean norm

Returns
self reference
dd.normalize(); // Euclidean in-place normalization

◆ operator*() [1/2]

template<typename T, int dim>
T Imagine::FVector< T, dim >::operator* ( const FVector< T, dim > &  v) const
inline

Scalar product of FVector

Parameters
vFVector to be combined with myself
Returns
Scalar product
x=a*b; // scalar product

◆ operator*() [2/2]

template<typename T, int dim>
FVector Imagine::FVector< T, dim >::operator* ( s) const
inline

Multiplies each coordinate by a scalar

Parameters
sThe scalar
Returns
Result
c=a*2; // * scalar

◆ operator*=()

template<typename T, int dim>
FVector& Imagine::FVector< T, dim >::operator*= ( s)
inline

Multiplies each coordinate by a scalar

Parameters
sThe scalar
Returns
self reference
c*=2; // *= scalar

◆ operator+() [1/2]

template<typename T, int dim>
FVector Imagine::FVector< T, dim >::operator+ ( const FVector< T, dim > &  v) const
inline

Addition of two FVector

Parameters
vFVector to be added to myself
Returns
sum
c=a+b; // +

◆ operator+() [2/2]

template<typename T, int dim>
FVector Imagine::FVector< T, dim >::operator+ ( s) const
inline

Adds a scalar to each coordinate

Parameters
sScalar to be added to myself
Returns
sum
c=a+3.; // + scalar

◆ operator+=() [1/2]

template<typename T, int dim>
FVector& Imagine::FVector< T, dim >::operator+= ( const FVector< T, dim > &  v)
inline

In place Addition of FVector

Parameters
vFVector to be added to myself
Returns
self reference
c+=a; // +=

◆ operator+=() [2/2]

template<typename T, int dim>
FVector& Imagine::FVector< T, dim >::operator+= ( s)
inline

Adds a scalar to each own coordinate

Parameters
sScalar to be added to myself
Returns
self reference
c+=3.; // += scalar

◆ operator-() [1/3]

template<typename T, int dim>
FVector Imagine::FVector< T, dim >::operator- ( const FVector< T, dim > &  v) const
inline

Substraction of two FVector

Parameters
vFVector to be substracted from myself
Returns
difference
c=a-b; // -

◆ operator-() [2/3]

template<typename T, int dim>
FVector Imagine::FVector< T, dim >::operator- ( s) const
inline

Substracts a scalar to each coordinate

Parameters
sScalar to be substracted from myself
Returns
difference
c=a-3.; // - scalar

◆ operator-() [3/3]

template<typename T, int dim>
FVector Imagine::FVector< T, dim >::operator- ( ) const
inline

Opposite of a FVector

Returns
Opposite
b=-a; // unary -

◆ operator-=() [1/2]

template<typename T, int dim>
FVector& Imagine::FVector< T, dim >::operator-= ( const FVector< T, dim > &  v)
inline

In place Substraction of FVector

Parameters
vFVector to be substracted from myself
Returns
self reference
c-=a; // -=

◆ operator-=() [2/2]

template<typename T, int dim>
FVector& Imagine::FVector< T, dim >::operator-= ( s)
inline

Subtracts a scalar to each own coordinate

Parameters
sScalar to be substracted from myself
Returns
self reference
c-=3.; // -= scalar

◆ operator/()

template<typename T, int dim>
FVector Imagine::FVector< T, dim >::operator/ ( s) const
inline

Divides each coordinate by a scalar

Parameters
sThe scalar
Returns
Result
x=a*b; // scalar product

◆ operator/=()

template<typename T, int dim>
FVector& Imagine::FVector< T, dim >::operator/= ( s)
inline

Divides each coordinate by a scalar

Parameters
sThe scalar
Returns
self reference
c/=2; // /= scalar

◆ operator=()

template<typename T, int dim>
template<typename T2 >
FVector& Imagine::FVector< T, dim >::operator= ( const FArray< T2, dim > &  b)
inline

Assigns from another FVector (of possibly different type but same size)

Parameters
bSource FVector
Template Parameters
T2value type of b
Returns
self reference
dd=c; // assignment (copies values)
di=c; // assignment from different type

◆ operator^() [1/2]

template<typename T, int dim>
T Imagine::FVector< T, dim >::operator^ ( const FVector< T, 2 > &  v) const
inline

Scalar Cross product of 2D FVector (dim must be 2)

Parameters
vFVector to be combined with myself
Returns
Cross product
x=e^FVector<double,2>(2,1); // 2D cross product

◆ operator^() [2/2]

template<typename T, int dim>
FVector<T,3> Imagine::FVector< T, dim >::operator^ ( const FVector< T, 3 > &  v) const
inline

Vector Cross product of 3D FVector (dim must be 3)

Parameters
vFVector to be combined with myself
Returns
Cross product
c=a^b; // 3D cross product

◆ x() [1/2]

template<typename T, int dim>
const T& Imagine::FVector< T, dim >::x ( ) const
inline

Alias to element of index 0

Returns
Const reference to Element 0
x=f.x(); // read alias 0

Examples:
Graphics/test/example.cpp.

◆ x() [2/2]

template<typename T, int dim>
T& Imagine::FVector< T, dim >::x ( )
inline

Alias to element of index 0

Returns
Reference to element 0
f.x()=x; // write alias 0

◆ y() [1/2]

template<typename T, int dim>
const T& Imagine::FVector< T, dim >::y ( ) const
inline

Alias to element of index 1

Returns
Const reference to Element 1
y=f.y(); // read alias 1

Examples:
Graphics/test/example.cpp.

◆ y() [2/2]

template<typename T, int dim>
T& Imagine::FVector< T, dim >::y ( )
inline

Alias to element of index 1

Returns
Reference to element 1
f.y()=y; // write alias 1

◆ z() [1/2]

template<typename T, int dim>
const T& Imagine::FVector< T, dim >::z ( ) const
inline

Alias to element of index 2

Returns
Const reference to Element 2
z=f.z(); // read alias 2

Examples:
Graphics/test/example.cpp.

◆ z() [2/2]

template<typename T, int dim>
T& Imagine::FVector< T, dim >::z ( )
inline

Alias to element of index 2

Returns
Reference to element 2
f.z()=z; // write alias 2

◆ Zero()

template<typename T, int dim>
static FVector Imagine::FVector< T, dim >::Zero ( )
inlinestatic
Returns
vector
b=FVector<double,3>::Zero(); // Vector with const 0 value

Friends And Related Function Documentation

◆ dist

template<typename T, int dim>
double dist ( const FVector< T, dim > &  a,
const FVector< T, dim > &  b 
)
friend

Distance between two vectors, whatever their type

Parameters
a,bFVector
Returns
Result
x=squaredDist(di,di); // squared distance

◆ div

template<typename T, int dim>
FVector div ( const FVector< T, dim > &  v,
const FVector< T, dim > &  w 
)
friend

Divides coordinates two by two

Parameters
v,wFVector
Returns
v/w
c=div(a,b); // pointwise /

◆ doubleNorm

template<typename T, int dim>
double doubleNorm ( const FVector< T, dim > &  v)
friend

Double Euclidean norm

Parameters
vargument
Returns
Double Euclidean norm
x=doubleNorm(di); // double Euclidean norm

◆ doubleNorm1

template<typename T, int dim>
double doubleNorm1 ( const FVector< T, dim > &  v)
friend

Double L1-norm

Parameters
vargument
Returns
Double L1-norm
x=doubleNorm1(di); // double L1-norm

◆ doubleNorm2

template<typename T, int dim>
double doubleNorm2 ( const FVector< T, dim > &  v)
friend

Double squared Euclidean norm

Parameters
vargument
Returns
Double squared Euclidean norm
x=doubleNorm2(di); // double squared Euclidean norm

◆ exp

template<typename T, int dim>
FVector exp ( const FVector< T, dim > &  a)
friend
Parameters
aFVector
Returns
Result
c=exp(a); // pointwise exp

◆ intL1Dist

template<typename T, int dim>
int intL1Dist ( const FVector< T, dim > &  a,
const FVector< T, dim > &  b 
)
friend

Integer L1-distance between two vectors with integer coordinates

Parameters
a,bFVector
Returns
Result
x=intL1Dist(di,di); // Integer L1-distance

◆ intNorm1

template<typename T, int dim>
int intNorm1 ( const FVector< T, dim > &  v)
friend

Integer L1-Euclidean norm ((to avoid overflow for vectors of char or short ints)

Parameters
vargument
Returns
Integer L1-norm.
i=intNorm1(di); // integer L1-norm

◆ intNorm2

template<typename T, int dim>
int intNorm2 ( const FVector< T, dim > &  v)
friend

Integer squared Euclidean norm ((to avoid overflow for vectors of char or short ints)

Parameters
vargument
Returns
Integer squared Euclidean norm
int i=intNorm2(di); // integer squared Euclidean norm

◆ L1Dist

template<typename T, int dim>
double L1Dist ( const FVector< T, dim > &  a,
const FVector< T, dim > &  b 
)
friend

Double L1-distance between two vectors, regardless of their type

Parameters
a,bFVector
Returns
Result
x=intL1Dist(di,di); // Integer L1-distance

◆ log

template<typename T, int dim>
FVector log ( const FVector< T, dim > &  a)
friend
Parameters
aFVector
Returns
Result
c=log(a); // pointwise log

◆ maxNorm

template<typename T, int dim>
T maxNorm ( const FVector< T, dim > &  v)
friend

Maximum norm

Parameters
vargument
Returns
Maximum norm
x=maxNorm(a); // Maximum norm

◆ mult

template<typename T, int dim>
FVector mult ( const FVector< T, dim > &  v,
const FVector< T, dim > &  w 
)
friend

Multiplies coordinates two by two

Parameters
v,wFVector
Returns
v*w
c=mult(a,b); // pointwise *

◆ norm

template<typename T, int dim>
T norm ( const FVector< T, dim > &  v)
friend

Euclidean norm (NB: assuming T type is OK)

Parameters
vargument
Returns
Euclidean norm
x=norm2(a); // squared Euclidean norm

◆ norm2

template<typename T, int dim>
T norm2 ( const FVector< T, dim > &  v)
friend

Squared Euclidean norm (NB: assuming T type is OK)

Parameters
vargument
Returns
squared Euclidean norm
x=norm2(a); // squared Euclidean norm

◆ normalized

template<typename T, int dim>
FVector normalized ( const FVector< T, dim > &  v)
friend

Normalization using Euclidean norm

Parameters
vFVector to normalize
Returns
normalized vector
c=normalized(dd); // Euclidean normalization

◆ operator*

template<typename T, int dim>
FVector operator* ( s,
const FVector< T, dim > &  v 
)
friend

Multiplies each coordinate by a scalar

Parameters
sThe scalar
vThe FVector
Returns
The result
c=2.*a; // scalar * FVector

◆ operator+

template<typename T, int dim>
FVector operator+ ( s,
const FVector< T, dim > &  v 
)
friend

Adds a scalar to each coordinate

Parameters
sThe scalar
vThe FVector
Returns
The result
c=2.+a; // scalar + FVector

◆ operator-

template<typename T, int dim>
FVector operator- ( s,
const FVector< T, dim > &  v 
)
friend

Substract each coordinate to a scalar

Parameters
sThe scalar
vThe FVector
Returns
The result
c=2.-a; // scalar - FVector

◆ pmax

template<typename T, int dim>
FVector pmax ( const FVector< T, dim > &  a,
const FVector< T, dim > &  b 
)
friend

Max of each coordinate

Parameters
a,bFVector
Returns
Result
c=pmax(a,b); // pointwise max

◆ pmin

template<typename T, int dim>
FVector pmin ( const FVector< T, dim > &  a,
const FVector< T, dim > &  b 
)
friend

Min of each coordinate

Parameters
a,bFVector
Returns
Result
c=pmin(a,b); // pointwise min

◆ sqrt

template<typename T, int dim>
FVector sqrt ( const FVector< T, dim > &  a)
friend
Parameters
aFVector
Returns
Result
c=sqrt(a); // pointwise sqrt

◆ squaredDist

template<typename T, int dim>
double squaredDist ( const FVector< T, dim > &  a,
const FVector< T, dim > &  b 
)
friend

Squared distance between two vectors, whatever their type

Parameters
a,bFVector
Returns
Result
x=squaredDist(di,di); // squared distance

◆ sum

template<typename T, int dim>
T sum ( const FVector< T, dim > &  v)
friend

Sum of coordinates (beware of overflow)

Parameters
vargument
Returns
Result
x=sum(a); // sum of coordinates


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