DGtal 1.4.0
Loading...
Searching...
No Matches
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted > Class Template Reference

Aim: implements weighted separable l_p metrics with exact predicates. More...

#include <DGtal/geometry/volumes/distance/ExactPredicateLpPowerSeparableMetric.h>

Public Types

typedef TSpace Space
 Copy the space type.
 
typedef Space::Point Point
 Type for points.
 
typedef Point::Coordinate Abscissa
 Type for points.
 
typedef Space::Vector Vector
 Type for vectors.
 
typedef TPromoted Promoted
 Type for internal distance values.
 
typedef TPromoted Weight
 Type for internal distance values.
 
typedef TPromoted Value
 Type for Value (alias)
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >))
 
 BOOST_CONCEPT_ASSERT ((concepts::CInteger< Promoted >))
 
 ExactPredicateLpPowerSeparableMetric ()
 
 ~ExactPredicateLpPowerSeparableMetric ()
 
 ExactPredicateLpPowerSeparableMetric (const ExactPredicateLpPowerSeparableMetric &)
 
ExactPredicateLpPowerSeparableMetricoperator= (const ExactPredicateLpPowerSeparableMetric &)
 
Weight powerDistance (const Point &aPoint, const Point &aQ, const Weight &aWq) const
 
DGtal::Closest closestPower (const Point &origin, const Point &first, const Weight &wF, const Point &second, const Weight &wS) const
 
bool hiddenByPower (const Point &u, const Weight &wu, const Point &v, const Weight &wv, const Point &w, const Weight &ww, const Point &startingPoint, const Point &endPoint, const typename Point::UnsignedComponent dim) const
 
void selfDisplay (std::ostream &out) const
 
bool isValid () const
 

Private Member Functions

Promoted exactDistanceRepresentation (const Point &aP, const Point &aQ) const
 
Abscissa binarySearchHidden (const Abscissa &udim, const Abscissa &vdim, const Promoted &nu, const Promoted &nv, const Abscissa &lower, const Abscissa &upper) const
 

Detailed Description

template<typename TSpace, DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
class DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >

Aim: implements weighted separable l_p metrics with exact predicates.

Description of template class 'ExactPredicateLpPowerSeparableMetric'

Given a template parameter p, the class implement classical l_p metric as a model of CPowerSeparableMetric. Hence, given two points \( x=(x_0...x_{n-1})\), \( y=(y_0...y_{n-1})\) in the given digital space (see below) and a weight \( w_y\) we define a power metric such that:

\( powerDistance(x,y,w_y)= \sum_{i=0}^{n-1} |x_i-y_i|^p - w_y \)

This class is said to be exact in the sense that the power p is computed without approximation (exponentiation by squaring in \( O(log(p))\) per computation, see BasicMathFunctions::power). As a consequence, hiddenByPower and closestPower methods are error free if the capacity of the template type TPromoted allows to store sums of \( |x_i-y_i|^p\) quantities.

Template Parameters
TSpacethe model of CSpace on which the metric is defined.
pthe exponent of the metric (static DGtal::uint32_t)
TPromotedmodel of CSignedInteger used to store power p sums (default: DGtal::int64_t)

Definition at line 87 of file ExactPredicateLpPowerSeparableMetric.h.

Member Typedef Documentation

◆ Abscissa

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
typedef Point::Coordinate DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Abscissa

Type for points.

Definition at line 100 of file ExactPredicateLpPowerSeparableMetric.h.

◆ Point

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
typedef Space::Point DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Point

Type for points.

Definition at line 98 of file ExactPredicateLpPowerSeparableMetric.h.

◆ Promoted

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
typedef TPromoted DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Promoted

Type for internal distance values.

Definition at line 105 of file ExactPredicateLpPowerSeparableMetric.h.

◆ Space

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
typedef TSpace DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Space

Copy the space type.

Definition at line 94 of file ExactPredicateLpPowerSeparableMetric.h.

◆ Value

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
typedef TPromoted DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Value

Type for Value (alias)

Definition at line 112 of file ExactPredicateLpPowerSeparableMetric.h.

◆ Vector

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
typedef Space::Vector DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Vector

Type for vectors.

Definition at line 102 of file ExactPredicateLpPowerSeparableMetric.h.

◆ Weight

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
typedef TPromoted DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Weight

Type for internal distance values.

Definition at line 108 of file ExactPredicateLpPowerSeparableMetric.h.

