f02 Chapter Contents
f02 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_real_symm_eigensystem (f02abc)

## 1  Purpose

nag_real_symm_eigensystem (f02abc) calculates all the eigenvalues and eigenvectors of a real symmetric matrix.

## 2  Specification

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

## 3  Description

nag_real_symm_eigensystem (f02abc) reduces the real symmetric matrix $A$ to a real symmetric tridiagonal matrix by Householder's method. The eigenvalues and eigenvectors are calculated using the $QL$ algorithm.

## 4  References

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

## 5  Arguments

1:     nIntegerInput
On entry: $n$, the order of the matrix $A$.
Constraint: ${\mathbf{n}}\ge 1$.
2:     a[${\mathbf{n}}×{\mathbf{tda}}$]const doubleInput
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 lower triangle of the $n$ by $n$ symmetric matrix $A$. The elements of the array above the diagonal need not be set. See also Section 8
3:     tdaIntegerInput
On entry: the stride separating matrix column elements in the array a.
Constraint: ${\mathbf{tda}}\ge {\mathbf{n}}$.
4:     r[n]doubleOutput
On exit: the eigenvalues in ascending order.
5:     v[${\mathbf{n}}×{\mathbf{tdv}}$]doubleOutput
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 normalized eigenvectors, stored by columns; the $i$th column corresponds to the $i$th eigenvalue. The eigenvectors are normalized so that the sum of squares of the elements is equal to 1.
6:     tdvIntegerInput
On entry: the stride separating matrix column elements in the array v.
Constraint: ${\mathbf{tdv}}\ge {\mathbf{n}}$.
7:     failNagError *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 eigenvectors are always accurately orthogonal but the accuracy of the individual eigenvectors is dependent on their inherent sensitivity to changes in the original matrix. For a detailed error analysis see pages  222 and 235 of Wilkinson and Reinsch (1971).

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

## 9  Example

To calculate all the eigenvalues and eigenvectors of the real symmetric matrix
 $0.5 0.0 2.3 -2.6 0.0 0.5 -1.4 -0.7 2.3 -1.4 0.5 0.0 -2.6 -0.7 0.0 0.5 .$

### 9.1  Program Text

Program Text (f02abce.c)

### 9.2  Program Data

Program Data (f02abce.d)

### 9.3  Program Results

Program Results (f02abce.r)