R/api-distances.R
register_distance.Rd
Register a distance spec under a name
register_distance(name, spec)
Character scalar registry key.
Either a distance spec or a function (X, x0, ctx) -> numeric(n).
(X, x0, ctx) -> numeric(n)
(Invisibly) the registered spec.
nm <- "tmp_l1_demo" register_distance( nm, function(X, x0, ctx = NULL) { rowSums(abs(X - matrix(x0, nrow(X), ncol(X), TRUE))) } ) nm %in% distance_names() #> [1] TRUE