Constructor & Destructor Documentation

◆ ExactPredicateLpPowerSeparableMetric() [1/2]

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::ExactPredicateLpPowerSeparableMetric ( )

Constructor.

◆ ~ExactPredicateLpPowerSeparableMetric()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::~ExactPredicateLpPowerSeparableMetric ( )

Destructor.

◆ ExactPredicateLpPowerSeparableMetric() [2/2]

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::ExactPredicateLpPowerSeparableMetric ( const ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted > & )
inline

Copy constructor.

Definition at line 128 of file ExactPredicateLpPowerSeparableMetric.h.

128{}

Member Function Documentation

◆ binarySearchHidden()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
Abscissa DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::binarySearchHidden ( const Abscissa & udim,
const Abscissa & vdim,
const Promoted & nu,
const Promoted & nv,
const Abscissa & lower,
const Abscissa & upper ) const
private

Perform a binary search on the interval [lower,upper] to detect the mid-point between u and v according to the weighted l_p distance.

Parameters
udimcoordinate of u along dimension dim
vdimcoordinate of v along dimension dim
nupartial distance of u (sum of |xj-x_i|^p) discarding the term along the dimension dim
nvpartial distance of v (sum of |xj-x_i|^p) discarding the term along the dimension dim
lowerinterval lower bound
upperinterval upper bound
Returns
the Voronoi boundary point coordinates along dimension dim.

◆ BOOST_CONCEPT_ASSERT() [1/2]

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::BOOST_CONCEPT_ASSERT ( (concepts::CInteger< Promoted >) )

◆ BOOST_CONCEPT_ASSERT() [2/2]

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::BOOST_CONCEPT_ASSERT ( (concepts::CSpace< TSpace >) )

◆ closestPower()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
DGtal::Closest DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::closestPower ( const Point & origin,
const Point & first,
const Weight & wF,
const Point & second,
const Weight & wS ) const

Given an origin and two points, this method decides which one is closest to the origin. This method should be faster than comparing distance values.

Parameters
originthe origin
firstthe first point
wFthe first point weight
secondthe second point
wSthe second point weight $
Returns
a Closest enum: FIRST, SECOND or BOTH.

◆ exactDistanceRepresentation()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
Promoted DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::exactDistanceRepresentation ( const Point & aP,
const Point & aQ ) const
private

Compute the Lp distance without the computation of the power 1/p. I.e. only \( \sum |p_i- q_i|^p\) is given.

Parameters
aPa first point
aQa second point
Returns
the power p of the l_p distance between aP and aQ.

◆ hiddenByPower()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
bool DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::hiddenByPower ( const Point & u,
const Weight & wu,
const Point & v,
const Weight & wv,
const Point & w,
const Weight & ww,
const Point & startingPoint,
const Point & endPoint,
const typename Point::UnsignedComponent dim ) const

Given three weighted sites (u,v,w) and a straight segment [startingPoint,endPoint] along dimension dim, we detect if the power cells of u and w strictly hide the power cell of v on the straight line.

This method is in \( O(log(n))\) if n is the size of the straight segment. For \( l_2\) metric (p=2), the method is in \( O(1)\).

Precondition
u,v and w must be such that u[dim] < v[dim] < w[dim]
Parameters
ua site
wua weight
va site
wva weight
wa site
wwa weight
startingPointstarting point of the segment
endPointend point of the segment
dimdirection of the straight line
Returns
true if (u,w) hides v.

◆ isValid()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
bool DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::isValid ( ) const

Checks the validity/consistency of the object.

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

◆ operator=()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
ExactPredicateLpPowerSeparableMetric & DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::operator= ( const ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted > & )
inline

Assignment.

Returns
a reference on 'this'.

Definition at line 134 of file ExactPredicateLpPowerSeparableMetric.h.

134{ return *this;}

◆ powerDistance()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
Weight DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::powerDistance ( const Point & aPoint,
const Point & aQ,
const Weight & aWq ) const

Return the power distance of a point aPoint and a weighted point (aQ,aWq)

Parameters
aPointa point
aQa second point
aWqweight of the second point
Returns
the power distance between aPoint and (Q,WQ)

◆ selfDisplay()

template<typename TSpace , DGtal::uint32_t p, typename TPromoted = DGtal::int64_t>
void DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::selfDisplay ( std::ostream & out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

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