pnull: Particular least-squares solution and Null-space basis

pnullR Documentation

Particular least-squares solution and Null-space basis

Description

use Lapack to find a particular solution xp of under-determined least squares system Ax=b and build null space basis B of A (derived from MASS::Null). In such a way, a general solution is given by x=xp+Bz where z is an arbitrary vector of size ncol(A)-rank(A).

Usage

pnull(A, b = NULL, qrat = NULL, rcond = 1e+10, keepqr = FALSE)

Arguments

A

matrix (or its QR decomposition) such that A%*%B=0 where B is a basis of Kern(A) (aka Null-space).

b

is the right hand side of the least squares system Ax=b.

qrat

is QR decomposition of t(A).

rcond

maximal condition number for rank definition

keepqr

if TRUE strore qr and qrat as attribute of B

Value

alist with xp and B, particular solution and numeric matrix whose columns are basis vectors. If requested, attributes 'qr' and 'qrat' of B contain QR decomposition of A and t(A) respectively.

See Also

MASS::Null Nulla

Examples

A=diag(nrow=3L)[1:2,,drop=FALSE]
b=A%*%(1:3)
res=pnull(A, b)
stopifnot(all.equal(res$xp, c(1:2,0)))
stopifnot(all.equal(c(res$B), c(0,0,1)))

nlsic documentation built on June 28, 2025, 1:08 a.m.

Related to pnull in nlsic...