f03 Chapter Contents
f03 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_real_cholesky (f03aec)

## 1  Purpose

nag_real_cholesky (f03aec) computes a Cholesky factorization of a real symmetric positive definite matrix, and evaluates the determinant.

## 2  Specification

 #include #include
 void nag_real_cholesky (Integer n, double a[], Integer tda, double p[], double *detf, Integer *dete, NagError *fail)

## 3  Description

nag_real_cholesky (f03aec) computes the Cholesky factorization of a real symmetric positive definite matrix $A={LL}^{\mathrm{T}}$ where $L$ is lower triangular. The determinant is the product of the squares of the diagonal elements of $L$.

## 4  References

Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## 5  Arguments

1:     nIntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 1$.
2:     a[${\mathbf{n}}×{\mathbf{tda}}$]doubleInput/Output
Note: the $\left(i,j\right)$th element of the matrix $A$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{tda}}+j-1\right]$.
On entry: the upper triangle of the $n$ by $n$ positive definite symmetric matrix $A$. The elements of the array below the diagonal need not be set.
On exit: the sub-diagonal elements of the lower triangular matrix $L$. The upper triangle of $A$ is unchanged.
3:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: ${\mathbf{tda}}\ge {\mathbf{n}}$.
4:     p[n]doubleOutput
On exit: the reciprocals of the diagonal elements of $L$.
5:     detfdouble *Output
6:     deteInteger *Output
On exit: the determinant of $A$ is given by ${\mathbf{detf}}×{2.0}^{{\mathbf{dete}}}$. It is given in this form to avoid overflow or underflow.
7:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, ${\mathbf{tda}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tda}}\ge {\mathbf{n}}$.
NE_INT_ARG_LT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
NE_NOT_POS_DEF
The matrix is not positive definite, possibly due to rounding errors. The factorization could not be completed. detf and dete are set to zero.

## 7  Accuracy

The accuracy of the determinant depends on the conditioning of the original matrix. For a detailed error analysis see page 25 of Wilkinson and Reinsch (1971).

The time taken by nag_real_cholesky (f03aec) is approximately proportional to ${n}^{3}$.

## 9  Example

To compute a Cholesky factorization and calculate the determinant of the real symmetric positive definite matrix
 $6 7 6 5 7 11 8 7 6 8 11 9 5 7 9 11 .$

### 9.1  Program Text

Program Text (f03aece.c)

### 9.2  Program Data

Program Data (f03aece.d)

### 9.3  Program Results

Program Results (f03aece.r)