Evaluate a distance spec at a single target
Arguments
- spec
Distance spec (see
is_distance()).- X
Numeric matrix \(n x p\).
- x0
Numeric vector length \(p\).
- ctx
Optional context; if
NULLandspec$setupexists, it will be called asspec$setup(X)to create a context.
Examples
x_mat <- matrix(rnorm(12), 4, 3)
x0_vec <- c(0, 0, 0)
distance_eval(distance_l2(), x_mat, x0_vec)
#> [1] 1.664026 1.179849 0.938389 2.523089