template struct BaseMinkowskiDistPp { /* 1-d pieces * These should only be used if p != infinity */ static inline void interval_interval_p(const ckdtree * tree, const Rectangle& rect1, const Rectangle& rect2, const ckdtree_intp_t k, const double p, double *min, double *max) { /* Compute the minimum/maximum distance along dimension k between points in * two hyperrectangles. */ Dist1D::interval_interval(tree, rect1, rect2, k, min, max); *min = std::pow(*min, p); *max = std::pow(*max, p); } static inline void rect_rect_p(const ckdtree * tree, const Rectangle& rect1, const Rectangle& rect2, const double p, double *min, double *max) { *min = 0.; *max = 0.; for(ckdtree_intp_t i=0; iupperbound) return r; } return r; } static inline double distance_p(const double s, const double p) { return std::pow(s,p); } }; template struct BaseMinkowskiDistP1 : public BaseMinkowskiDistPp { static inline void interval_interval_p(const ckdtree * tree, const Rectangle& rect1, const Rectangle& rect2, const ckdtree_intp_t k, const double p, double *min, double *max) { /* Compute the minimum/maximum distance along dimension k between points in * two hyperrectangles. */ Dist1D::interval_interval(tree, rect1, rect2, k, min, max); } static inline void rect_rect_p(const ckdtree * tree, const Rectangle& rect1, const Rectangle& rect2, const double p, double *min, double *max) { *min = 0.; *max = 0.; for(ckdtree_intp_t i=0; iupperbound) return r; } return r; } static inline double distance_p(const double s, const double p) { return s; } }; template struct BaseMinkowskiDistPinf : public BaseMinkowskiDistPp { static inline void interval_interval_p(const ckdtree * tree, const Rectangle& rect1, const Rectangle& rect2, const ckdtree_intp_t k, double p, double *min, double *max) { return rect_rect_p(tree, rect1, rect2, p, min, max); } static inline void rect_rect_p(const ckdtree * tree, const Rectangle& rect1, const Rectangle& rect2, const double p, double *min, double *max) { *min = 0.; *max = 0.; for(ckdtree_intp_t i=0; iupperbound) return r; } return r; } static inline double distance_p(const double s, const double p) { return s; } }; template struct BaseMinkowskiDistP2 : public BaseMinkowskiDistPp { static inline void interval_interval_p(const ckdtree * tree, const Rectangle& rect1, const Rectangle& rect2, const ckdtree_intp_t k, const double p, double *min, double *max) { /* Compute the minimum/maximum distance along dimension k between points in * two hyperrectangles. */ Dist1D::interval_interval(tree, rect1, rect2, k, min, max); *min *= *min; *max *= *max; } static inline void rect_rect_p(const ckdtree * tree, const Rectangle& rect1, const Rectangle& rect2, const double p, double *min, double *max) { *min = 0.; *max = 0.; for(ckdtree_intp_t i=0; iupperbound) return r; } return r; } static inline double distance_p(const double s, const double p) { return s * s; } };