R/sqdist.R

#' Squared distances
#'
#' @param x numeric matrix
#' @return squared distance matrix
sqdist <- function (x) {
    s <- tcrossprod (x)
    v <- diag (s)
    out <- outer (v, v, "+") - 2 * s #Was bug: could be less than 0
    out[out<0] <- 0 
    return(out)
}

sqdistOld <- function (x) {
    s <- tcrossprod (x)
    v <- diag (s)
    return(outer (v, v, "+") - 2 * s) #Bug
}

Try the smacofx package in your browser

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

smacofx documentation built on Sept. 22, 2024, 5:07 p.m.