F12 Chapter Contents
F12 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentF12FBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.
Note: this routine uses optional parameters to define choices in the problem specification. If you wish to use default settings for all of the optional parameters, then the option setting routine F12FDF need not be called. If, however, you wish to reset some or all of the settings please refer to Section 11 in F12FDF for a detailed description of the specification of the optional parameters.

## 1  Purpose

F12FBF is an iterative solver in a suite of routines consisting of F12FAF, F12FBF, F12FCF, F12FDF and F12FEF. It is used to find some of the eigenvalues (and optionally the corresponding eigenvectors) of a standard or generalized eigenvalue problem defined by real symmetric matrices.

## 2  Specification

 SUBROUTINE F12FBF ( IREVCM, RESID, V, LDV, X, MX, NSHIFT, COMM, ICOMM, IFAIL)
 INTEGER IREVCM, LDV, NSHIFT, ICOMM(*), IFAIL REAL (KIND=nag_wp) RESID(*), V(LDV,*), X(*), MX(*), COMM(*)

## 3  Description

The suite of routines is designed to calculate some of the eigenvalues, $\lambda$, (and optionally the corresponding eigenvectors, $x$) of a standard eigenvalue problem $Ax=\lambda x$, or of a generalized eigenvalue problem $Ax=\lambda Bx$ of order $n$, where $n$ is large and the coefficient matrices $A$ and $B$ are sparse, real and symmetric. The suite can also be used to find selected eigenvalues/eigenvectors of smaller scale dense, real and symmetric problems.
F12FBF is a reverse communication routine, based on the ARPACK routine dsaupd, using the Implicitly Restarted Arnoldi iteration method, which for symmetric problems reduces to a variant of the Lanczos method. The method is described in Lehoucq and Sorensen (1996) and Lehoucq (2001) while its use within the ARPACK software is described in great detail in Lehoucq et al. (1998). An evaluation of software for computing eigenvalues of sparse symmetric matrices is provided in Lehoucq and Scott (1996). This suite of routines offers the same functionality as the ARPACK software for real symmetric problems, but the interface design is quite different in order to make the option setting clearer and to simplify the interface of F12FBF.
The setup routine F12FAF must be called before F12FBF, the reverse communication iterative solver. Options may be set for F12FBF by prior calls to the option setting routine F12FDF and a post-processing routine F12FCF must be called following a successful final exit from F12FBF. F12FEF, may be called following certain flagged, intermediate exits from F12FBF to provide additional monitoring information about the computation.
F12FBF uses reverse communication, i.e., it returns repeatedly to the calling program with the parameter IREVCM (see Section 5) set to specified values which require the calling program to carry out one of the following tasks:
 – compute the matrix-vector product $y=\mathrm{OP}x$, where $\mathrm{OP}$ is defined by the computational mode; – compute the matrix-vector product $y=Bx$; – notify the completion of the computation; – allow the calling program to monitor the solution.
The problem type to be solved (standard or generalized), the spectrum of eigenvalues of interest, the mode used (regular, regular inverse, shifted inverse, Buckling or Cayley) and other options can all be set using the option setting routine F12FDF.
Lehoucq R B (2001) Implicitly restarted Arnoldi methods and subspace iteration SIAM Journal on Matrix Analysis and Applications 23 551–562
Lehoucq R B and Scott J A (1996) An evaluation of software for computing eigenvalues of sparse nonsymmetric matrices Preprint MCS-P547-1195 Argonne National Laboratory
Lehoucq R B and Sorensen D C (1996) Deflation techniques for an implicitly restarted Arnoldi iteration SIAM Journal on Matrix Analysis and Applications 17 789–821
Lehoucq R B, Sorensen D C and Yang C (1998) ARPACK Users' Guide: Solution of Large-scale Eigenvalue Problems with Implicitly Restarted Arnoldi Methods SIAM, Philidelphia

## 5  Parameters

