gi: General inverse of a matrix

Description Usage Arguments Value Examples

View source: R/gi.R

Description

This function returns general inverse of a matrix.

Usage

1
gi(A)

Arguments

A

A is a numberical matrix

Value

aplus is the general inverse of A.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (A)
{
    svda <- svd(A, nu = nrow(A), nv = ncol(A))
    dplus <- t(A)
    dplus[] <- 0
    diag(dplus) <- svda$d
    dplus[which(as.matrix(dplus) < 0.1^(4))] <- 0
    dplus[which(as.matrix(dplus) != 0)] <- 1/dplus[which(as.matrix(dplus) !=
        0)]
    aplus <- svda$v %*% dplus %*% t(svda$u)
    return(aplus)
  }

xzheng-ac/scPADGRN documentation built on July 26, 2020, 12:41 a.m.