DGtal 1.4.0
|
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 &) | |
ExactPredicateLpPowerSeparableMetric & | operator= (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 |
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.
TSpace | the model of CSpace on which the metric is defined. |
p | the exponent of the metric (static DGtal::uint32_t) |
TPromoted | model of CSignedInteger used to store power p sums (default: DGtal::int64_t) |
Definition at line 87 of file ExactPredicateLpPowerSeparableMetric.h.
typedef Point::Coordinate DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Abscissa |
Type for points.
Definition at line 100 of file ExactPredicateLpPowerSeparableMetric.h.
typedef Space::Point DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Point |
Type for points.
Definition at line 98 of file ExactPredicateLpPowerSeparableMetric.h.
typedef TPromoted DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Promoted |
Type for internal distance values.
Definition at line 105 of file ExactPredicateLpPowerSeparableMetric.h.
typedef TSpace DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Space |
Copy the space type.
Definition at line 94 of file ExactPredicateLpPowerSeparableMetric.h.
typedef TPromoted DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Value |
Type for Value (alias)
Definition at line 112 of file ExactPredicateLpPowerSeparableMetric.h.
typedef Space::Vector DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Vector |
Type for vectors.
Definition at line 102 of file ExactPredicateLpPowerSeparableMetric.h.
typedef TPromoted DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::Weight |
Type for internal distance values.
Definition at line 108 of file ExactPredicateLpPowerSeparableMetric.h.
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::ExactPredicateLpPowerSeparableMetric | ( | ) |
Constructor.
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::~ExactPredicateLpPowerSeparableMetric | ( | ) |
Destructor.
|
inline |
|
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.
udim | coordinate of u along dimension dim |
vdim | coordinate of v along dimension dim |
nu | partial distance of u (sum of |xj-x_i|^p) discarding the term along the dimension dim |
nv | partial distance of v (sum of |xj-x_i|^p) discarding the term along the dimension dim |
lower | interval lower bound |
upper | interval upper bound |
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::BOOST_CONCEPT_ASSERT | ( | (concepts::CInteger< Promoted >) | ) |
DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSpace< TSpace >) | ) |
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.
origin | the origin |
first | the first point |
wF | the first point weight |
second | the second point |
wS | the second point weight $ |
|
private |
Compute the Lp distance without the computation of the power 1/p. I.e. only \( \sum |p_i- q_i|^p\) is given.
aP | a first point |
aQ | a second point |
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)\).
u | a site |
wu | a weight |
v | a site |
wv | a weight |
w | a site |
ww | a weight |
startingPoint | starting point of the segment |
endPoint | end point of the segment |
dim | direction of the straight line |
bool DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
|
inline |
Assignment.
Definition at line 134 of file ExactPredicateLpPowerSeparableMetric.h.
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)
aPoint | a point |
aQ | a second point |
aWq | weight of the second point |
void DGtal::ExactPredicateLpPowerSeparableMetric< TSpace, p, TPromoted >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |