# NAG CL Interfacef08jcc (dstevd)

Settings help

CL Name Style:

## 1Purpose

f08jcc computes all the eigenvalues and, optionally, all the eigenvectors of a real symmetric tridiagonal 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.

## 2Specification

 #include
 void f08jcc (Nag_OrderType order, Nag_JobType job, Integer n, double d[], double e[], double z[], Integer pdz, NagError *fail)
The function may be called by the names: f08jcc, nag_lapackeig_dstevd or nag_dstevd.

## 3Description

f08jcc computes all the eigenvalues and, optionally, all the eigenvectors of a real symmetric tridiagonal matrix $T$. In other words, it can compute the spectral factorization of $T$ as
 $T=ZΛZT,$
where $\Lambda$ is a diagonal matrix whose diagonal elements are the eigenvalues ${\lambda }_{i}$, and $Z$ is the orthogonal matrix whose columns are the eigenvectors ${z}_{i}$. Thus
 $Tzi=λizi, i=1,2,…,n.$

## 4References

Golub G H and Van Loan C F (1996) Matrix Computations (3rd Edition) Johns Hopkins University Press, Baltimore

## 5Arguments

1: $\mathbf{order}$Nag_OrderType Input
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.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint: ${\mathbf{order}}=\mathrm{Nag_RowMajor}$ or $\mathrm{Nag_ColMajor}$.
2: $\mathbf{job}$Nag_JobType Input
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: $\mathbf{n}$Integer Input
On entry: $n$, the order of the matrix $T$.
Constraint: ${\mathbf{n}}\ge 0$.
4: $\mathbf{d}\left[\mathit{dim}\right]$double Input/Output
Note: the dimension, dim, of the array d must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the $n$ diagonal elements of the tridiagonal matrix $T$.
On exit: the eigenvalues of the matrix $T$ in ascending order.
5: $\mathbf{e}\left[\mathit{dim}\right]$double Input/Output
Note: the dimension, dim, of the array e must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{n}}\right)$.
On entry: the $n-1$ off-diagonal elements of the tridiagonal matrix $T$. The $n$th element of this array is used as workspace.
On exit: e is overwritten with intermediate results.
6: $\mathbf{z}\left[\mathit{dim}\right]$double Output
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 orthogonal matrix $Z$ which contains the eigenvectors of $T$.
If ${\mathbf{job}}=\mathrm{Nag_DoNothing}$, z is not referenced.
7: $\mathbf{pdz}$Integer Input
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$.
8: $\mathbf{fail}$NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

## 6Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument $⟨\mathit{\text{value}}⟩$ had an illegal value.
NE_CONVERGENCE
The algorithm failed to converge; $⟨\mathit{\text{value}}⟩$ off-diagonal elements of e did not converge to zero.
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{n}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{n}}\ge 0$.
On entry, ${\mathbf{pdz}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{pdz}}>0$.
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.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

## 7Accuracy

The computed eigenvalues and eigenvectors are exact for a nearby matrix $\left(T+E\right)$, where
 $‖E‖2 = O(ε) ‖T‖2 ,$
and $\epsilon$ is the machine precision.
If ${\lambda }_{i}$ is an exact eigenvalue and ${\stackrel{~}{\lambda }}_{i}$ is the corresponding computed value, then
 $|λ~i-λi| ≤ c (n) ε ‖T‖2 ,$
where $c\left(n\right)$ is a modestly increasing function of $n$.
If ${z}_{i}$ is the corresponding exact eigenvector, and ${\stackrel{~}{z}}_{i}$ is the corresponding computed eigenvector, then the angle $\theta \left({\stackrel{~}{z}}_{i},{z}_{i}\right)$ between them is bounded as follows:
 $θ (z~i,zi) ≤ c (n) ε ‖T‖2 min i≠j |λi-λj| .$
Thus the accuracy of a computed eigenvector depends on the gap between its eigenvalue and all the other eigenvalues.

## 8Parallelism and Performance

f08jcc is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f08jcc 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.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

There is no complex analogue of this function.

## 10Example

This example computes all the eigenvalues and eigenvectors of the symmetric tridiagonal matrix $T$, where
 $T = ( 1.0 1.0 0.0 0.0 1.0 4.0 2.0 0.0 0.0 2.0 9.0 3.0 0.0 0.0 3.0 16.0 ) .$

### 10.1Program Text

Program Text (f08jcce.c)

### 10.2Program Data

Program Data (f08jcce.d)

### 10.3Program Results

Program Results (f08jcce.r)