R/sinv.R

Defines functions sinv

Documented in sinv

#' Invert a symmetric positive-definite matrix
#'
#' Inverts a symmetric positive-definite matrix without requiring the Matrix package.
#'
#' @param obj The symmetric positive-definite matrix
#' @return A matrix of the same size as the input object
#' @details This function does no error checking and it is up to the user to ensure that the input is indeed symmetric, positive-definite, and a matrix.
#'
#' @examples
#' m <- matrix(c(1, 0, .5, .5, 0, 1, .5, .5, .5, .5, 1, .5, .5, .5, .5, 1), 4)
#' sinv(m)
#'
#' @author Claus Ekstrom, \email{claus@@rprimer.dk}.
#' @keywords file
#' @export

sinv <- function(obj) {
    return(chol2inv(chol(obj)))
}

Try the MESS package in your browser

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

MESS documentation built on Aug. 21, 2023, 1:05 a.m.