# IMSL_CHSOL

The IMSL_CHSOL function solves a symmetric positive definite system of real or complex linear equations Ax = b.

Note: This routine requires an IDL Analyst license. For more information, contact your Exelis VIS sales or technical support representative.

The IMSL_CHSOL function solves a system of linear algebraic equations having a symmetric positive definite coefficient matrix A. The function first computes the Cholesky factorization LLH of A. The solution of the linear system is then found by solving the two simpler systems, y = L–1b and x = L–Hy. An estimate of the L1 condition number of A is computed using the same algorithm as in Dongarra et al. (1979). If the estimated condition number is greater than 1/ε (where ε is the machine precision), a warning message is issued. This indicates that very small changes in A may produce large changes in the solution x.

The IMSL_CHSOL function fails if L, the lower-triangular matrix in the factorization, has a zero diagonal element.

## Examples

For additional information on using IMSL_CHSOL, see Additional Examples.

### Example 1

RM, a, 3, 3

; Define the coefficient matrix.

row 0: 1 -3 2

row 1: -3 10 -5

row 2: 2 -5 6

RM, b, 3, 1

; Define the right-hand side.

row 0: 27

row 1: -78

row 2: 64

x = IMSL_CHSOL(b, a)

; Call IMSL_CHSOL to compute the solution.

PM, x, Title = 'Solution'

Solution

1.00000

-4.00000

Chapter 4: Linear Systems 93

IDL Analyst Reference Guide IMSL_CHSOL

7.00000

PM, a # x - b, Title = 'Residual'

Residual

0.00000

0.00000

0.00000

## Syntax

Result =IMSL_CHSOL( b [, a] [, CONDITION=variable] [, /DOUBLE] [, FACTOR=variable] [, INVERSE=variable] )

## Return Value

The solution of the linear system Ax = b.

## Arguments

### b

One-dimensional matrix containing the right-hand side.

### a

Two-dimensional matrix containing the coefficient matrix. Matrix A (i, j) containsthe j-th coefficient of the i-th equation.

## Keywords

### CONDITION

Named variable into which an estimate of the L1 condition number is stored. The CONDITION and FACTOR keywords cannot be used together.

### DOUBLE

If present and nonzero, double precision is used.

### FACTOR

Named variable in which the LLH factorization of A is stored. The lower-triangular part of this matrix contains L, and the upper-triangular part contains LH. The CONDITION and FACTOR keywords cannot be used together.

### INVERSE

Specifies a named variable into which the inverse of the matrix A is stored. This keyword is not allowed if A is complex.

## Errors

### Warning Errors

`MATH_ILL_CONDITIONED` - Input matrix is too ill-conditioned. An estimate of the reciprocal of its L1 condition number is #. The solution might not be accurate.

### Fatal Errors

`MATH_NONPOSITIVE_MATRIX` - Leading # by # submatrix of the input matrix is not positive definite.

`MATH_SINGULAR_MATRIX` - Input matrix is singular

`MATH_SINGULAR_TRI_MATRIX` - Input triangular matrix is singular. The index of the first zero diagonal element is #.

## Additional Examples

### Example 2

This example solves a system of five linear equations with Hermitian positive definite coefficient matrix. The equations are as follows:

2x0 + (–1 + i ) x1 = 1 + 5i

(–1 –i ) x0 + 4x1 + (1 + 2i ) x2 = 12 – 6i

(–1 –2i ) x1 + 10x2 + 4ix3 = 1 + (–16i )

(–4ix2) + 6x3 + (i + 1)x4 = –3 –3i

(1 – i ) x3 + 9x4 = 25 + 16i

RM, a, 5, 5, /Complex

; Input the complex matrix A.

row 0: 2 (-1,1) 0 0 0

row 1: (-1,-1) 4 (1,2) 0 0

row 2: 0 (1,-2) 10 (0,4) 0

row 3: 0 0 (0,-4) 6 (1,1)

row 4: 0 0 0 (1,-1) 9

RM, b, 5, 1, /Complex

; Input the right-hand side.

row 0: (1, 5)

row 1: (12, -6)

row 2: (1, -16)

row 3: (-3, -3)

row 4: (25, 16)

x = IMSL_CHSOL(b, a)

; Compute the solution.

PM, x, Title = 'Solution', Format = '("(",f8.5,",",f8.5,")")'

; Output the results.

Solution

( 2.00000, 1.00000)

( 3.00000,-0.00000)

(-1.00000,-1.00000)

( 0.00000,-2.00000)

( 3.00000, 2.00000)

PM, a # x-b, Title = 'Residual', Format='("(",f8.5,",",f8.5,")")'

Residual

( 0.00000, 0.00000)

( 0.00000,-0.00000)

( 0.00000, 0.00000)

( 0.00000, 0.00000)

( 0.00000, 0.00000)

## Version History

6.4 | Introduced