R/pinv.R

Defines functions pinv

Documented in pinv

pinv <- function(X, tol = sqrt(.Machine$double.eps)) {
    X <- .mat(X)
    fm <- svd(X)
    posit <- fm$d > max(tol * fm$d[1L], 0)
    fm$d[!posit] <- 0
    sv <- fm$d[posit]
    V <- fm$v[, posit, drop = FALSE]
    U <- fm$u[, posit, drop = FALSE]
    Xplus <- V %*% (1 / sv * t(U))
    list(Xplus = Xplus, sv = fm$d)
    }

Try the rchemo package in your browser

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

rchemo documentation built on Sept. 11, 2024, 8:05 p.m.