# NAG CL Interfacef01mdc (real_​modified_​cholesky)

Settings help

CL Name Style:

## 1Purpose

f01mdc computes the Cheng–Higham modified Cholesky factorization of a real symmetric matrix.

## 2Specification

 #include
 void f01mdc (Nag_UploType uplo, Integer n, double a[], Integer pda, double offdiag[], Integer ipiv[], double delta, NagError *fail)
The function may be called by the names: f01mdc or nag_matop_real_modified_cholesky.

## 3Description

Given a symmetric, possibly indefinite matrix $A$, f01mdc finds the Cheng–Higham modified Cholesky factorization
 $PT(A+E)P=LDLT ,$
when ${\mathbf{uplo}}=\mathrm{Nag_Lower}$. Here $L$ is a unit lower triangular matrix, $P$ is a permutation matrix, $D$ is a symmetric block diagonal matrix (with blocks of order $1$ or $2$) with minimum eigenvalue $\delta$, and $E$ is a perturbation matrix of small norm chosen so that such a factorization can be found. Note that $E$ is not computed explicitly.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, we compute the factorization ${P}^{\mathrm{T}}\left(A+E\right)P=UD{U}^{\mathrm{T}}$, where $U$ is a unit upper triangular matrix.
If the matrix $A$ is symmetric positive definite, the algorithm ensures that $E=0$. The function f01mec can be used to compute the matrix $A+E$.

## 4References

Ashcraft C, Grimes R G, and Lewis J G (1998) Accurate symmetric indefinite linear equation solvers SIAM J. Matrix Anal. Appl. 20 513–561
Cheng S H and Higham N J (1998) A modified Cholesky algorithm based on a symmetric indefinite factorization SIAM J. Matrix Anal. Appl. 19(4) 1097–1110

## 5Arguments

1: $\mathbf{uplo}$Nag_UploType Input
On entry: specifies whether the upper or lower triangular part of $A$ is stored and how $A$ is to be factorized.
${\mathbf{uplo}}=\mathrm{Nag_Upper}$
The upper triangular part of $A$ is stored and we compute ${P}^{\mathrm{T}}\left(A+E\right)P=UD{U}^{\mathrm{T}}$.
${\mathbf{uplo}}=\mathrm{Nag_Lower}$
The lower triangular part of $A$ is stored and we compute ${P}^{\mathrm{T}}\left(A+E\right)P=LD{L}^{\mathrm{T}}$.
Constraint: ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$.
2: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}>0$.
3: $\mathbf{a}\left[\mathit{dim}\right]$double Input/Output
Note: the dimension, dim, of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pda}}×{\mathbf{n}}\right)$.
On entry: the $n×n$ symmetric matrix $A$.
${A}_{ij}$ is stored in ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, the upper triangular part of $A$ must be stored and the elements of the array below the diagonal are not referenced.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the lower triangular part of $A$ must be stored and the elements of the array above the diagonal are not referenced.
On exit: a is overwritten.
${A}_{ij}$ is stored in ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$.
See Section 9 for further details.
4: $\mathbf{pda}$Integer Input
On entry: the stride separating row elements of the matrix $A$ in the array a.
Constraint: ${\mathbf{pda}}\ge {\mathbf{n}}$.
5: $\mathbf{offdiag}\left[{\mathbf{n}}\right]$double Output
On exit: the offdiagonals of the symmetric matrix $D$ are returned in ${\mathbf{offdiag}}\left[0\right],{\mathbf{offdiag}}\left[1\right],\dots ,{\mathbf{offdiag}}\left[n-2\right]$, for ${\mathbf{uplo}}=\mathrm{Nag_Lower}$ and in ${\mathbf{offdiag}}\left[1\right],{\mathbf{offdiag}}\left[2\right],\dots ,{\mathbf{offdiag}}\left[n-1\right]$, for ${\mathbf{uplo}}=\mathrm{Nag_Upper}$. See Section 9 for further details.
6: $\mathbf{ipiv}\left[{\mathbf{n}}\right]$Integer Output
On exit: gives the permutation information of the factorization. The entries of ipiv are either positive, indicating a $1×1$ pivot block, or pairs of negative entries, indicating a $2×2$ pivot block.
${\mathbf{ipiv}}\left[i-1\right]=k>0$
The $i$th and $k$th rows and columns of $A$ were interchanged and ${d}_{ii}$ is a $1×1$ block.
${\mathbf{ipiv}}\left[i-1\right]=-k<0$ and ${\mathbf{ipiv}}\left[i\right]=-\ell <0$
The $i$th and $k$th rows and columns, and the $i+1$st and $\ell$th rows and columns, were interchanged and $D$ has the $2×2$ block:
 $( dii di+1,i di+1,i di+1,i+1 )$
