R/SRM_PINV.R

Defines functions SRM_PINV

## File Name: SRM_PINV.R
## File Version: 0.081

SRM_PINV <- function(x, output_det=FALSE)
{
    is_ginv <- FALSE
    e1 <- try( chol2inv(chol(x)), silent=TRUE)
    if (inherits(x=e1, what="try-error") ){
        e1 <- try( solve(x), silent=TRUE)
    }
    if (inherits(x=e1, what="try-error") ){
        res <- SRM_GINV(x=x, output_det=output_det)
        is_ginv <- TRUE
        output_det <- FALSE
    }
    if (! is_ginv){
        res <- list(inv=e1)
    }
    if (output_det){
        res$log_det <- log(det(x))
    }
    return(res)
}

Try the srm package in your browser

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

srm documentation built on Nov. 3, 2022, 5:06 p.m.