Population
Image processing library in C++
Public Types | Public Member Functions | Friends | List of all members
pop::VecN< D, CoordinateType > Class Template Reference

tuple of numbers of fixed for the representation of a point or a vector as element position of a matrix More...

Public Types

enum  { DIM =D }
 
typedef int E
 
typedef CoordinateType F
 

Public Member Functions

 VecN ()
 
template<int D1, class G >
 VecN (const VecN< D1, G > &p)
 
 VecN (CoordinateType value)
 
 VecN (CoordinateType value0, CoordinateType value1)
 
 VecN (CoordinateType value0, CoordinateType value1, CoordinateType value2)
 
 VecN (CoordinateType value0, CoordinateType value1, CoordinateType value2, CoordinateType value3)
 
template<class G >
 VecN (const Vec< G > &x)
 
template<class G >
VecNoperator= (const VecN< D, G > &x)
 
VecNoperator= (CoordinateType value)
 
VecNoperator+= (const VecN &x)
 
VecNoperator+= (CoordinateType value)
 
VecN operator+ (const VecN &x) const
 
VecN operator+ (CoordinateType value) const
 
VecNoperator-= (const VecN &x)
 
VecNoperator-= (CoordinateType value)
 
VecN operator- (const VecN &x) const
 
VecN operator- (CoordinateType value) const
 
VecN operator- () const
 
VecNoperator*= (const VecN &x)
 
VecNoperator*= (CoordinateType value)
 
VecN operator* (const VecN &x) const
 
VecN operator* (CoordinateType value) const
 
VecNoperator/= (const VecN &x)
 
VecNoperator/= (CoordinateType value)
 
VecN operator/ (const VecN &x) const
 
VecN operator/ (CoordinateType value) const
 
bool allSuperiorEqual (const VecN &x) const
 
bool operator>= (const VecN &x) const
 
bool allInferiorEqual (const VecN &x) const
 
bool operator<= (const VecN &x) const
 
bool allSuperior (const VecN &x) const
 
bool operator> (const VecN &x) const
 
bool allInferior (const VecN &x) const
 
bool operator< (const VecN &x) const
 
bool operator== (const VecN &x) const
 
bool operator== (CoordinateType value) const
 
bool operator!= (const VecN &x) const
 
const CoordinateType & operator[] (int i) const
 
CoordinateType & operator[] (int i)
 
const CoordinateType & operator() (int i) const
 
CoordinateType & operator() (int i)
 
CoordinateType multCoordinate () const
 
F32 norm (int p=2) const
 
F32 normPower (int p=2) const
 
CoordinateType minCoordinate () const
 
CoordinateType maxCoordinate () const
 
void load (const char *file)
 
void save (const char *file) const
 
VecNclone () const
 
VecN< DIM+1, CoordinateType > addCoordinate (int coordinate, CoordinateType value)
 
VecN< DIM-1, CoordinateType > removeCoordinate (int coordinate)
 
void display ()
 
CoordinateType * data ()
 
const CoordinateType * data () const
 

Friends

template<int D1, class Type1 >
VecN< D1, Type1 > operator/ (Type1 value, const VecN< D1, Type1 > &v)
 

Detailed Description

template<int D = 2, class CoordinateType = int>
class pop::VecN< D, CoordinateType >

tuple of numbers of fixed for the representation of a point or a vector as element position of a matrix

Author
Tariel Vincent
Template Parameters
DSpace dimension (size of the vector)
CoordinateTypeelement type

The template class VecN is a fixed-size arrays of consecutive elements of the same type taking two template parameters:

For instance with a constant value equal 2 and a type equal to integer type, it allows to access of an element of a matrix. We have x=(x(0),x(1))=(i,j) where the first one represents the vertical from top to down and the second one represents the horizontal from left to right .

PointData.png

To facilitate its utilisation, we use some typedef declarations to define the usual types to allow coding in C-style as these ones:

For instance for a 2d grey-level matrix, this code:

Mat2UI8 img(3,3);
Vec2I32 x;
x(0)=1;x(1)=1;//x=(1,1)
img(x)=255;
std::cout<<img;

produce this output
0 0 0
0 255 0
0 0 0


A fixed-size array allows code optimization with a specialization for D=2 and D=3.

Member Typedef Documentation

template<int D = 2, class CoordinateType = int>
pop::VecN< D, CoordinateType >::E

index type to access elements

template<int D = 2, class CoordinateType = int>
pop::VecN< D, CoordinateType >::F

type of the consecutive elements

Member Enumeration Documentation

template<int D = 2, class CoordinateType = int>
anonymous enum
Enumerator
DIM 

Space dimension

Constructor & Destructor Documentation

