Actual source code: epsimpl.h
1: /*
2: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3: SLEPc - Scalable Library for Eigenvalue Problem Computations
4: Copyright (c) 2002-2012, Universitat Politecnica de Valencia, Spain
6: This file is part of SLEPc.
7:
8: SLEPc is free software: you can redistribute it and/or modify it under the
9: terms of version 3 of the GNU Lesser General Public License as published by
10: the Free Software Foundation.
12: SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
13: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14: FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15: more details.
17: You should have received a copy of the GNU Lesser General Public License
18: along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
19: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
20: */
22: #ifndef _EPSIMPL
23: #define _EPSIMPL
25: #include <slepceps.h>
27: PETSC_EXTERN PetscFList EPSList;
28: PETSC_EXTERN PetscLogEvent EPS_SetUp, EPS_Solve;
30: typedef struct _EPSOps *EPSOps;
32: struct _EPSOps {
33: PetscErrorCode (*solve)(EPS);
34: PetscErrorCode (*setup)(EPS);
35: PetscErrorCode (*setfromoptions)(EPS);
36: PetscErrorCode (*publishoptions)(EPS);
37: PetscErrorCode (*destroy)(EPS);
38: PetscErrorCode (*reset)(EPS);
39: PetscErrorCode (*view)(EPS,PetscViewer);
40: PetscErrorCode (*backtransform)(EPS);
41: PetscErrorCode (*computevectors)(EPS);
42: };
44: /*
45: Maximum number of monitors you can run with a single EPS
46: */
47: #define MAXEPSMONITORS 5
49: /*
50: Defines the EPS data structure.
51: */
52: struct _p_EPS {
53: PETSCHEADER(struct _EPSOps);
54: /*------------------------- User parameters --------------------------*/
55: PetscInt max_it, /* maximum number of iterations */
56: nev, /* number of eigenvalues to compute */
57: ncv, /* number of basis vectors */
58: mpd, /* maximum dimension of projected problem */
59: nini, ninil, /* number of initial vectors (negative means not copied yet) */
60: nds; /* number of basis vectors of deflation space */
61: PetscScalar target; /* target value */
62: PetscReal tol; /* tolerance */
63: EPSConv conv; /* convergence test */
64: PetscErrorCode (*conv_func)(EPS,PetscScalar,PetscScalar,PetscReal,PetscReal*,void*);
65: void *conv_ctx;
66: EPSWhich which; /* which part of the spectrum to be sought */
67: PetscBool leftvecs; /* if left eigenvectors are requested */
68: PetscErrorCode (*which_func)(PetscScalar,PetscScalar,PetscScalar,PetscScalar,PetscInt*,void*);
69: void *which_ctx;
70: PetscErrorCode (*arbit_func)(PetscScalar,PetscScalar,Vec,Vec,PetscScalar*,PetscScalar*,void*);
71: void *arbit_ctx;
72: PetscScalar *rr,*ri; /* values computed by user's arbitrary selection function */
73: PetscReal inta, intb; /* interval [a,b] for spectrum slicing */
74: EPSProblemType problem_type; /* which kind of problem to be solved */
75: EPSExtraction extraction; /* which kind of extraction to be applied */
76: EPSBalance balance; /* the balancing method */
77: PetscInt balance_its; /* number of iterations of the balancing method */
78: PetscReal balance_cutoff; /* cutoff value for balancing */
79: PetscReal nrma, nrmb; /* matrix norms */
80: PetscBool adaptive; /* whether matrix norms are adaptively improved */
81: PetscBool trueres; /* whether the true residual norm must be computed */
82: PetscBool trackall; /* whether all the residuals must be computed */
84: /*------------------------- Working data --------------------------*/
85: Vec D, /* diagonal matrix for balancing */
86: *V, /* set of basis vectors and computed eigenvectors */
87: *W, /* set of left basis vectors and computed left eigenvectors */
88: *IS, *ISL, /* placeholder for references to user-provided initial space */
89: *defl; /* deflation space */
90: PetscScalar *eigr, *eigi; /* real and imaginary parts of eigenvalues */
91: PetscReal *errest, /* error estimates */
92: *errest_left; /* left error estimates */
93: ST OP; /* spectral transformation object */
94: IP ip; /* innerproduct object */
95: DS ds; /* direct solver object */
96: void *data; /* placeholder for misc stuff associated
97: with a particular solver */
98: PetscInt nconv, /* number of converged eigenvalues */
99: its, /* number of iterations so far computed */
100: *perm, /* permutation for eigenvalue ordering */
101: nv, /* size of current Schur decomposition */
102: n, nloc, /* problem dimensions (global, local) */
103: allocated_ncv; /* number of basis vectors allocated */
104: PetscBool evecsavailable; /* computed eigenvectors */
105: PetscRandom rand; /* random number generator */
106: Vec t; /* template vector */
108: /* ---------------- Default work-area and status vars -------------------- */
109: PetscInt nwork;
110: Vec *work;
112: PetscBool ds_ortho; /* if defl vectors have been stored & orthonormalized */
113: PetscInt setupcalled;
114: PetscBool isgeneralized,
115: ispositive,
116: ishermitian;
117: EPSConvergedReason reason;
119: PetscErrorCode (*monitor[MAXEPSMONITORS])(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
120: PetscErrorCode (*monitordestroy[MAXEPSMONITORS])(void**);
121: void *monitorcontext[MAXEPSMONITORS];
122: PetscInt numbermonitors;
123: };
125: PETSC_EXTERN PetscErrorCode EPSMonitor(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt);
127: PETSC_EXTERN PetscErrorCode EPSReset_Default(EPS);
128: PETSC_EXTERN PetscErrorCode EPSDefaultGetWork(EPS,PetscInt);
129: PETSC_EXTERN PetscErrorCode EPSDefaultFreeWork(EPS);
130: PETSC_EXTERN PetscErrorCode EPSDefaultSetWhich(EPS);
131: PETSC_EXTERN PetscErrorCode EPSAllocateSolution(EPS);
132: PETSC_EXTERN PetscErrorCode EPSFreeSolution(EPS);
133: PETSC_EXTERN PetscErrorCode EPSBackTransform_Default(EPS);
134: PETSC_EXTERN PetscErrorCode EPSComputeVectors_Default(EPS);
135: PETSC_EXTERN PetscErrorCode EPSComputeVectors_Hermitian(EPS);
136: PETSC_EXTERN PetscErrorCode EPSComputeVectors_Schur(EPS);
137: PETSC_EXTERN PetscErrorCode EPSComputeResidualNorm_Private(EPS,PetscScalar,PetscScalar,Vec,Vec,PetscReal*);
138: PETSC_EXTERN PetscErrorCode EPSComputeRelativeError_Private(EPS,PetscScalar,PetscScalar,Vec,Vec,PetscReal*);
139: PETSC_EXTERN PetscErrorCode EPSComputeRitzVector(EPS,PetscScalar*,PetscScalar*,Vec*,PetscInt,Vec,Vec);
141: /* Private functions of the solver implementations */
143: PETSC_EXTERN PetscErrorCode EPSBasicArnoldi(EPS,PetscBool,PetscScalar*,PetscInt,Vec*,PetscInt,PetscInt*,Vec,PetscReal*,PetscBool*);
144: PETSC_EXTERN PetscErrorCode EPSDelayedArnoldi(EPS,PetscScalar*,PetscInt,Vec*,PetscInt,PetscInt*,Vec,PetscReal*,PetscBool*);
145: PETSC_EXTERN PetscErrorCode EPSDelayedArnoldi1(EPS,PetscScalar*,PetscInt,Vec*,PetscInt,PetscInt*,Vec,PetscReal*,PetscBool*);
146: PETSC_EXTERN PetscErrorCode EPSKrylovConvergence(EPS,PetscBool,PetscInt,PetscInt,Vec*,PetscInt,PetscReal,PetscReal,PetscInt*);
147: PETSC_EXTERN PetscErrorCode EPSFullLanczos(EPS,PetscReal*,PetscReal*,Vec*,PetscInt,PetscInt*,Vec,PetscBool*);
148: PETSC_EXTERN PetscErrorCode EPSBuildBalance_Krylov(EPS);
150: #endif