**Purpose**

To scale a matrix or undo scaling. Scaling is performed, if necessary, so that the matrix norm will be in a safe range of representable numbers.

SUBROUTINE MB01PD( SCUN, TYPE, M, N, KL, KU, ANRM, NBL, NROWS, A, $ LDA, INFO ) C .. Scalar Arguments .. CHARACTER SCUN, TYPE INTEGER INFO, KL, KU, LDA, M, MN, N, NBL DOUBLE PRECISION ANRM C .. Array Arguments .. INTEGER NROWS ( * ) DOUBLE PRECISION A( LDA, * )

**Mode Parameters**

SCUN CHARACTER*1 SCUN indicates the operation to be performed. = 'S': scale the matrix. = 'U': undo scaling of the matrix. TYPE CHARACTER*1 TYPE indicates the storage type of the input matrix. = 'G': A is a full matrix. = 'L': A is a (block) lower triangular matrix. = 'U': A is an (block) upper triangular matrix. = 'H': A is an (block) upper Hessenberg matrix. = 'B': A is a symmetric band matrix with lower bandwidth KL and upper bandwidth KU and with the only the lower half stored. = 'Q': A is a symmetric band matrix with lower bandwidth KL and upper bandwidth KU and with the only the upper half stored. = 'Z': A is a band matrix with lower bandwidth KL and upper bandwidth KU.

M (input) INTEGER The number of rows of the matrix A. M >= 0. N (input) INTEGER The number of columns of the matrix A. N >= 0. KL (input) INTEGER The lower bandwidth of A. Referenced only if TYPE = 'B', 'Q' or 'Z'. KU (input) INTEGER The upper bandwidth of A. Referenced only if TYPE = 'B', 'Q' or 'Z'. ANRM (input) DOUBLE PRECISION The norm of the initial matrix A. ANRM >= 0. When ANRM = 0 then an immediate return is effected. ANRM should be preserved between the call of the routine with SCUN = 'S' and the corresponding one with SCUN = 'U'. NBL (input) INTEGER The number of diagonal blocks of the matrix A, if it has a block structure. To specify that matrix A has no block structure, set NBL = 0. NBL >= 0. NROWS (input) INTEGER array, dimension max(1,NBL) NROWS(i) contains the number of rows and columns of the i-th diagonal block of matrix A. The sum of the values NROWS(i), for i = 1: NBL, should be equal to min(M,N). The elements of the array NROWS are not referenced if NBL = 0. A (input/output) DOUBLE PRECISION array, dimension (LDA,N) On entry, the leading M by N part of this array must contain the matrix to be scaled/unscaled. On exit, the leading M by N part of A will contain the modified matrix. The storage mode of A is specified by TYPE. LDA (input) INTEGER The leading dimension of the array A. LDA >= max(1,M).

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

Denote by ANRM the norm of the matrix, and by SMLNUM and BIGNUM, two positive numbers near the smallest and largest safely representable numbers, respectively. The matrix is scaled, if needed, such that the norm of the result is in the range [SMLNUM, BIGNUM]. The scaling factor is represented as a ratio of two numbers, one of them being ANRM, and the other one either SMLNUM or BIGNUM, depending on ANRM being less than SMLNUM or larger than BIGNUM, respectively. For undoing the scaling, the norm is again compared with SMLNUM or BIGNUM, and the reciprocal of the previous scaling factor is used.

None

**Program Text**

None

None

None