DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
DGtal::PointVector< dim, TEuclideanRing > Class Template Reference

#include <PointVector.h>

Inheritance diagram for DGtal::PointVector< dim, TEuclideanRing >:
Inheritance graph
[legend]
Collaboration diagram for DGtal::PointVector< dim, TEuclideanRing >:
Collaboration graph
[legend]

Public Types

enum  NormType { L_2, L_1, L_infty }
typedef PointVector< dim,
TEuclideanRing > 
Self
typedef TEuclideanRing Component
typedef Component Coordinate
typedef NumberTraits
< Component >::UnsignedVersion 
UnsignedComponent
typedef DGtal::Dimension Dimension
typedef boost::array
< Component, dimension >
::iterator 
Iterator
typedef boost::array
< Component, dimension >
::const_iterator 
ConstIterator
typedef boost::array
< Component, dimension >
::reverse_iterator 
ReverseIterator
typedef boost::array
< Component, dimension >
::const_reverse_iterator 
ConstReverseIterator

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CEuclideanRing< TEuclideanRing >))
 PointVector ()
 PointVector (const Component *ptrValues)
 PointVector (const Component &x, const Component &y)
 PointVector (const Component &x, const Component &y, const Component &z)
 PointVector (const Component &x, const Component &y, const Component &z, const Component &t)
template<typename Functor >
 PointVector (const Self &apoint1, const Self &apoint2, const Functor &f)
 ~PointVector ()
 PointVector (const Self &other)
template<typename OtherComponent >
 PointVector (const PointVector< dim, OtherComponent > &other)
Selfoperator= (const Self &pv)
SelfpartialCopy (const Self &pv, const std::vector< Dimension > &dimensions)
SelfpartialCopyInv (const Self &pv, const std::vector< Dimension > &dimensions)
bool partialEqual (const Self &pv, const std::vector< Dimension > &dimensions) const
bool partialEqualInv (const Self &pv, const std::vector< Dimension > &dimensions) const
Iterator begin ()
Iterator end ()
ConstIterator begin () const
ConstIterator end () const
ReverseIterator rbegin ()
ReverseIterator rend ()
ConstReverseIterator rbegin () const
ConstReverseIterator rend () const
const Componentat (Dimension i) const
Componentat (Dimension i)
const Componentoperator[] (Dimension i) const
Componentoperator[] (Dimension i)
bool operator== (const Self &pv) const
bool operator!= (const Self &pv) const
bool operator< (const Self &pv) const
bool operator<= (const Self &pv) const
bool operator> (const Self &pv) const
bool operator>= (const Self &pv) const
PointVectoroperator*= (Component coeff)
PointVector operator* (Component coeff) const
Component dot (const Self &v) const
Selfoperator+= (const Self &v)
Self operator+ (const Self &v) const
Selfoperator-= (const Self &v)
Self operator- (const Self &v) const
Selfoperator/= (const Self &v)
Self operator/ (const Self &v) const
Self operator/ (const Component coeff)
Selfoperator/= (const Component coeff)
template<typename AnotherComponent >
Selfoperator= (const PointVector< dim, AnotherComponent > &v)
void reset ()
Self inf (const Self &apoint) const
Self sup (const Self &apoint) const
bool isLower (const Self &p) const
bool isUpper (const Self &p) const
Component max () const
Component min () const
Iterator maxElement ()
Iterator minElement ()
void negate ()
double norm (const NormType type=L_2) const
UnsignedComponent norm1 () const
UnsignedComponent normInfinity () const
PointVector< dim, double > getNormalized () const
std::string className () const
void selfDisplay (std::ostream &out) const
bool isValid () const
template<typename Component2 >
DGtal::PointVector< dim,
TComponent > & 
operator= (const DGtal::PointVector< dim, Component2 > &v)

Static Public Member Functions

static Dimension size ()
static Self diagonal (Component val=1)
static Self base (Dimension k, Component val=1)

Data Fields

boost::array< Component,
dimension
myArray

Static Public Attributes

static const Dimension dimension = dim
static Self zero

Detailed Description

template<DGtal::Dimension dim, typename TEuclideanRing>
class DGtal::PointVector< dim, TEuclideanRing >

