NAG FL Interface f12jrf (feast_complex_herm_solve)
Note:this routine usesoptional parametersto define choices in the problem specification. If you wish to use default settings for all of the optional parameters, then the option setting routine f12jbf need not be called.
If, however, you wish to reset some or all of the settings please refer to Section 11 in f12jbf for a detailed description of the specification of the optional parameters.
f12jrf is an iterative solver used to find some of the eigenvalues and the corresponding eigenvectors of a standard or generalized eigenvalue problem defined by complex Hermitian matrices. This is part of a suite of routines that also includes f12jaf,f12jbfandf12jef.
The routine may be called by the names f12jrf or nagf_sparseig_feast_complex_herm_solve.
3Description
The suite of routines is designed to calculate some of the eigenvalues, $\lambda $, and the corresponding eigenvectors, $x$, of a standard eigenvalue problem $Ax=\lambda x$, or of a generalized eigenvalue problem $Ax=\lambda Bx$, where the coefficient matrices $A$ and $B$ are sparse Hermitian, and $B$ is positive definite. The suite can also be used to find selected eigenvalues/eigenvectors of smaller scale, dense, Hermitian problems.
f12jrf is a reverse communication routine, based on the FEAST eigensolver, described in Polizzi (2009), which finds eigenvalues using contour integration. Prior to calling f12jrf, the contour definition routine f12jef is used to specify a search interval on the real line, $[{E}_{\mathrm{min}},{E}_{\mathrm{max}}]$, within which eigenvalues will be sought (note that the eigenvalues of complex Hermitian eigenproblems are themselves real). f12jef uses this interval to define nodes and weights for an elliptical contour to be used by f12jrf.
The setup routine f12jaf and the contour definition routine f12jef must be called before f12jrf. Between the calls to f12jafandf12jef, options may be set by calls to the option setting routine f12jbf.
f12jrf uses reverse communication, i.e., it returns repeatedly to the calling program with the argument irevcm (see Section 5) set to specified values which require the calling program to carry out one of the following tasks:
–compute a factorization of the matrix ${\mathbf{ze}}B-A$, where ${\mathbf{ze}}$ is a point on the search contour;
–optionally, compute a factorization of the matrix ${({\mathbf{ze}}B-A)}^{\mathrm{H}}$ (this need only be done if the factorization ${\mathbf{ze}}B-A$ does not allow linear systems involving ${({\mathbf{ze}}B-A)}^{\mathrm{H}}$ to be solved);
–solve a linear system involving ${\mathbf{ze}}B-A$ or ${({\mathbf{ze}}B-A)}^{\mathrm{H}}$, using the factorizations above;
–compute the matrix product $x=Az$;
–compute the matrix product $x=Bz$;
–notify the completion of the computation.
The number of contour points, the number of iterations, and other options can all be set using the option setting routine f12jbf (see Section 11.1 in f12jbf for details on setting options and of the default settings). The search contour itself is defined by a call to f12jef.
4References
Polizzi E (2009) Density-Matrix-Based Algorithms for Solving Eigenvalue Problems Phys. Rev. B. 79 115112
5Arguments
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 argument irevcm. Between intermediate exits and re-entries, all arguments other thanx and y must remain unchanged.
1: $\mathbf{handle}$ – Type (c_ptr)Input
On entry: the handle to the internal data structure used by the NAG FEAST suite. It needs to be initialized by f12jaf. It must not be changed between calls to the NAG FEAST suite.
2: $\mathbf{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 a factorization of the matrix ${\mathbf{ze}}B-A$ suitable for solving a linear system, for example using f11dnf which computes an incomplete $LU$ factorization of a complex sparse matrix. All arguments to the routine must remain unchanged.
Note: the factorization can be computed in single precision.
${\mathbf{irevcm}}=2$
The calling program must compute the solution to the linear system $({\mathbf{ze}}B-A)w=y$, overwriting $y$ with the result $w$. The matrix ${\mathbf{ze}}B-A$ has previously been factorized (when ${\mathbf{irevcm}}=1$ was returned) and this factorization can be reused here.
Note: the solve can be performed in single precision.
${\mathbf{irevcm}}=3$
Optionally, the calling program must compute a factorization of the matrix ${({\mathbf{ze}}B-A)}^{\mathrm{H}}$. This need only be done if it is not possible to use the factorization computed when ${\mathbf{irevcm}}=1$ was returned to solve linear systems involving ${({\mathbf{ze}}B-A)}^{\mathrm{H}}$.
Note: the solve can be performed in single precision.
${\mathbf{irevcm}}=4$
The calling program must compute the solution to the linear system ${({\mathbf{ze}}B-A)}^{\mathrm{H}}w=y$, overwriting $y$ with the result $w$. If it is not possible to use the factorization of ${\mathbf{ze}}B-A$ (computed when ${\mathbf{irevcm}}=1$ was returned) then the factorization of ${({\mathbf{ze}}B-A)}^{\mathrm{H}}$ (computed when ${\mathbf{irevcm}}=2$ was returned) should be used here.
${\mathbf{irevcm}}=5$
The calling program must compute $Az$, storing the result in $x$.
${\mathbf{irevcm}}=6$
The calling program must compute $Bz$, storing the result in $x$. If a standard eigenproblem is being solved (so that $B=I$) then the calling program should set $x=z$.
On final exit: ${\mathbf{irevcm}}=0$: f12jrf has completed its tasks. The value of ifail determines whether the iteration has been successfully completed, or whether errors have been detected.
Constraint:
on initial entry, ${\mathbf{irevcm}}=0$; on re-entry irevcm must remain unchanged.
Note: the matrices $x$, $y$ and $z$ referred to in this section are all of size ${\mathbf{n}}\times {\mathbf{m0}}$ and are stored in the arrays x, y and z, respectively.
Note: any values you return to f12jrf as part of the reverse communication procedure should not include floating-point NaN (Not a Number) or infinity values, since these are not handled by f12jrf. If your code does inadvertently return any NaNs or infinities, f12jrf is likely to produce unexpected results.
Note: the second dimension of the array y
must be at least
${\mathbf{m0}}$.
On initial entry: need not be set.
On intermediate exit:
if ${\mathbf{irevcm}}=2$, the calling program must compute the solution to the linear system $({\mathbf{ze}}B-A)w=y$, overwriting $y$ with the result $w$, prior to re-entry. The linear system has m0 right-hand sides.
If ${\mathbf{irevcm}}=4$, the calling program must compute the solution to the linear system ${({\mathbf{ze}}B-A)}^{\mathrm{H}}w=y$, overwriting $y$ with the result $w$, prior to re-entry. The linear system has m0 right-hand sides.
8: $\mathbf{ldy}$ – IntegerInput
On entry: the first dimension of the array y as declared in the (sub)program from which f12jrf is called.
Constraint:
${\mathbf{ldy}}\ge {\mathbf{n}}$.
9: $\mathbf{m0}$ – IntegerInput/Output
On initial entry: the size of the search subspace used to find the eigenvalues. This should exceed the number of eigenvalues within the search contour. See Section 9 for further details.
On intermediate re-entry: m0 must remain unchanged.
On exit: if the initial search subspace was found by f12jrf to be too large, then a new smaller suitable choice is returned.
Constraint:
$0<{\mathbf{m0}}\le {\mathbf{n}}$.
10: $\mathbf{nconv}$ – IntegerOutput
On exit: the number of eigenvalues found within the search contour.
Note: if the optional parameter ${\mathbf{Execution\; Mode}}=\mathrm{Estimate}$ was set in the option setting routine f12jbf, then nconv contains a stochastic estimate of the number of eigenvalues within the search contour.
11: $\mathbf{d}\left(*\right)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the dimension of the array d
must be at least
${\mathbf{m0}}$.
On initial entry: if the option ${\mathbf{Subspace}}=\mathrm{Yes}$ was set using the option setting routine f12jbf, then d should contain an initial guess at the eigenvalues lying within the eigenvector search subspace (this subspace should be specified by z), otherwise d need not be set.
On final exit: the first nconv entries in d contain the eigenvalues.
Note: if the option ${\mathbf{Subspace}}=\mathrm{Yes}$ was set using the option setting routine f12jbf, then on final exit d contains an estimate of the eigenvalues after a single contour integral.
Note: the second dimension of the array z
must be at least
${\mathbf{m0}}$.
On initial entry: if the option ${\mathbf{Subspace}}=\mathrm{Yes}$ was set using the option setting routine f12jbf, then z should contain an initial guess at the eigenvector search subspace, otherwise z need not be set.
On intermediate exit:
must not be changed.
On final exit: the first nconv columns of z contain the eigenvectors corresponding to the eigenvalues found within the contour.
Note: if the option ${\mathbf{Execution\; Mode}}=\mathrm{Subspace}$ was set using the option setting routine f12jbf, then on final exit columns $1:{\mathbf{m0}}$ of z contain the current search subspace after one contour integral.
13: $\mathbf{ldz}$ – IntegerInput
On entry: the first dimension of the array z as declared in the (sub)program from which f12jrf is called.
Constraint:
${\mathbf{ldz}}\ge {\mathbf{n}}$.
14: $\mathbf{eps}$ – Real (Kind=nag_wp)Input/Output
On initial entry: need not be set.
On exit: the relative error on the trace. At iteration $k$, eps is given by the expression $|{\mathrm{trace}}_{k}-{\mathrm{trace}}_{k-1}|/\mathrm{max}\phantom{\rule{0.125em}{0ex}}(\left|{E}_{\mathrm{min}}\right|,\left|{E}_{\mathrm{max}}\right|)$, where ${\mathrm{trace}}_{k}$ is the sum of the eigenvalues found at the $k$th iteration, and ${E}_{\mathrm{min}}$ and ${E}_{\mathrm{max}}$ are the lower and upper bounds respectively of the eigenvalue search interval.
15: $\mathbf{iter}$ – IntegerInput/Output
On initial entry: need not be set.
On exit: the number of subspace iterations performed.
16: $\mathbf{resid}\left(*\right)$ – Real (Kind=nag_wp) arrayInput/Output
Note: the dimension of the array resid
must be at least
${\mathbf{m0}}$.
On initial entry: need not be set.
On final exit: for $i=1,\dots ,{\mathbf{nconv}}$, ${\mathbf{resid}}\left(i\right)$ contains the relative residual, in the $1$-norm, of the $i$th eigenpair found, that is ${\mathbf{resid}}\left(i\right)=\Vert A{z}_{i}-{\lambda}_{i}B{z}_{i}\Vert /(\Vert B{z}_{i}\Vert \times \mathrm{max}\phantom{\rule{0.125em}{0ex}}(\left|{E}_{\mathrm{min}}\right|,\left|{E}_{\mathrm{max}}\right|))$, where ${E}_{\mathrm{min}}$ and ${E}_{\mathrm{max}}$ are the lower and upper bounds respectively of the eigenvalue search interval.
17: $\mathbf{ifail}$ – IntegerInput/Output
On initial entry: ifail must be set to $0$, $\mathrm{-1}$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $\mathrm{-1}$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $\mathrm{-1}$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $\mathrm{-1}$ is recommended since useful values can be provided in some output arguments even when ${\mathbf{ifail}}\ne {\mathbf{0}}$ on exit. When the value $-\mathbf{1}$ or $\mathbf{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).
6Error Indicators and Warnings
If on entry ${\mathbf{ifail}}=0$ or $\mathrm{-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$
Either the contour setting routine f12jef has not been called prior to the first call of this routine or the supplied handle has become corrupted.
${\mathbf{ifail}}=2$
No eigenvalues were found within the search contour.
${\mathbf{ifail}}=3$
The routine did not converge after the maximum number of iterations. The results returned may still be useful, however they might be improved by increasing the maximum number of iterations using the option setting routine f12jbf, increasing the size of the eigenvector search subspace, m0, or experimenting with the choice of contour. Note that the returned eigenvalues and eigenvectors, together with the returned value of m0, can be used as the initial estimates for a new iteration of the solver.
${\mathbf{ifail}}=4$
The size of the eigenvector search subspace, m0, is too small.
${\mathbf{ifail}}=5$
The optional parameter ${\mathbf{Execution\; Mode}}=\mathrm{Subspace}$ was set using f12jbf. Columns $1:{\mathbf{m0}}$ of z contain the search subspace after one contour integral and d contains an estimate of the eigenvalues.
${\mathbf{ifail}}=6$
The optional parameter ${\mathbf{Execution\; Mode}}=\mathrm{Estimate}$ was set using f12jbf so only a stochastic estimate of the number of eigenvalues within the contour has been returned.
${\mathbf{ifail}}=7$
An internal error occurred in the reduced eigenvalue solver. A possible cause is that the matrix $B$ is not positive definite.
${\mathbf{ifail}}=8$
On entry, ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{n}}\ge 1$.
${\mathbf{ifail}}=9$
On entry, ${\mathbf{m0}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: $0<{\mathbf{m0}}\le {\mathbf{n}}$.
${\mathbf{ifail}}=10$
On entry, ${\mathbf{ldx}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{ldx}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=11$
On entry, ${\mathbf{ldy}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{ldy}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=12$
On entry, ${\mathbf{ldz}}=\u27e8\mathit{\text{value}}\u27e9$ and ${\mathbf{n}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{ldz}}\ge {\mathbf{n}}$.
${\mathbf{ifail}}=13$
On initial entry, ${\mathbf{irevcm}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{irevcm}}=0$.
On intermediate entry, ${\mathbf{irevcm}}=\u27e8\mathit{\text{value}}\u27e9$. Constraint: ${\mathbf{irevcm}}=1$, $2$, $3$, $4$, $5$ or $6$.
${\mathbf{ifail}}=14$
The option ${\mathbf{Subspace}}=\mathrm{Yes}$ was set using the option setting routine f12jbf but no nonzero elements were found in the supplied subspace.
${\mathbf{ifail}}=-99$
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
A gauge on the accuracy of the computation can be obtained by looking at eps, the relative error on the trace, and the residuals, stored in resid.
Note: the factorizations and linear system solves required when ${\mathbf{irevcm}}=1$, $2$, $3$ or $4$ can be performed in single precision, without any loss of accuracy in the final eigenvalues and eigenvectors.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
f12jrf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
f12jrf 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.
9Further Comments
Ideally, when using f12jrf you should have an idea of the distribution of the eigenvalue spectrum to allow good choices of the search interval and m0 to be made. For best performance, m0 should exceed the number of eigenvalues in the search interval by a factor of approximately $1.5$.
A stochastic estimate of the number of eigenvalues within the search contour can be obtained by setting ${\mathbf{Execution\; Mode}}=\mathrm{Estimate}$ in the option setting routine f12jbf. In this case, f12jrf can be called with a small value of m0 (for example $~10$). On final output nconv will contain an estimate of the number of eigenvalues, which can then be used to guide the choice of m0.
The complex allocatable memory required by f12jrf is approximately $4\times {\mathbf{m0}}\times {\mathbf{m0}}$.
f12jjf can be used to solve real symmetric eigenvalue problems.
9.1Additional Licensor
Parts of the code for f12jrf are distributed under the BSD software License. Please refer to Library Licensors for further details.
10Example
This example solves the generalized eigenvalue problem $Ax=\lambda Bx$, where
Only those eigenvalues lying within the interval $[-1,0]$ are returned (together with the associated right eigenvectors). The matrices $A$ and $B$ are stored in symmetric coordinate storage format, with appropriate sparse matrix multiplication routines and sparse linear system solvers used.