#include "slepceps.h" PetscErrorCode EPSSetArbitrarySelection(EPS eps,PetscErrorCode (*func)(PetscScalar er,PetscScalar ei,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx),void* ctx)Logically Collective
eps | - eigensolver context obtained from EPSCreate() | |
func | - a pointer to the evaluation function | |
ctx | - a context pointer (the last parameter to the evaluation function) |
PetscErrorCode func(PetscScalar er,PetscScalar ei,Vec xr,Vec xi,PetscScalar *rr,PetscScalar *ri,void *ctx)
er | - real part of the current eigenvalue approximation | |
ei | - imaginary part of the current eigenvalue approximation | |
xr | - real part of the current eigenvector approximation | |
xi | - imaginary part of the current eigenvector approximation | |
rr | - result of evaluation (real part) | |
ri | - result of evaluation (imaginary part) | |
ctx | - optional context, as set by EPSSetArbitrarySelection() |
For instance, suppose you want to compute those eigenvectors that maximize a certain computable expression. Then implement the computation using the arguments xr and xi, and return the result in rr. Then set the standard sorting by magnitude so that the eigenpair with largest value of rr is selected.
This evaluation function is collective, that is, all processes call it and it can use collective operations; furthermore, the computed result must be the same in all processes.
The result of func is expressed as a complex number so that it is possible to use the standard eigenvalue sorting functions, but normally only rr is used. Set ri to zero unless it is meaningful in your application.