Aim: Implements basic operations that will be used in Point and Vector classes.

Description of class 'PointVector'

A PointVector may represent either a symbolic point or a symbolic vector depending on the context. The coordinates of the point or the components of the vector should be part of a ring. For performance reasons, these two types are just aliases. The user should take care how to use it depending on the context. For instance, adding two points has no meaning, but will be authorized by the compiler.

Template Parameters:
dimstatic constant of type DGtal::Dimension that specifies the static dimension of the space and thus the number of elements of the Point or Vector.
TEuclideanRingspeficies the number type assoicated to an Euclidean domain (or Euclidean ring) algebraic structure (commutative unitary ring with no zero divisors and with a division operator but not necessarily an inverse for the multiplication operator). This type is used to represent PointVector elements (Coordinate for Point and Component for Vector) and define operations on Point or Vectors.

If TEuclideanRing is a Integer type (built-in integers, BigIntegers, ...), the "/" operator on Points corresponds to component by component Euclidean division.

If TEuclideanRing is a double, the "/" operator on Points correspond to the classical division on real numbers (x*1/x = 1).

The default less than operator is the one of the lexicographic ordering, starting from dimension 0 to N-1.

PointVector also realizes the concept CLattice with an infimum (meet, greatest lower bound) and a supremum (join, least upper bound) operation.

Usage example:

...
typedef PointVector<5, int> VectorD5;
VectorD5 p, q, r;
p.at(1) = 2; // p = {0, 2, 0, 0, 0}
q.at(3) = -5 // q = {0, 0, 0, -5, 0}
r = p + q ; // r = {0, 2, 0, -5, 0}
...

PointVector is a model of CBidirectionalRange.

See also:
testPointVector.cpp

Definition at line 153 of file PointVector.h.


Member Typedef Documentation

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef TEuclideanRing DGtal::PointVector< dim, TEuclideanRing >::Component

Type for Vector elements.

Definition at line 164 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef boost::array<Component, dimension>::const_iterator DGtal::PointVector< dim, TEuclideanRing >::ConstIterator

Definition at line 189 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef boost::array<Component, dimension>::const_reverse_iterator DGtal::PointVector< dim, TEuclideanRing >::ConstReverseIterator

Definition at line 191 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef Component DGtal::PointVector< dim, TEuclideanRing >::Coordinate

Type for Point elements.

Definition at line 167 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef DGtal::Dimension DGtal::PointVector< dim, TEuclideanRing >::Dimension

Copy of the dimension type.

Definition at line 173 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef boost::array<Component, dimension>::iterator DGtal::PointVector< dim, TEuclideanRing >::Iterator

Copy of the Boost::array iterator type

Definition at line 188 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef boost::array<Component, dimension>::reverse_iterator DGtal::PointVector< dim, TEuclideanRing >::ReverseIterator

Definition at line 190 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef PointVector<dim, TEuclideanRing> DGtal::PointVector< dim, TEuclideanRing >::Self

Self type.

Definition at line 161 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
typedef NumberTraits<Component>::UnsignedVersion DGtal::PointVector< dim, TEuclideanRing >::UnsignedComponent

Unsigned version of the components.

Definition at line 170 of file PointVector.h.


Member Enumeration Documentation

template<DGtal::Dimension dim, typename TEuclideanRing>
enum DGtal::PointVector::NormType

Specify the set of norm types

Enumerator:
L_2 
L_1 
L_infty 

Definition at line 695 of file PointVector.h.

{ L_2, L_1, L_infty };

Constructor & Destructor Documentation

template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::PointVector ( )
inline

Constructor.

Definition at line 70 of file PointVector.ih.

