Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_lapack_zpteqr (f08ju)

## Purpose

nag_lapack_zpteqr (f08ju) computes all the eigenvalues and, optionally, all the eigenvectors of a complex Hermitian positive definite matrix which has been reduced to tridiagonal form.

## Syntax

[d, e, z, info] = f08ju(compz, d, e, z, 'n', n)
[d, e, z, info] = nag_lapack_zpteqr(compz, d, e, z, 'n', n)

## Description

nag_lapack_zpteqr (f08ju) computes all the eigenvalues and, optionally, all the eigenvectors of a real symmetric positive definite tridiagonal matrix $T$. In other words, it can compute the spectral factorization of $T$ as
 $T=ZΛZT,$
where $\Lambda$ is a diagonal matrix whose diagonal elements are the eigenvalues ${\lambda }_{i}$, and $Z$ is the orthogonal matrix whose columns are the eigenvectors ${z}_{i}$. Thus
 $Tzi=λizi, i=1,2,…,n.$
The function stores the real orthogonal matrix $Z$ in a complex array, so that it may be used to compute all the eigenvalues and eigenvectors of a complex Hermitian positive definite matrix $A$ which has been reduced to tridiagonal form $T$:
 $A =QTQH, where ​Q​ is unitary =QZΛQZH.$
In this case, the matrix $Q$ must be formed explicitly and passed to nag_lapack_zpteqr (f08ju), which must be called with ${\mathbf{compz}}=\text{'V'}$. The functions which must be called to perform the reduction to tridiagonal form and form $Q$ are:
 full matrix nag_lapack_zhetrd (f08fs) and nag_lapack_zungtr (f08ft) full matrix, packed storage nag_lapack_zhptrd (f08gs) and nag_lapack_zupgtr (f08gt) band matrix nag_lapack_zhbtrd (f08hs) with ${\mathbf{vect}}=\text{'V'}$.
nag_lapack_zpteqr (f08ju) first factorizes $T$ as $LD{L}^{\mathrm{H}}$ where $L$ is unit lower bidiagonal and $D$ is diagonal. It forms the bidiagonal matrix $B=L{D}^{\frac{1}{2}}$, and then calls nag_lapack_zbdsqr (f08ms) to compute the singular values of $B$ which are the same as the eigenvalues of $T$. The method used by the function allows high relative accuracy to be achieved in the small eigenvalues of $T$. The eigenvectors are normalized so that ${‖{z}_{i}‖}_{2}=1$, but are determined only to within a complex factor of absolute value $1$.

## References

Barlow J and Demmel J W (1990) Computing accurate eigensystems of scaled diagonally dominant matrices SIAM J. Numer. Anal. 27 762–791

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{compz}$ – string (length ≥ 1)
Indicates whether the eigenvectors are to be computed.
${\mathbf{compz}}=\text{'N'}$
Only the eigenvalues are computed (and the array z is not referenced).
${\mathbf{compz}}=\text{'V'}$
The eigenvalues and eigenvectors of $A$ are computed (and the array z must contain the matrix $Q$ on entry).
${\mathbf{compz}}=\text{'I'}$
The eigenvalues and eigenvectors of $T$ are computed (and the array z is initialized by the function).
Constraint: ${\mathbf{compz}}=\text{'N'}$, $\text{'V'}$ or $\text{'I'}$.
2:     $\mathrm{d}\left(:\right)$ – double array
The dimension of the array d must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The diagonal elements of the tridiagonal matrix $T$.
3:     $\mathrm{e}\left(:\right)$ – double array
The dimension of the array e must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$
The off-diagonal elements of the tridiagonal matrix $T$.
4:     $\mathrm{z}\left(\mathit{ldz},:\right)$ – complex array
The first dimension, $\mathit{ldz}$, of the array z must satisfy
• if ${\mathbf{compz}}=\text{'V'}$ or $\text{'I'}$, $\mathit{ldz}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{compz}}=\text{'N'}$, $\mathit{ldz}\ge 1$.
The second dimension of the array z must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if ${\mathbf{compz}}=\text{'V'}$ or $\text{'I'}$ and at least $1$ if ${\mathbf{compz}}=\text{'N'}$.
If ${\mathbf{compz}}=\text{'V'}$, z must contain the unitary matrix $Q$ from the reduction to tridiagonal form.
If ${\mathbf{compz}}=\text{'I'}$, z need not be set.

