R/vol_splx.R

Defines functions vol_splx

Documented in vol_splx

#' Volume of a simplex
#'
#' calculates the volume of a simplex
#'
#' @param S : matrix (d+1) rows * d columns containing the coordinates in d-dim of d + 1 vertices of a simplex
#' @return V : simplex volume
#'
#' @examples
#' # Definition of the parameters
#' S <- matrix(rexp(6), 3, 2)
#' # Call the function
#' res <- vol_splx(S)
#'
#' @author Fabrice Zaoui

vol_splx <- function(S) {

  d <- dim(S)[2]
  A <- S[2:dim(S)[1], ] - matrix(1, nrow = d, ncol = 1) %*% S[1, ]
  V <- (1 / factorial(d)) * abs(det(A))

  return(V)
}

Try the caRamel package in your browser

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

caRamel documentation built on March 18, 2022, 7:23 p.m.