# NAG CL Interfacef01mec (real_​mod_​chol_​perturbed_​a)

Settings help

CL Name Style:

## 1Purpose

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

## 2Specification

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

## 3Description

f01mec computes the positive definite perturbed matrix $A+E$ from the factors provided by a previous call to f01mdc. For 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$). The matrix $E$ is not explicitly formed.
If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, 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}$Nag_UploType Input
On entry: indicates whether the upper or lower triangular part of $A$ was stored and how it was factorized.
${\mathbf{uplo}}=\mathrm{Nag_Upper}$
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}}=\mathrm{Nag_Lower}$
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}}=\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 modified Cholesky factor of $A$, as returned by f01mdc.
On exit:
• If ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, the upper triangular part of $A+E$ is returned and the elements of the array below the diagonal are not referenced.
• If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the lower triangular part of $A+E$ is returned and the elements of the array above the diagonal are not referenced.
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]$const double Input
On entry: the array offdiag as returned by f01mdc.
6: $\mathbf{ipiv}\left[{\mathbf{n}}\right]$const Integer Input
On entry: the array ipiv as returned by f01mdc.
7: $\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_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.

## 7Accuracy

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

## 8Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
f01mec is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f01mec 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.

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