### Optional Input Parameters

1:     $\mathrm{n}$int64int32nag_int scalar
Default: the first dimension of the array d and the second dimension of the array d. (An error is raised if these dimensions are not equal.)
$n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.

### Output Parameters

1:     $\mathrm{d}\left(:\right)$ – double array
The dimension of the array d will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$
The $n$ eigenvalues in descending order, unless ${\mathbf{info}}>{\mathbf{0}}$, in which case d is overwritten.
2:     $\mathrm{e}\left(:\right)$ – double array
The dimension of the array e will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}-1\right)$
3:     $\mathrm{z}\left(\mathit{ldz},:\right)$ – complex array
The first dimension, $\mathit{ldz}$, of the array z will be
• if ${\mathbf{compz}}=\text{'V'}$ or $\text{'I'}$, $\mathit{ldz}=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{compz}}=\text{'N'}$, $\mathit{ldz}=1$.
The second dimension of the array z will be $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$ if ${\mathbf{compz}}=\text{'V'}$ or $\text{'I'}$ and at least $1$ if ${\mathbf{compz}}=\text{'N'}$.
If ${\mathbf{compz}}=\text{'V'}$ or $\text{'I'}$, the $n$ required orthonormal eigenvectors stored as columns of $Z$; the $i$th column corresponds to the $i$th eigenvalue, where $i=1,2,\dots ,n$, unless ${\mathbf{info}}>{\mathbf{0}}$.
If ${\mathbf{compz}}=\text{'N'}$, z is not referenced.
4:     $\mathrm{info}$int64int32nag_int scalar
${\mathbf{info}}=0$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

${\mathbf{info}}=-i$
If ${\mathbf{info}}=-i$, parameter $i$ had an illegal value on entry. The parameters are numbered as follows:
1: compz, 2: n, 3: d, 4: e, 5: z, 6: ldz, 7: work, 8: info.
It is possible that info refers to a parameter that is omitted from the MATLAB interface. This usually indicates that an error in one of the other input parameters has caused an incorrect value to be inferred.
${\mathbf{info}}>0$
If ${\mathbf{info}}=i$, the leading minor of order $i$ is not positive definite and the Cholesky factorization of $T$ could not be completed. Hence $T$ itself is not positive definite.
If ${\mathbf{info}}={\mathbf{n}}+i$, the algorithm to compute the singular values of the Cholesky factor $B$ failed to converge; $i$ off-diagonal elements did not converge to zero.

## Accuracy

The eigenvalues and eigenvectors of $T$ are computed to high relative accuracy which means that if they vary widely in magnitude, then any small eigenvalues (and corresponding eigenvectors) will be computed more accurately than, for example, with the standard $QR$ method. However, the reduction to tridiagonal form (prior to calling the function) may exclude the possibility of obtaining high relative accuracy in the small eigenvalues of the original matrix if its eigenvalues vary widely in magnitude.
To be more precise, let $H$ be the tridiagonal matrix defined by $H=DTD$, where $D$ is diagonal with ${d}_{ii}={t}_{ii}^{-\frac{1}{2}}$, and ${h}_{ii}=1$ for all $i$. If ${\lambda }_{i}$ is an exact eigenvalue of $T$ and ${\stackrel{~}{\lambda }}_{i}$ is the corresponding computed value, then
 $λ~i - λi ≤ c n ε κ2 H λi$