Note: this routine uses reverse communication. Its use involves an initial entry, intermediate exits and re-entries, and a final exit, as indicated by the parameter IREVCM. Between intermediate exits and re-entries, all parameters other than X, MX and COMM must remain unchanged.
1:     $\mathrm{IREVCM}$ – INTEGERInput/Output
On initial entry: ${\mathbf{IREVCM}}=0$, otherwise an error condition will be raised.
On intermediate re-entry: must be unchanged from its previous exit value. Changing IREVCM to any other value between calls will result in an error.
On intermediate exit: has the following meanings.
${\mathbf{IREVCM}}=-1$
The calling program must compute the matrix-vector product $y=\mathrm{OP}x$, where $x$ is stored in X (by default) or in the array COMM (starting from the location given by the first element of ICOMM) when the option ${\mathbf{Pointers}}=\mathrm{YES}$ is set in a prior call to F12FDF. The result $y$ is returned in X (by default) or in the array COMM (starting from the location given by the second element of ICOMM) when the option ${\mathbf{Pointers}}=\mathrm{YES}$ is set.
${\mathbf{IREVCM}}=1$
The calling program must compute the matrix-vector product $y=\mathrm{OP}x$. This is similar to the case ${\mathbf{IREVCM}}=-1$ except that the result of the matrix-vector product $Bx$ (as required in some computational modes) has already been computed and is available in MX (by default) or in the array COMM (starting from the location given by the third element of ICOMM) when the option ${\mathbf{Pointers}}=\mathrm{YES}$ is set.
${\mathbf{IREVCM}}=2$
The calling program must compute the matrix-vector product $y=Bx$, where $x$ is stored in X and $y$ is returned in MX (by default) or in the array COMM (starting from the location given by the second element of ICOMM) when the option ${\mathbf{Pointers}}=\mathrm{YES}$ is set.
${\mathbf{IREVCM}}=3$
Compute the NSHIFT real and imaginary parts of the shifts where the real parts are to be returned in the first NSHIFT locations of the array X and the imaginary parts are to be returned in the first NSHIFT locations of the array MX. Only complex conjugate pairs of shifts may be applied and the pairs must be placed in consecutive locations. This value of IREVCM will only arise if the optional parameter Supplied Shifts is set in a prior call to F12FDF which is intended for experienced users only; the default and recommended option is to use exact shifts (see Lehoucq et al. (1998) for details and guidance on the choice of shift strategies).
${\mathbf{IREVCM}}=4$
Monitoring step: a call to F12FEF can now be made to return the number of Arnoldi iterations, the number of converged Ritz values, their real and imaginary parts, and the corresponding Ritz estimates.
On final exit: ${\mathbf{IREVCM}}=5$: F12FBF has completed its tasks. The value of IFAIL determines whether the iteration has been successfully completed, or whether errors have been detected. On successful completion F12FCF must be called to return the requested eigenvalues and eigenvectors (and/or Schur vectors).
Constraint: on initial entry, ${\mathbf{IREVCM}}=0$; on re-entry IREVCM must remain unchanged.
2:     $\mathrm{RESID}\left(*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array RESID must be at least ${\mathbf{N}}$ (see F12FAF).
On initial entry: need not be set unless the option Initial Residual has been set in a prior call to F12FDF in which case RESID should contain an initial residual vector, possibly from a previous run.
On intermediate re-entry: must be unchanged from its previous exit. Changing RESID to any other value between calls may result in an error exit.
On intermediate exit: contains the current residual vector.
On final exit: contains the final residual vector.
3:     $\mathrm{V}\left({\mathbf{LDV}},*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the second dimension of the array V must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{NCV}}\right)$ (see F12FAF).
On initial entry: need not be set.
On intermediate re-entry: must be unchanged from its previous exit.
On intermediate exit: contains the current set of Arnoldi basis vectors.
On final exit: contains the final set of Arnoldi basis vectors.
4:     $\mathrm{LDV}$ – INTEGERInput
On entry: the first dimension of the array V as declared in the (sub)program from which F12FBF is called.
Constraint: ${\mathbf{LDV}}\ge {\mathbf{N}}$.
5:     $\mathrm{X}\left(*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array X must be at least ${\mathbf{N}}$ if ${\mathbf{Pointers}}=\mathrm{NO}$ (default) and at least $1$ if ${\mathbf{Pointers}}=\mathrm{YES}$ (see F12FAF).
On initial entry: need not be set, it is used as a convenient mechanism for accessing elements of COMM.
On intermediate re-entry: if ${\mathbf{Pointers}}=\mathrm{YES}$, X need not be set.
If ${\mathbf{Pointers}}=\mathrm{NO}$, X must contain the result of $y=\mathrm{OP}x$ when IREVCM returns the value $-1$ or $+1$. It must return the real parts of the computed shifts when IREVCM returns the value $3$.
On intermediate exit: if ${\mathbf{Pointers}}=\mathrm{YES}$, X is not referenced.
If ${\mathbf{Pointers}}=\mathrm{NO}$, X contains the vector $x$ when IREVCM returns the value $-1$ or $+1$.
On final exit: does not contain useful data.
6:     $\mathrm{MX}\left(*\right)$ – REAL (KIND=nag_wp) arrayInput/Output
Note: the dimension of the array MX must be at least ${\mathbf{N}}$ if ${\mathbf{Pointers}}=\mathrm{NO}$ (default) and at least $1$ if ${\mathbf{Pointers}}=\mathrm{YES}$ (see F12FAF).
On initial entry: need not be set, it is used as a convenient mechanism for accessing elements of COMM.
On intermediate re-entry: if ${\mathbf{Pointers}}=\mathrm{YES}$, MX need not be set.
If ${\mathbf{Pointers}}=\mathrm{NO}$, MX must contain the result of $y=Bx$ when IREVCM returns the value $2$. It must return the imaginary parts of the computed shifts when IREVCM returns the value $3$.
On intermediate exit: if ${\mathbf{Pointers}}=\mathrm{YES}$, MX is not referenced.
If ${\mathbf{Pointers}}=\mathrm{NO}$, MX contains the vector $Bx$ when IREVCM returns the value $+1$.
On final exit: does not contain any useful data.
7:     $\mathrm{NSHIFT}$ – INTEGEROutput
On intermediate exit: if the option Supplied Shifts is set and IREVCM returns a value of $3$, NSHIFT returns the number of complex shifts required.
8:     $\mathrm{COMM}\left(*\right)$ – REAL (KIND=nag_wp) arrayCommunication Array
Note: the dimension of the array COMM must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LCOMM}}\right)$ (see F12FAF).
On initial entry: must remain unchanged following a call to the setup routine F12FAF.
On exit: contains data defining the current state of the iterative process.
9:     $\mathrm{ICOMM}\left(*\right)$ – INTEGER arrayCommunication Array
Note: the dimension of the array ICOMM must be at least $\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(1,{\mathbf{LICOMM}}\right)$ (see F12FAF).
On initial entry: must remain unchanged following a call to the setup routine F12FAF.
On exit: contains data defining the current state of the iterative process.
10:   $\mathrm{IFAIL}$ – INTEGERInput/Output
On initial entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, because for this routine the values of the output parameters may be useful even if ${\mathbf{IFAIL}}\ne {\mathbf{0}}$ on exit, the recommended value is $-1$. When the value $-\mathbf{1}\text{​ or ​}1$ is used it is essential to test the value of IFAIL on exit.
On final exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
On initial entry, the maximum number of iterations $\le 0$, the option Iteration Limit has been set to a non-positive value.
${\mathbf{IFAIL}}=2$
The options Generalized and Regular are incompatible.
${\mathbf{IFAIL}}=3$
Eigenvalues from both ends of the spectrum were requested, but the number of eigenvalues requested is one.
${\mathbf{IFAIL}}=4$
The option Initial Residual was selected but the starting vector held in RESID is zero.
${\mathbf{IFAIL}}=5$
The maximum number of iterations has been reached. Some Ritz values may have converged; a subsequent call to F12FCF will return the number of converged values and the converged values.
${\mathbf{IFAIL}}=6$
No shifts could be applied during a cycle of the implicitly restarted Arnoldi iteration. One possibility is to increase the size of NCV relative to NEV (see Section 5 in F12FAF for details of these parameters).
${\mathbf{IFAIL}}=7$
Could not build a Lanczos factorization. Consider changing NCV or NEV in the initialization routine (see Section 5 in F12FAF for details of these parameters).
${\mathbf{IFAIL}}=8$
Unexpected error in internal call to compute eigenvalues and corresponding error bounds of the current upper Hessenberg matrix. Please contact NAG.
${\mathbf{IFAIL}}=9$
${\mathbf{IFAIL}}=-99$
See Section 3.8 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

