flann L2结构体

编程入门 行业动态 更新时间:2024-10-26 07:36:32

flann L2<a href=https://www.elefans.com/category/jswz/34/1771419.html style=结构体"/>

flann L2结构体

/*** Squared Euclidean distance functor, optimized version欧式距离平方优化后的版本*/
template<class T>
struct L2
{typedef bool is_kdtree_distance;typedef T ElementType;typedef typename Accumulator<T>::Type ResultType;/***  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.最后为了效率省略了平方根*/template <typename Iterator1, typename Iterator2>ResultType operator()(Iterator1 a, Iterator2 b, size_t size, ResultType worst_dist = -1) const{ResultType result = ResultType();ResultType diff0, diff1, diff2, diff3;Iterator1 last = a + size;Iterator1 lastgroup = last - 3;/* Process 4 items with each loop for efficiency. */while (a < lastgroup) {diff0 = (ResultType)(a[0] - b[0]);diff1 = (ResultType)(a[1] - b[1]);diff2 = (ResultType)(a[2] - b[2]);diff3 = (ResultType)(a[3] - b[3]);result += diff0 * diff0 + diff1 * diff1 + diff2 * diff2 + diff3 * diff3;a += 4;b += 4;if ((worst_dist>0)&&(result>worst_dist)){return result;}}/* Process last 0-3 pixels.  Not needed for standard vector lengths.不需要标准向量长度 */while (a < last) {diff0 = (ResultType)(*a++ - *b++);result += diff0 * diff0;}return result;}/***  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 U, typename V>inline ResultType accum_dist(const U& a, const V& b, int) const{return (a-b)*(a-b);}
};

更多推荐

flann L2结构体

本文发布于:2024-02-08 20:51:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1674902.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:结构   flann

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!