Learn R Programming

BigDataStatMeth (version 2.0.3)

pseudoinverse: Moore-Penrose pseudoinverse

Description

Generic function for computing the Moore-Penrose pseudoinverse.

The HDF5Matrix method delegates to bdpseudoinv_hdf5(). This method reads the complete dataset into memory, computes the pseudoinverse via a direct LAPACK SVD, and writes the result back to HDF5. It is HDF5-backed but not block-wise: the full matrix and its pseudoinverse must both fit in available RAM during the computation. Result stored in the same HDF5 file under OUTPUT/<dataset>_pinv by default.

The matrix method delegates to bdpseudoinv() and computes the pseudoinverse of an in-memory matrix, returning a plain R matrix.

Both methods use the same singular-value tolerance (\(10^{-9}\)): singular values at or below the tolerance are treated as zero, following the standard Moore-Penrose construction \(A^+ = V \Sigma^+ U^\top\).

Usage

pseudoinverse(x, ...)

# S3 method for HDF5Matrix pseudoinverse(x, ...)

# S3 method for matrix pseudoinverse(x, threads = NULL, ...)

# S3 method for default pseudoinverse(x, ...)

Value

For HDF5Matrix: a new HDF5Matrix containing the pseudoinverse. For matrix: a plain numeric matrix.

Arguments

x

An object: an HDF5Matrix, or a numeric matrix.

threads

Optional integer. Number of threads for parallel computation when x is a plain matrix. If NULL (default), uses the maximum available threads. Ignored for HDF5Matrix, where the thread count is passed via \dots instead (see below).

\dots

Additional arguments. For HDF5Matrix: passed to x$pseudoinverse(), i.e. outgroup, outdataset, overwrite, threads, compression.

See Also

solve.HDF5Matrix, svd.HDF5Matrix

Examples

Run this code
# \donttest{
## In-memory matrix
m <- matrix(c(1,2,3,4,5,6), 3, 2)
pseudoinverse(m)

## HDF5Matrix
tmp <- tempfile(fileext = ".h5")
X   <- hdf5_create_matrix(tmp, "data/A", data = m)
P   <- pseudoinverse(X)
dim(P)   # 2 x 3
close(X); close(P)
unlink(tmp)
# }

Run the code above in your browser using DataLab