| bdpseudoinv | R Documentation |
Computes the Moore-Penrose pseudoinverse of a matrix using SVD decomposition. This implementation handles both square and rectangular matrices, and provides numerically stable results even for singular or near-singular matrices.
bdpseudoinv(X, threads = NULL)
X |
Numeric matrix or vector to be pseudoinverted. |
threads |
Optional integer. Number of threads for parallel computation. If NULL, uses maximum available threads. |
The Moore-Penrose pseudoinverse (denoted A+) of a matrix A is computed using Singular Value Decomposition (SVD).
For a matrix A = USigmaV^T (where ^T denotes transpose), the pseudoinverse is computed as:
A^+ = V \Sigma^+ U^T
where Sigma+ is obtained by taking the reciprocal of non-zero singular values.
The pseudoinverse matrix of X.
SVD decomposition: A = U \Sigma V^T
Pseudoinverse: A^+ = V \Sigma^+ U^T
\Sigma^+_{ii} = 1/\Sigma_{ii} if \Sigma_{ii} > \text{tolerance}
\Sigma^+_{ii} = 0 otherwise
Key features:
Robust computation:
Handles singular and near-singular matrices
Automatic threshold for small singular values
Numerically stable implementation
Implementation details:
Uses efficient SVD algorithms
Parallel processing support
Memory-efficient computation
Handles both dense and sparse inputs
The pseudoinverse satisfies the Moore-Penrose conditions:
AA^+A = A
A^+AA^+ = A^+
(AA^+)^* = AA^+
(A^+A)^* = A^+A
Golub, G. H., & Van Loan, C. F. (2013). Matrix Computations, 4th Edition. Johns Hopkins University Press.
Ben-Israel, A., & Greville, T. N. E. (2003). Generalized Inverses: Theory and Applications, 2nd Edition. Springer.
# Create a singular matrix
X <- matrix(c(1,2,3,2,4,6), 2, 3) # rank-deficient matrix
# Compute pseudoinverse
X_pinv <- bdpseudoinv(X)
# Verify Moore-Penrose conditions
# 1. X %*% X_pinv %*% X = X
all.equal(X %*% X_pinv %*% X, X)
# 2. X_pinv %*% X %*% X_pinv = X_pinv
all.equal(X_pinv %*% X %*% X_pinv, X_pinv)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.