# NAG FL Interfacef01buf (real_​symm_​posdef_​fac)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f01buf performs a $ULD{L}^{\mathrm{T}}{U}^{\mathrm{T}}$ decomposition of a real symmetric positive definite band matrix.

## 2Specification

Fortran Interface
 Subroutine f01buf ( n, m1, k, a, lda, w,
 Integer, Intent (In) :: n, m1, k, lda Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (Inout) :: a(lda,n) Real (Kind=nag_wp), Intent (Out) :: w(m1)
#include <nag.h>
 void f01buf_ (const Integer *n, const Integer *m1, const Integer *k, double a[], const Integer *lda, double w[], Integer *ifail)
The routine may be called by the names f01buf or nagf_matop_real_symm_posdef_fac.

## 3Description

The symmetric positive definite matrix $A$, of order $n$ and bandwidth $2m+1$, is divided into the leading principal sub-matrix of order $k$ and its complement, where $m\le k\le n$. A $UD{U}^{\mathrm{T}}$ decomposition of the latter and an $LD{L}^{\mathrm{T}}$ decomposition of the former are obtained by means of a sequence of elementary transformations, where $U$ is unit upper triangular, $L$ is unit lower triangular and $D$ is diagonal. Thus if $k=n$, an $LD{L}^{\mathrm{T}}$ decomposition of $A$ is obtained.
This routine is specifically designed to precede f01bvf for the transformation of the symmetric-definite eigenproblem $Ax=\lambda Bx$ by the method of Crawford where $A$ and $B$ are of band form. In this context, $k$ is chosen to be close to $n/2$ and the decomposition is applied to the matrix $B$.

## 4References

Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, Oxford
Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## 5Arguments

1: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
2: $\mathbf{m1}$Integer Input
On entry: $m+1$, where $m$ is the number of nonzero superdiagonals in $A$. Normally ${\mathbf{m1}}\ll {\mathbf{n}}$.
3: $\mathbf{k}$Integer Input
On entry: $k$, the change-over point in the decomposition.
Constraint: ${\mathbf{m1}}-1\le {\mathbf{k}}\le {\mathbf{n}}$.
4: $\mathbf{a}\left({\mathbf{lda}},{\mathbf{n}}\right)$Real (Kind=nag_wp) array Input/Output
On entry: the upper triangle of the $n×n$ symmetric band matrix $A$, with the diagonal of the matrix stored in the $\left(m+1\right)$th row of the array, and the $m$ superdiagonals within the band stored in the first $m$ rows of the array. Each column of the matrix is stored in the corresponding column of the array. For example, if $n=6$ and $m=2$, the storage scheme is
 $* * a13 a24 a35 a46 * a12 a23 a34 a45 a56 a11 a22 a33 a44 a55 a66$
Elements in the top left corner of the array are not used. The matrix elements within the band can be assigned to the correct elements of the array using the following code:
```   Do 20 j = 1, n
Do 10 i = max(1,j-m1+1), j
a(i-j+m1,j) = matrix(i,j)
End Do
End Do```
On exit: $A$ is overwritten by the corresponding elements of $L$, $D$ and $U$.
5: $\mathbf{lda}$Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f01buf is called.
Constraint: ${\mathbf{lda}}\ge {\mathbf{m1}}$.
6: $\mathbf{w}\left({\mathbf{m1}}\right)$Real (Kind=nag_wp) array Workspace
7: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-1$, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{m1}}-1=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{k}}\ge {\mathbf{m1}}-1$.
On entry, ${\mathbf{k}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{k}}\le {\mathbf{n}}$.
${\mathbf{ifail}}=2$
The matrix $A$ is not positive definite. This is probably a result of rounding errors, giving an element of $D$ which is zero or negative. The failure occurs in the leading principal sub-matrix of order k.
${\mathbf{ifail}}=3$
The matrix $A$ is not positive definite. This is probably a result of rounding errors, giving an element of $D$ which is zero or negative. The failure occurs in the complement.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

The Cholesky decomposition of a positive definite matrix is known for its remarkable numerical stability (see Wilkinson (1965)). The computed $U$, $L$ and $D$ satisfy the relation $ULD{L}^{\mathrm{T}}{U}^{\mathrm{T}}=A+E$ where the $2$-norms of $A$ and $E$ are related by $‖E‖\le c{\left(m+1\right)}^{2}\epsilon ‖A‖$ where $c$ is a constant of order unity and $\epsilon$ is the machine precision. In practice, the error is usually appreciably smaller than this.

## 8Parallelism and Performance

f01buf is not threaded in any implementation.

The time taken by f01buf is approximately proportional to $n{m}^{2}+3nm$.
This routine is specifically designed for use as the first stage in the solution of the generalized symmetric eigenproblem $Ax=\lambda Bx$ by Crawford's method which preserves band form in the transformation to a similar standard problem. In this context, for maximum efficiency, $k$ should be chosen as the multiple of $m$ nearest to $n/2$.
The matrix $U$ is such that ${U}^{-1}A{U}^{-\mathrm{T}}$ is diagonal in its last $n-k$ rows and columns, $L$ is such that ${L}^{-1}{U}^{-1}A{U}^{-\mathrm{T}}{L}^{-\mathrm{T}}=D$ and $D$ is diagonal. To find $U$, $L$ and $D$ where $A=ULD{L}^{\mathrm{T}}{U}^{\mathrm{T}}$ requires $nm\left(m+3\right)/2-m\left(m+1\right)\left(m+2\right)/3$ multiplications and divisions which, is independent of $k$.

## 10Example

This example finds a $ULD{L}^{\mathrm{T}}{U}^{\mathrm{T}}$ decomposition of the real symmetric positive definite matrix
 $( 3 −9 6 −9 31 −2 −4 6 −2 123 −66 15 −4 −66 145 −24 4 15 −24 61 −74 −18 4 −74 98 24 −18 24 6 ) .$

### 10.1Program Text

Program Text (f01bufe.f90)

### 10.2Program Data

Program Data (f01bufe.d)

### 10.3Program Results

Program Results (f01bufe.r)