f02 Chapter Contents
f02 Chapter Introduction
NAG Library Manual

# NAG Library Function Documentnag_real_eigensystem (f02agc)

## 1  Purpose

nag_real_eigensystem (f02agc) calculates all the eigenvalues and eigenvectors of a real unsymmetric matrix.

## 2  Specification

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

## 3  Description

The matrix $A$ is first balanced and then reduced to upper Hessenberg form using real stabilised elementary similarity transformations. The eigenvalues and eigenvectors of the Hessenberg matrix are calculated using the $QR$ algorithm. The eigenvectors of the Hessenberg matrix are back-transformed to give the eigenvectors of the original matrix $A$.

## 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]$doubleInput/Output
Note: the $\left(i,j\right)$th element of the matrix $A$ is stored in ${\mathbf{a}}\left[\left(i-1\right)×{\mathbf{tda}}+j-1\right]$.
On entry: the $n$ by $n$ matrix $A$.
On exit: a is overwritten.
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]$ComplexOutput
On exit: the eigenvalues.
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 eigenvalue. 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. This ensures that real eigenvalues have real eigenvectors.
6:    $\mathbf{tdv}$IntegerInput
On entry: the stride separating matrix column elements in the array v.
Constraint: ${\mathbf{tdv}}\ge {\mathbf{n}}$.
7:    $\mathbf{iter}\left[{\mathbf{n}}\right]$IntegerOutput
On exit: ${\mathbf{iter}}\left[i-1\right]$ contains the number of iterations used to find the $i$th eigenvalue. If ${\mathbf{iter}}\left[i-1\right]$ is negative, the $i$th eigenvalue is the second of a pair found simultaneously.
Note: the eigenvalues are found in reverse order, starting with the $n$th.
8:    $\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_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 accuracy of the results depends on the original matrix and the multiplicity of the roots. For a detailed error analysis see pages 352 and 390 Wilkinson and Reinsch (1971).

## 8  Parallelism and Performance

Not applicable.

The time taken by nag_real_eigensystem (f02agc) is approximately proportional to ${n}^{3}$.

## 10  Example

To calculate all the eigenvalues and eigenvectors of the real matrix
 $1.5 0.1 4.5 -1.5 -22.5 3.5 12.5 -2.5 -2.5 0.3 4.5 -2.5 -2.5 0.1 4.5 2.5 .$

### 10.1  Program Text

Program Text (f02agce.c)

### 10.2  Program Data

Program Data (f02agce.d)

### 10.3  Program Results

Program Results (f02agce.r)