nag_real_symm_general_eigensystem (f02aec) (PDF version)
f02 Chapter Contents
f02 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_real_symm_general_eigensystem (f02aec)

## 1  Purpose

nag_real_symm_general_eigensystem (f02aec) calculates all the eigenvalues and eigenvectors of $Ax=\lambda Bx$, where $A$ is a real symmetric matrix and $B$ is a real symmetric positive definite matrix.

## 2  Specification

 #include #include
 void nag_real_symm_general_eigensystem (Integer n, double a[], Integer tda, double b[], Integer tdb, double r[], double v[], Integer tdv, NagError *fail)

## 3  Description

The problem is reduced to the standard symmetric eigenproblem using Cholesky's method to decompose $B$ into triangular matrices $B={LL}^{\mathrm{T}}$, where $L$ is lower triangular. Then $Ax=\lambda Bx$ implies $\left({L}^{-1}{AL}^{-T}\right)\left({L}^{\mathrm{T}}x\right)=\lambda \left({L}^{\mathrm{T}}x\right)$; hence the eigenvalues of $Ax=\lambda Bx$ are those of $Py=\lambda y$, where $P$ is the symmetric matrix ${L}^{-1}{AL}^{-T}$. Householder's method is used to tridiagonalise the matrix $P$ and the eigenvalues are found using the $QL$ algorithm. An eigenvector $z$ of the derived problem is related to an eigenvector $x$ of the original problem by $z={L}^{\mathrm{T}}x$. The eigenvectors $z$ are determined using the $QL$ algorithm and are normalized so that ${z}^{\mathrm{T}}z=1$; the eigenvectors of the original problem are then determined by solving ${L}^{\mathrm{T}}x=z$, and are normalized so that ${x}^{\mathrm{T}}Bx=1$.

## 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 matrices $A$ and $B$.
Constraint: ${\mathbf{n}}\ge 1$.
2:     a[${\mathbf{n}}×{\mathbf{tda}}$]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 upper triangle of the $n$ by $n$ symmetric matrix $A$. The elements of the array below the diagonal need not be set.
On exit: the lower triangle of the array is overwritten. The rest of the array is unchanged. 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:     b[${\mathbf{n}}×{\mathbf{tdb}}$]doubleInput/Output
Note: the $\left(i,j\right)$th element of the matrix $B$ is stored in ${\mathbf{b}}\left[\left(i-1\right)×{\mathbf{tdb}}+j-1\right]$.
On entry: the upper triangle of the $n$ by $n$ symmetric positive definite matrix $B$. The elements of the array below the diagonal need not be set.
On exit: the elements below the diagonal are overwritten. The rest of the array is unchanged.
5:     tdbIntegerInput
On entry: the stride separating matrix column elements in the array b.
Constraint: ${\mathbf{tdb}}\ge {\mathbf{n}}$.
6:     r[n]doubleOutput
On exit: the eigenvalues in ascending order.
7:     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 $x$ are normalized so that ${x}^{\mathrm{T}}Bx=1$. See also Section 8
8:     tdvIntegerInput
On entry: the stride separating matrix column elements in the array v.
Constraint: ${\mathbf{tdv}}\ge {\mathbf{n}}$.
9:     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{tdb}}=〈\mathit{\text{value}}〉$ while ${\mathbf{n}}=〈\mathit{\text{value}}〉$. These arguments must satisfy ${\mathbf{tdb}}\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_NOT_POS_DEF
The matrix $B$ is not positive definite, possibly due to rounding errors.
NE_TOO_MANY_ITERATIONS
More than $〈\mathit{\text{value}}〉$ iterations are required to isolate all the eigenvalues.

## 7  Accuracy

In general this function is very accurate. However, if $B$ is ill-conditioned with respect to inversion, the eigenvectors could be inaccurately determined. For a detailed error analysis see pages 310, 222 and 235 of Wilkinson and Reinsch (1971).

## 8  Further Comments

The time taken by nag_real_symm_general_eigensystem (f02aec) 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 $A$.

## 9  Example

To calculate all the eigenvalues and eigenvectors of the general symmetric eigenproblem $Ax=\lambda Bx$ where $A$ is the symmetric matrix
 $0.5 1.5 6.6 4.8 1.5 6.5 16.2 8.6 6.6 16.2 37.6 9.8 4.8 8.6 9.8 -17.1$
and $B$ is the symmetric positive definite matrix
 $1 3 4 1 3 13 16 11 4 16 24 18 1 11 18 27 .$

### 9.1  Program Text

Program Text (f02aece.c)

### 9.2  Program Data

Program Data (f02aece.d)

### 9.3  Program Results

Program Results (f02aece.r)

nag_real_symm_general_eigensystem (f02aec) (PDF version)
f02 Chapter Contents
f02 Chapter Introduction
NAG C Library Manual