27 #ifndef MPBLOCKS_CUDANN_KERNELS_EUCLIDEAN_CU_HPP_
28 #define MPBLOCKS_CUDANN_KERNELS_EUCLIDEANCU_HPP_
38 namespace linalg = cuda::linalg2;
41 template<
typename Scalar,
int NDim >
50 template<
typename Scalar,
int NDim >
60 template<
typename Format_t,
unsigned int NDim>
66 unsigned int pitchOut,
75 int idx = blockId * N + threadId;
92 read(g_in,pitchIn,idx,q1);
97 g_out[0*pitchOut + idx] = d;
99 g_out[1*pitchOut + idx] = idx;
103 template <
int Arg,
int i,
bool final>
109 template <
int Arg,
int i>
122 template<
bool Pseudo,
typename Scalar,
unsigned int NDim>
128 using namespace linalg;
142 med[idx] = Scalar(0.5)*( query.
min[idx] + query.
max[idx] );
148 if( childIdx & (0x01 << idx ) )
151 max[idx] = query.
max[idx];
155 min[idx] = query.
min[idx];
162 Scalar q_i = query.
point[idx];
165 Scalar min_i = min[idx];
168 Scalar max_i = max[idx];
173 dist_i = min_i - q_i;
175 dist_i = q_i - max_i;
183 if(idx <
s && idx+
s < NDim)
184 dist[idx] += dist[idx+
s];
191 g_out[childIdx] = dist[0];
193 g_out[childIdx] = std::sqrt(dist[0]);
__device__ __host__ Scalar norm_squared(const RValue< Scalar, ROWS, COLS, Exp > &M)
compute the norm
__device__ __host__ Scalar norm(const RValue< Scalar, ROWS, COLS, Exp > &M)
compute the norm
__global__ void euclidean_distance(QueryPoint< Format_t, NDim > query, Format_t *g_in, unsigned int pitchIn, Format_t *g_out, unsigned int pitchOut, unsigned int n)
vector norm (2-norm) between two points
__device__ void read(Format_t *g_data, unsigned int pitch, int idx, linalg::Matrix< Format_t, NDim, 1 > &v)
__device__ Scalar euclidean_pseudo_distance(const linalg::Matrix< Scalar, NDim, 1 > &q0, const linalg::Matrix< Scalar, NDim, 1 > &q1)