template<int D = 2, class CoordinateType = int>
pop::VecN< D, CoordinateType >::VecN ( )
inline

default constructor

template<int D = 2, class CoordinateType = int>
template<int D1, class G >
pop::VecN< D, CoordinateType >::VecN ( const VecN< D1, G > &  p)
inline
Parameters
pcopied VecN

copy constructor

template<int D = 2, class CoordinateType = int>
pop::VecN< D, CoordinateType >::VecN ( CoordinateType  value)
inline
Parameters
valueinput value

all elements are equal to this value

template<int D = 2, class CoordinateType = int>
pop::VecN< D, CoordinateType >::VecN ( CoordinateType  value0,
CoordinateType  value1 
)
inline
Parameters
value0input value for the first channel
value1input value for the second channel
template<int D = 2, class CoordinateType = int>
pop::VecN< D, CoordinateType >::VecN ( CoordinateType  value0,
CoordinateType  value1,
CoordinateType  value2 
)
inline
Parameters
value0input value for the first channel
value1input value for the second channel
value2input value for the third channel
template<int D = 2, class CoordinateType = int>
pop::VecN< D, CoordinateType >::VecN ( CoordinateType  value0,
CoordinateType  value1,
CoordinateType  value2,
CoordinateType  value3 
)
inline
Parameters
value0input value for the first channel
value1input value for the second channel
value2input value for the third channel
value3input value for the fourth channel
template<int D = 2, class CoordinateType = int>
template<class G >
pop::VecN< D, CoordinateType >::VecN ( const Vec< G > &  x)
inline
Parameters
xinput Vec

constructor with a vector

See also
Vec

Member Function Documentation

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::allInferior ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

return true for each elements of this VecN is strictly less than to the element of same index of the other VecN, false otherwise

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::allInferiorEqual ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

return true for each elements of this VecN is strictly less or equal than to the element of same index of the other VecN, false otherwise

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::allSuperior ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

return true for each elements of this VecN is strictly greater than to the element of same index of the other VecN, false otherwise

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::allSuperiorEqual ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

return true for each elements of this VecN is strictly greater or equal than to the element of same index of the other VecN, false otherwise

template<int D = 2, class CoordinateType = int>
VecN* pop::VecN< D, CoordinateType >::clone ( ) const
inline

clone the VecN

template<int D = 2, class CoordinateType = int>
CoordinateType* pop::VecN< D, CoordinateType >::data ( )
inline

Return a ptr to the first vector value

direct access to the vector data

template<int D = 2, class CoordinateType = int>
const CoordinateType* pop::VecN< D, CoordinateType >::data ( ) const
inline

Return a ptr to the first vector value

direct access to the vector data

template<int D = 2, class CoordinateType = int>
void pop::VecN< D, CoordinateType >::load ( const char *  file)
inline
Parameters
fileinput file

load the values elements from the input file

template<int D = 2, class CoordinateType = int>
CoordinateType pop::VecN< D, CoordinateType >::maxCoordinate ( ) const
inline
Returns
min coordinate

returns the min coordinate for x = (7,-2), we have x.minCoordinate()=max(7,-2)=7

template<int D = 2, class CoordinateType = int>
CoordinateType pop::VecN< D, CoordinateType >::minCoordinate ( ) const
inline
Returns
min coordinate

returns the min coordinate for x = (7,-2), we have x.minCoordinate()=min(7,-2)=-2

template<int D = 2, class CoordinateType = int>
CoordinateType pop::VecN< D, CoordinateType >::multCoordinate ( ) const
inline
Returns
coordinate multiplication

Multiplies all elements of this VecNs for instance x=(5,6,20) x.multCoordinate()=5*6*20=600

template<int D = 2, class CoordinateType = int>
F32 pop::VecN< D, CoordinateType >::norm ( int  p = 2) const
inline

\ param p norm

Returns
p-norm

returns the p-norm of this vector for instance for x = (7,-2), we have x.norm(1)=abs(7)+abs(-2)=9

template<int D = 2, class CoordinateType = int>
F32 pop::VecN< D, CoordinateType >::normPower ( int  p = 2) const
inline
Returns
p-norm power p

returns the p-norm at power 2pof this VecN for instance for x = (7,-2), we have x.normPower(2)=7*7+-2*-2=53

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::operator!= ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

return true for at least one elements of this VecN is different to the element of same index of the other VecN, false otherwise

template<int D = 2, class CoordinateType = int>
CoordinateType& pop::VecN< D, CoordinateType >::operator() ( int  i)
inline
Parameters
iindex
Returns
element

Access to the element at the given index

template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator* ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
this VecN

Multiplies term by term

See also
productInner(const pop::VecN<D, Type1>& x1,const pop::VecN<D, Type2>& x2)
template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator* ( CoordinateType  value) const
inline
Parameters
valuefactor
Returns
output VecN

