f08 Chapter Contents
f08 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_zhbevd (f08hqc)

## 1  Purpose

nag_zhbevd (f08hqc) computes all the eigenvalues and, optionally, all the eigenvectors of a complex Hermitian band matrix. If the eigenvectors are requested, then it uses a divide-and-conquer algorithm to compute eigenvalues and eigenvectors. However, if only eigenvalues are required, then it uses the Pal–Walker–Kahan variant of the $QL$ or $QR$ algorithm.

## 2  Specification

 #include #include
 void nag_zhbevd (Nag_OrderType order, Nag_JobType job, Nag_UploType uplo, Integer n, Integer kd, Complex ab[], Integer pdab, double w[], Complex z[], Integer pdz, NagError *fail)

## 3  Description

nag_zhbevd (f08hqc) computes all the eigenvalues and, optionally, all the eigenvectors of a complex Hermitian band matrix $A$. In other words, it can compute the spectral factorization of $A$ as
 $A=ZΛZH,$
where $\Lambda$ is a real diagonal matrix whose diagonal elements are the eigenvalues ${\lambda }_{i}$, and $Z$ is the (complex) unitary matrix whose columns are the eigenvectors ${z}_{i}$. Thus
 $Azi=λizi, i=1,2,…,n.$

## 4  References

Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (1999) LAPACK Users' Guide (3rd Edition) SIAM, Philadelphia http://www.netlib.org/lapack/lug
Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5  Arguments

