# NAG Library Function Document

## 1Purpose

nag_zpstrf (f07krc) computes the Cholesky factorization with complete pivoting of a complex Hermitian positive semidefinite matrix.

## 2Specification

 #include #include
 void nag_zpstrf (Nag_OrderType order, Nag_UploType uplo, Integer n, Complex a[], Integer pda, Integer piv[], Integer *rank, double tol, NagError *fail)

## 3Description

nag_zpstrf (f07krc) forms the Cholesky factorization of a complex Hermitian positive semidefinite matrix $A$ either as ${P}^{\mathrm{T}}AP={U}^{\mathrm{H}}U$ if ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or ${P}^{\mathrm{T}}AP=L{L}^{\mathrm{H}}$ if ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, where $P$ is a permutation matrix, $U$ is an upper triangular matrix and $L$ is lower triangular.
This algorithm does not attempt to check that $A$ is positive semidefinite.

## 4References

Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia
Lucas C (2004) LAPACK-style codes for Level 2 and 3 pivoted Cholesky factorizations LAPACK Working Note No. 161. Technical Report CS-04-522 Department of Computer Science, University of Tennessee, 107 Ayres Hall, Knoxville, TN 37996-1301, USA http://www.netlib.org/lapack/lawnspdf/lawn161.pdf

## 5Arguments

1:    $\mathbf{order}$Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by ${\mathbf{order}}=\mathrm{Nag_RowMajor}$. See Section 3.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:    $\mathbf{uplo}$Nag_UploTypeInput
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 $A$ is factorized as ${U}^{\mathrm{H}}U$, where $U$ is upper triangular.
${\mathbf{uplo}}=\mathrm{Nag_Lower}$
The lower triangular part of $A$ is stored and $A$ is factorized as $L{L}^{\mathrm{H}}$, where $L$ is lower triangular.
Constraint: ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$.
3:    $\mathbf{n}$IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
4:    $\mathbf{a}\left[\mathit{dim}\right]$ComplexInput/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$ by $n$ Hermitian positive semidefinite matrix $A$.
If ${\mathbf{order}}=\mathrm{Nag_ColMajor}$, ${A}_{ij}$ is stored in ${\mathbf{a}}\left[\left(j-1\right)×{\mathbf{pda}}+i-1\right]$.
If ${\mathbf{order}}=\mathrm{Nag_RowMajor}$, ${A}_{ij}$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{pda}}+j-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: if ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, the first rank rows of the upper triangle of $A$ are overwritten with the nonzero elements of the Cholesky factor $U$, and the remaining rows of the triangle are destroyed.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the first rank columns of the lower triangle of $A$ are overwritten with the nonzero elements of the Cholesky factor $L$, and the remaining columns of the triangle are destroyed.
5:    $\mathbf{pda}$IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) of the matrix $A$ in the array a.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
6:    $\mathbf{piv}\left[{\mathbf{n}}\right]$IntegerOutput
On exit: piv is such that the nonzero entries of $P$ are $P\left({\mathbf{piv}}\left[\mathit{k}-1\right],\mathit{k}\right)=1$, for $\mathit{k}=1,2,\dots ,n$.
7:    $\mathbf{rank}$Integer *Output
On exit: the computed rank of $A$ given by the number of steps the algorithm completed.
8:    $\mathbf{tol}$doubleInput
On entry: user defined tolerance. If ${\mathbf{tol}}<0$,  will be used. The algorithm terminates at the $r$th step if the $\left(r+1\right)$th step pivot $\text{}<{\mathbf{tol}}$.
9:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation 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}}\ge 0$.
NE_INT_2
On entry, ${\mathbf{pda}}=〈\mathit{\text{value}}〉$ and ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{pda}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
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 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NW_NOT_POS_DEF
The matrix $A$ is not positive definite. It is either positive semidefinite with computed rank as returned in rank and less than $n$, or it may be indefinite, see Section 9.

## 7Accuracy

If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$ and ${\mathbf{rank}}=r$, the computed Cholesky factor $L$ and permutation matrix $P$ satisfy the following upper bound
 $A - PLLHPT 2 A2 ≤ 2r cr ε W 2 + 1 2 + Oε2 ,$
where
 $W = L 11 -1 L12 , L = L11 0 L12 0 , L11 ∈ ℂr×r ,$
$c\left(r\right)$ is a modest linear function of $r$, $\epsilon$ is machine precision, and
 $W2 ≤ 13 n-r 4r-1 .$
So there is no guarantee of stability of the algorithm for large $n$ and $r$, although ${‖W‖}_{2}$ is generally small in practice.

## 8Parallelism and Performance

nag_zpstrf (f07krc) 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 total number of real floating-point operations is approximately $4n{r}^{2}-8/3{r}^{3}$, where $r$ is the computed rank of $A$.
This algorithm does not attempt to check that $A$ is positive semidefinite, and in particular the rank detection criterion in the algorithm is based on $A$ being positive semidefinite. If there is doubt over semidefiniteness then you should use the indefinite factorization nag_zhetrf (f07mrc). See Lucas (2004) for further information.
The real analogue of this function is nag_dpstrf (f07kdc).

## 10Example

This example computes the Cholesky factorization of the matrix $A$, where
 $A= 12.40+0.00i 2.39+0.00i 5.50+0.05i 4.47+0.00i 11.89+0.00i 2.39+0.00i 1.63+0.00i 1.04+0.10i 1.14+0.00i 1.81+0.00i 5.50+0.05i 1.04+0.10i 2.45+0.00i 1.98-0.03i 5.28-0.02i 4.47+0.00i 1.14+0.00i 1.98-0.03i 1.71+0.00i 4.14+0.00i 11.89+0.00i 1.81+0.00i 5.28-0.02i 4.14+0.00i 11.63+0.00i .$

### 10.1Program Text

Program Text (f07krce.c)

### 10.2Program Data

Program Data (f07krce.d)

### 10.3Program Results

Program Results (f07krce.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017