# NAG FL Interfacef01mef (real_​mod_​chol_​perturbed_​a)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f01mef computes the positive definite perturbed matrix $A+E$ from the factors of a modified Cholesky factorization of a real symmetric matrix, $A$.

## 2Specification

Fortran Interface
 Subroutine f01mef ( uplo, n, a, lda, ipiv,
 Integer, Intent (In) :: n, lda, ipiv(n) Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: offdiag(n) Real (Kind=nag_wp), Intent (Inout) :: a(lda,*) Character (1), Intent (In) :: uplo
#include <nag.h>
 void f01mef_ (const char *uplo, const Integer *n, double a[], const Integer *lda, const double offdiag[], const Integer ipiv[], Integer *ifail, const Charlen length_uplo)
The routine may be called by the names f01mef or nagf_matop_real_mod_chol_perturbed_a.

## 3Description

f01mef computes the positive definite perturbed matrix $A+E$ from the factors provided by a previous call to f01mdf. For a symmetric, possibly indefinite matrix $A$, f01mdf finds the Cheng–Higham modified Cholesky factorization
 $PT(A+E)P=LDLT ,$
when ${\mathbf{uplo}}=\text{'L'}$. 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$). The matrix $E$ is not explicitly formed.
If ${\mathbf{uplo}}=\text{'U'}$, we compute $A+E$ from the factorization ${P}^{\mathrm{T}}\left(A+E\right)P=UD{U}^{\mathrm{T}}$, where $U$ is a unit upper triangular matrix.

## 4References

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}$Character(1) Input
On entry: indicates whether the upper or lower triangular part of $A$ was stored and how it was factorized.
${\mathbf{uplo}}=\text{'U'}$
The upper triangular part of $A$ was stored and we compute $A+E$ such that ${P}^{\mathrm{T}}\left(A+E\right)P=UD{U}^{\mathrm{T}}$.
${\mathbf{uplo}}=\text{'L'}$
The lower triangular part of $A$ was stored and we compute $A+E$ such that ${P}^{\mathrm{T}}\left(A+E\right)P=LD{L}^{\mathrm{T}}$.
Constraint: ${\mathbf{uplo}}=\text{'U'}$ or $\text{'L'}$.
2: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}>0$.
3: $\mathbf{a}\left({\mathbf{lda}},*\right)$Real (Kind=nag_wp) array Input/Output
Note: the second dimension of the array a must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the modified Cholesky factor of $A$, as returned by f01mdf.
On exit:
• If ${\mathbf{uplo}}=\text{'U'}$, the upper triangular part of $A+E$ is returned and the elements of the array below the diagonal are not referenced.
• If ${\mathbf{uplo}}=\text{'L'}$, the lower triangular part of $A+E$ is returned and the elements of the array above the diagonal are not referenced.
4: $\mathbf{lda}$Integer Input
On entry: the first dimension of the array a as declared in the (sub)program from which f01mef is called.
Constraint: ${\mathbf{lda}}\ge {\mathbf{n}}$.
5: $\mathbf{offdiag}\left({\mathbf{n}}\right)$Real (Kind=nag_wp) array Input
On entry: the array offdiag as returned by f01mdf.
6: $\mathbf{ipiv}\left({\mathbf{n}}\right)$Integer array Input
On entry: the array ipiv as returned by f01mdf.
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{uplo}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{uplo}}=\text{'U'}$ or $\text{'L'}$.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}>0$.
${\mathbf{ifail}}=3$
On entry, ${\mathbf{lda}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{lda}}\ge {\mathbf{n}}$.
${\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

See Section 7 in f01mdf for an indication of the accuracy of the computed factors $L$, $U$, and $D$.

## 8Parallelism and Performance

f01mef is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f01mef 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 routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

Arrays are internally allocated by f01mef. The total size of these arrays does not exceed ${n}^{2}$ real elements. All allocated memory is freed before return of f01mef.