Actual source code: slepcnep.h

      1: /*
      2:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      3:    SLEPc - Scalable Library for Eigenvalue Problem Computations
      4:    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain

      6:    This file is part of SLEPc.
      7:    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
      8:    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      9: */
     10: /*
     11:    User interface for SLEPc's nonlinear eigenvalue solvers
     12: */

     14: #pragma once

     16: #include <slepceps.h>
     17: #include <slepcpep.h>
     18: #include <slepcfn.h>

     20: /* SUBMANSEC = NEP */

     22: SLEPC_EXTERN PetscErrorCode NEPInitializePackage(void);
     23: SLEPC_EXTERN PetscErrorCode NEPFinalizePackage(void);

     25: /*S
     26:    NEP - SLEPc object that manages all solvers for nonlinear eigenvalue problems.

     28:    Level: beginner

     30: .seealso: [](ch:nep), `NEPCreate()`
     31: S*/
     32: typedef struct _p_NEP* NEP;

     34: /*J
     35:    NEPType - String with the name of a nonlinear eigensolver.

     37:    Level: beginner

     39: .seealso: [](ch:nep), `NEPSetType()`, `NEP`
     40: J*/
     41: typedef const char *NEPType;
     42: #define NEPRII       "rii"
     43: #define NEPSLP       "slp"
     44: #define NEPNARNOLDI  "narnoldi"
     45: #define NEPNLEIGS    "nleigs"
     46: #define NEPCISS      "ciss"
     47: #define NEPINTERPOL  "interpol"

     49: /* Logging support */
     50: SLEPC_EXTERN PetscClassId NEP_CLASSID;

     52: /*E
     53:    NEPProblemType - Determines the type of the nonlinear eigenproblem.

     55:    Values:
     56: +  `NEP_GENERAL`  - no particular structure
     57: -  `NEP_RATIONAL` - problem defined in split form with all $f_i$ rational

     59:    Note:
     60:    Currently, the `NEP_RATIONAL` case is only used in `NEPNLEIGS` to
     61:    determine the singularities automatically.

     63:    Level: intermediate

     65: .seealso: [](ch:nep), `NEPSetProblemType()`, `NEPGetProblemType()`
     66: E*/
     67: typedef enum { NEP_GENERAL  = 1,
     68:                NEP_RATIONAL = 2
     69:              } NEPProblemType;

     71: /*E
     72:    NEPWhich - Determines which part of the spectrum is requested.

     74:    Values:
     75: +  `NEP_LARGEST_MAGNITUDE`  - largest $|\lambda|$
     76: .  `NEP_SMALLEST_MAGNITUDE` - smallest $|\lambda|$
     77: .  `NEP_LARGEST_REAL`       - largest $\mathrm{Re}(\lambda)$
     78: .  `NEP_SMALLEST_REAL`      - smallest $\mathrm{Re}(\lambda)$
     79: .  `NEP_LARGEST_IMAGINARY`  - largest $\mathrm{Im}(\lambda)$
     80: .  `NEP_SMALLEST_IMAGINARY` - smallest $\mathrm{Im}(\lambda)$
     81: .  `NEP_TARGET_MAGNITUDE`   - smallest $|\lambda-\tau|$
     82: .  `NEP_TARGET_REAL`        - smallest $|\mathrm{Re}(\lambda-\tau)|$
     83: .  `NEP_TARGET_IMAGINARY`   - smallest $|\mathrm{Im}(\lambda-\tau)|$
     84: .  `NEP_ALL`                - all $\lambda\in\Omega$
     85: -  `NEP_WHICH_USER`         - user-defined sorting criterion

     87:    Notes:
     88:    The target $\tau$ is a scalar value provided with `NEPSetTarget()`.

     90:    The case `NEP_ALL` needs a region $\Omega$ specified with an `RG` object.

     92:    Level: intermediate

     94: .seealso: [](ch:nep), `NEPSetWhichEigenpairs()`, `NEPSetTarget()`
     95: E*/
     96: typedef enum { NEP_LARGEST_MAGNITUDE  = 1,
     97:                NEP_SMALLEST_MAGNITUDE = 2,
     98:                NEP_LARGEST_REAL       = 3,
     99:                NEP_SMALLEST_REAL      = 4,
    100:                NEP_LARGEST_IMAGINARY  = 5,
    101:                NEP_SMALLEST_IMAGINARY = 6,
    102:                NEP_TARGET_MAGNITUDE   = 7,
    103:                NEP_TARGET_REAL        = 8,
    104:                NEP_TARGET_IMAGINARY   = 9,
    105:                NEP_ALL                = 10,
    106:                NEP_WHICH_USER         = 11 } NEPWhich;

    108: /*E
    109:    NEPErrorType - The error type used to assess the accuracy of computed solutions.

    111:    Values:
    112: +  `NEP_ERROR_ABSOLUTE` - compute error bound as $\|r\|$
    113: .  `NEP_ERROR_RELATIVE` - compute error bound as $\|r\|/|\lambda|$
    114: -  `NEP_ERROR_BACKWARD` - compute error bound as $\|r\|/(\sum_i|f_i(\lambda)|\|A_i\|)$

    116:    Level: intermediate

    118: .seealso: [](ch:nep), `NEPComputeError()`
    119: E*/
    120: typedef enum { NEP_ERROR_ABSOLUTE,
    121:                NEP_ERROR_RELATIVE,
    122:                NEP_ERROR_BACKWARD } NEPErrorType;
    123: SLEPC_EXTERN const char *NEPErrorTypes[];

    125: /*E
    126:    NEPRefine - The type of Newton iterative refinement.

    128:    Values:
    129: +  `NEP_REFINE_NONE`     - no refinement
    130: .  `NEP_REFINE_SIMPLE`   - refinement of each converged eigenpair individually
    131: -  `NEP_REFINE_MULTIPLE` - refinement of the invariant pair as a whole

    133:    Note:
    134:    See section [](#sec:refine) for a discussion of the different refinement strategies.

    136:    Level: intermediate

    138: .seealso: [](ch:nep), [](#sec:refine), `NEPSetRefine()`
    139: E*/
    140: typedef enum { NEP_REFINE_NONE,
    141:                NEP_REFINE_SIMPLE,
    142:                NEP_REFINE_MULTIPLE } NEPRefine;
    143: SLEPC_EXTERN const char *NEPRefineTypes[];

    145: /*E
    146:    NEPRefineScheme - The scheme used for solving linear systems during iterative refinement.

    148:    Values:
    149: +  `NEP_REFINE_SCHEME_SCHUR`    - use the Schur complement
    150: .  `NEP_REFINE_SCHEME_MBE`      - use the mixed block elimination (MBE) scheme
    151: -  `NEP_REFINE_SCHEME_EXPLICIT` - build the full matrix explicitly

    153:    Note:
    154:    Iterative refinement may be very costly, due to the expensive linear
    155:    solves. These linear systems have a particular structure that can be
    156:    exploited in different ways, as described in {cite:p}`Cam16b`. See
    157:    `NEPSetRefine()` for additional details.

    159:    Level: intermediate

    161: .seealso: [](ch:nep), [](#sec:refine), `NEPSetRefine()`
    162: E*/
    163: typedef enum { NEP_REFINE_SCHEME_SCHUR    = 1,
    164:                NEP_REFINE_SCHEME_MBE      = 2,
    165:                NEP_REFINE_SCHEME_EXPLICIT = 3 } NEPRefineScheme;
    166: SLEPC_EXTERN const char *NEPRefineSchemes[];

    168: /*E
    169:    NEPConv - The convergence criterion to be used by the solver.

    171:    Values:
    172: +  `NEP_CONV_ABS`  - absolute convergence criterion, $\|r\|$
    173: .  `NEP_CONV_REL`  - convergence criterion relative to eigenvalue, $\|r\|/|\lambda|$
    174: .  `NEP_CONV_NORM` - convergence criterion relative to matrix norms, $\|r\|/(\sum_j|f_j(\lambda)|\|A_j\|)$
    175: -  `NEP_CONV_USER` - convergence dictated by user-provided function

    177:    Level: intermediate

    179: .seealso: [](ch:nep), `NEPSetConvergenceTest()`, `NEPSetConvergenceTestFunction()`
    180: E*/
    181: typedef enum { NEP_CONV_ABS,
    182:                NEP_CONV_REL,
    183:                NEP_CONV_NORM,
    184:                NEP_CONV_USER } NEPConv;

    186: /*E
    187:    NEPStop - The stopping test to decide the termination of the outer loop
    188:    of the eigensolver.

    190:    Values:
    191: +  `NEP_STOP_BASIC` - default stopping test
    192: -  `NEP_STOP_USER`  - user-provided stopping test

    194:    Level: advanced

    196: .seealso: [](ch:nep), `NEPSetStoppingTest()`, `NEPSetStoppingTestFunction()`
    197: E*/
    198: typedef enum { NEP_STOP_BASIC,
    199:                NEP_STOP_USER } NEPStop;

    201: /*MC
    202:    NEP_STOP_BASIC - The default stopping test.

    204:    Note:
    205:    By default, the termination of the outer loop is decided by calling
    206:    `NEPStoppingBasic()`, which will stop if all requested eigenvalues are converged,
    207:    or if the maximum number of iterations has been reached.

    209:    Level: advanced

    211: .seealso: [](ch:nep), `NEPStop`, `NEPSetStoppingTest()`, `NEPStoppingBasic()`
    212: M*/

    214: /*MC
    215:    NEP_STOP_USER - The user-provided stopping test.

    217:    Note:
    218:    Customized stopping test using the user-provided function given with
    219:    `NEPSetStoppingTestFunction()`.

    221:    Level: advanced

    223: .seealso: [](ch:nep), `NEPStop`, `NEPSetStoppingTest()`, `NEPSetStoppingTestFunction()`
    224: M*/

    226: /*E
    227:    NEPConvergedReason - Reason a nonlinear eigensolver was determined to have converged
    228:    or diverged.

    230:    Values:
    231: +  `NEP_CONVERGED_TOL`               - converged up to tolerance
    232: .  `NEP_CONVERGED_USER`              - converged due to a user-defined condition
    233: .  `NEP_DIVERGED_ITS`                - exceeded the maximum number of allowed iterations
    234: .  `NEP_DIVERGED_BREAKDOWN`          - generic breakdown in method
    235: .  `NEP_DIVERGED_LINEAR_SOLVE`       - inner linear solve failed
    236: .  `NEP_DIVERGED_SUBSPACE_EXHAUSTED` - run out of space for the basis in an unrestarted solver
    237: -  `NEP_CONVERGED_ITERATING`         - the solver is still running

    239:    Level: intermediate

    241: .seealso: [](ch:nep), `NEPSolve()`, `NEPGetConvergedReason()`, `NEPSetTolerances()`
    242: E*/
    243: typedef enum {/* converged */
    244:               NEP_CONVERGED_TOL                =  1,
    245:               NEP_CONVERGED_USER               =  2,
    246:               /* diverged */
    247:               NEP_DIVERGED_ITS                 = -1,
    248:               NEP_DIVERGED_BREAKDOWN           = -2,
    249:                     /* unused                  = -3 */
    250:               NEP_DIVERGED_LINEAR_SOLVE        = -4,
    251:               NEP_DIVERGED_SUBSPACE_EXHAUSTED  = -5,
    252:               NEP_CONVERGED_ITERATING          =  0} NEPConvergedReason;
    253: SLEPC_EXTERN const char *const*NEPConvergedReasons;

    255: /*MC
    256:    NEP_CONVERGED_TOL - The computed error estimates, based on residual norms,
    257:    for all requested eigenvalues are below the tolerance.

    259:    Level: intermediate

    261: .seealso: [](ch:nep), `NEPSolve()`, `NEPGetConvergedReason()`, `NEPConvergedReason`
    262: M*/

    264: /*MC
    265:    NEP_CONVERGED_USER - The solver was declared converged due to a user-defined condition.

    267:    Note:
    268:    This happens only when a user-defined stopping test has been set with
    269:    `NEPSetStoppingTestFunction()`.

    271:    Level: intermediate

    273: .seealso: [](ch:nep), `NEPSolve()`, `NEPGetConvergedReason()`, `NEPConvergedReason`, `NEPSetStoppingTestFunction()`
    274: M*/

    276: /*MC
    277:    NEP_DIVERGED_ITS - Exceeded the maximum number of allowed iterations
    278:    before the convergence criterion was satisfied.

    280:    Level: intermediate

    282: .seealso: [](ch:nep), `NEPSolve()`, `NEPGetConvergedReason()`, `NEPConvergedReason`
    283: M*/

    285: /*MC
    286:    NEP_DIVERGED_BREAKDOWN - A breakdown in the solver was detected so the
    287:    method could not continue.

    289:    Level: intermediate

    291: .seealso: [](ch:nep), `NEPSolve()`, `NEPGetConvergedReason()`, `NEPConvergedReason`
    292: M*/

    294: /*MC
    295:    NEP_DIVERGED_LINEAR_SOLVE - The inner linear solve failed so the nonlinear
    296:    eigensolver could not continue.

    298:    Level: intermediate

    300: .seealso: [](ch:nep), `NEPSolve()`, `NEPGetConvergedReason()`, `NEPConvergedReason`
    301: M*/

    303: /*MC
    304:    NEP_DIVERGED_SUBSPACE_EXHAUSTED - The solver has run out of space for the
    305:    basis in the case of an unrestarted method.

    307:    Level: intermediate

    309: .seealso: [](ch:nep), `NEPSolve()`, `NEPGetConvergedReason()`, `NEPConvergedReason`
    310: M*/

    312: /*MC
    313:    NEP_CONVERGED_ITERATING - This value is returned if `NEPGetConvergedReason()` is called
    314:    while `NEPSolve()` is still running.

    316:    Level: intermediate

    318: .seealso: [](ch:nep), `NEPSolve()`, `NEPGetConvergedReason()`, `NEPConvergedReason`
    319: M*/

    321: SLEPC_EXTERN PetscErrorCode NEPCreate(MPI_Comm,NEP*);
    322: SLEPC_EXTERN PetscErrorCode NEPDestroy(NEP*);
    323: SLEPC_EXTERN PetscErrorCode NEPReset(NEP);
    324: SLEPC_EXTERN PetscErrorCode NEPSetType(NEP,NEPType);
    325: SLEPC_EXTERN PetscErrorCode NEPGetType(NEP,NEPType*);
    326: SLEPC_EXTERN PetscErrorCode NEPSetProblemType(NEP,NEPProblemType);
    327: SLEPC_EXTERN PetscErrorCode NEPGetProblemType(NEP,NEPProblemType*);
    328: SLEPC_EXTERN PetscErrorCode NEPSetTarget(NEP,PetscScalar);
    329: SLEPC_EXTERN PetscErrorCode NEPGetTarget(NEP,PetscScalar*);
    330: SLEPC_EXTERN PetscErrorCode NEPSetFromOptions(NEP);
    331: SLEPC_EXTERN PetscErrorCode NEPSetDSType(NEP);
    332: SLEPC_EXTERN PetscErrorCode NEPSetUp(NEP);
    333: SLEPC_EXTERN PetscErrorCode NEPSolve(NEP);
    334: SLEPC_EXTERN PetscErrorCode NEPView(NEP,PetscViewer);
    335: SLEPC_EXTERN PetscErrorCode NEPViewFromOptions(NEP,PetscObject,const char[]);
    336: SLEPC_EXTERN PetscErrorCode NEPErrorView(NEP,NEPErrorType,PetscViewer);
    337: SLEPC_EXTERN PetscErrorCode NEPErrorViewFromOptions(NEP);
    338: SLEPC_EXTERN PetscErrorCode NEPConvergedReasonView(NEP,PetscViewer);
    339: SLEPC_EXTERN PetscErrorCode NEPConvergedReasonViewFromOptions(NEP);
    340: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "NEPConvergedReasonView()", ) static inline PetscErrorCode NEPReasonView(NEP nep,PetscViewer v) {return NEPConvergedReasonView(nep,v);}
    341: PETSC_DEPRECATED_FUNCTION(3, 14, 0, "NEPConvergedReasonViewFromOptions()", ) static inline PetscErrorCode NEPReasonViewFromOptions(NEP nep) {return NEPConvergedReasonViewFromOptions(nep);}
    342: SLEPC_EXTERN PetscErrorCode NEPValuesView(NEP,PetscViewer);
    343: SLEPC_EXTERN PetscErrorCode NEPValuesViewFromOptions(NEP);
    344: SLEPC_EXTERN PetscErrorCode NEPVectorsView(NEP,PetscViewer);
    345: SLEPC_EXTERN PetscErrorCode NEPVectorsViewFromOptions(NEP);

    347: /*S
    348:    NEPFunctionFn - A prototype of a `NEP` function evaluation function that
    349:    would be passed to `NEPSetFunction()`.

    351:    Calling Sequence:
    352: +  nep    - the nonlinear eigensolver context
    353: .  lambda - the scalar argument where $T(\cdot)$ must be evaluated
    354: .  T      - matrix that will contain $T(\lambda)$
    355: .  P      - [optional] different matrix to build the preconditioner
    356: -  ctx    - [optional] user-defined context for private data for the
    357:             function evaluation routine (may be `NULL`)

    359:    Level: beginner

    361: .seealso: [](ch:nep), `NEPSetFunction()`
    362: S*/
    363: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPFunctionFn(NEP nep,PetscScalar lambda,Mat T,Mat P,PetscCtx ctx);

    365: /*S
    366:    NEPJacobianFn - A prototype of a `NEP` Jacobian evaluation function that
    367:    would be passed to `NEPSetJacobian()`.

    369:    Calling Sequence:
    370: +  nep    - the nonlinear eigensolver context
    371: .  lambda - the scalar argument where $T'(\cdot)$ must be evaluated
    372: .  J      - matrix that will contain $T'(\lambda)$
    373: -  ctx    - [optional] user-defined context for private data for the
    374:             Jacobian evaluation routine (may be `NULL`)

    376:    Level: beginner

    378: .seealso: [](ch:nep), `NEPSetJacobian()`
    379: S*/
    380: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPJacobianFn(NEP nep,PetscScalar lambda,Mat J,PetscCtx ctx);

    382: SLEPC_EXTERN PetscErrorCode NEPSetFunction(NEP,Mat,Mat,NEPFunctionFn*,PetscCtx);
    383: SLEPC_EXTERN PetscErrorCode NEPGetFunction(NEP,Mat*,Mat*,NEPFunctionFn**,PetscCtxRt);
    384: SLEPC_EXTERN PetscErrorCode NEPSetJacobian(NEP,Mat,NEPJacobianFn*,PetscCtx);
    385: SLEPC_EXTERN PetscErrorCode NEPGetJacobian(NEP,Mat*,NEPJacobianFn**,PetscCtxRt);
    386: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "NEPSetFunction() and NEPSetJacobian()", ) static inline PetscErrorCode NEPSetDerivatives(NEP nep,Mat A,PetscErrorCode (*fun)(NEP,PetscScalar,PetscInt,Mat,void*),void *ctx) {(void)A;(void)fun;(void)ctx;SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Not implemented in this version");}
    387: PETSC_DEPRECATED_FUNCTION(3, 12, 0, "NEPGetFunction() and NEPGetJacobian()", ) static inline PetscErrorCode NEPGetDerivatives(NEP nep,Mat *A,PetscErrorCode (**fun)(NEP,PetscScalar,PetscInt,Mat,void*),void **ctx) {(void)A;(void)fun;(void)ctx;SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"Not implemented in this version");}
    388: SLEPC_EXTERN PetscErrorCode NEPSetSplitOperator(NEP,PetscInt,Mat[],FN[],MatStructure);
    389: SLEPC_EXTERN PetscErrorCode NEPGetSplitOperatorTerm(NEP,PetscInt,Mat*,FN*);
    390: SLEPC_EXTERN PetscErrorCode NEPGetSplitOperatorInfo(NEP,PetscInt*,MatStructure*);
    391: SLEPC_EXTERN PetscErrorCode NEPSetSplitPreconditioner(NEP,PetscInt,Mat[],MatStructure);
    392: SLEPC_EXTERN PetscErrorCode NEPGetSplitPreconditionerTerm(NEP,PetscInt,Mat*);
    393: SLEPC_EXTERN PetscErrorCode NEPGetSplitPreconditionerInfo(NEP,PetscInt*,MatStructure*);

    395: SLEPC_EXTERN PetscErrorCode NEPSetBV(NEP,BV);
    396: SLEPC_EXTERN PetscErrorCode NEPGetBV(NEP,BV*);
    397: SLEPC_EXTERN PetscErrorCode NEPSetRG(NEP,RG);
    398: SLEPC_EXTERN PetscErrorCode NEPGetRG(NEP,RG*);
    399: SLEPC_EXTERN PetscErrorCode NEPSetDS(NEP,DS);
    400: SLEPC_EXTERN PetscErrorCode NEPGetDS(NEP,DS*);
    401: SLEPC_EXTERN PetscErrorCode NEPRefineGetKSP(NEP,KSP*);
    402: SLEPC_EXTERN PetscErrorCode NEPSetTolerances(NEP,PetscReal,PetscInt);
    403: SLEPC_EXTERN PetscErrorCode NEPGetTolerances(NEP,PetscReal*,PetscInt*);
    404: SLEPC_EXTERN PetscErrorCode NEPSetDimensions(NEP,PetscInt,PetscInt,PetscInt);
    405: SLEPC_EXTERN PetscErrorCode NEPGetDimensions(NEP,PetscInt*,PetscInt*,PetscInt*);
    406: SLEPC_EXTERN PetscErrorCode NEPSetRefine(NEP,NEPRefine,PetscInt,PetscReal,PetscInt,NEPRefineScheme);
    407: SLEPC_EXTERN PetscErrorCode NEPGetRefine(NEP,NEPRefine*,PetscInt*,PetscReal*,PetscInt*,NEPRefineScheme*);

    409: SLEPC_EXTERN PetscErrorCode NEPGetConverged(NEP,PetscInt*);
    410: SLEPC_EXTERN PetscErrorCode NEPGetEigenpair(NEP,PetscInt,PetscScalar*,PetscScalar*,Vec,Vec);
    411: SLEPC_EXTERN PetscErrorCode NEPGetLeftEigenvector(NEP,PetscInt,Vec,Vec);

    413: SLEPC_EXTERN PetscErrorCode NEPComputeError(NEP,PetscInt,NEPErrorType,PetscReal*);
    414: PETSC_DEPRECATED_FUNCTION(3, 6, 0, "NEPComputeError()", ) static inline PetscErrorCode NEPComputeRelativeError(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_RELATIVE,r);}
    415: PETSC_DEPRECATED_FUNCTION(3, 6, 0, "NEPComputeError() with NEP_ERROR_ABSOLUTE", ) static inline PetscErrorCode NEPComputeResidualNorm(NEP nep,PetscInt i,PetscReal *r) {return NEPComputeError(nep,i,NEP_ERROR_ABSOLUTE,r);}
    416: SLEPC_EXTERN PetscErrorCode NEPGetErrorEstimate(NEP,PetscInt,PetscReal*);

    418: SLEPC_EXTERN PetscErrorCode NEPComputeFunction(NEP,PetscScalar,Mat,Mat);
    419: SLEPC_EXTERN PetscErrorCode NEPComputeJacobian(NEP,PetscScalar,Mat);
    420: SLEPC_EXTERN PetscErrorCode NEPApplyFunction(NEP,PetscScalar,Vec,Vec,Vec,Mat,Mat);
    421: SLEPC_EXTERN PetscErrorCode NEPApplyAdjoint(NEP,PetscScalar,Vec,Vec,Vec,Mat,Mat);
    422: SLEPC_EXTERN PetscErrorCode NEPApplyJacobian(NEP,PetscScalar,Vec,Vec,Vec,Mat);
    423: SLEPC_EXTERN PetscErrorCode NEPProjectOperator(NEP,PetscInt,PetscInt);
    424: SLEPC_EXTERN PetscErrorCode NEPGetIterationNumber(NEP,PetscInt*);

    426: SLEPC_EXTERN PetscErrorCode NEPSetInitialSpace(NEP,PetscInt,Vec[]);
    427: SLEPC_EXTERN PetscErrorCode NEPSetWhichEigenpairs(NEP,NEPWhich);
    428: SLEPC_EXTERN PetscErrorCode NEPGetWhichEigenpairs(NEP,NEPWhich*);
    429: SLEPC_EXTERN PetscErrorCode NEPSetTwoSided(NEP,PetscBool);
    430: SLEPC_EXTERN PetscErrorCode NEPGetTwoSided(NEP,PetscBool*);

    432: SLEPC_EXTERN PetscErrorCode NEPApplyResolvent(NEP,RG,PetscScalar,Vec,Vec);

    434: SLEPC_EXTERN PetscErrorCode NEPSetTrackAll(NEP,PetscBool);
    435: SLEPC_EXTERN PetscErrorCode NEPGetTrackAll(NEP,PetscBool*);

    437: SLEPC_EXTERN PetscErrorCode NEPGetConvergedReason(NEP,NEPConvergedReason*);

    439: /*S
    440:    NEPMonitorFn - A function prototype for functions provided to `NEPMonitorSet()`.

    442:    Calling Sequence:
    443: +  nep    - the nonlinear eigensolver context
    444: .  its    - iteration number
    445: .  nconv  - number of converged eigenpairs
    446: .  eigr   - real part of the eigenvalues
    447: .  eigi   - imaginary part of the eigenvalues
    448: .  errest - relative error estimates for each eigenpair
    449: .  nest   - number of error estimates
    450: -  ctx    - optional monitoring context, as provided with `NEPMonitorSet()`

    452:    Level: intermediate

    454: .seealso: [](ch:nep), `NEPMonitorSet()`
    455: S*/
    456: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPMonitorFn(NEP nep,PetscInt its,PetscInt nconv,PetscScalar eigr[],PetscScalar eigi[],PetscReal errest[],PetscInt nest,PetscCtx ctx);

    458: /*S
    459:    NEPMonitorRegisterFn - A function prototype for functions provided to `NEPMonitorRegister()`.

    461:    Calling Sequence:
    462: +  nep    - the nonlinear eigensolver context
    463: .  its    - iteration number
    464: .  nconv  - number of converged eigenpairs
    465: .  eigr   - real part of the eigenvalues
    466: .  eigi   - imaginary part of the eigenvalues
    467: .  errest - relative error estimates for each eigenpair
    468: .  nest   - number of error estimates
    469: -  ctx    - `PetscViewerAndFormat` object

    471:    Level: advanced

    473:    Note:
    474:    This is a `NEPMonitorFn` specialized for a context of `PetscViewerAndFormat`.

    476: .seealso: [](ch:nep), `NEPMonitorSet()`, `NEPMonitorRegister()`, `NEPMonitorFn`, `NEPMonitorRegisterCreateFn`, `NEPMonitorRegisterDestroyFn`
    477: S*/
    478: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPMonitorRegisterFn(NEP nep,PetscInt its,PetscInt nconv,PetscScalar eigr[],PetscScalar eigi[],PetscReal errest[],PetscInt nest,PetscViewerAndFormat *ctx);

    480: /*S
    481:    NEPMonitorRegisterCreateFn - A function prototype for functions that do the
    482:    creation when provided to `NEPMonitorRegister()`.

    484:    Calling Sequence:
    485: +  viewer - the viewer to be used with the `NEPMonitorRegisterFn`
    486: .  format - the format of the viewer
    487: .  ctx    - a context for the monitor
    488: -  result - a `PetscViewerAndFormat` object

    490:    Level: advanced

    492: .seealso: [](ch:nep), `NEPMonitorRegisterFn`, `NEPMonitorSet()`, `NEPMonitorRegister()`, `NEPMonitorFn`, `NEPMonitorRegisterDestroyFn`
    493: S*/
    494: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPMonitorRegisterCreateFn(PetscViewer viewer,PetscViewerFormat format,PetscCtx ctx,PetscViewerAndFormat **result);

    496: /*S
    497:    NEPMonitorRegisterDestroyFn - A function prototype for functions that do the after
    498:    use destruction when provided to `NEPMonitorRegister()`.

    500:    Calling Sequence:
    501: .  vf - a `PetscViewerAndFormat` object to be destroyed, including any context

    503:    Level: advanced

    505: .seealso: [](ch:nep), `NEPMonitorRegisterFn`, `NEPMonitorSet()`, `NEPMonitorRegister()`, `NEPMonitorFn`, `NEPMonitorRegisterCreateFn`
    506: S*/
    507: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPMonitorRegisterDestroyFn(PetscViewerAndFormat **result);

    509: SLEPC_EXTERN PetscErrorCode NEPMonitor(NEP,PetscInt,PetscInt,PetscScalar[],PetscScalar[],PetscReal[],PetscInt);
    510: SLEPC_EXTERN PetscErrorCode NEPMonitorSet(NEP,NEPMonitorFn,PetscCtx,PetscCtxDestroyFn*);
    511: SLEPC_EXTERN PetscErrorCode NEPMonitorCancel(NEP);
    512: SLEPC_EXTERN PetscErrorCode NEPGetMonitorContext(NEP,PetscCtxRt);

    514: SLEPC_EXTERN PetscErrorCode NEPMonitorSetFromOptions(NEP,const char[],const char[],PetscCtx,PetscBool);
    515: SLEPC_EXTERN NEPMonitorRegisterFn        NEPMonitorFirst;
    516: SLEPC_EXTERN NEPMonitorRegisterFn        NEPMonitorFirstDrawLG;
    517: SLEPC_EXTERN NEPMonitorRegisterCreateFn  NEPMonitorFirstDrawLGCreate;
    518: SLEPC_EXTERN NEPMonitorRegisterFn        NEPMonitorAll;
    519: SLEPC_EXTERN NEPMonitorRegisterFn        NEPMonitorAllDrawLG;
    520: SLEPC_EXTERN NEPMonitorRegisterCreateFn  NEPMonitorAllDrawLGCreate;
    521: SLEPC_EXTERN NEPMonitorRegisterFn        NEPMonitorConverged;
    522: SLEPC_EXTERN NEPMonitorRegisterCreateFn  NEPMonitorConvergedCreate;
    523: SLEPC_EXTERN NEPMonitorRegisterFn        NEPMonitorConvergedDrawLG;
    524: SLEPC_EXTERN NEPMonitorRegisterCreateFn  NEPMonitorConvergedDrawLGCreate;

    526: SLEPC_EXTERN PetscErrorCode NEPSetOptionsPrefix(NEP,const char[]);
    527: SLEPC_EXTERN PetscErrorCode NEPAppendOptionsPrefix(NEP,const char[]);
    528: SLEPC_EXTERN PetscErrorCode NEPGetOptionsPrefix(NEP,const char*[]);

    530: SLEPC_EXTERN PetscFunctionList NEPList;
    531: SLEPC_EXTERN PetscFunctionList NEPMonitorList;
    532: SLEPC_EXTERN PetscFunctionList NEPMonitorCreateList;
    533: SLEPC_EXTERN PetscFunctionList NEPMonitorDestroyList;
    534: SLEPC_EXTERN PetscErrorCode NEPRegister(const char[],PetscErrorCode(*)(NEP));
    535: SLEPC_EXTERN PetscErrorCode NEPMonitorRegister(const char[],PetscViewerType,PetscViewerFormat,NEPMonitorRegisterFn*,NEPMonitorRegisterCreateFn*,NEPMonitorRegisterDestroyFn*);

    537: SLEPC_EXTERN PetscErrorCode NEPSetWorkVecs(NEP,PetscInt);
    538: SLEPC_EXTERN PetscErrorCode NEPAllocateSolution(NEP,PetscInt);

    540: /*S
    541:    NEPConvergenceTestFn - A prototype of a `NEP` convergence test function that
    542:    would be passed to `NEPSetConvergenceTestFunction()`.

    544:    Calling Sequence:
    545: +  nep    - the nonlinear eigensolver context
    546: .  eigr   - real part of the eigenvalue
    547: .  eigi   - imaginary part of the eigenvalue
    548: .  res    - residual norm associated to the eigenpair
    549: .  errest - [output] computed error estimate
    550: -  ctx    - optional convergence context, as set by `NEPSetConvergenceTestFunction()`

    552:    Level: advanced

    554: .seealso: [](ch:nep), `NEPSetConvergenceTest()`, `NEPSetConvergenceTestFunction()`
    555: S*/
    556: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPConvergenceTestFn(NEP nep,PetscScalar eigr,PetscScalar eigi,PetscReal res,PetscReal *errest,PetscCtx ctx);

    558: SLEPC_EXTERN PetscErrorCode NEPSetConvergenceTest(NEP,NEPConv);
    559: SLEPC_EXTERN PetscErrorCode NEPGetConvergenceTest(NEP,NEPConv*);
    560: SLEPC_EXTERN NEPConvergenceTestFn NEPConvergedAbsolute;
    561: SLEPC_EXTERN NEPConvergenceTestFn NEPConvergedRelative;
    562: SLEPC_EXTERN NEPConvergenceTestFn NEPConvergedNorm;
    563: SLEPC_EXTERN PetscErrorCode NEPSetConvergenceTestFunction(NEP,NEPConvergenceTestFn*,PetscCtx,PetscCtxDestroyFn*);

    565: /*S
    566:    NEPStoppingTestFn - A prototype of a `NEP` stopping test function that would
    567:    be passed to `NEPSetStoppingTestFunction()`.

    569:    Calling Sequence:
    570: +  nep    - the nonlinear eigensolver context
    571: .  its    - current number of iterations
    572: .  max_it - maximum number of iterations
    573: .  nconv  - number of currently converged eigenpairs
    574: .  nev    - number of requested eigenpairs
    575: .  reason - [output] result of the stopping test
    576: -  ctx    - optional stopping context, as set by `NEPSetStoppingTestFunction()`

    578:    Note:
    579:    A positive value of `reason` indicates that the iteration has finished successfully
    580:    (converged), and a negative value indicates an error condition (diverged). If
    581:    the iteration needs to be continued, `reason` must be set to `NEP_CONVERGED_ITERATING`
    582:    (zero).

    584:    Level: advanced

    586: .seealso: [](ch:nep), `NEPSetStoppingTestFunction()`
    587: S*/
    588: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPStoppingTestFn(NEP nep,PetscInt its,PetscInt max_it,PetscInt nconv,PetscInt nev,NEPConvergedReason *reason,PetscCtx ctx);

    590: SLEPC_EXTERN PetscErrorCode NEPSetStoppingTest(NEP,NEPStop);
    591: SLEPC_EXTERN PetscErrorCode NEPGetStoppingTest(NEP,NEPStop*);
    592: SLEPC_EXTERN NEPStoppingTestFn NEPStoppingBasic;
    593: SLEPC_EXTERN PetscErrorCode NEPSetStoppingTestFunction(NEP,NEPStoppingTestFn*,PetscCtx,PetscCtxDestroyFn*);

    595: SLEPC_EXTERN PetscErrorCode NEPSetEigenvalueComparison(NEP,SlepcEigenvalueComparisonFn*,PetscCtx);

    597: /* --------- options specific to particular eigensolvers -------- */

    599: SLEPC_EXTERN PetscErrorCode NEPRIISetMaximumIterations(NEP,PetscInt);
    600: SLEPC_EXTERN PetscErrorCode NEPRIIGetMaximumIterations(NEP,PetscInt*);
    601: SLEPC_EXTERN PetscErrorCode NEPRIISetLagPreconditioner(NEP,PetscInt);
    602: SLEPC_EXTERN PetscErrorCode NEPRIIGetLagPreconditioner(NEP,PetscInt*);
    603: SLEPC_EXTERN PetscErrorCode NEPRIISetConstCorrectionTol(NEP,PetscBool);
    604: SLEPC_EXTERN PetscErrorCode NEPRIIGetConstCorrectionTol(NEP,PetscBool*);
    605: SLEPC_EXTERN PetscErrorCode NEPRIISetHermitian(NEP,PetscBool);
    606: SLEPC_EXTERN PetscErrorCode NEPRIIGetHermitian(NEP,PetscBool*);
    607: SLEPC_EXTERN PetscErrorCode NEPRIISetDeflationThreshold(NEP,PetscReal);
    608: SLEPC_EXTERN PetscErrorCode NEPRIIGetDeflationThreshold(NEP,PetscReal*);
    609: SLEPC_EXTERN PetscErrorCode NEPRIISetKSP(NEP,KSP);
    610: SLEPC_EXTERN PetscErrorCode NEPRIIGetKSP(NEP,KSP*);

    612: SLEPC_EXTERN PetscErrorCode NEPSLPSetDeflationThreshold(NEP,PetscReal);
    613: SLEPC_EXTERN PetscErrorCode NEPSLPGetDeflationThreshold(NEP,PetscReal*);
    614: SLEPC_EXTERN PetscErrorCode NEPSLPSetEPS(NEP,EPS);
    615: SLEPC_EXTERN PetscErrorCode NEPSLPGetEPS(NEP,EPS*);
    616: SLEPC_EXTERN PetscErrorCode NEPSLPSetEPSLeft(NEP,EPS);
    617: SLEPC_EXTERN PetscErrorCode NEPSLPGetEPSLeft(NEP,EPS*);
    618: SLEPC_EXTERN PetscErrorCode NEPSLPSetKSP(NEP,KSP);
    619: SLEPC_EXTERN PetscErrorCode NEPSLPGetKSP(NEP,KSP*);

    621: SLEPC_EXTERN PetscErrorCode NEPNArnoldiSetKSP(NEP,KSP);
    622: SLEPC_EXTERN PetscErrorCode NEPNArnoldiGetKSP(NEP,KSP*);
    623: SLEPC_EXTERN PetscErrorCode NEPNArnoldiSetLagPreconditioner(NEP,PetscInt);
    624: SLEPC_EXTERN PetscErrorCode NEPNArnoldiGetLagPreconditioner(NEP,PetscInt*);

    626: /*E
    627:    NEPCISSExtraction - The extraction technique used in the CISS solver.

    629:    Values:
    630: +  `NEP_CISS_EXTRACTION_RITZ`   - Rayleigh-Ritz extraction
    631: .  `NEP_CISS_EXTRACTION_HANKEL` - block Hankel method
    632: -  `NEP_CISS_EXTRACTION_CAA`    - communication-avoiding Arnoldi method

    634:    Level: advanced

    636: .seealso: [](ch:nep), `NEPCISSSetExtraction()`, `NEPCISSGetExtraction()`
    637: E*/
    638: typedef enum { NEP_CISS_EXTRACTION_RITZ,
    639:                NEP_CISS_EXTRACTION_HANKEL,
    640:                NEP_CISS_EXTRACTION_CAA    } NEPCISSExtraction;
    641: SLEPC_EXTERN const char *NEPCISSExtractions[];

    643: #if defined(PETSC_USE_COMPLEX) || defined(PETSC_CLANG_STATIC_ANALYZER)
    644: SLEPC_EXTERN PetscErrorCode NEPCISSSetExtraction(NEP,NEPCISSExtraction);
    645: SLEPC_EXTERN PetscErrorCode NEPCISSGetExtraction(NEP,NEPCISSExtraction*);
    646: SLEPC_EXTERN PetscErrorCode NEPCISSSetSizes(NEP,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscBool);
    647: SLEPC_EXTERN PetscErrorCode NEPCISSGetSizes(NEP,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscInt*,PetscBool*);
    648: SLEPC_EXTERN PetscErrorCode NEPCISSSetThreshold(NEP,PetscReal,PetscReal);
    649: SLEPC_EXTERN PetscErrorCode NEPCISSGetThreshold(NEP,PetscReal*,PetscReal*);
    650: SLEPC_EXTERN PetscErrorCode NEPCISSSetRefinement(NEP,PetscInt,PetscInt);
    651: SLEPC_EXTERN PetscErrorCode NEPCISSGetRefinement(NEP,PetscInt*,PetscInt*);
    652: SLEPC_EXTERN PetscErrorCode NEPCISSGetKSPs(NEP,PetscInt*,KSP*[]);
    653: #else
    654: #define SlepcNEPCISSUnavailable(nep) do { \
    655:     PetscFunctionBegin; \
    656:     SETERRQ(PetscObjectComm((PetscObject)nep),PETSC_ERR_SUP,"%s() not available with real scalars",PETSC_FUNCTION_NAME); \
    657:     } while (0)
    658: static inline PetscErrorCode NEPCISSSetExtraction(NEP nep,PETSC_UNUSED NEPCISSExtraction ex) {SlepcNEPCISSUnavailable(nep);}
    659: static inline PetscErrorCode NEPCISSGetExtraction(NEP nep,PETSC_UNUSED NEPCISSExtraction *ex) {SlepcNEPCISSUnavailable(nep);}
    660: static inline PetscErrorCode NEPCISSSetSizes(NEP nep,PETSC_UNUSED PetscInt ip,PETSC_UNUSED PetscInt bs,PETSC_UNUSED PetscInt ms,PETSC_UNUSED PetscInt npart,PETSC_UNUSED PetscInt bsmax,PETSC_UNUSED PetscBool realmats) {SlepcNEPCISSUnavailable(nep);}
    661: static inline PetscErrorCode NEPCISSGetSizes(NEP nep,PETSC_UNUSED PetscInt *ip,PETSC_UNUSED PetscInt *bs,PETSC_UNUSED PetscInt *ms,PETSC_UNUSED PetscInt *npart,PETSC_UNUSED PetscInt *bsmak,PETSC_UNUSED PetscBool *realmats) {SlepcNEPCISSUnavailable(nep);}
    662: static inline PetscErrorCode NEPCISSSetThreshold(NEP nep,PETSC_UNUSED PetscReal delta,PETSC_UNUSED PetscReal spur) {SlepcNEPCISSUnavailable(nep);}
    663: static inline PetscErrorCode NEPCISSGetThreshold(NEP nep,PETSC_UNUSED PetscReal *delta,PETSC_UNUSED PetscReal *spur) {SlepcNEPCISSUnavailable(nep);}
    664: static inline PetscErrorCode NEPCISSSetRefinement(NEP nep,PETSC_UNUSED PetscInt inner,PETSC_UNUSED PetscInt blsize) {SlepcNEPCISSUnavailable(nep);}
    665: static inline PetscErrorCode NEPCISSGetRefinement(NEP nep,PETSC_UNUSED PetscInt *inner,PETSC_UNUSED PetscInt *blsize) {SlepcNEPCISSUnavailable(nep);}
    666: static inline PetscErrorCode NEPCISSGetKSPs(NEP nep,PETSC_UNUSED PetscInt *nsolve,PETSC_UNUSED KSP *ksp[]) {SlepcNEPCISSUnavailable(nep);}
    667: #undef SlepcNEPCISSUnavailable
    668: #endif

    670: SLEPC_EXTERN PetscErrorCode NEPInterpolSetPEP(NEP,PEP);
    671: SLEPC_EXTERN PetscErrorCode NEPInterpolGetPEP(NEP,PEP*);
    672: SLEPC_EXTERN PetscErrorCode NEPInterpolSetInterpolation(NEP,PetscReal,PetscInt);
    673: SLEPC_EXTERN PetscErrorCode NEPInterpolGetInterpolation(NEP,PetscReal*,PetscInt*);

    675: /*S
    676:    NEPNLEIGSSingularitiesFn - A prototype of a function that would be passed
    677:    to `NEPNLEIGSSetSingularitiesFunction()`.

    679:    Calling Sequence:
    680: +  nep   - the nonlinear eigensolver context
    681: .  maxnp - on input the number of requested points in the discretization (can be modified)
    682: .  xi    - computed values of the discretization
    683: -  ctx   - optional context, as set by `NEPNLEIGSSetSingularitiesFunction()`

    685:    Note:
    686:    The user-defined function can set a smaller value of `maxnp` if necessary.
    687:    It is wrong to return a larger value.

    689:    Level: intermediate

    691: .seealso: [](ch:nep), `NEPNLEIGSSetSingularitiesFunction()`
    692: S*/
    693: PETSC_EXTERN_TYPEDEF typedef PetscErrorCode NEPNLEIGSSingularitiesFn(NEP nep,PetscInt *maxnp,PetscScalar *xi,PetscCtx ctx);

    695: SLEPC_EXTERN PetscErrorCode NEPNLEIGSSetSingularitiesFunction(NEP,NEPNLEIGSSingularitiesFn*,PetscCtx);
    696: SLEPC_EXTERN PetscErrorCode NEPNLEIGSGetSingularitiesFunction(NEP,NEPNLEIGSSingularitiesFn**,PetscCtxRt);
    697: SLEPC_EXTERN PetscErrorCode NEPNLEIGSSetRestart(NEP,PetscReal);
    698: SLEPC_EXTERN PetscErrorCode NEPNLEIGSGetRestart(NEP,PetscReal*);
    699: SLEPC_EXTERN PetscErrorCode NEPNLEIGSSetLocking(NEP,PetscBool);
    700: SLEPC_EXTERN PetscErrorCode NEPNLEIGSGetLocking(NEP,PetscBool*);
    701: SLEPC_EXTERN PetscErrorCode NEPNLEIGSSetInterpolation(NEP,PetscReal,PetscInt);
    702: SLEPC_EXTERN PetscErrorCode NEPNLEIGSGetInterpolation(NEP,PetscReal*,PetscInt*);
    703: SLEPC_EXTERN PetscErrorCode NEPNLEIGSSetRKShifts(NEP,PetscInt,PetscScalar[]);
    704: SLEPC_EXTERN PetscErrorCode NEPNLEIGSGetRKShifts(NEP,PetscInt*,PetscScalar*[]);
    705: SLEPC_EXTERN PetscErrorCode NEPNLEIGSGetKSPs(NEP,PetscInt*,KSP*[]);
    706: SLEPC_EXTERN PetscErrorCode NEPNLEIGSSetFullBasis(NEP,PetscBool);
    707: SLEPC_EXTERN PetscErrorCode NEPNLEIGSGetFullBasis(NEP,PetscBool*);
    708: SLEPC_EXTERN PetscErrorCode NEPNLEIGSSetEPS(NEP,EPS);
    709: SLEPC_EXTERN PetscErrorCode NEPNLEIGSGetEPS(NEP,EPS*);