Skip to main content

ClikaRT::ops::cdist

function

cdist()

Tensor cdist(
    Tensor a,
    Tensor b,
    Scalar p = 2.0
)

Pairwise L_p distance between every ROW pair of two matrices.

outmn=ambnp\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

  • a: rows [.., M, K].
  • b: 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 2647