multiplication of the factor value to all elements of this VecN

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator*= ( const VecN< D, CoordinateType > &  x)
inline
Parameters
xother VecN
Returns
this VecN

Multiply the contents of other to this VecN.

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator*= ( CoordinateType  value)
inline
Parameters
valuefactor
Returns
this VecN

Multiplies all elements of this VecN by factor.

template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator+ ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
output VecN

addition of this VecNs by the other VecN

template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator+ ( CoordinateType  value) const
inline
Parameters
valuefactor
Returns
output VecN

addition of the factor value to all elements of this VecN

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator+= ( const VecN< D, CoordinateType > &  x)
inline
Parameters
xother VecN
Returns
this VecN

Adds the contents of other to this VecN.

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator+= ( CoordinateType  value)
inline
Parameters
valuevalue
Returns
this VecN

Adds all element of this VecN of this VecN by the factor value

template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator- ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
output VecN

subtraction of this VecN u by the other VecN v

template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator- ( CoordinateType  value) const
inline
Parameters
valuefactor
Returns
output VecN

Subtraction to all elements of this VecN by the factor value $(u_1-value,u_2-value) $

template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator- ( ) const
inline
Returns
minus

minus operator

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator-= ( const VecN< D, CoordinateType > &  x)
inline
Parameters
xother VecN
Returns
this VecN

Subtracts the contents of other to this VecN.

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator-= ( CoordinateType  value)
inline
Parameters
valuefactor
Returns
this VecN

Subtracts all element of this VecN of this VecN by the factor value

template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator/ ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
this VecN

Divide term by term the contents of other to this VecN.

template<int D = 2, class CoordinateType = int>
VecN pop::VecN< D, CoordinateType >::operator/ ( CoordinateType  value) const
inline
Parameters
valuefactor
Returns
output VecN

division by the factor value to all elements of this VecN $(u_1/value,u_2/value) $

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator/= ( const VecN< D, CoordinateType > &  x)
inline
Parameters
xother VecN
Returns
this VecN

Divide term by term the contents of other to this VecN.

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator/= ( CoordinateType  value)
inline
Parameters
valuefactor
Returns
this VecN

Divides all elements of this VecN by factor value

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::operator< ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

relation order, return true if it exists i>=0 this[i]<x[i] and for all 0<=j<i this[j]=x[j], false otherwise

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::operator<= ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

relation order, return true if it exists i>=0 this[i]<x[i] and for all 0<=j<i this[j]=x[j] or (forall i this[i]=x[i]), false otherwise

template<int D = 2, class CoordinateType = int>
template<class G >
VecN& pop::VecN< D, CoordinateType >::operator= ( const VecN< D, G > &  x)
inline
Parameters
xother VecN
Returns
this VecN

Basic assignment of this VecN by other

template<int D = 2, class CoordinateType = int>
VecN& pop::VecN< D, CoordinateType >::operator= ( CoordinateType  value)
inline
Parameters
valuefactor
Returns
this VecN

Basic assignment of all elements of VecN by the factor value

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::operator== ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

return true for each elements of this VecN is equal to the element of same index of the other VecN, false otherwise

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::operator== ( CoordinateType  value) const
inline
Parameters
valuefactor
Returns
boolean

return true for all elements of this VecN is equal to the factor, false otherwise

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::operator> ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

relation order, return true if it exists i>=0 this[i]>x[i] and for all 0<=j<i this[j]=x[j], false otherwise

template<int D = 2, class CoordinateType = int>
bool pop::VecN< D, CoordinateType >::operator>= ( const VecN< D, CoordinateType > &  x) const
inline
Parameters
xother VecN
Returns
boolean

relation order, return true if (it exists i>=0 this[i]>x[i] and for all 0<=j<i this[j]=x[j]) or (forall i this[i]=x[i]), false otherwise

template<int D = 2, class CoordinateType = int>
CoordinateType& pop::VecN< D, CoordinateType >::operator[] ( int  i)
inline
Parameters
iindex
Returns
element

Access to the element at the given index

template<int D = 2, class CoordinateType = int>
void pop::VecN< D, CoordinateType >::save ( const char *  file) const
inline
Parameters
fileinput file

save the values elements to the input file

Friends And Related Function Documentation

template<int D = 2, class CoordinateType = int>
template<int D1, class Type1 >
VecN<D1, Type1> operator/ ( Type1  value,
const VecN< D1, Type1 > &  v 
)
friend
Parameters
vVecN
valuefactor
Returns
output VecN

division of the factor value to all elements of the VecN $(value/v_1,value/v_2) $


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