## 7  Accuracy

The relative accuracy of a Ritz value, $\lambda$, is considered acceptable if its Ritz estimate $\text{}\le {\mathbf{Tolerance}}×\left|\lambda \right|$. The default Tolerance used is the machine precision given by X02AJF.

## 8  Parallelism and Performance

F12FBF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
F12FBF 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 routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

None.

## 10  Example

For this routine two examples are presented, with a main program and two example problems given in Example 1 (EX1) and Example 2 (EX2).
Example 1 (EX1)
The example solves $Ax=\lambda x$ in shift-invert mode, where $A$ is obtained from the standard central difference discretization of the one-dimensional Laplacian operator $\frac{{\partial }^{2}u}{\partial {x}^{2}}$ with zero Dirichlet boundary conditions. Eigenvalues closest to the shift $\sigma =0$ are sought.
Example 2 (EX2)
This example illustrates the use of F12FBF to compute the leading terms in the singular value decomposition of a real general matrix $A$. The example finds a few of the largest singular values ($\sigma$) and corresponding right singular values ($\nu$) for the matrix $A$ by solving the symmetric problem:
 $ATA ν=σν .$
Here $A$ is the $m$ by $n$ real matrix derived from the simplest finite difference discretization of the two-dimensional kernal $k\left(s,t\right)dt$ where
 $ks,t = st-1 if ​0≤s≤t≤1 ts-1 if ​0≤t
Note: this formulation is appropriate for the case $m\ge n$. Reverse the rules of $A$ and ${A}^{\mathrm{T}}$ in the case of $m.

### 10.1  Program Text

Program Text (f12fbfe.f90)

### 10.2  Program Data

Program Data (f12fbfe.d)

### 10.3  Program Results

Program Results (f12fbfe.r)