# ?laln2

Solves a 1-by-1 or 2-by-2 linear system of equations of the specified form.

## Syntax

call slaln2( ltrans, na, nw, smin, ca, a, lda, d1, d2, b, ldb, wr, wi, x, ldx, scale, xnorm, info )

call dlaln2( ltrans, na, nw, smin, ca, a, lda, d1, d2, b, ldb, wr, wi, x, ldx, scale, xnorm, info )

## Description

The routine solves a system of the form

`(ca*A - w*D)*X = s*B,` or `(ca*A' - w*D)*X = s*B`

with possible scaling (s) and perturbation of A (A' means A-transpose.)

A is an na-by-na real matrix, ca is a real scalar, D is an na-by-na real diagonal matrix, w is a real or complex value, and X and B are na-by-1 matrices: real if w is real, complex if w is complex. The parameter na may be 1 or 2.

If w is complex, X and B are represented as na-by-2 matrices, the first column of each being the real part and the second being the imaginary part.

The routine computes the scaling factor `s ( ≤ 1 )` so chosen that X can be computed without overflow. X is further scaled if necessary to assure that `norm(ca*A - w*D)*norm(X)` is less than overflow.

If both singular values of `(ca&*A - w*D)` are less than smin, smin*I (where I stands for identity) will be used instead of (ca*A - w*D). If only one singular value is less than smin, one element of (ca*A - w*D) will be perturbed enough to make the smallest singular value roughly smin.

If both singular values are at least `smin, (ca*A - w*D)` will not be perturbed. In any case, the perturbation will be at most some small multiple of `max(smin, ulp*norm(ca*A - w*D))`.

The singular values are computed by infinity-norm approximations, and thus will only be correct to a factor of 2 or so.

### Note

All input quantities are assumed to be smaller than overflow by a reasonable factor (see bignum).

## Input Parameters

trans

  LOGICAL.

  If `trans = .TRUE.`, A- transpose will be used.

  If `trans = .FALSE.`, A will be used (not transposed.)

na

  INTEGER. The size of the matrix A, possible values 1 or 2.

nw

  INTEGER. This parameter must be 1 if w is real, and 2 if w is complex. Possible values 1 or 2.

smin

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  The desired lower bound on the singular values of A.

  This should be a safe distance away from underflow or overflow, for example, between (underflow/machine_precision) and (machine_precision * overflow). (See bignum and ulp).

ca

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  The coefficient by which A is multiplied.

a

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  Array, DIMENSION (lda,na).

  The na-by-na matrix A.

lda

  INTEGER. The leading dimension of a. Must be at least na.

d1, d2

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  The (1,1) and (2,2) elements in the diagonal matrix D, respectively. d2 is not used if `nw = 1`.

b

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  Array, DIMENSION (ldb,nw). The na-by-nw matrix B (right-hand side). If nw =2 (w is complex), column 1 contains the real part of B and column 2 contains the imaginary part.

ldb

  INTEGER. The leading dimension of b. Must be at least na.

wr, wi

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  The real and imaginary part of the scalar w, respectively.

  wi is not used if `nw = 1`.

ldx

  INTEGER. The leading dimension of the output array x. Must be at least na.

## Output Parameters

x

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  Array, DIMENSION (ldx,nw). The na-by-nw matrix X (unknowns), as computed by the routine. If `nw = 2` (w is complex), on exit, column 1 will contain the real part of X and column 2 will contain the imaginary part.

scale

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  The scale factor that B must be multiplied by to insure that overflow does not occur when computing X. Thus `(ca*A - w*D) X` will be scale*B, not B (ignoring perturbations of A.) It will be at most 1.

xnorm

  REAL for slaln2

  DOUBLE PRECISION for dlaln2.

  The infinity-norm of X, when X is regarded as an na-by-nw real matrix.

info

  INTEGER.

  An error flag. It will be zero if no error occurs, a negative number if an argument is in error, or a positive number if `(ca*A - w*D)` had to be perturbed. The possible values are:

  If `info = 0`: no error occurred, and (`ca*A - w*D`) did not have to be perturbed.

  If `info = 1`: (`ca*A - w*D`) had to be perturbed to make its smallest (or only) singular value greater than smin.

### Note

For higher speed, this routine does not check the inputs for errors.

Parent topic: Auxiliary Routines