1:     orderNag_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.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2:     jobNag_JobTypeInput
On entry: indicates whether eigenvectors are computed.
${\mathbf{job}}=\mathrm{Nag_DoNothing}$
Only eigenvalues are computed.
${\mathbf{job}}=\mathrm{Nag_EigVecs}$
Eigenvalues and eigenvectors are computed.
Constraint: ${\mathbf{job}}=\mathrm{Nag_DoNothing}$ or $\mathrm{Nag_EigVecs}$.
3:     uploNag_UploTypeInput
On entry: indicates whether the upper or lower triangular part of $A$ is stored.
${\mathbf{uplo}}=\mathrm{Nag_Upper}$
The upper triangular part of $A$ is stored.
${\mathbf{uplo}}=\mathrm{Nag_Lower}$
The lower triangular part of $A$ is stored.
Constraint: ${\mathbf{uplo}}=\mathrm{Nag_Upper}$ or $\mathrm{Nag_Lower}$.
4:     nIntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 0$.
5:     kdIntegerInput
On entry: if ${\mathbf{uplo}}=\mathrm{Nag_Upper}$, the number of superdiagonals, ${k}_{d}$, of the matrix $A$.
If ${\mathbf{uplo}}=\mathrm{Nag_Lower}$, the number of subdiagonals, ${k}_{d}$, of the matrix $A$.
Constraint: ${\mathbf{kd}}\ge 0$.
6:     ab[$\mathit{dim}$]ComplexInput/Output
Note: the dimension, dim, of the array ab must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdab}}×{\mathbf{n}}\right)$.
On entry: the upper or lower triangle of the $n$ by $n$ Hermitian band matrix $A$.
This is stored as a notional two-dimensional array with row elements or column elements stored contiguously. The storage of elements of ${A}_{ij}$, depends on the order and uplo arguments as follows:
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$ and ${\mathbf{uplo}}=\mathrm{Nag_Upper}$,
${A}_{ij}$ is stored in ${\mathbf{ab}}\left[{k}_{d}+i-j+\left(j-1\right)×{\mathbf{pdab}}\right]$, for $j=1,\dots ,n$ and $i=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,j-{k}_{d}\right),\dots ,j$;
• if ${\mathbf{order}}=\mathrm{Nag_ColMajor}$ and ${\mathbf{uplo}}=\mathrm{Nag_Lower}$,
${A}_{ij}$ is stored in ${\mathbf{ab}}\left[i-j+\left(j-1\right)×{\mathbf{pdab}}\right]$, for $j=1,\dots ,n$ and $i=j,\dots ,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(n,j+{k}_{d}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ and ${\mathbf{uplo}}=\mathrm{Nag_Upper}$,
${A}_{ij}$ is stored in ${\mathbf{ab}}\left[j-i+\left(i-1\right)×{\mathbf{pdab}}\right]$, for $i=1,\dots ,n$ and $j=i,\dots ,\mathrm{min}\phantom{\rule{0.125em}{0ex}}\left(n,i+{k}_{d}\right)$;
• if ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ and ${\mathbf{uplo}}=\mathrm{Nag_Lower}$,
${A}_{ij}$ is stored in ${\mathbf{ab}}\left[{k}_{d}+j-i+\left(i-1\right)×{\mathbf{pdab}}\right]$, for $i=1,\dots ,n$ and $j=\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,i-{k}_{d}\right),\dots ,i$.
On exit: ab is overwritten by values generated during the reduction to tridiagonal form.
The first superdiagonal or subdiagonal and the diagonal of the tridiagonal matrix $T$ are returned in ab using the same storage format as described above.
7:     pdabIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) of the matrix $A$ in the array ab.
Constraint: ${\mathbf{pdab}}\ge {\mathbf{kd}}+1$.
8:     w[$\mathit{dim}$]doubleOutput
Note: the dimension, dim, of the array w must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On exit: the eigenvalues of the matrix $A$ in ascending order.
9:     z[$\mathit{dim}$]ComplexOutput
Note: the dimension, dim, of the array z must be at least
• $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{pdz}}×{\mathbf{n}}\right)$ when ${\mathbf{job}}=\mathrm{Nag_EigVecs}$;
• $1$ when ${\mathbf{job}}=\mathrm{Nag_DoNothing}$.
The $\left(i,j\right)$th element of the matrix $Z$ is stored in
• ${\mathbf{z}}\left[\left(j-1\right)×{\mathbf{pdz}}+i-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_ColMajor}$;
• ${\mathbf{z}}\left[\left(i-1\right)×{\mathbf{pdz}}+j-1\right]$ when ${\mathbf{order}}=\mathrm{Nag_RowMajor}$.
On exit: if ${\mathbf{job}}=\mathrm{Nag_EigVecs}$, z is overwritten by the unitary matrix $Z$ which contains the eigenvectors of $A$. The $i$th column of $Z$ contains the eigenvector which corresponds to the eigenvalue ${\mathbf{w}}\left[i-1\right]$.
If ${\mathbf{job}}=\mathrm{Nag_DoNothing}$, z is not referenced.
10:   pdzIntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array z.
Constraints:
• if ${\mathbf{job}}=\mathrm{Nag_EigVecs}$, ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
• if ${\mathbf{job}}=\mathrm{Nag_DoNothing}$, ${\mathbf{pdz}}\ge 1$.
11:   failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_CONVERGENCE
If ${\mathbf{fail}}\mathbf{.}\mathbf{errnum}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{job}}=\mathrm{Nag_DoNothing}$, the algorithm failed to converge; $⟨\mathit{\text{value}}⟩$ elements of an intermediate tridiagonal form did not converge to zero; if ${\mathbf{fail}}\mathbf{.}\mathbf{errnum}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{job}}=\mathrm{Nag_EigVecs}$, then the algorithm failed to compute an eigenvalue while working on the submatrix lying in rows and column $⟨\mathit{\text{value}}⟩/\left({\mathbf{n}}+1\right)$ through .
NE_ENUM_INT_2
On entry, ${\mathbf{job}}=⟨\mathit{\text{value}}⟩$, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: if ${\mathbf{job}}=\mathrm{Nag_EigVecs}$, ${\mathbf{pdz}}\ge \mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$;
if ${\mathbf{job}}=\mathrm{Nag_DoNothing}$, ${\mathbf{pdz}}\ge 1$.
NE_INT
On entry, ${\mathbf{kd}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{kd}}\ge 0$.
On entry, ${\mathbf{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pdab}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdab}}>0$.
On entry, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdz}}>0$.
NE_INT_2
On entry, ${\mathbf{pdab}}=⟨\mathit{\text{value}}⟩$ and ${\mathbf{kd}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdab}}\ge {\mathbf{kd}}+1$.
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.

## 7  Accuracy

The computed eigenvalues and eigenvectors are exact for a nearby matrix $\left(A+E\right)$, where
 $E2 = Oε A2 ,$
and $\epsilon$ is the machine precision. See Section 4.7 of Anderson et al. (1999) for further details.

## 8  Parallelism and Performance

nag_zhbevd (f08hqc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_zhbevd (f08hqc) 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.

The real analogue of this function is nag_dsbevd (f08hcc).

## 10  Example

This example computes all the eigenvalues and eigenvectors of the Hermitian band matrix $A$, where
 $A = 1+0i 2-1i 3-1i 0+0i 0+0i 2+1i 2+0i 3-2i 4-2i 0+0i 3+1i 3+2i 3+0i 4-3i 5-3i 0+0i 4+2i 4+3i 4+0i 5-4i 0+0i 0+0i 5+3i 5+4i 5+0i .$

### 10.1  Program Text

Program Text (f08hqce.c)

### 10.2  Program Data

Program Data (f08hqce.d)

### 10.3  Program Results

Program Results (f08hqce.r)