**Purpose**

To determine a value for the Levenberg-Marquardt parameter PAR such that if x solves the system J*x = b , sqrt(PAR)*D*x = 0 , in the least squares sense, where J is an m-by-n matrix, D is an n-by-n nonsingular diagonal matrix, and b is an m-vector, and if DELTA is a positive number, DXNORM is the Euclidean norm of D*x, then either PAR is zero and ( DXNORM - DELTA ) .LE. 0.1*DELTA , or PAR is positive and ABS( DXNORM - DELTA ) .LE. 0.1*DELTA . The matrix J is the current Jacobian matrix of a nonlinear least squares problem, provided in a compressed form by SLICOT Library routine NF01BD. It is assumed that a block QR factorization, with column pivoting, of J is available, that is, J*P = Q*R, where P is a permutation matrix, Q has orthogonal columns, and R is an upper triangular matrix with diagonal elements of nonincreasing magnitude for each block, as returned by SLICOT Library routine NF01BS. The routine NF01BP needs the upper triangle of R in compressed form, the permutation matrix P, and the first n components of Q'*b (' denotes the transpose). On output, NF01BP also provides a compressed representation of an upper triangular matrix S, such that P'*(J'*J + PAR*D*D)*P = S'*S . Matrix S is used in the solution process. The matrix R has the following structure / R_1 0 .. 0 | L_1 \ | 0 R_2 .. 0 | L_2 | | : : .. : | : | , | 0 0 .. R_l | L_l | \ 0 0 .. 0 | R_l+1 / where the submatrices R_k, k = 1:l, have the same order BSN, and R_k, k = 1:l+1, are square and upper triangular. This matrix is stored in the compressed form / R_1 | L_1 \ | R_2 | L_2 | Rc = | : | : | , | R_l | L_l | \ X | R_l+1 / where the submatrix X is irrelevant. The matrix S has the same structure as R, and its diagonal blocks are denoted by S_k, k = 1:l+1. If l <= 1, then the full upper triangle of the matrix R is stored.

SUBROUTINE NF01BP( COND, N, IPAR, LIPAR, R, LDR, IPVT, DIAG, QTB, $ DELTA, PAR, RANKS, X, RX, TOL, DWORK, LDWORK, $ INFO ) C .. Scalar Arguments .. CHARACTER COND INTEGER INFO, LDR, LDWORK, LIPAR, N DOUBLE PRECISION DELTA, PAR, TOL C .. Array Arguments .. INTEGER IPAR(*), IPVT(*), RANKS(*) DOUBLE PRECISION DIAG(*), DWORK(*), QTB(*), R(LDR,*), RX(*), X(*)

**Mode Parameters**

COND CHARACTER*1 Specifies whether the condition of the diagonal blocks R_k and S_k of the matrices R and S should be estimated, as follows: = 'E' : use incremental condition estimation for each diagonal block of R_k and S_k to find its numerical rank; = 'N' : do not use condition estimation, but check the diagonal entries of R_k and S_k for zero values; = 'U' : use the ranks already stored in RANKS (for R).

N (input) INTEGER The order of the matrix R. N = BN*BSN + ST >= 0. (See parameter description below.) IPAR (input) INTEGER array, dimension (LIPAR) The integer parameters describing the structure of the matrix R, as follows: IPAR(1) must contain ST, the number of columns of the submatrices L_k and the order of R_l+1. ST >= 0. IPAR(2) must contain BN, the number of blocks, l, in the block diagonal part of R. BN >= 0. IPAR(3) must contain BSM, the number of rows of the blocks R_k, k = 1:l. BSM >= 0. IPAR(4) must contain BSN, the number of columns of the blocks R_k, k = 1:l. BSN >= 0. BSM is not used by this routine, but assumed equal to BSN. LIPAR (input) INTEGER The length of the array IPAR. LIPAR >= 4. R (input/output) DOUBLE PRECISION array, dimension (LDR, NC) where NC = N if BN <= 1, and NC = BSN+ST, if BN > 1. On entry, the leading N-by-NC part of this array must contain the (compressed) representation (Rc) of the upper triangular matrix R. If BN > 1, the submatrix X in Rc is not referenced. The zero strict lower triangles of R_k, k = 1:l+1, need not be set. If BN <= 1 or BSN = 0, then the full upper triangle of R must be stored. On exit, the full upper triangles of R_k, k = 1:l+1, and L_k, k = 1:l, are unaltered, and the strict lower triangles of R_k, k = 1:l+1, contain the corresponding strict upper triangles (transposed) of the upper triangular matrix S. If BN <= 1 or BSN = 0, then the transpose of the strict upper triangle of S is stored in the strict lower triangle of R. LDR INTEGER The leading dimension of array R. LDR >= MAX(1,N). IPVT (input) INTEGER array, dimension (N) This array must define the permutation matrix P such that J*P = Q*R. Column j of P is column IPVT(j) of the identity matrix. DIAG (input) DOUBLE PRECISION array, dimension (N) This array must contain the diagonal elements of the matrix D. DIAG(I) <> 0, I = 1,...,N. QTB (input) DOUBLE PRECISION array, dimension (N) This array must contain the first n elements of the vector Q'*b. DELTA (input) DOUBLE PRECISION An upper bound on the Euclidean norm of D*x. DELTA > 0. PAR (input/output) DOUBLE PRECISION On entry, PAR must contain an initial estimate of the Levenberg-Marquardt parameter. PAR >= 0. On exit, it contains the final estimate of this parameter. RANKS (input or output) INTEGER array, dimension (r), where r = BN + 1, if ST > 0, BSN > 0, and BN > 1; r = BN, if ST = 0 and BSN > 0; r = 1, if ST > 0 and ( BSN = 0 or BN <= 1 ); r = 0, if ST = 0 and BSN = 0. On entry, if COND = 'U' and N > 0, this array must contain the numerical ranks of the submatrices R_k, k = 1:l(+1). On exit, if N > 0, this array contains the numerical ranks of the submatrices S_k, k = 1:l(+1). X (output) DOUBLE PRECISION array, dimension (N) This array contains the least squares solution of the system J*x = b, sqrt(PAR)*D*x = 0. RX (output) DOUBLE PRECISION array, dimension (N) This array contains the matrix-vector product -R*P'*x.

