View source: R/S3_pseudoinverse.R
| pseudoinverse | R Documentation |
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.
pseudoinverse(x, ...)
## S3 method for class 'HDF5Matrix'
pseudoinverse(x, ...)
## S3 method for class 'matrix'
pseudoinverse(x, threads = NULL, ...)
## Default S3 method:
pseudoinverse(x, ...)
x |
An object: an |
threads |
Optional integer. Number of threads for parallel computation
when |
... |
Additional arguments.
For |
For HDF5Matrix: a new HDF5Matrix containing the
pseudoinverse. For matrix: a plain numeric matrix.
solve.HDF5Matrix, svd.HDF5Matrix
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.