{
for ( Dimension i = 0; i < dim; ++i )
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::PointVector ( const Component ptrValues)
inlineexplicit

Constructor from array of values.

Parameters:
ptrValuesthe array of values.

Definition at line 94 of file PointVector.ih.

{
// The problem here is that we have no guaranty on the size of init !!
for ( Dimension i = 0; i < dim; ++i )
myArray[ i ] = ptrValues[ i ];
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::PointVector ( const Component x,
const Component y 
)
inline

Constructor from two values (the Dimension of the vector should be at least 2). Other components are set to 0.

Parameters:
xthe first value.
ythe second value.

Definition at line 103 of file PointVector.ih.

{
ASSERT( dim >= 2 );
myArray[ 0 ] = x;
myArray[ 1 ] = y;
for ( Dimension i = 2; i < dim; ++i )
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::PointVector ( const Component x,
const Component y,
const Component z 
)
inline

Constructor from three values (the Dimension of the vector should be at least 3). Other components are set to 0.

Parameters:
xthe first value.
ythe second value.
zthe third value.

Definition at line 114 of file PointVector.ih.

{
ASSERT( dim >= 3 );
myArray[ 0 ] = x;
myArray[ 1 ] = y;
myArray[ 2 ] = z;
for ( Dimension i = 3; i < dim; ++i )
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::PointVector ( const Component x,
const Component y,
const Component z,
const Component t 
)
inline

Constructor from four values (the Dimension of the vector should be at least 4). Other components are set to 0.

Parameters:
xthe first value.
ythe second value.
zthe third value.
tthe fourth value.

Definition at line 128 of file PointVector.ih.

{
ASSERT( dim >= 4 );
myArray[ 0 ] = x;
myArray[ 1 ] = y;
myArray[ 2 ] = z;
myArray[ 3 ] = t;
for ( Dimension i = 4; i < dim; ++i )
}
template<Dimension dim, typename TComponent >
template<typename Functor >
DGtal::PointVector< dim, TComponent >::PointVector ( const Self apoint1,
const Self apoint2,
const Functor &  f 
)
inline

Constructor taking apoint and a functor as parameters. The new point is initialized by the result of functor f for each coordinate of apoint1 and apoint2

Definition at line 79 of file PointVector.ih.

{
for ( Dimension i = 0; i < dim; ++i )
myArray[ i ] = f.operator() (apoint1[i], apoint2[i]);
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::~PointVector ( )
inline

Destructor.

Definition at line 89 of file PointVector.ih.

{}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::PointVector ( const Self other)
inline

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 157 of file PointVector.ih.

: myArray( other.myArray )
{}
template<Dimension dim, typename TComponent >
template<typename OtherComponent >
DGtal::PointVector< dim, TComponent >::PointVector ( const PointVector< dim, OtherComponent > &  other)
inline

Copy constructor from another component PointVector. A static cast is used to cast the values during the copy.

Parameters:
otherthe object to clone.

Definition at line 164 of file PointVector.ih.

{
for ( Dimension i = 0; i < dimension; ++i )
this->myArray[ i ] = (int)(static_cast<OtherComponent>(other[ i ]));
}

Member Function Documentation

template<Dimension dim, typename TComponent >
const DGtal::PointVector< dim, TComponent >::Component & DGtal::PointVector< dim, TComponent >::at ( Dimension  i) const
inline
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Component & DGtal::PointVector< dim, TComponent >::at ( Dimension  i)
inline

Returns a non-const reference to the i-th element of the vector.

Precondition:
The i index must lie between 0 and size() .
Parameters:
iis the index of the retrieved coefficient.

Definition at line 254 of file PointVector.ih.

{
ASSERT ( i < dim );
return myArray.at( i );
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::base ( Dimension  k,
Component  val = 1 
)
inlinestatic
Parameters:
kany number between 0 and Dimension-1.
valany value.
Returns:
the [k]-th base vector (0,0, ..., 0, val, 0, ..., 0).

Definition at line 720 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
Self p;
p.myArray[ k ] = val;
return p;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Iterator DGtal::PointVector< dim, TComponent >::begin ( )
inline

PointVector begin() iterator.

Returns:
an Iterator on the first element of a Point/Vector.

Definition at line 173 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::begin().

Referenced by DGtal::PointVector< dim, TEuclideanRing >::begin(), and DGtal::HyperRectDomain< TSpace >::size().

{
return myArray.begin();
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::ConstIterator DGtal::PointVector< dim, TComponent >::begin ( ) const
inline

PointVector begin() const iterator.

Returns:
an ConstIterator on the first element of a Point/Vector.

Definition at line 189 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::begin().

{
return myArray.begin();
}
template<DGtal::Dimension dim, typename TEuclideanRing>
DGtal::PointVector< dim, TEuclideanRing >::BOOST_CONCEPT_ASSERT ( (CEuclideanRing< TEuclideanRing >)  )
template<Dimension dim, typename TComponent >
std::string DGtal::PointVector< dim, TComponent >::className ( ) const
inline

Default drawing style object.

Returns:
the dyn. alloc. default style for this object.
the style name used for drawing this object.

Definition at line 742 of file PointVector.ih.

Referenced by DGtal::Display3DFactory::draw(), and DGtal::Display2DFactory::draw().

{
return "PointVector";
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::diagonal ( Component  val = 1)
inlinestatic
Parameters:
valany value.
Returns:
the diagonal vector (val,val, .. val).

Definition at line 709 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
Self p;
for ( Dimension i = 0; i < dim; ++i )
p.myArray[ i ] = val;
return p;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Component DGtal::PointVector< dim, TComponent >::dot ( const Self v) const
inline

dot product with a PointVector

Parameters:
va vector that is dot-producted to *this.
Returns:
the dot product of this and v.

Definition at line 526 of file PointVector.ih.

{
for ( Dimension i = 0; i < dim; ++i )
dotprod += this->myArray[ i ]*v[ i ];
return dotprod;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Iterator DGtal::PointVector< dim, TComponent >::end ( )
inline

PointVector end() iterator.

Returns:
an Iterator on the last element of a Point/Vector.

Definition at line 181 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::end().

Referenced by DGtal::PointVector< dim, TEuclideanRing >::end(), and DGtal::HyperRectDomain< TSpace >::size().

{
return myArray.end();
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::ConstIterator DGtal::PointVector< dim, TComponent >::end ( ) const
inline

PointVector end() const iterator.

Returns:
a ConstIterator on the last element of a Point/Vector.

Definition at line 197 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::end().

{
return myArray.end();
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, double > DGtal::PointVector< dim, TComponent >::getNormalized ( ) const
inline

Compute the normalization of a given vector (*this) and return a unitary vector on double.

Returns:
a unitary vector with double as coordiante type.

Definition at line 699 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::norm().

{
PointVector<dim,double> normalized =(*this);
normalized /= normalized.norm();
return normalized;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::inf ( const Self apoint) const
inline

Implements the infimum (or greatest lower bound). It means the point whose coordinates are exactly the minimum of the two points coordinate by coordinate.

Parameters:
apointany point.
Returns:
a new point being the inf between *this and apoint.
See also:
isLower

Definition at line 554 of file PointVector.ih.

{
return Self(*this, apoint, MinFunctor<Component>());
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::isLower ( const Self p) const
inline
Parameters:
pany point.
Returns:
true if this is below p (ie. this==inf(this,p)) NB: faster than computing the infimum and compare it afterwards.

Definition at line 570 of file PointVector.ih.

{
for ( Dimension i = 0; i < myArray.size(); ++i )
if ( p[ i ] < myArray[ i ] )
return false;
return true;
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::isUpper ( const Self p) const
inline
Parameters:
pany point.
Returns:
true if this is upper p (ie. this==sup(this,p)) NB: faster than computing the supremum and compare it afterwards.

Definition at line 581 of file PointVector.ih.

{
for ( Dimension i = 0; i < myArray.size(); ++i )
if ( p[ i ] > myArray[ i ] )
return false;
return true;
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.

Definition at line 761 of file PointVector.ih.

{
return true;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Component DGtal::PointVector< dim, TComponent >::max ( ) const
inline

Return the maximum component value of a point/vector.

Returns:
the maximum value.

Definition at line 592 of file PointVector.ih.

{
return *std::max_element(this->begin(), this->end());
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Iterator DGtal::PointVector< dim, TComponent >::maxElement ( )
inline

Return the iterator on the component with maximim value of a point/vector.

Returns:
an iterator.

Definition at line 608 of file PointVector.ih.

{
return std::max_element(this->begin(), this->end());
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Component DGtal::PointVector< dim, TComponent >::min ( ) const
inline

Return the minimum component value of a point/vector.

Returns:
the minimum value.

Definition at line 600 of file PointVector.ih.

{
return *std::min_element(this->begin(), this->end());
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Iterator DGtal::PointVector< dim, TComponent >::minElement ( )
inline

Return the iterator on the component with minimum value of a point/vector.

Returns:
an iterator.

Definition at line 616 of file PointVector.ih.

{
return std::min_element(this->begin(), this->end());
}
template<Dimension dim, typename TComponent >
void DGtal::PointVector< dim, TComponent >::negate ( )
inline

Negates this vector.

Definition at line 625 of file PointVector.ih.

Referenced by DGtal::COBANaivePlane< TSpace, TInternalInteger >::doubleCut().

{
for ( Dimension i = 0; i < dimension; ++i )
this->myArray[ i ] = - this->myArray[ i ];
}
template<Dimension dim, typename TComponent >
double DGtal::PointVector< dim, TComponent >::norm ( const NormType  type = L_2) const
inline

Computes the norm of a point/vector.

Warning:
This method performs a conversion from the type T to double for each components to compute the norms. For exact norms (restricted to L_1 and L_infinity norms), please refer to PointVector::norm1 and PointVector::normInfinity.
Parameters:
typespecifies the type of norm to consider (see NormType).
Returns:
the norm of the point/vector as a double.

Definition at line 634 of file PointVector.ih.

References DGtal::NumberTraits< T >::castToDouble().

Referenced by DGtal::FPLengthEstimator< TConstIterator >::eval(), DGtal::MLPLengthEstimator< TConstIterator >::eval(), DGtal::DigitalSurface< TDigitalSurfaceContainer >::exportEmbeddedIteratedSurfaceAs3DNOFF(), DGtal::PointVector< dim, TEuclideanRing >::getNormalized(), and DGtal::ArithmeticalDSS< TIterator, TInteger, connectivity >::projectedSegmentLength().

{
double tmp = 0.0;
ASSERT ( dim > 0 );
switch ( aType )
{
case L_2:
for ( Dimension i = 0; i < dimension; i++ )
tmp = ( double ) sqrt ( tmp );
break;
case L_1:
for ( Dimension i = 0; i < dimension; i++ )
break;
case L_infty:
for ( Dimension i = 1; i < dimension; i++ )
if ( tmp < fabs ( NumberTraits<Component>::castToDouble(at ( i ) ) ))
break;
}
return tmp;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::UnsignedComponent DGtal::PointVector< dim, TComponent >::norm1 ( ) const
inline

Computes the 1-norm of a vector.

Returns:
the absolute sum of the components of this vector.

Definition at line 666 of file PointVector.ih.

{
ASSERT ( dimension > 0 );
( ( myArray[ 0 ] >= 0 ) ? myArray[ 0 ] : UnsignedComponent(-myArray[ 0 ]) );
for ( Dimension i = 1; i < dimension; ++i )
val += ( myArray[ i ] >= 0 )
? myArray[ i ]
return val;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::UnsignedComponent DGtal::PointVector< dim, TComponent >::normInfinity ( ) const
inline

Computes the infinity-norm of a vector.

Returns:
the maximum absolute value of the components of this vector.

Definition at line 681 of file PointVector.ih.

{
ASSERT ( dimension > 0 );
UnsignedComponent val( ( myArray[ 0 ] >= 0 ) ? myArray[ 0 ] : -myArray[ 0 ] );
for ( Dimension i = 1; i < dimension; ++i )
{
tmp = ( myArray[ i ] >= 0 ) ? myArray[ i ] : -myArray[ i ] ;
if ( tmp > val )
val = tmp;
}
return val;
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::operator!= ( const Self pv) const
inline

Difference operator on Points/Vectors.

Parameters:
pvthe Point/Vector to compare to this.
Returns:
true iff this differs from pv, false otherwise.

Definition at line 419 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
return (myArray != pv.myArray);
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::operator* ( Component  coeff) const

Multiplication operator with a scalar number

Parameters:
coeffis the factor 'this' is multiplied by.
Returns:
a new Point that is the multiplication of 'this' by coeff.

Definition at line 289 of file PointVector.ih.

{
Self v = *this;
v *= coeff;
return v;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > & DGtal::PointVector< dim, TComponent >::operator*= ( Component  coeff)

Multiplies *this by the coeff scalar number.

Parameters:
coeffis the factor *this get multiplied by.
Returns:
a reference on 'this'.

Definition at line 280 of file PointVector.ih.

{
for ( Dimension i = 0; i < myArray.size(); ++i )
myArray[ i ] *= coeff;
return *this;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::operator+ ( const Self v) const
inline

Addition operator.

Parameters:
vis the Point that gets added to *this.
Returns:
a new Point that is the addition of 'this' to [v].

Definition at line 469 of file PointVector.ih.

{
return Self(*this, v, std::plus<Component>());
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > & DGtal::PointVector< dim, TComponent >::operator+= ( const Self v)
inline

Addition operator with assignement.

Parameters:
vis the Point that gets added to *this.
Returns:
a reference on 'this'.

Definition at line 459 of file PointVector.ih.

{
for ( Dimension i = 0; i < dim; ++i )
this->myArray[ i ] += v[ i ];
return *this;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::operator- ( const Self v) const
inline

Substraction operator. Point - Vector => Point

Parameters:
vis the Point that gets added to *this.
Returns:
a new Point that is the subtraction 'this'-[v].

Definition at line 537 of file PointVector.ih.

{
return Self(*this, v, MinusFunctor<Component>());
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > & DGtal::PointVector< dim, TComponent >::operator-= ( const Self v)
inline

Substraction operator with assignement.

Parameters:
vis the Point that gets substracted to *this.
Returns:
a reference on 'this'.

Definition at line 477 of file PointVector.ih.

{
for ( Dimension i = 0; i < dim; ++i )
this->myArray[ i ] -= v[ i ];
return *this;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::operator/ ( const Self v) const
inline

Division operator.

Parameters:
vis the Point that gets divided to *this.
Returns:
the component division of *this by v.

Definition at line 497 of file PointVector.ih.

{
return Self(*this, v, std::divides<Component>());
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::operator/ ( const Component  coeff)
inline

Divides *this by the coeff scalar number.

Parameters:
coeffis the factor *this get divided by.
Returns:
the component division of *this by coeff.

Definition at line 515 of file PointVector.ih.

{
Self p;
for ( Dimension i = 0; i < dimension; ++i )
p[i] = this->myArray[ i ] / coeff;
return p;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > & DGtal::PointVector< dim, TComponent >::operator/= ( const Self v)
inline

Division operator with assignement.

Parameters:
vis the Point that gets divided to *this.
Returns:
a reference on 'this'.

Definition at line 487 of file PointVector.ih.

{
for ( Dimension i = 0; i < dim; ++i )
this->myArray[ i ] /= v[ i ];
return *this;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > & DGtal::PointVector< dim, TComponent >::operator/= ( const Component  coeff)
inline

Divides *this by the coeff scalar number.

Parameters:
coeffis the factor *this get divided by.
Returns:
a reference on 'this'.

Definition at line 505 of file PointVector.ih.

{
for ( Dimension i = 0; i < dimension; ++i )
this->myArray[ i ] /= coeff;
return *this;
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::operator< ( const Self pv) const
inline

Comparison operator on Points/Vectors (LesserThan).

Parameters:
pvthe Point/Vector to compare to this.
Returns:
true iff this < pv, false otherwise.

Definition at line 427 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
return (myArray < pv.myArray);
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::operator<= ( const Self pv) const
inline

Comparison operator on Points/Vectors (LesserOrEqualThan).

Parameters:
pvthe Point/Vector to compare to this.
Returns:
true iff this <= pv, false otherwise.

Definition at line 435 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
return (myArray <= pv.myArray);
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > & DGtal::PointVector< dim, TComponent >::operator= ( const Self pv)
inline

Assignement Operator

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'.

Definition at line 299 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
myArray = pv.myArray;
return *this;
}
template<DGtal::Dimension dim, typename TEuclideanRing>
template<typename Component2 >
DGtal::PointVector<dim,TComponent>& DGtal::PointVector< dim, TEuclideanRing >::operator= ( const DGtal::PointVector< dim, Component2 > &  v)
inline

Definition at line 309 of file PointVector.ih.

{
for ( Dimension i = 0; i < dimension; ++i )
{
this->myArray[ i ] = static_cast<Component>(v[ i ]);
}
return *this;
}
template<DGtal::Dimension dim, typename TEuclideanRing>
template<typename AnotherComponent >
Self& DGtal::PointVector< dim, TEuclideanRing >::operator= ( const PointVector< dim, AnotherComponent > &  v)

Assignment operator from PointVector with different component type. A static cast is used to cast the values during the copy.

Parameters:
vis the Point that gets divided to *this.
Returns:
a reference on 'this'.
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::operator== ( const Self pv) const
inline

Equality operator.

Parameters:
pvPoint/Vector to compare to this.
Returns:
true iff points are equal.

Definition at line 411 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
return (myArray == pv.myArray);
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::operator> ( const Self pv) const
inline

Comparison operator on Points/Vectors (GreaterThan).

Parameters:
pvthe Point/Vector to compare to this.
Returns:
true iff this > pv, false otherwise.

Definition at line 443 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
return (myArray > pv.myArray);
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::operator>= ( const Self pv) const
inline

Comparison operator on Points/Vectors (GreaterOrEqualThan).

Parameters:
pvthe Point/Vector to compare to this.
Returns:
true iff this >= pv, false otherwise.

Definition at line 451 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
return (myArray >= pv.myArray);
}
template<Dimension dim, typename TComponent >
const DGtal::PointVector< dim, TComponent >::Component & DGtal::PointVector< dim, TComponent >::operator[] ( Dimension  i) const
inline

Returns the i-th coefficient of the vector.

Precondition:
The i index must lie between 0 and size() .
Parameters:
iis the index of the retrieved coefficient.

Definition at line 263 of file PointVector.ih.

{
ASSERT ( i < dim );
return myArray[i];
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::Component & DGtal::PointVector< dim, TComponent >::operator[] ( Dimension  i)
inline

Returns a non-const reference to the i-th element of the vector.

Precondition:
The i index must lie between 0 and size() .
Parameters:
iis the index of the retrieved coefficient.

Definition at line 272 of file PointVector.ih.

{
ASSERT ( i < dim );
return myArray[i];
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > & DGtal::PointVector< dim, TComponent >::partialCopy ( const Self pv,
const std::vector< Dimension > &  dimensions 
)
inline

Partial copy of a given PointVector. Only coordinates in dimensions are copied.

Parameters:
otherthe object to copy.
dimthe dimensions of v to copy (Size between 0 and N, all differents).
Returns:
a reference on 'this'.

Definition at line 352 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
std::bitset<dim> dims = ::setDimensionsIn<dim>(dimensions);
for ( Dimension i = 0; i < dim; ++i )
{
if ( dims.test(i) ) myArray[i] = pv.myArray[i];
}
return *this;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > & DGtal::PointVector< dim, TComponent >::partialCopyInv ( const Self pv,
const std::vector< Dimension > &  dimensions 
)
inline

Partial copy of a given PointVector. Only coordinates not in dimensions are copied.

Parameters:
otherthe object to copy.
dimthe dimensions of v to copy (Size between 0 and N, all differents).
Returns:
a reference on 'this'.

Definition at line 367 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

Referenced by DGtal::HyperRectDomain< TSpace >::ConstSubRange::ConstSubRange().

{
std::bitset<dim> dims = ::setDimensionsIn<dim>(dimensions);
for ( Dimension i = 0; i < dim; ++i )
{
if ( !dims.test(i) ) myArray[i] = pv.myArray[i];
}
return *this;
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::partialEqual ( const Self pv,
const std::vector< Dimension > &  dimensions 
) const
inline

Partial equality.

Parameters:
pvPoint/Vector to compare to this.
Returns:
true iff points are equal for given dimensions .

Definition at line 382 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

{
std::bitset<dim> dims = setDimensionsIn<dim>(dimensions);
for ( Dimension i = 0; i < dim; ++i )
{
if ( dims.test(i) && myArray[i] != pv.myArray[i]) return false;
}
return true;
}
template<Dimension dim, typename TComponent >
bool DGtal::PointVector< dim, TComponent >::partialEqualInv ( const Self pv,
const std::vector< Dimension > &  dimensions 
) const
inline

Partial inverse equality.

Parameters:
pvPoint/Vector to compare to this.
Returns:
true iff points are equal for dimensions not in dimensions.

Definition at line 397 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::myArray.

Referenced by DGtal::HyperRectDomain< TSpace >::ConstSubRange::begin().

{
std::bitset<dim> dims = setDimensionsIn<dim>(dimensions);
for ( Dimension i = 0; i < dim; ++i )
{
if ( !dims.test(i) && myArray[i] != pv.myArray[i]) return false;
}
return true;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::ReverseIterator DGtal::PointVector< dim, TComponent >::rbegin ( )
inline

PointVector rbegin() reverse iterator.

Returns:
a ReverseIterator on the first element of a Point/Vector.

Definition at line 205 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::rbegin().

Referenced by DGtal::PointVector< dim, TEuclideanRing >::rbegin().

{
return myArray.rbegin();
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::ConstReverseIterator DGtal::PointVector< dim, TComponent >::rbegin ( ) const
inline

PointVector rbegin() const reverse iterator.

Returns:
an ConstReverseIterator on the first element of a Point/Vector.

Definition at line 221 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::rbegin().

{
return myArray.rbegin();
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::ReverseIterator DGtal::PointVector< dim, TComponent >::rend ( )
inline

PointVector rend() reverse iterator.

Returns:
a ReverseIterator on the last element of a Point/Vector.

Definition at line 213 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::rend().

Referenced by DGtal::PointVector< dim, TEuclideanRing >::rend().

{
return myArray.rend();
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent >::ConstReverseIterator DGtal::PointVector< dim, TComponent >::rend ( ) const
inline

PointVector rend() const reverse iterator.

Returns:
a ConstReverseIterator on the last element of a Point/Vector.

Definition at line 229 of file PointVector.ih.

References DGtal::PointVector< dim, TEuclideanRing >::rend().

{
return myArray.rend();
}
template<Dimension dim, typename TComponent >
void DGtal::PointVector< dim, TComponent >::reset ( )
inline

Resets all the values to zero.

Definition at line 545 of file PointVector.ih.

{
for ( Dimension i = 0; i < myArray.size(); ++i )
myArray[ i ] = 0;
}
template<Dimension dim, typename TComponent >
void DGtal::PointVector< dim, TComponent >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 730 of file PointVector.ih.

{
out << "[PointVector] {";
for (Dimension i = 0; i < dimension ; ++i)
out << at( i ) << (i == dimension - 1 ? "" : ", ");
out << "}";
}
template<Dimension dim, typename TComponent >
DGtal::Dimension DGtal::PointVector< dim, TComponent >::size ( )
inlinestatic

Returns the size of the vector (i.e. the number of its coefficients). Same as getDimension

Definition at line 237 of file PointVector.ih.

Referenced by DGtal::ContourHelper::getMeanPoint().

{
return dim;
}
template<Dimension dim, typename TComponent >
DGtal::PointVector< dim, TComponent > DGtal::PointVector< dim, TComponent >::sup ( const Self apoint) const
inline

Implements the supremum (or least upper bound). It means the point whose coordinates are exactly the maximum of the two points coordinate by coordinate.

Parameters:
apointany point.
Returns:
a new point being the sup between *this and apoint.
See also:
isUpper

Definition at line 562 of file PointVector.ih.

{
return Self(*this, apoint, MaxFunctor<Component>());
}

Field Documentation

template<DGtal::Dimension dim, typename TEuclideanRing>
const Dimension DGtal::PointVector< dim, TEuclideanRing >::dimension = dim
static

Copy of the static dimension of the Point/Vector.

Definition at line 176 of file PointVector.h.

template<DGtal::Dimension dim, typename TEuclideanRing>
boost::array<Component, dimension> DGtal::PointVector< dim, TEuclideanRing >::myArray
template<DGtal::Dimension dim, typename TEuclideanRing>
PointVector< dim, Component > DGtal::PointVector< dim, Component >::zero
static

Static const for zero PointVector.

Definition at line 787 of file PointVector.h.


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