TOL DOUBLE PRECISION If COND = 'E', the tolerance to be used for finding the ranks of the submatrices R_k and S_k. If the user sets TOL > 0, then the given value of TOL is used as a lower bound for the reciprocal condition number; a (sub)matrix whose estimated condition number is less than 1/TOL is considered to be of full rank. If the user sets TOL <= 0, then an implicitly computed, default tolerance, defined by TOLDEF = N*EPS, is used instead, where EPS is the machine precision (see LAPACK Library routine DLAMCH). This parameter is not relevant if COND = 'U' or 'N'.

DWORK DOUBLE PRECISION array, dimension (LDWORK) On exit, the first N elements of this array contain the diagonal elements of the upper triangular matrix S. If BN > 1 and BSN > 0, the elements N+1 : N+ST*(N-ST) contain the submatrix (S(1:N-ST,N-ST+1:N))' of the matrix S. LDWORK INTEGER The length of the array DWORK. LDWORK >= 2*N, if BN <= 1 or BSN = 0 and COND <> 'E'; LDWORK >= 4*N, if BN <= 1 or BSN = 0 and COND = 'E'; LDWORK >= ST*(N-ST) + 2*N, if BN > 1 and BSN > 0 and COND <> 'E'; LDWORK >= ST*(N-ST) + 2*N + 2*MAX(BSN,ST), if BN > 1 and BSN > 0 and COND = 'E'.

INFO INTEGER = 0: successful exit; < 0: if INFO = -i, the i-th argument had an illegal value.

The algorithm computes the Gauss-Newton direction. An approximate basic least squares solution is found if the Jacobian is rank deficient. The computations exploit the special structure and storage scheme of the matrix R. If one or more of the submatrices R_k or S_k, k = 1:l+1, is singular, then the computed result is not the basic least squares solution for the whole problem, but a concatenation of (least squares) solutions of the individual subproblems involving R_k or S_k, k = 1:l+1 (with adapted right hand sides). If the Gauss-Newton direction is not acceptable, then an iterative algorithm obtains improved lower and upper bounds for the Levenberg-Marquardt parameter PAR. Only a few iterations are generally needed for convergence of the algorithm. If, however, the limit of ITMAX = 10 iterations is reached, then the output PAR will contain the best value obtained so far. If the Gauss-Newton step is acceptable, it is stored in x, and PAR is set to zero, hence S = R.

[1] More, J.J., Garbow, B.S, and Hillstrom, K.E. User's Guide for MINPACK-1. Applied Math. Division, Argonne National Laboratory, Argonne, Illinois, Report ANL-80-74, 1980.

The algorithm requires 0(N*(BSN+ST)) operations and is backward stable, if R is nonsingular.

This routine is a structure-exploiting, LAPACK-based modification of LMPAR from the MINPACK package [1], and with optional condition estimation. The option COND = 'U' is useful when dealing with several right-hand side vectors, but RANKS array should be reset. If COND = 'E', but the matrix S is guaranteed to be nonsingular and well conditioned relative to TOL, i.e., rank(R) = N, and min(DIAG) > 0, then its condition is not estimated.

**Program Text**

None

None

None