DGtal
0.9.4.1
|
#include <DGtal/kernel/PointVector.h>
Public Types | |
enum | NormType { L_2, L_1, L_infty } |
typedef PointVector< dim, TEuclideanRing, TContainer > | Self |
typedef TEuclideanRing | Component |
typedef Component | Coordinate |
typedef NumberTraits< Component >::UnsignedVersion | UnsignedComponent |
typedef DGtal::Dimension | Dimension |
typedef Component | Scalar |
typedef Dimension | Index |
typedef TContainer | Container |
typedef Container::iterator | Iterator |
typedef Container::const_iterator | ConstIterator |
typedef Container::reverse_iterator | ReverseIterator |
typedef Container::const_reverse_iterator | ConstReverseIterator |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::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) | |
PointVector (std::initializer_list< Component > init) | |
template<typename BinaryFunctor > | |
PointVector (const Self &apoint1, const Self &apoint2, const BinaryFunctor &f) | |
template<typename UnaryFunctor > | |
PointVector (const Self &apoint1, const UnaryFunctor &f) | |
~PointVector () | |
PointVector (const Self &other) | |
template<typename OtherComponent , typename OtherCont > | |
PointVector (const PointVector< dim, OtherComponent, OtherCont > &other) | |
Self & | operator= (const Self &pv) |
Self & | partialCopy (const Self &pv, std::initializer_list< Dimension > dimensions) |
Self & | partialCopyInv (const Self &pv, std::initializer_list< Dimension > dimensions) |
Self & | partialCopy (const Self &pv, const std::vector< Dimension > &dimensions) |
Self & | partialCopyInv (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 |
Dimension | rows () const |
const Component & | operator[] (Dimension i) const |
const Component & | operator() (Dimension i) const |
Component & | operator[] (Dimension i) |
Component & | operator() (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 |
PointVector & | operator*= (Component coeff) |
PointVector | operator* (Component coeff) const |
Component | dot (const Self &v) const |
Self | crossProduct (const Self &v) const |
double | cosineSimilarity (const Self &v) const |
Self & | operator+= (const Self &v) |
Self | operator+ (const Self &v) const |
Self & | operator-= (const Self &v) |
Self | operator- (const Self &v) const |
Self | operator- () const |
Self & | operator/= (const Self &v) |
Self | operator/ (const Self &v) const |
Self | operator/ (const Component coeff) const |
Self & | operator/= (const Component coeff) |
template<typename AnotherComponent > | |
Self & | operator= (const PointVector< dim, AnotherComponent, Container > &v) |
void | reset () |
void | clear () |
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, std::array< double, dim > > | getNormalized () const |
std::string | className () const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Static Public Member Functions | |
static Dimension | size () |
static Self | diagonal (Component val=1) |
static Self | base (Dimension k, Component val=1) |
Static Public Attributes | |
static const Dimension | dimension = dim |
static Self | zero |
Protected Attributes | |
Container | myArray |
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.
dim | static constant of type DGtal::Dimension that specifies the static dimension of the space and thus the number of elements of the Point or Vector. |
TEuclideanRing | speficies 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. |
TContainer | specifies the container to be used to store the point coordinates. At this point, such container must be a random access bidirectionnal a-la STL containers (e.g. vector, boost/array). If TContainer implements comparison operators == != < <= > <=, then PointVector will also implements it and with the exact same behaviour. |
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:
PointVector is a model of CBidirectionalRange.
Definition at line 141 of file PointVector.h.
typedef TEuclideanRing DGtal::PointVector< dim, TEuclideanRing, TContainer >::Component |
Type for Vector elements.
Definition at line 155 of file PointVector.h.
typedef Container::const_iterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::ConstIterator |
Definition at line 182 of file PointVector.h.
typedef Container::const_reverse_iterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::ConstReverseIterator |
Definition at line 184 of file PointVector.h.
typedef TContainer DGtal::PointVector< dim, TEuclideanRing, TContainer >::Container |
Copy of the container type.
Definition at line 174 of file PointVector.h.
typedef Component DGtal::PointVector< dim, TEuclideanRing, TContainer >::Coordinate |
Type for Point elements.
Definition at line 158 of file PointVector.h.
typedef DGtal::Dimension DGtal::PointVector< dim, TEuclideanRing, TContainer >::Dimension |
Copy of the dimension type.
Definition at line 164 of file PointVector.h.
typedef Dimension DGtal::PointVector< dim, TEuclideanRing, TContainer >::Index |
Definition at line 171 of file PointVector.h.
typedef Container::iterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::Iterator |
Copy of the Container iterator types
Definition at line 181 of file PointVector.h.
typedef Container::reverse_iterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::ReverseIterator |
Definition at line 183 of file PointVector.h.
typedef Component DGtal::PointVector< dim, TEuclideanRing, TContainer >::Scalar |
Types needed by CLinearAlgebraContainer.
Definition at line 170 of file PointVector.h.
typedef PointVector<dim, TEuclideanRing, TContainer> DGtal::PointVector< dim, TEuclideanRing, TContainer >::Self |
Self type.
We cannot check the TContainer since boost::array is not a model of boost::RandomAccessContainer
Definition at line 152 of file PointVector.h.
typedef NumberTraits<Component>::UnsignedVersion DGtal::PointVector< dim, TEuclideanRing, TContainer >::UnsignedComponent |
Unsigned version of the components.
Definition at line 161 of file PointVector.h.
enum DGtal::PointVector::NormType |
Specify the set of norm types
Enumerator | |
---|---|
L_2 | |
L_1 | |
L_infty |
Definition at line 718 of file PointVector.h.
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | ) |
Constructor.
|
explicit |
Constructor from array of values.
ptrValues | the array of values. |
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | const Component & | x, |
const Component & | y | ||
) |
Constructor from two values (the Dimension of the vector should be at least 2). Other components are set to 0.
x | the first value. |
y | the second value. |
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | const Component & | x, |
const Component & | y, | ||
const Component & | z | ||
) |
Constructor from three values (the Dimension of the vector should be at least 3). Other components are set to 0.
x | the first value. |
y | the second value. |
z | the third value. |
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | const Component & | x, |
const Component & | y, | ||
const Component & | z, | ||
const Component & | t | ||
) |
Constructor from four values (the Dimension of the vector should be at least 4). Other components are set to 0.
x | the first value. |
y | the second value. |
z | the third value. |
t | the fourth value. |
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | std::initializer_list< Component > | init | ) |
Constructor from initializer list.
init | the initializer list. |
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | const Self & | apoint1, |
const Self & | apoint2, | ||
const BinaryFunctor & | f | ||
) |
Constructor taking two points and a functor as parameters. The new point is initialized by the result of functor f applied for each pair of coordinates of apoint1 and apoint2
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | const Self & | apoint1, |
const UnaryFunctor & | f | ||
) |
Constructor taking a point and a unary functor as parameters. The new point is initialized by the result of functor f for each coordinate of apoint1
DGtal::PointVector< dim, TEuclideanRing, TContainer >::~PointVector | ( | ) |
Destructor.
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | const Self & | other | ) |
Copy constructor.
other | the object to clone. |
DGtal::PointVector< dim, TEuclideanRing, TContainer >::PointVector | ( | const PointVector< dim, OtherComponent, OtherCont > & | other | ) |
Copy constructor from another component PointVector. A static cast is used to cast the values during the copy.
other | the object to clone. |
|
static |
k | any number between 0 and Dimension-1. |
val | any value. |
Iterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::begin | ( | ) |
PointVector begin() iterator.
Referenced by DGtal::HyperRectDomain< Space >::size(), and TEST_CASE().
ConstIterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::begin | ( | ) | const |
PointVector begin() const iterator.
DGtal::PointVector< dim, TEuclideanRing, TContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CEuclideanRing< TEuclideanRing >) | ) |
std::string DGtal::PointVector< dim, TEuclideanRing, TContainer >::className | ( | ) | const |
Referenced by main(), and testDisplayDT3d().
|
inline |
Resets all the values to zero. Needed by CLinearAlgebraContainer.
Definition at line 641 of file PointVector.h.
double DGtal::PointVector< dim, TEuclideanRing, TContainer >::cosineSimilarity | ( | const Self & | v | ) | const |
Positive angle between two vectors, deduced from their scalar product.
v | any vector |
Self DGtal::PointVector< dim, TEuclideanRing, TContainer >::crossProduct | ( | const Self & | v | ) | const |
cross product with a PointVector
v | a vector that is cross-producted to *this. |
|
static |
val | any value. |
Referenced by DGtal::ImplicitBall< TSpace >::getLowerBound(), DGtal::ImplicitNorm1Ball< TSpace >::getLowerBound(), DGtal::ImplicitHyperCube< TSpace >::getLowerBound(), DGtal::ImplicitRoundedHyperCube< TSpace >::getLowerBound(), DGtal::ImplicitBall< TSpace >::getUpperBound(), DGtal::ImplicitHyperCube< TSpace >::getUpperBound(), DGtal::ImplicitNorm1Ball< TSpace >::getUpperBound(), and DGtal::ImplicitRoundedHyperCube< TSpace >::getUpperBound().
Component DGtal::PointVector< dim, TEuclideanRing, TContainer >::dot | ( | const Self & | v | ) | const |
dot product with a PointVector
v | a vector that is dot-producted to *this. |
Referenced by LSF(), main(), naiveConvexHull(), and testOperators().
Iterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::end | ( | ) |
PointVector end() iterator.
Referenced by DGtal::HyperRectDomain< Space >::size(), and TEST_CASE().
ConstIterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::end | ( | ) | const |
PointVector end() const iterator.
PointVector<dim, double, std::array<double,dim> > DGtal::PointVector< dim, TEuclideanRing, TContainer >::getNormalized | ( | ) | const |
Compute the normalization of a given vector (*this) and return a unitary vector on double.
Referenced by main(), TEST_CASE(), testBallQuad(), and testQuadNorm().
Self DGtal::PointVector< dim, TEuclideanRing, TContainer >::inf | ( | const Self & | apoint | ) | const |
Implements the infimum (or greatest lower bound). It means the point whose coordinates are exactly the minimum of the two points coordinate by coordinate.
apoint | any point. |
Referenced by testOperators().
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::isLower | ( | const Self & | p | ) | const |
p | any point. |
Referenced by DGtal::HyperRectDomain< TSpace >::ConstSubRange::begin().
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::isUpper | ( | const Self & | p | ) | const |
p | any point. |
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Component DGtal::PointVector< dim, TEuclideanRing, TContainer >::max | ( | ) | const |
Return the maximum component value of a point/vector.
Referenced by TEST_CASE().
Iterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::maxElement | ( | ) |
Return the iterator on the component with maximim value of a point/vector.
Referenced by TEST_CASE().
Component DGtal::PointVector< dim, TEuclideanRing, TContainer >::min | ( | ) | const |
Return the minimum component value of a point/vector.
Referenced by TEST_CASE().
Iterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::minElement | ( | ) |
Return the iterator on the component with minimum value of a point/vector.
Referenced by TEST_CASE().
void DGtal::PointVector< dim, TEuclideanRing, TContainer >::negate | ( | ) |
Negates this vector.
double DGtal::PointVector< dim, TEuclideanRing, TContainer >::norm | ( | const NormType | type = L_2 | ) | const |
Computes the norm of a point/vector.
type | specifies the type of norm to consider (see NormType). |
Referenced by DGtal::TangentFromDSS3DFunctor< DSS, LambdaFunction >::operator()(), and DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::Point2DEmbedderIn3D().
UnsignedComponent DGtal::PointVector< dim, TEuclideanRing, TContainer >::norm1 | ( | ) | const |
Computes the 1-norm of a vector.
Referenced by testIntegerNorms().
UnsignedComponent DGtal::PointVector< dim, TEuclideanRing, TContainer >::normInfinity | ( | ) | const |
Computes the infinity-norm of a vector.
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator!= | ( | const Self & | pv | ) | const |
Difference operator on Points/Vectors.
pv | the Point/Vector to compare to this. |
|
inline |
Definition at line 425 of file PointVector.h.
|
inline |
Definition at line 436 of file PointVector.h.
PointVector DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator* | ( | Component | coeff | ) | const |
Multiplication operator with a scalar number
coeff | is the factor 'this' is multiplied by. |
PointVector& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator*= | ( | Component | coeff | ) |
Multiplies *this by the coeff scalar number.
coeff | is the factor *this get multiplied by. |
Self DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator+ | ( | const Self & | v | ) | const |
Addition operator.
v | is the Point that gets added to *this. |
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator+= | ( | const Self & | v | ) |
Addition operator with assignement.
v | is the Point that gets added to *this. |
Self DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator- | ( | const Self & | v | ) | const |
Substraction operator. Point - Vector => Point
v | is the Point that gets substracted to *this. |
Self DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator- | ( | ) | const |
Unary minus operator. -Vector => Vector
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator-= | ( | const Self & | v | ) |
Substraction operator with assignement.
v | is the Point that gets substracted to *this. |
Self DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator/ | ( | const Self & | v | ) | const |
Division operator.
v | is the Point that gets divided to *this. |
Self DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator/ | ( | const Component | coeff | ) | const |
Divides *this by the coeff scalar number.
coeff | is the factor *this get divided by. |
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator/= | ( | const Self & | v | ) |
Division operator with assignement.
v | is the Point that gets divided to *this. |
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator/= | ( | const Component | coeff | ) |
Divides *this by the coeff scalar number.
coeff | is the factor *this get divided by. |
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator< | ( | const Self & | pv | ) | const |
Comparison operator on Points/Vectors (LesserThan).
pv | the Point/Vector to compare to this. |
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator<= | ( | const Self & | pv | ) | const |
Comparison operator on Points/Vectors (LesserOrEqualThan).
pv | the Point/Vector to compare to this. |
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator= | ( | const Self & | pv | ) |
Assignement Operator
pv | the object to copy. |
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator= | ( | const PointVector< dim, AnotherComponent, Container > & | v | ) |
Assignment operator from PointVector with different component type. A static cast is used to cast the values during the copy.
v | is the Point that gets divided to *this. |
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator== | ( | const Self & | pv | ) | const |
Equality operator.
pv | Point/Vector to compare to this. |
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator> | ( | const Self & | pv | ) | const |
Comparison operator on Points/Vectors (GreaterThan).
pv | the Point/Vector to compare to this. |
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator>= | ( | const Self & | pv | ) | const |
Comparison operator on Points/Vectors (GreaterOrEqualThan).
pv | the Point/Vector to compare to this. |
const Component& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator[] | ( | Dimension | i | ) | const |
Returns the i-th coefficient of the vector.
i | is the index of the retrieved coefficient. |
Component& DGtal::PointVector< dim, TEuclideanRing, TContainer >::operator[] | ( | Dimension | i | ) |
Returns a non-const reference to the i-th element of the vector.
i | is the index of the retrieved coefficient. |
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::partialCopy | ( | const Self & | pv, |
std::initializer_list< Dimension > | dimensions | ||
) |
Partial copy of a given PointVector. Only coordinates in dimensions are copied.
pv | the object to copy. |
dimensions | the dimensions of v to copy (Size between 0 and N, all differents). |
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::partialCopy | ( | const Self & | pv, |
const std::vector< Dimension > & | dimensions | ||
) |
Partial copy of a given PointVector. Only coordinates in dimensions are copied.
pv | the object to copy. |
dimensions | the dimensions of v to copy (Size between 0 and N, all differents). |
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::partialCopyInv | ( | const Self & | pv, |
std::initializer_list< Dimension > | dimensions | ||
) |
Inverse partial copy of a given PointVector. Only coordinates not in dimensions are copied.
pv | the object to copy. |
dimensions | the dimensions of v to copy (Size between 0 and N, all differents). |
Referenced by DGtal::HyperRectDomain< TSpace >::ConstSubRange::ConstSubRange().
Self& DGtal::PointVector< dim, TEuclideanRing, TContainer >::partialCopyInv | ( | const Self & | pv, |
const std::vector< Dimension > & | dimensions | ||
) |
Partial copy of a given PointVector. Only coordinates not in dimensions are copied.
pv | the object to copy. |
dimensions | the dimensions of v to copy (Size between 0 and N, all differents). |
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::partialEqual | ( | const Self & | pv, |
const std::vector< Dimension > & | dimensions | ||
) | const |
Partial equality.
pv | Point/Vector to compare to this. |
dimensions | Dimensions along which to compare the points. |
bool DGtal::PointVector< dim, TEuclideanRing, TContainer >::partialEqualInv | ( | const Self & | pv, |
const std::vector< Dimension > & | dimensions | ||
) | const |
Partial inverse equality.
pv | Point/Vector to compare to this. |
dimensions | Dimensions along which to compare the points. |
ReverseIterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::rbegin | ( | ) |
PointVector rbegin() reverse iterator.
ConstReverseIterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::rbegin | ( | ) | const |
PointVector rbegin() const reverse iterator.
ReverseIterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::rend | ( | ) |
PointVector rend() reverse iterator.
ConstReverseIterator DGtal::PointVector< dim, TEuclideanRing, TContainer >::rend | ( | ) | const |
PointVector rend() const reverse iterator.
void DGtal::PointVector< dim, TEuclideanRing, TContainer >::reset | ( | ) |
Resets all the values to zero.
Referenced by DGtal::PointVector< dim, Integer >::clear().
|
inline |
Definition at line 415 of file PointVector.h.
void DGtal::PointVector< dim, TEuclideanRing, TContainer >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
|
static |
Returns the size of the vector (i.e. the number of its coefficients).
Referenced by DGtal::functors::SliceRotator2D< TDomain3D, TInteger >::operator()(), and DGtal::functors::Point2DEmbedderIn3D< TDomain3D, TInteger >::operator()().
Self DGtal::PointVector< dim, TEuclideanRing, TContainer >::sup | ( | const Self & | apoint | ) | const |
Implements the supremum (or least upper bound). It means the point whose coordinates are exactly the maximum of the two points coordinate by coordinate.
apoint | any point. |
Referenced by testOperators().
|
static |
Copy of the static dimension of the Point/Vector.
Definition at line 167 of file PointVector.h.
Referenced by DGtal::ImplicitRoundedHyperCube< TSpace >::operator()(), and testSimpleVector().
|
protected |
Internal data-structure: std::array with constant size.
Definition at line 804 of file PointVector.h.
|
static |
Static const for zero PointVector.
Static const for zero definition.
Definition at line 798 of file PointVector.h.