ginv2: Generalized Inverse (Moore-Penrose Inverse)

View source: R/13_MASS.R

ginv2R Documentation

Generalized Inverse (Moore-Penrose Inverse)

Description

Compute the Moore-Penrose generalized inverse of a matrix. This is an S3 generic function with methods for base matrices, dense Matrix objects, and sparse Matrix objects.

Usage

ginv2(X, tol = sqrt(.Machine$double.eps), ...)

ginv2_beachmat(X, tol = sqrt(.Machine$double.eps), ...)

ginv2_default(X, tol = sqrt(.Machine$double.eps), ...)

Arguments

X

A numeric or complex matrix

tol

Tolerance for determining rank. Default is sqrt(.Machine$double.eps)

...

Additional arguments passed to methods

Value

The generalized inverse of X

Examples

## Not run: 
# Base R matrix
m <- matrix(c(1, 2, 3, 4, 5, 6), 2, 3)
ginv2(m)

# Dense Matrix
library(Matrix)
dm <- Matrix(m, sparse = FALSE)
ginv2(dm)

# Sparse Matrix
sm <- Matrix(m, sparse = TRUE)
ginv2(sm)

## End(Not run)

SigBridgeRUtils documentation built on Sept. 29, 2026, 5:09 p.m.