Skip to main content

ClikaRT::ops::cdist

function

cdist()​

Tensor cdist(
    Tensor x1,
    Tensor x2,
    Scalar p = 2.0
)

Pairwise L_p distance between every ROW pair of two matrices.

outmn=∥am−bn∥p\mathrm{out}_{mn} = \lVert a_m - b_n \rVert_p

(B?, M, K) x (B?, N, K) -> (B?, M, N); the optional leading batch dims broadcast.

Parameters

  • x1: rows [.., M, K].
  • x2: rows [.., N, K] (same trailing K).
  • p: the norm degree, an int or float Scalar, kind-preserved; default 2.

Returns: the distance matrix [.., M, N].

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when the trailing Ks disagree.

Declared in ClikaRT/compute/ops.h, line 2667