where $c\left(n\right)$ is a modestly increasing function of $n$, $\epsilon$ is the machine precision, and ${\kappa }_{2}\left(H\right)$ is the condition number of $H$ with respect to inversion defined by: ${\kappa }_{2}\left(H\right)=‖H‖·‖{H}^{-1}‖$.
If ${z}_{i}$ is the corresponding exact eigenvector of $T$, and ${\stackrel{~}{z}}_{i}$ is the corresponding computed eigenvector, then the angle $\theta \left({\stackrel{~}{z}}_{i},{z}_{i}\right)$ between them is bounded as follows:
 $θ z~i,zi ≤ c n ε κ2 H relgapi$
where ${\mathit{relgap}}_{i}$ is the relative gap between ${\lambda }_{i}$ and the other eigenvalues, defined by
 $relgapi = min i≠j λi - λj λi + λj .$

The total number of real floating-point operations is typically about $30{n}^{2}$ if ${\mathbf{compz}}=\text{'N'}$ and about $12{n}^{3}$ if ${\mathbf{compz}}=\text{'V'}$ or $\text{'I'}$, but depends on how rapidly the algorithm converges. When ${\mathbf{compz}}=\text{'N'}$, the operations are all performed in scalar mode; the additional operations to compute the eigenvectors when ${\mathbf{compz}}=\text{'V'}$ or $\text{'I'}$ can be vectorized and on some machines may be performed much faster.
The real analogue of this function is nag_lapack_dpteqr (f08jg).

## Example

This example computes all the eigenvalues and eigenvectors of the complex Hermitian positive definite matrix $A$, where
 $A = 6.02+0.00i -0.45+0.25i -1.30+1.74i 1.45-0.66i -0.45-0.25i 2.91+0.00i 0.05+1.56i -1.04+1.27i -1.30-1.74i 0.05-1.56i 3.29+0.00i 0.14+1.70i 1.45+0.66i -1.04-1.27i 0.14-1.70i 4.18+0.00i .$
```function f08ju_example

fprintf('f08ju example results\n\n');

% Hermitian matrix A, lower triangular part stored
uplo = 'L';
n = 4;
a = [ 6.02 + 0i,     0    + 0i,     0    + 0i,     0    + 0i,
-0.45 - 0.25i,  2.91 + 0i,     0    + 0i,     0    + 0i,
-1.30 - 1.74i,  0.05 - 1.56i,  3.29 + 0i,     0    + 0i,
1.45 + 0.66i, -1.04 - 1.27i,  0.14 - 1.70i,  4.18 + 0.00i];

% Reduce to tridiagonal form
[QT, d, e, tau, info] = f08fs( ...
uplo, a);

% Form Q
[Q, info] = f08ft( ...
uplo, QT, tau);

% Calculate eigenvalues and eigenvectors of A
compz = 'V';
[w, ~, z, info] = f08ju( ...
compz, d, e, Q);

% Normalize: largest elements are real
for i = 1:n
[~,k] = max(abs(real(z(:,i)))+abs(imag(z(:,i))));
z(:,i) = z(:,i)*conj(z(k,i))/abs(z(k,i));
end

disp(' Eigenvalues of A:');
disp(w');
disp(' Corresponding eigenvectors:');
disp(z);

```
```f08ju example results

Eigenvalues of A:
7.9995    5.9976    2.0003    0.4026

Corresponding eigenvectors:
0.7289 + 0.0000i   0.2001 + 0.4724i  -0.2133 + 0.1498i   0.0995 - 0.3573i
-0.1651 - 0.2067i  -0.2461 + 0.3742i   0.7308 + 0.0000i   0.2867 - 0.3364i
-0.4170 - 0.1413i   0.4476 + 0.1455i  -0.3282 + 0.0471i   0.6890 + 0.0000i
0.1748 + 0.4175i   0.5610 + 0.0000i   0.5203 + 0.1317i   0.0659 + 0.4336i

```