latest version v1.9 - last update 10 Apr 2010 |
This member accumulates in the given accumulator, the given element. More...
#include <ltiL2Distance.h>
Public Types | |
typedef D | distance_type |
Public Member Functions | |
distance_type | operator() (const T &a, const T &b) const |
Special methods for Minkowski distances | |
void | accumulate (const distance_type element, distance_type &accumulator) const |
void | accumulate (const typename T::value_type element1, const typename T::value_type element2, distance_type &accumulator) const |
distance_type | computeDistance (const distance_type &accumulator) const |
distance_type | component (const typename T::value_type element1, const typename T::value_type element2) const |
bool | accLessThan (const distance_type acc, const distance_type dist) const |
bool | accGreaterThan (const distance_type acc, const distance_type dist) const |
This member accumulates in the given accumulator, the given element.
It can be used when the distance need to be computed manually, but using a distantor to still allow the flexibility of changing distances.
For the l2SquareDistantor this is just acc+=(elem*elem).
element | component of the difference between two points. | |
accumulator | variable where the elements will be accumulated. This member accumulates in the given accumulator, the difference of the given elements. |
It can be used when the distance need to be computed manually, but using a distantor to still allow the flexibility of changing distances.
For the l2SquareDistantor this is just acc+=((elem2-elem1)^2).
element1 | component of the first point | |
element2 | component of the second point | |
accumulator | variable where the elements will be accumulated. Compute from the given accumulator the desired distance return the distance between two components, which is in some way a component of the total distance (that is the reason for the name). |
For this distantor it return (element2-element1)^2 Return true if the given partial computed from accumulator is less than the given distance.
Assume you have accumulated acc until now, and you want to check if the partial distance derived from this accumulator is less than the given distance. So you check accLessThan(accumulator,distance)
For this norm it computes acc < (dist*dist) Return true if the given partial computed from accumulator is greater than the given distance.
Assume you have accumulated acc until now, and you want to check if the partial distance derived from this accumulator is less than the given distance. So you check accLessThan(accumulator,distance)
For this norm it computes acc > (dist*dist) Policy class used by several classifiers/trees to measure the euclidian distance between two points of type T.
The type T MUST define the value_type type, which exist for example for vectors, (t)points and (t)rgbPixels.
If you really want, you can use this class directly through the operator().
l2Distantor< vector<double> > myDist; dvector a,b; ... // fill vectors with data double dist = myDist(a,b);
But remember that there is also a global template function distanceSqr() which can be more easily used:
dvector a,b; ... // fill vectors with data double dist = sqrt(distanceSqr(a,b));
You can of course also use the lti::l2Distance functor, as usual with its apply() methods.
typedef D lti::l2Distantor< T, D >::distance_type |
type returned by the distantor
bool lti::l2Distantor< T, D >::accGreaterThan | ( | const distance_type | acc, | |
const distance_type | dist | |||
) | const [inline] |
Return true if the given partial computed from accumulator is greater than the given distance.
Assume you have accumulated acc until now, and you want to check if the partial distance derived from this accumulator is less than the given distance. So you check accLessThan(accumulator,distance)
For this norm it computes acc > (dist*dist)
bool lti::l2Distantor< T, D >::accLessThan | ( | const distance_type | acc, | |
const distance_type | dist | |||
) | const [inline] |
Return true if the given partial computed from accumulator is less than the given distance.
Assume you have accumulated acc until now, and you want to check if the partial distance derived from this accumulator is less than the given distance. So you check accLessThan(accumulator,distance)
For this norm it computes acc < (dist*dist)
void lti::l2Distantor< T, D >::accumulate | ( | const typename T::value_type | element1, | |
const typename T::value_type | element2, | |||
distance_type & | accumulator | |||
) | const [inline] |
This member accumulates in the given accumulator, the difference of the given elements.
It can be used when the distance need to be computed manually, but using a distantor to still allow the flexibility of changing distances.
For the l2Distantor this is just acc+=((elem2-elem1)^2).
element1 | component of the first point | |
element2 | component of the second point | |
accumulator | variable where the elements will be accumulated. |
void lti::l2Distantor< T, D >::accumulate | ( | const distance_type | element, | |
distance_type & | accumulator | |||
) | const [inline] |
This member accumulates in the given accumulator, the given element.
It can be used when the distance need to be computed manually, but using a distantor to still allow the flexibility of changing distances.
For the l2Distantor this is just acc+=(elem*elem).
element | component of the difference between two points. | |
accumulator | variable where the elements will be accumulated. |
distance_type lti::l2Distantor< T, D >::component | ( | const typename T::value_type | element1, | |
const typename T::value_type | element2 | |||
) | const [inline] |
return the distance between two components, which is in some way a component of the total distance (that is the reason for the name).
For this distantor it return abs(element2-element1)
References lti::abs().
distance_type lti::l2Distantor< T, D >::computeDistance | ( | const distance_type & | accumulator | ) | const [inline] |
Compute from the given accumulator the desired distance.
References lti::sqrt().
distance_type lti::l2Distantor< T, D >::operator() | ( | const T & | a, | |
const T & | b | |||
) | const [inline] |
compute the distance between a and b
References lti::distanceSqr(), and lti::sqrt().