Language Reference

APPCORT Call

CALL APPCORT (prqb, lindep, a, b, <, sing> ) ;

This subroutine is supported by the IML procedure and the iml action.

If bold upper A is rank-deficient, then the least squares problem min Underscript x Endscripts double-vertical-bar bold upper A bold x minus bold b double-vertical-bar Subscript 2 Superscript 2 has infinitely many solutions (Golub and Van Loan 1989, p. 241). However, there is a unique solution which has the smallest Euclidean norm. The APPCORT subroutine computes the minimum Euclidean-norm solution of the (rank-deficient) least squares problem by applying a complete orthogonal decomposition by Householder transformations to the vector bold b.

The input arguments to the APPCORT subroutine are as follows:

a

is an m times n matrix bold upper A, with m greater-than-or-equal-to n, which is to be decomposed into the product of the m times m orthogonal matrix bold upper Q, the n times n upper triangular matrix bold upper R, and the n times n orthogonal matrix bold upper P,

bold upper A equals bold upper Q StartBinomialOrMatrix bold upper R Choose bold 0 EndBinomialOrMatrix bold upper Pi prime bold upper P prime bold upper Pi
b

is a m times p matrix, bold upper B.

sing

is an optional scalar that specifies a singularity criterion.

The APPCORT subroutine returns the following values:

prqb

is an n times p matrix product

bold upper P bold upper Pi Start 2 By 2 Matrix 1st Row 1st Column left-parenthesis bold upper L prime right-parenthesis Superscript negative 1 2nd Column bold 0 2nd Row 1st Column bold 0 2nd Column bold 0 EndMatrix bold upper Q prime bold upper B

which is the minimum Euclidean-norm solution of the rank-deficient least squares problem double-vertical-bar bold upper A bold x minus bold b vertical-bar Subscript 2 Baseline Superscript 2 Baseline.

lindep

is the number of linearly dependent columns in the matrix bold upper A that are detected by applying the r Householder transformations. That is, lindep is n minus r, where r is the numerical rank of bold upper A.

See the section COMPORT Call for information about complete orthogonal decomposition.

The following example uses the APPCORT call to solve a rank-deficient least squares problem:

/* compute solution for rank-deficient least squares problem:
      min |Ax-b|^2
   The range of A is a line; b is a point not on the line. */
A = {1  2,
     2  4,
    -1 -2};
b = {1, 3, -2};
call appcort(x,lindep,A,b);
print x;

Figure 40: Solution to a Rank-Deficient Least Squares Problem

x
0.3
0.6


The argument b can also be a matrix. If b is an identity matrix, then you can use the APPCORT subroutine to form a generalized inverse, as shown in the following example:

/* A has only four linearly independent columns */
A = {1 0 1 0 0,
     1 0 0 1 0,
     1 0 0 0 1,
     0 1 1 0 0,
     0 1 0 1 0,
     0 1 0 0 1 };

/* compute Moore-Penrose generalized inverse */
b = i(nrow(A));                   /* identity matrix */
call appcort(Ainv, lindep, A, b);
print Ainv;

/* verify generalized inverse conditions (Golub & Van Loan, p. 243) */
eps = 1e-12;
if any(A*Ainv*A-A > eps) |
   any(Ainv*A*Ainv-Ainv > eps) |
   any((A*Ainv)`-A*Ainv > eps) |
   any((Ainv*A)`-Ainv*A > eps) then
   msg = "Pseudoinverse conditions not satisfied";
else
   msg = "Pseudoinverse conditions satisfied";
print msg;

Figure 41: Generalized Inverse

Ainv
0.26666670.26666670.2666667-0.066667-0.066667-0.066667
-0.066667-0.066667-0.0666670.26666670.26666670.2666667
0.4-0.1-0.10.4-0.1-0.1
-0.10.4-0.1-0.10.4-0.1
-0.1-0.10.4-0.1-0.10.4

msg
Pseudoinverse conditions satisfied


Last updated: July 20, 2026