template struct cvflann::L2

Overview

Squared Euclidean distance functor, optimized version Moreā€¦

#include <dist.h>

template <class T>
struct L2
{
    // typedefs

    typedef T ElementType;
    typedef True is_kdtree_distance;
    typedef True is_vector_space_distance;
    typedef Accumulator<T>::Type ResultType;

    // methods

    template <
        typename U,
        typename V
        >
    ResultType
    accum_dist(
        const U& a,
        const V& b,
        int
        ) const;

    template <
        typename Iterator1,
        typename Iterator2
        >
    ResultType
    operator()(
        Iterator1 a,
        Iterator2 b,
        size_t size,
        ResultType worst_dist = -1
        ) const;
};

Detailed Documentation

Squared Euclidean distance functor, optimized version

Methods

template <
    typename U,
    typename V
    >
ResultType
accum_dist(
    const U& a,
    const V& b,
    int
    ) const

Partial euclidean distance, using just one dimension. This is used by the kd-tree when computing partial distances while traversing the tree.

Squared root is omitted for efficiency.

template <
    typename Iterator1,
    typename Iterator2
    >
ResultType
operator()(
    Iterator1 a,
    Iterator2 b,
    size_t size,
    ResultType worst_dist = -1
    ) const

Compute the squared Euclidean distance between two vectors.

This is highly optimised, with loop unrolling, as it is one of the most expensive inner loops.

The computation of squared root at the end is omitted for efficiency.