E04PCF (PDF version)
E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

NAG Library Routine Document


Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

E04PCF solves a linear least squares problem with bounds on the variables.

2  Specification

REAL (KIND=nag_wp)  A(LDA,*), B(M), BL(N), BU(N), TOL, X(N), RNORM, W(N)

3  Description

Given an m by n matrix A, and an m-vector, b, E04PCF computes an n-vector, x, that solves the least-squares problem Ax=b subject to xi satisfying li xi ui .
A facility is provided to return a ‘regularized’ solution, which will closely approximate a minimal length solution whenever A is not of full rank.

4  References

Lawson C L and Hanson R J (1974) Solving Least-squares Problems Prentice–Hall

5  Parameters

1:     ITYPE – INTEGERInput
On entry:
Specifies that a regularized solution will be computed.
Specifies that no regularization is to take place.
2:     M – INTEGERInput
On entry: m, the number of equations.
Constraint: M0.
3:     N – INTEGERInput
On entry: n, the number of variables.
Constraint: N0.
4:     A(LDA,*) – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array A must be at least N.
On entry: the m by n matrix A.
On exit: if ITYPE=1, A contains the product matrix, QA, where Q is an m by m orthogonal matrix generated by E04PCF; otherwise A is unchanged.
5:     LDA – INTEGERInput
On entry: the first dimension of the array A as declared in the (sub)program from which E04PCF is called.
Constraint: LDAM.
6:     B(M) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the right-hand side vector b.
On exit: if ITYPE=1, the product of Q times the original vector B; otherwise B is unchanged.
7:     BL(N) – REAL (KIND=nag_wp) arrayInput
8:     BU(N) – REAL (KIND=nag_wp) arrayInput
On entry: BLi and BUi must specify the lower and upper bounds, li and ui respectively to be imposed on the solution vector xi.
Constraint: BLi BUi, for i=1,2,,N.
9:     TOL – REAL (KIND=nag_wp)Input
On entry: TOL specifies a parameter used to determine the relative linear dependence of a column vector for a variable moved from its initial value. It determines the computational rank of the matrix.
If on entry TOL<machine precision, then machine precision is used.
10:   X(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the solution vector x.
11:   RNORM – REAL (KIND=nag_wp)Output
On exit: the Euclidean norm of the residual vector, b-Ax.
12:   NFREE – INTEGEROutput
On exit: indicates the number of components of the solution vector that are not at one of the constraints.
13:   W(N) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the dual solution vector.
A value of Wi equal to the special value -999 is indicative of the matrix A not having full rank. It is only likely to occur when ITYPE=1. However a matrix may have less than full rank without Wi being set to -999. Under these circumstances the value of Wi, and hence INDXi, may be unreliable. If you have any doubts set ITYPE=0. Otherwise values have the following meaning:
If xi is unconstrained.
If xi is constrained by its lower bound.
If xi is constrained by its upper bound.
May be any value if li=ui.
14:   INDX(N) – INTEGER arrayOutput
On exit: the contents of this array describe the components of the solution vector as follows:
INDXi, for i=1,2,,NFREE
These elements have not hit a constraint i.e., Wi=0.
INDXi, for i=NFREE+1,,k
These elements have been constrained by either the lower or upper bound constraint.
INDXi, for i=k+1 ,,N
These elements are fixed by the bounds i.e., BLi=BUi.
Here k is determined from NFREE and the number of fixed components. (Often the latter will be 0, so k will be N-NFREE.)
15:   IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if IFAIL0 on exit, the recommended value is -1. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Note: E04PCF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
On entry, M=value and LDA=value.
Constraint: LDAM.
On entry, M=value and N=value.
Constraint: M0 and N0.
On entry, when i=value, BLi=value and BUi=value.
Constraint: BLiBUi.
Failed to converge in value iterations.
Dynamic memory allocation failed.

7  Accuracy

Orthogonal rotations are used.

8  Further Comments

If either M or N is zero on entry then E04PCF sets IFAIL=0 and simply returns without setting any other output variables.

9  Example

The example minimizes Ax-b2  where
A = 0.05 0.05 0.25 -0.25 0.25 0.25 0.05 -0.05 0.35 0.35 1.75 -1.75 1.75 1.75 0.35 -0.35 0.30 -0.30 0.30 0.30 0.40 -0.40 0.40 0.40
b = 1.0 2.0 3.0 4.0 5.0 6.0 T
subject to 1x5.

9.1  Program Text

Program Text (e04pcfe.f90)

9.2  Program Data

Program Data (e04pcfe.d)

9.3  Program Results

Program Results (e04pcfe.r)

E04PCF (PDF version)
E04 Chapter Contents
E04 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012