NullC: Null Space of a Matrix

Description Usage Arguments Value Note Author(s) Examples

View source: R/NullC.R

Description

Given a matrix M, find a matrix N giving a basis for the null space. This is a modified version of Null from the package MASS.

Usage

1
NullC(M)

Arguments

M

input matrix.

Value

an orthonormal matrix such that t(N)%*%M is a matrix of zeros.

Note

The MASS function Null(matrix(0,4,2)) returns a 4*2 matrix, whereas NullC(matrix(0,4,2)) returns diag(4).

Author(s)

Peter Hoff

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
NullC(matrix(0,4,2))

## The function is currently defined as
function (M) 
{
    tmp <- qr(M)
    set <- if (tmp$rank == 0L) 
        1L:nrow(M)
    else -(1L:tmp$rank)
    qr.Q(tmp, complete = TRUE)[, set, drop = FALSE]
  }

rstiefel documentation built on June 15, 2021, 5:07 p.m.