R/pdist.R

#' Squared p-distances
#'
#' @param x numeric matrix
#' @param p p>0 the Minkoswki distance
#' @return squared Minkowski distance matrix
pdist <- function (x,p) {
    s <- tcrossprod (x)
    v <- diag (s)
    return (outer (v, v, "+") - 2 * s)
}

Try the cops package in your browser

Any scripts or data that you put into this service are public.

cops documentation built on Feb. 2, 2024, 3:02 p.m.