• If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, ${d}_{i+1,i}$ is stored in ${\mathbf{offdiag}}\left[i\right]$. The interchanges were made in the order $i={\mathbf{n}},{\mathbf{n}}-1,\dots ,2$.
• If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, ${d}_{i+1,i}$ is stored in ${\mathbf{offdiag}}\left[i-1\right]$. The interchanges were made in the order $i=1,2,\dots ,{\mathbf{n}}-1$.
7: $\mathbf{delta}$double Input
On entry: the value of $\delta$.
Constraint: ${\mathbf{delta}}\ge 0.0$.
8: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_EIGENPROBLEM
NE_INT
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}>0$.
NE_INT_2
On entry, ${\mathbf{pda}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pda}}\ge {\mathbf{n}}$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_REAL
On entry, ${\mathbf{delta}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{delta}}\ge 0.0$.

## 7Accuracy

If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the computed factors $L$ and $D$ are the exact factors not of ${P}^{\mathrm{T}}\left(A+E\right)P$ but of $P\left(A+E+F\right){P}^{\mathrm{T}}$, where
 $‖F‖2 ≤ c(n) ε ‖A+E‖2 ≤ c(n) ε ‖L‖2 ‖D‖2 ‖LT‖2 ,$
$c\left(n\right)$ is a modest linear function of $n$, and $\epsilon$ is the machine precision.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, a similar statement holds for the computed factors $U$ and $D$.

## 8Parallelism and Performance

f01mdc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f01mdc makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

The elements of the main diagonal of $D$ overwrite the corresponding elements of the main diagonal of $A$; the $n-1$ elements of the subdiagonal (and superdiagonal, by symmetry) elements of $D$ are stored in the array offdiag. If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, then these are stored in ${\mathbf{offdiag}}\left[0\right],\dots ,{\mathbf{offdiag}}\left[n-2\right]$ that is ${d}_{i+1,i}$, for $i=1,\dots ,n-1$ is stored in ${\mathbf{offdiag}}\left[i-1\right]$; otherwise, they are stored in ${\mathbf{offdiag}}\left[1\right],\dots ,{\mathbf{offdiag}}\left[n-1\right]$, with ${d}_{i+1,i}$ stored in ${\mathbf{offdiag}}\left(i+1\right)-1$.
The unit diagonal elements of $U$ or $L$ are not stored. The remaining elements of $U$ or $L$ are stored explicitly in either the strictly upper or strictly lower triangular part of the array a, respectively.
The total number of floating-point operations is approximately $\frac{1}{3}{n}^{3}$. The searching overhead for rook pivoting used by the algorithm is between $\mathit{O}\left({n}^{2}\right)$ and $\mathit{O}\left({n}^{3}\right)$ comparisons. Experimental evidence suggests $\mathit{O}\left({n}^{2}\right)$ comparisons are usual, see Ashcraft et al. (1998).
All of the entries of the triangular matrix $L$ or $U$ are bounded above (by approximately $2.78$), and, therefore, the norm of the matrix itself is also bounded.
The exact size of the perturbation matrix $E$ cannot be predicted a priori. However, the algorithm attempts to ensure that it is not much greater than the minimum perturbation $\Delta A$ such that $A+\Delta A$ has the minimum eigenvalue $\delta$. In particular, it should be zero when $A$ is positive definite and $\delta =0$. If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, then in general it can be shown that
 $‖E‖2 ≤ λmax(LLT) (δ- λmin(A) λmin(LLT) ) ,$
where ${\lambda }_{\text{max}}$ and ${\lambda }_{\text{min}}$ denote the largest and smallest eigenvalues of the matrix in question. A similar result holds if ${\mathbf{uplo}}=\mathrm{Nag_Upper}$.

## 10Example

This example computes the modified Cholesky factorization $A+E=PLD{L}^{\mathrm{T}}{P}^{\mathrm{T}}$, for the indefinite matrix $A$, where
 $A= ( 0.9649 0.1419 0.0357 0.3922 0.0462 0.1419 0.4218 0.8491 0.6555 0.0971 0.0357 0.8491 0.9340 0.1712 0.8235 0.3922 0.6555 0.1712 0.7060 0.6948 0.0462 0.0971 0.8235 0.6948 0.3171 ) .$
The output is then passed to f01mec to explicitly form the matrix $A+E$ and the norm of $E$ is computed.

### 10.1Program Text

Program Text (f01mdce.c)

### 10.2Program Data

Program Data (f01mdce.d)

### 10.3Program Results

Program Results (f01mdce.r)