# NAG FL Interfacef12jgf (feast_​custom_​contour)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

f12jgf is a setup routine in a suite of routines consisting of f12jaf, f12jbf, f12jgf, f12jkf, f12jsf, f12jtf, f12juf and f12jvf. It is used to find some of the eigenvalues, and the corresponding eigenvectors, of a standard, generalized or polynomial eigenvalue problem. The initialization routine f12jaf must have been called prior to calling f12jgf. In addition calls to f12jbf can be made to supply individual optional parameters to f12jgf.
The suite of routines is suitable for the solution of large sparse eigenproblems where only a few eigenvalues from a selected range of the spectrum are required.

## 2Specification

Fortran Interface
 Subroutine f12jgf ( ccn,
 Integer, Intent (In) :: ccn, nedge(ccn), tedge(ccn) Integer, Intent (Inout) :: ifail Complex (Kind=nag_wp), Intent (In) :: zedge(ccn) Type (c_ptr), Intent (In) :: handle
#include <nag.h>
 void f12jgf_ (void **handle, const Integer *ccn, const Integer nedge[], const Integer tedge[], const Complex zedge[], Integer *ifail)
The routine may be called by the names f12jgf or nagf_sparseig_feast_custom_contour.

## 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$, a generalized eigenvalue problem $Ax=\lambda Bx$, or a polynomial eigenvalue problem ${\sum }_{i}{\lambda }^{i}{A}_{i}x=0$, where the coefficient matrices are large and sparse. The suite can also be used to find selected eigenvalues/eigenvectors of smaller scale dense problems.
f12jgf is used to specify a closed contour in the complex plane within which eigenvalues will be sought. The contour can be made up of a combination of line segments and half ellipses. f12jgf uses this information to create a polygonal representation of the contour and to then define the integration nodes and weights to be used by the solvers f12jkf, f12jsf, f12jtf, f12juf or f12jvf.
The arrays zedge, tedge and nedge are used to define the geometry of your contour. Each array is of size ccn, where ccn is the number of pieces that make up the contour. The entries in zedge specify the endpoints in the complex plane of each piece of the contour. The entries in tedge specify whether each piece of the contour is a line segment or a half ellipse. Finally, entries in nedge specify the number of integration points to use for each piece of the contour. See the individual argument descriptions in Section 5 for further details.
Prior to calling f12jgf, the option setting routine f12jbf can be called to specify various optional parameters for the solution of the eigenproblem. For details of the options available and how to set them see Section 11.1 in f12jbf.
Polizzi E (2009) Density-Matrix-Based Algorithms for Solving Eigenvalue Problems Phys. Rev. B. 79 115112

## 5Arguments

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{ccn}$Integer Input
On entry: the number of pieces that make up the contour.
Constraint: ${\mathbf{ccn}}>1$.
3: $\mathbf{nedge}\left({\mathbf{ccn}}\right)$Integer array Input
On entry: ${\mathbf{nedge}}\left(i\right)$ specifies how many integration nodes and weights f12jgf should use for the $i$th piece of the contour.
Constraint: ${\mathbf{nedge}}\left(\mathit{i}\right)>0$, for $\mathit{i}=1,2,\dots ,{\mathbf{ccn}}$.
4: $\mathbf{tedge}\left({\mathbf{ccn}}\right)$Integer array Input
On entry: ${\mathbf{tedge}}\left(i\right)$ specifies what shape the $i$th piece of the contour should be.
${\mathbf{tedge}}\left(i\right)=0$
The $i$th piece of the contour is straight.
${\mathbf{tedge}}\left(i\right)>0$
The $i$th piece of the contour is a (convex) half-ellipse, with ${\mathbf{tedge}}\left(i\right)/100=a/b$, where $a$ is the primary radius from the endpoints of the piece, and $b$ is the radius perpendicular to this. Thus, if ${\mathbf{tedge}}\left(i\right)=100$, then the $i$th piece of the contour is a semicircle.
Constraint: ${\mathbf{tedge}}\left(\mathit{i}\right)\ge 0$, for $\mathit{i}=1,2,\dots ,{\mathbf{ccn}}$.
5: $\mathbf{zedge}\left({\mathbf{ccn}}\right)$Complex (Kind=nag_wp) array Input
On entry: zedge specifies the endpoints of the contour piece.
The $i$th piece has endpoints at ${\mathbf{zedge}}\left(i\right)$ and ${\mathbf{zedge}}\left(i+1\right)$, for $i=1,\dots ,{\mathbf{ccn}}-1$.
The last piece has endpoints at ${\mathbf{zedge}}\left({\mathbf{ccn}}\right)$ and ${\mathbf{zedge}}\left(1\right)$.
Note: the contour should be described in a clockwise direction..
6: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-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 $-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 $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On 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 $-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$
The supplied handle does not define a valid handle to the data structure used by the NAG FEAST suite. It has not been properly initialized or it has been corrupted.
${\mathbf{ifail}}=2$
On entry, ${\mathbf{ccn}}=⟨\mathit{\text{value}}⟩$.
Constraint: ${\mathbf{ccn}}>1$.
${\mathbf{ifail}}=3$
On entry, one or more elements of nedge were less than or equal to zero.
${\mathbf{ifail}}=4$
On entry, one or more elements of tedge were negative.
${\mathbf{ifail}}=-99$
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.

Not applicable.