f02 Chapter Contents
f02 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_hermitian_eigensystem (f02axc)

## 1  Purpose

nag_hermitian_eigensystem (f02axc) calculates all the eigenvalues and eigenvectors of a complex Hermitian matrix.

## 2  Specification

 #include #include
 void nag_hermitian_eigensystem (Integer n, const Complex a[], Integer tda, double r[], Complex v[], Integer tdv, NagError *fail)

## 3  Description

The complex Hermitian matrix $A$ is first reduced to a real tridiagonal matrix by $n-2$ unitary transformations and a subsequent diagonal transformation. The eigenvalues and eigenvectors are then derived using the $QL$ algorithm, an adaptation of the $QR$ algorithm.

## 4  References

Wilkinson J H and Reinsch C (1971) Handbook for Automatic Computation II, Linear Algebra Springer–Verlag

## 5  Arguments

1:    $\mathbf{n}$IntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 1$.
2:    $\mathbf{a}\left[{\mathbf{n}}×{\mathbf{tda}}\right]$const ComplexInput
On entry: the elements of the lower triangle of the $n$ by $n$ complex Hermitian matrix $A$. Elements of the array above the diagonal need not be set. See also Section 9.
3:    $\mathbf{tda}$IntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: ${\mathbf{tda}}\ge {\mathbf{n}}$.
4:    $\mathbf{r}\left[{\mathbf{n}}\right]$doubleOutput
On exit: the eigenvalues in ascending order.
5:    $\mathbf{v}\left[{\mathbf{n}}×{\mathbf{tdv}}\right]$ComplexOutput
Note: the $\left(i,j\right)$th element of the matrix $V$ is stored in ${\mathbf{v}}\left[\left(i-1\right)×{\mathbf{tdv}}+j-1\right]$.
On exit: the eigenvectors, stored by columns. The $i$th column corresponds to the $i$th eigenvector. The eigenvectors are normalized so that the sum of the squares of the moduli of the elements is equal to 1 and the element of largest modulus is real. See also Section 9.
6:    $\mathbf{tdv}$IntegerInput
On entry: the stride separating matrix column elements in the array v.
Constraint: ${\mathbf{tdv}}\ge {\mathbf{n}}$.
7:    $\mathbf{fail}$NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, ${\mathbf{tda}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tda}}\ge {\mathbf{n}}$.
On entry, ${\mathbf{tdv}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdv}}\ge {\mathbf{n}}$.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_DIAG_IMAG_NON_ZERO
Matrix diagonal element ${\mathbf{a}}\left[\left(〈\mathit{\text{value}}〉\right)×{\mathbf{tda}}+〈\mathit{\text{value}}〉\right]$ has nonzero imaginary part.
NE_INT_ARG_LT
On entry, ${\mathbf{n}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{n}}\ge 1$.
NE_TOO_MANY_ITERATIONS
More than $〈\mathit{\text{value}}〉$ iterations are required to isolate all the eigenvalues.

## 7  Accuracy

The eigenvectors are always accurately orthogonal but the accuracy of the individual eigenvalues and eigenvectors is dependent on their inherent sensitivity to small changes in the original matrix. For a detailed error analysis see page 235 of Wilkinson and Reinsch (1971).

Not applicable.

## 9  Further Comments

The time taken by nag_hermitian_eigensystem (f02axc) is approximately proportional to ${n}^{3}$.
The function may be called with the same actual array supplied for a and v, in which case the eigenvectors will overwrite the original matrix $A$.

## 10  Example

To calculate the eigenvalues and eigenvectors of the complex Hermitian matrix:
 $0.50 -1.38 i - 0.00 +0.84 i 1.84 + 1.38 i - 2.08 - 1.56 i 0.00 -1.38 i - 0.50 +0.84 i - 1.12 + 0.84 i -0.56 + 0.42 i 1.84 - 1.38 i - 1.12 - 0.84 i 0.50 +0.84 i - 0.00 +0.84 i 2.08 + 1.56 i -0.56 - 0.42 i 0.00 +0.84 i - 0.50 +0.84 i .$

### 10.1  Program Text

Program Text (f02axce.c)

### 10.2  Program Data

Program Data (f02axce.d)

### 10.3  Program Results

Program Results (f02axce.r)