Line data Source code
1 : /*
2 : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3 : SLEPc - Scalable Library for Eigenvalue Problem Computations
4 : Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
5 :
6 : This file is part of SLEPc.
7 : SLEPc is distributed under a 2-clause BSD license (see LICENSE).
8 : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9 : */
10 : /*
11 : EPS routines related to options that can be set via the command-line
12 : or procedurally.
13 : */
14 :
15 : #include <slepc/private/epsimpl.h> /*I "slepceps.h" I*/
16 : #include <petscdraw.h>
17 :
18 : /*@C
19 : EPSMonitorSetFromOptions - Sets a monitor function and viewer appropriate for the type
20 : indicated by the user.
21 :
22 : Collective
23 :
24 : Input Parameters:
25 : + eps - the eigensolver context
26 : . opt - the command line option for this monitor
27 : . name - the monitor type one is seeking
28 : . ctx - an optional user context for the monitor, or NULL
29 : - trackall - whether this monitor tracks all eigenvalues or not
30 :
31 : Level: developer
32 :
33 : .seealso: EPSMonitorSet(), EPSSetTrackAll()
34 : @*/
35 1767 : PetscErrorCode EPSMonitorSetFromOptions(EPS eps,const char opt[],const char name[],void *ctx,PetscBool trackall)
36 : {
37 1767 : PetscErrorCode (*mfunc)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,void*);
38 1767 : PetscErrorCode (*cfunc)(PetscViewer,PetscViewerFormat,void*,PetscViewerAndFormat**);
39 1767 : PetscErrorCode (*dfunc)(PetscViewerAndFormat**);
40 1767 : PetscViewerAndFormat *vf;
41 1767 : PetscViewer viewer;
42 1767 : PetscViewerFormat format;
43 1767 : PetscViewerType vtype;
44 1767 : char key[PETSC_MAX_PATH_LEN];
45 1767 : PetscBool flg;
46 :
47 1767 : PetscFunctionBegin;
48 1767 : PetscCall(PetscOptionsCreateViewer(PetscObjectComm((PetscObject)eps),((PetscObject)eps)->options,((PetscObject)eps)->prefix,opt,&viewer,&format,&flg));
49 1767 : if (!flg) PetscFunctionReturn(PETSC_SUCCESS);
50 :
51 5 : PetscCall(PetscViewerGetType(viewer,&vtype));
52 5 : PetscCall(SlepcMonitorMakeKey_Internal(name,vtype,format,key));
53 5 : PetscCall(PetscFunctionListFind(EPSMonitorList,key,&mfunc));
54 5 : PetscCheck(mfunc,PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"Specified viewer and format not supported");
55 5 : PetscCall(PetscFunctionListFind(EPSMonitorCreateList,key,&cfunc));
56 5 : PetscCall(PetscFunctionListFind(EPSMonitorDestroyList,key,&dfunc));
57 5 : if (!cfunc) cfunc = PetscViewerAndFormatCreate_Internal;
58 5 : if (!dfunc) dfunc = PetscViewerAndFormatDestroy;
59 :
60 5 : PetscCall((*cfunc)(viewer,format,ctx,&vf));
61 5 : PetscCall(PetscViewerDestroy(&viewer));
62 5 : PetscCall(EPSMonitorSet(eps,mfunc,vf,(PetscCtxDestroyFn*)dfunc));
63 5 : if (trackall) PetscCall(EPSSetTrackAll(eps,PETSC_TRUE));
64 5 : PetscFunctionReturn(PETSC_SUCCESS);
65 : }
66 :
67 : /*@
68 : EPSSetFromOptions - Sets EPS options from the options database.
69 : This routine must be called before EPSSetUp() if the user is to be
70 : allowed to set the solver type.
71 :
72 : Collective
73 :
74 : Input Parameters:
75 : . eps - the eigensolver context
76 :
77 : Notes:
78 : To see all options, run your program with the -help option.
79 :
80 : Level: beginner
81 :
82 : .seealso: EPSSetOptionsPrefix()
83 : @*/
84 589 : PetscErrorCode EPSSetFromOptions(EPS eps)
85 : {
86 589 : char type[256];
87 589 : PetscBool set,flg,flg1,flg2,flg3,bval;
88 589 : PetscReal r,array[2]={0,0};
89 589 : PetscScalar s;
90 589 : PetscInt i,j,k;
91 589 : EPSBalance bal;
92 :
93 589 : PetscFunctionBegin;
94 589 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
95 589 : PetscCall(EPSRegisterAll());
96 1767 : PetscObjectOptionsBegin((PetscObject)eps);
97 650 : PetscCall(PetscOptionsFList("-eps_type","Eigensolver method","EPSSetType",EPSList,(char*)(((PetscObject)eps)->type_name?((PetscObject)eps)->type_name:EPSKRYLOVSCHUR),type,sizeof(type),&flg));
98 589 : if (flg) PetscCall(EPSSetType(eps,type));
99 337 : else if (!((PetscObject)eps)->type_name) PetscCall(EPSSetType(eps,EPSKRYLOVSCHUR));
100 :
101 589 : PetscCall(PetscOptionsBoolGroupBegin("-eps_hermitian","Hermitian eigenvalue problem","EPSSetProblemType",&flg));
102 589 : if (flg) PetscCall(EPSSetProblemType(eps,EPS_HEP));
103 589 : PetscCall(PetscOptionsBoolGroup("-eps_gen_hermitian","Generalized Hermitian eigenvalue problem","EPSSetProblemType",&flg));
104 589 : if (flg) PetscCall(EPSSetProblemType(eps,EPS_GHEP));
105 589 : PetscCall(PetscOptionsBoolGroup("-eps_non_hermitian","Non-Hermitian eigenvalue problem","EPSSetProblemType",&flg));
106 589 : if (flg) PetscCall(EPSSetProblemType(eps,EPS_NHEP));
107 589 : PetscCall(PetscOptionsBoolGroup("-eps_gen_non_hermitian","Generalized non-Hermitian eigenvalue problem","EPSSetProblemType",&flg));
108 589 : if (flg) PetscCall(EPSSetProblemType(eps,EPS_GNHEP));
109 589 : PetscCall(PetscOptionsBoolGroup("-eps_pos_gen_non_hermitian","Generalized non-Hermitian eigenvalue problem with positive semi-definite B","EPSSetProblemType",&flg));
110 589 : if (flg) PetscCall(EPSSetProblemType(eps,EPS_PGNHEP));
111 589 : PetscCall(PetscOptionsBoolGroup("-eps_gen_indefinite","Generalized Hermitian-indefinite eigenvalue problem","EPSSetProblemType",&flg));
112 589 : if (flg) PetscCall(EPSSetProblemType(eps,EPS_GHIEP));
113 589 : PetscCall(PetscOptionsBoolGroupEnd("-eps_bse","Structured Bethe-Salpeter eigenvalue problem","EPSSetProblemType",&flg));
114 589 : if (flg) PetscCall(EPSSetProblemType(eps,EPS_BSE));
115 :
116 589 : PetscCall(PetscOptionsBoolGroupBegin("-eps_ritz","Rayleigh-Ritz extraction","EPSSetExtraction",&flg));
117 589 : if (flg) PetscCall(EPSSetExtraction(eps,EPS_RITZ));
118 589 : PetscCall(PetscOptionsBoolGroup("-eps_harmonic","Harmonic Ritz extraction","EPSSetExtraction",&flg));
119 589 : if (flg) PetscCall(EPSSetExtraction(eps,EPS_HARMONIC));
120 589 : PetscCall(PetscOptionsBoolGroup("-eps_harmonic_relative","Relative harmonic Ritz extraction","EPSSetExtraction",&flg));
121 589 : if (flg) PetscCall(EPSSetExtraction(eps,EPS_HARMONIC_RELATIVE));
122 589 : PetscCall(PetscOptionsBoolGroup("-eps_harmonic_right","Right harmonic Ritz extraction","EPSSetExtraction",&flg));
123 589 : if (flg) PetscCall(EPSSetExtraction(eps,EPS_HARMONIC_RIGHT));
124 589 : PetscCall(PetscOptionsBoolGroup("-eps_harmonic_largest","Largest harmonic Ritz extraction","EPSSetExtraction",&flg));
125 589 : if (flg) PetscCall(EPSSetExtraction(eps,EPS_HARMONIC_LARGEST));
126 589 : PetscCall(PetscOptionsBoolGroup("-eps_refined","Refined Ritz extraction","EPSSetExtraction",&flg));
127 589 : if (flg) PetscCall(EPSSetExtraction(eps,EPS_REFINED));
128 589 : PetscCall(PetscOptionsBoolGroupEnd("-eps_refined_harmonic","Refined harmonic Ritz extraction","EPSSetExtraction",&flg));
129 589 : if (flg) PetscCall(EPSSetExtraction(eps,EPS_REFINED_HARMONIC));
130 :
131 589 : bal = eps->balance;
132 589 : PetscCall(PetscOptionsEnum("-eps_balance","Balancing method","EPSSetBalance",EPSBalanceTypes,(PetscEnum)bal,(PetscEnum*)&bal,&flg1));
133 589 : j = eps->balance_its;
134 589 : PetscCall(PetscOptionsInt("-eps_balance_its","Number of iterations in balancing","EPSSetBalance",eps->balance_its,&j,&flg2));
135 589 : r = eps->balance_cutoff;
136 589 : PetscCall(PetscOptionsReal("-eps_balance_cutoff","Cutoff value in balancing","EPSSetBalance",eps->balance_cutoff,&r,&flg3));
137 589 : if (flg1 || flg2 || flg3) PetscCall(EPSSetBalance(eps,bal,j,r));
138 :
139 589 : i = eps->max_it;
140 589 : PetscCall(PetscOptionsInt("-eps_max_it","Maximum number of iterations","EPSSetTolerances",eps->max_it,&i,&flg1));
141 589 : r = eps->tol;
142 974 : PetscCall(PetscOptionsReal("-eps_tol","Tolerance","EPSSetTolerances",SlepcDefaultTol(eps->tol),&r,&flg2));
143 589 : if (flg1 || flg2) PetscCall(EPSSetTolerances(eps,r,i));
144 :
145 589 : PetscCall(PetscOptionsBoolGroupBegin("-eps_conv_rel","Relative error convergence test","EPSSetConvergenceTest",&flg));
146 589 : if (flg) PetscCall(EPSSetConvergenceTest(eps,EPS_CONV_REL));
147 589 : PetscCall(PetscOptionsBoolGroup("-eps_conv_norm","Convergence test relative to the eigenvalue and the matrix norms","EPSSetConvergenceTest",&flg));
148 589 : if (flg) PetscCall(EPSSetConvergenceTest(eps,EPS_CONV_NORM));
149 589 : PetscCall(PetscOptionsBoolGroup("-eps_conv_abs","Absolute error convergence test","EPSSetConvergenceTest",&flg));
150 589 : if (flg) PetscCall(EPSSetConvergenceTest(eps,EPS_CONV_ABS));
151 589 : PetscCall(PetscOptionsBoolGroupEnd("-eps_conv_user","User-defined convergence test","EPSSetConvergenceTest",&flg));
152 589 : if (flg) PetscCall(EPSSetConvergenceTest(eps,EPS_CONV_USER));
153 :
154 589 : PetscCall(PetscOptionsBoolGroupBegin("-eps_stop_basic","Stop iteration if all eigenvalues converged or max_it reached","EPSSetStoppingTest",&flg));
155 589 : if (flg) PetscCall(EPSSetStoppingTest(eps,EPS_STOP_BASIC));
156 589 : PetscCall(PetscOptionsBoolGroupEnd("-eps_stop_user","User-defined stopping test","EPSSetStoppingTest",&flg));
157 589 : if (flg) PetscCall(EPSSetStoppingTest(eps,EPS_STOP_USER));
158 :
159 589 : i = eps->nev;
160 589 : PetscCall(PetscOptionsInt("-eps_nev","Number of eigenvalues to compute","EPSSetDimensions",eps->nev,&i,&flg1));
161 589 : j = eps->ncv;
162 589 : PetscCall(PetscOptionsInt("-eps_ncv","Number of basis vectors","EPSSetDimensions",eps->ncv,&j,&flg2));
163 589 : k = eps->mpd;
164 589 : PetscCall(PetscOptionsInt("-eps_mpd","Maximum dimension of projected problem","EPSSetDimensions",eps->mpd,&k,&flg3));
165 589 : if (flg1 || flg2 || flg3) PetscCall(EPSSetDimensions(eps,i,j,k));
166 :
167 589 : PetscCall(PetscOptionsBoolGroupBegin("-eps_largest_magnitude","Compute largest eigenvalues in magnitude","EPSSetWhichEigenpairs",&flg));
168 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_LARGEST_MAGNITUDE));
169 589 : PetscCall(PetscOptionsBoolGroup("-eps_smallest_magnitude","Compute smallest eigenvalues in magnitude","EPSSetWhichEigenpairs",&flg));
170 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_SMALLEST_MAGNITUDE));
171 589 : PetscCall(PetscOptionsBoolGroup("-eps_largest_real","Compute eigenvalues with largest real parts","EPSSetWhichEigenpairs",&flg));
172 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_LARGEST_REAL));
173 589 : PetscCall(PetscOptionsBoolGroup("-eps_smallest_real","Compute eigenvalues with smallest real parts","EPSSetWhichEigenpairs",&flg));
174 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL));
175 589 : PetscCall(PetscOptionsBoolGroup("-eps_largest_imaginary","Compute eigenvalues with largest imaginary parts","EPSSetWhichEigenpairs",&flg));
176 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_LARGEST_IMAGINARY));
177 589 : PetscCall(PetscOptionsBoolGroup("-eps_smallest_imaginary","Compute eigenvalues with smallest imaginary parts","EPSSetWhichEigenpairs",&flg));
178 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_SMALLEST_IMAGINARY));
179 589 : PetscCall(PetscOptionsBoolGroup("-eps_target_magnitude","Compute eigenvalues closest to target","EPSSetWhichEigenpairs",&flg));
180 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE));
181 589 : PetscCall(PetscOptionsBoolGroup("-eps_target_real","Compute eigenvalues with real parts closest to target","EPSSetWhichEigenpairs",&flg));
182 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_TARGET_REAL));
183 589 : PetscCall(PetscOptionsBoolGroup("-eps_target_imaginary","Compute eigenvalues with imaginary parts closest to target","EPSSetWhichEigenpairs",&flg));
184 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_TARGET_IMAGINARY));
185 589 : PetscCall(PetscOptionsBoolGroupEnd("-eps_all","Compute all eigenvalues in an interval or a region","EPSSetWhichEigenpairs",&flg));
186 589 : if (flg) PetscCall(EPSSetWhichEigenpairs(eps,EPS_ALL));
187 :
188 589 : PetscCall(PetscOptionsScalar("-eps_target","Value of the target","EPSSetTarget",eps->target,&s,&flg));
189 589 : if (flg) {
190 38 : if (eps->which!=EPS_TARGET_REAL && eps->which!=EPS_TARGET_IMAGINARY) PetscCall(EPSSetWhichEigenpairs(eps,EPS_TARGET_MAGNITUDE));
191 38 : PetscCall(EPSSetTarget(eps,s));
192 : }
193 :
194 589 : k = 2;
195 589 : PetscCall(PetscOptionsRealArray("-eps_interval","Computational interval (two real values separated with a comma without spaces)","EPSSetInterval",array,&k,&flg));
196 589 : if (flg) {
197 19 : PetscCheck(k>1,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_SIZ,"Must pass two values in -eps_interval (comma-separated without spaces)");
198 19 : PetscCall(EPSSetWhichEigenpairs(eps,EPS_ALL));
199 19 : PetscCall(EPSSetInterval(eps,array[0],array[1]));
200 : }
201 :
202 589 : PetscCall(PetscOptionsBool("-eps_true_residual","Compute true residuals explicitly","EPSSetTrueResidual",eps->trueres,&eps->trueres,NULL));
203 589 : PetscCall(PetscOptionsBool("-eps_purify","Postprocess eigenvectors for purification","EPSSetPurify",eps->purify,&bval,&flg));
204 589 : if (flg) PetscCall(EPSSetPurify(eps,bval));
205 589 : PetscCall(PetscOptionsBool("-eps_two_sided","Use two-sided variant (to compute left eigenvectors)","EPSSetTwoSided",eps->twosided,&bval,&flg));
206 589 : if (flg) PetscCall(EPSSetTwoSided(eps,bval));
207 :
208 : /* -----------------------------------------------------------------------*/
209 : /*
210 : Cancels all monitors hardwired into code before call to EPSSetFromOptions()
211 : */
212 589 : PetscCall(PetscOptionsBool("-eps_monitor_cancel","Remove any hardwired monitor routines","EPSMonitorCancel",PETSC_FALSE,&flg,&set));
213 589 : if (set && flg) PetscCall(EPSMonitorCancel(eps));
214 589 : PetscCall(EPSMonitorSetFromOptions(eps,"-eps_monitor","first_approximation",NULL,PETSC_FALSE));
215 589 : PetscCall(EPSMonitorSetFromOptions(eps,"-eps_monitor_all","all_approximations",NULL,PETSC_TRUE));
216 589 : PetscCall(EPSMonitorSetFromOptions(eps,"-eps_monitor_conv","convergence_history",NULL,PETSC_FALSE));
217 :
218 : /* -----------------------------------------------------------------------*/
219 589 : PetscCall(PetscOptionsName("-eps_view","Print detailed information on solver used","EPSView",&set));
220 589 : PetscCall(PetscOptionsName("-eps_view_vectors","View computed eigenvectors","EPSVectorsView",&set));
221 589 : PetscCall(PetscOptionsName("-eps_view_values","View computed eigenvalues","EPSValuesView",&set));
222 589 : PetscCall(PetscOptionsName("-eps_converged_reason","Print reason for convergence, and number of iterations","EPSConvergedReasonView",&set));
223 589 : PetscCall(PetscOptionsName("-eps_error_absolute","Print absolute errors of each eigenpair","EPSErrorView",&set));
224 589 : PetscCall(PetscOptionsName("-eps_error_relative","Print relative errors of each eigenpair","EPSErrorView",&set));
225 589 : PetscCall(PetscOptionsName("-eps_error_backward","Print backward errors of each eigenpair","EPSErrorView",&set));
226 :
227 589 : PetscTryTypeMethod(eps,setfromoptions,PetscOptionsObject);
228 589 : PetscCall(PetscObjectProcessOptionsHandlers((PetscObject)eps,PetscOptionsObject));
229 589 : PetscOptionsEnd();
230 :
231 589 : if (!eps->V) PetscCall(EPSGetBV(eps,&eps->V));
232 589 : PetscCall(BVSetFromOptions(eps->V));
233 589 : if (!eps->rg) PetscCall(EPSGetRG(eps,&eps->rg));
234 589 : PetscCall(RGSetFromOptions(eps->rg));
235 589 : if (eps->useds) {
236 523 : if (!eps->ds) PetscCall(EPSGetDS(eps,&eps->ds));
237 523 : PetscCall(EPSSetDSType(eps));
238 523 : PetscCall(DSSetFromOptions(eps->ds));
239 : }
240 589 : if (!eps->st) PetscCall(EPSGetST(eps,&eps->st));
241 589 : PetscCall(EPSSetDefaultST(eps));
242 589 : PetscCall(STSetFromOptions(eps->st));
243 589 : PetscFunctionReturn(PETSC_SUCCESS);
244 : }
245 :
246 : /*@
247 : EPSGetTolerances - Gets the tolerance and maximum iteration count used
248 : by the EPS convergence tests.
249 :
250 : Not Collective
251 :
252 : Input Parameter:
253 : . eps - the eigensolver context
254 :
255 : Output Parameters:
256 : + tol - the convergence tolerance
257 : - maxits - maximum number of iterations
258 :
259 : Notes:
260 : The user can specify NULL for any parameter that is not needed.
261 :
262 : Level: intermediate
263 :
264 : .seealso: EPSSetTolerances()
265 : @*/
266 268 : PetscErrorCode EPSGetTolerances(EPS eps,PetscReal *tol,PetscInt *maxits)
267 : {
268 268 : PetscFunctionBegin;
269 268 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
270 268 : if (tol) *tol = eps->tol;
271 268 : if (maxits) *maxits = eps->max_it;
272 268 : PetscFunctionReturn(PETSC_SUCCESS);
273 : }
274 :
275 : /*@
276 : EPSSetTolerances - Sets the tolerance and maximum iteration count used
277 : by the EPS convergence tests.
278 :
279 : Logically Collective
280 :
281 : Input Parameters:
282 : + eps - the eigensolver context
283 : . tol - the convergence tolerance
284 : - maxits - maximum number of iterations to use
285 :
286 : Options Database Keys:
287 : + -eps_tol <tol> - Sets the convergence tolerance
288 : - -eps_max_it <maxits> - Sets the maximum number of iterations allowed
289 :
290 : Notes:
291 : Use PETSC_CURRENT to retain the current value of any of the parameters.
292 : Use PETSC_DETERMINE for either argument to assign a default value computed
293 : internally (may be different in each solver).
294 : For maxits use PETSC_UMLIMITED to indicate there is no upper bound on this value.
295 :
296 : Level: intermediate
297 :
298 : .seealso: EPSGetTolerances()
299 : @*/
300 532 : PetscErrorCode EPSSetTolerances(EPS eps,PetscReal tol,PetscInt maxits)
301 : {
302 532 : PetscFunctionBegin;
303 532 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
304 1596 : PetscValidLogicalCollectiveReal(eps,tol,2);
305 1596 : PetscValidLogicalCollectiveInt(eps,maxits,3);
306 532 : if (tol == (PetscReal)PETSC_DETERMINE) {
307 11 : eps->tol = PETSC_DETERMINE;
308 11 : eps->state = EPS_STATE_INITIAL;
309 521 : } else if (tol != (PetscReal)PETSC_CURRENT) {
310 521 : PetscCheck(tol>0.0,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
311 521 : eps->tol = tol;
312 : }
313 532 : if (maxits == PETSC_DETERMINE) {
314 131 : eps->max_it = PETSC_DETERMINE;
315 131 : eps->state = EPS_STATE_INITIAL;
316 401 : } else if (maxits == PETSC_UNLIMITED) {
317 0 : eps->max_it = PETSC_INT_MAX;
318 401 : } else if (maxits != PETSC_CURRENT) {
319 197 : PetscCheck(maxits>0,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
320 197 : eps->max_it = maxits;
321 : }
322 532 : PetscFunctionReturn(PETSC_SUCCESS);
323 : }
324 :
325 : /*@
326 : EPSGetDimensions - Gets the number of eigenvalues to compute
327 : and the dimension of the subspace.
328 :
329 : Not Collective
330 :
331 : Input Parameter:
332 : . eps - the eigensolver context
333 :
334 : Output Parameters:
335 : + nev - number of eigenvalues to compute
336 : . ncv - the maximum dimension of the subspace to be used by the solver
337 : - mpd - the maximum dimension allowed for the projected problem
338 :
339 : Level: intermediate
340 :
341 : .seealso: EPSSetDimensions()
342 : @*/
343 400 : PetscErrorCode EPSGetDimensions(EPS eps,PetscInt *nev,PetscInt *ncv,PetscInt *mpd)
344 : {
345 400 : PetscFunctionBegin;
346 400 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
347 400 : if (nev) *nev = eps->nev;
348 400 : if (ncv) *ncv = eps->ncv;
349 400 : if (mpd) *mpd = eps->mpd;
350 400 : PetscFunctionReturn(PETSC_SUCCESS);
351 : }
352 :
353 : /*@
354 : EPSSetDimensions - Sets the number of eigenvalues to compute
355 : and the dimension of the subspace.
356 :
357 : Logically Collective
358 :
359 : Input Parameters:
360 : + eps - the eigensolver context
361 : . nev - number of eigenvalues to compute
362 : . ncv - the maximum dimension of the subspace to be used by the solver
363 : - mpd - the maximum dimension allowed for the projected problem
364 :
365 : Options Database Keys:
366 : + -eps_nev <nev> - Sets the number of eigenvalues
367 : . -eps_ncv <ncv> - Sets the dimension of the subspace
368 : - -eps_mpd <mpd> - Sets the maximum projected dimension
369 :
370 : Notes:
371 : Use PETSC_DETERMINE for ncv and mpd to assign a reasonably good value, which is
372 : dependent on the solution method. For any of the arguments, use PETSC_CURRENT
373 : to preserve the current value.
374 :
375 : The parameters ncv and mpd are intimately related, so that the user is advised
376 : to set one of them at most. Normal usage is that
377 : (a) in cases where nev is small, the user sets ncv (a reasonable default is 2*nev); and
378 : (b) in cases where nev is large, the user sets mpd.
379 :
380 : The value of ncv should always be between nev and (nev+mpd), typically
381 : ncv=nev+mpd. If nev is not too large, mpd=nev is a reasonable choice, otherwise
382 : a smaller value should be used.
383 :
384 : When computing all eigenvalues in an interval, see EPSSetInterval(), these
385 : parameters lose relevance, and tuning must be done with
386 : EPSKrylovSchurSetDimensions().
387 :
388 : Level: intermediate
389 :
390 : .seealso: EPSGetDimensions(), EPSSetInterval(), EPSKrylovSchurSetDimensions()
391 : @*/
392 561 : PetscErrorCode EPSSetDimensions(EPS eps,PetscInt nev,PetscInt ncv,PetscInt mpd)
393 : {
394 561 : PetscFunctionBegin;
395 561 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
396 1683 : PetscValidLogicalCollectiveInt(eps,nev,2);
397 1683 : PetscValidLogicalCollectiveInt(eps,ncv,3);
398 1683 : PetscValidLogicalCollectiveInt(eps,mpd,4);
399 561 : if (nev != PETSC_CURRENT) {
400 561 : PetscCheck(nev>0,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0");
401 561 : eps->nev = nev;
402 : }
403 561 : if (ncv == PETSC_DETERMINE) {
404 383 : eps->ncv = PETSC_DETERMINE;
405 178 : } else if (ncv != PETSC_CURRENT) {
406 175 : PetscCheck(ncv>0,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
407 175 : eps->ncv = ncv;
408 : }
409 561 : if (mpd == PETSC_DETERMINE) {
410 507 : eps->mpd = PETSC_DETERMINE;
411 54 : } else if (mpd != PETSC_CURRENT) {
412 51 : PetscCheck(mpd>0,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of mpd. Must be > 0");
413 51 : eps->mpd = mpd;
414 : }
415 561 : eps->state = EPS_STATE_INITIAL;
416 561 : PetscFunctionReturn(PETSC_SUCCESS);
417 : }
418 :
419 : /*@
420 : EPSSetWhichEigenpairs - Specifies which portion of the spectrum is
421 : to be sought.
422 :
423 : Logically Collective
424 :
425 : Input Parameters:
426 : + eps - eigensolver context obtained from EPSCreate()
427 : - which - the portion of the spectrum to be sought
428 :
429 : Options Database Keys:
430 : + -eps_largest_magnitude - Sets largest eigenvalues in magnitude
431 : . -eps_smallest_magnitude - Sets smallest eigenvalues in magnitude
432 : . -eps_largest_real - Sets largest real parts
433 : . -eps_smallest_real - Sets smallest real parts
434 : . -eps_largest_imaginary - Sets largest imaginary parts
435 : . -eps_smallest_imaginary - Sets smallest imaginary parts
436 : . -eps_target_magnitude - Sets eigenvalues closest to target
437 : . -eps_target_real - Sets real parts closest to target
438 : . -eps_target_imaginary - Sets imaginary parts closest to target
439 : - -eps_all - Sets all eigenvalues in an interval or region
440 :
441 : Notes:
442 : The parameter 'which' can have one of these values
443 :
444 : + EPS_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default)
445 : . EPS_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude
446 : . EPS_LARGEST_REAL - largest real parts
447 : . EPS_SMALLEST_REAL - smallest real parts
448 : . EPS_LARGEST_IMAGINARY - largest imaginary parts
449 : . EPS_SMALLEST_IMAGINARY - smallest imaginary parts
450 : . EPS_TARGET_MAGNITUDE - eigenvalues closest to the target (in magnitude)
451 : . EPS_TARGET_REAL - eigenvalues with real part closest to target
452 : . EPS_TARGET_IMAGINARY - eigenvalues with imaginary part closest to target
453 : . EPS_ALL - all eigenvalues contained in a given interval or region
454 : - EPS_WHICH_USER - user defined ordering set with EPSSetEigenvalueComparison()
455 :
456 : Not all eigensolvers implemented in EPS account for all the possible values
457 : stated above. Also, some values make sense only for certain types of
458 : problems. If SLEPc is compiled for real numbers EPS_LARGEST_IMAGINARY
459 : and EPS_SMALLEST_IMAGINARY use the absolute value of the imaginary part
460 : for eigenvalue selection.
461 :
462 : The target is a scalar value provided with EPSSetTarget().
463 :
464 : The criterion EPS_TARGET_IMAGINARY is available only in case PETSc and
465 : SLEPc have been built with complex scalars.
466 :
467 : EPS_ALL is intended for use in combination with an interval (see
468 : EPSSetInterval()), when all eigenvalues within the interval are requested,
469 : or in the context of the CISS solver for computing all eigenvalues in a region.
470 : In those cases, the number of eigenvalues is unknown, so the nev parameter
471 : has a different sense, see EPSSetDimensions().
472 :
473 : Level: intermediate
474 :
475 : .seealso: EPSGetWhichEigenpairs(), EPSSetTarget(), EPSSetInterval(),
476 : EPSSetDimensions(), EPSSetEigenvalueComparison(), EPSWhich
477 : @*/
478 630 : PetscErrorCode EPSSetWhichEigenpairs(EPS eps,EPSWhich which)
479 : {
480 630 : PetscFunctionBegin;
481 630 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
482 3150 : PetscValidLogicalCollectiveEnum(eps,which,2);
483 630 : switch (which) {
484 630 : case EPS_LARGEST_MAGNITUDE:
485 : case EPS_SMALLEST_MAGNITUDE:
486 : case EPS_LARGEST_REAL:
487 : case EPS_SMALLEST_REAL:
488 : case EPS_LARGEST_IMAGINARY:
489 : case EPS_SMALLEST_IMAGINARY:
490 : case EPS_TARGET_MAGNITUDE:
491 : case EPS_TARGET_REAL:
492 : #if defined(PETSC_USE_COMPLEX)
493 : case EPS_TARGET_IMAGINARY:
494 : #endif
495 : case EPS_ALL:
496 : case EPS_WHICH_USER:
497 630 : if (eps->which != which) {
498 549 : eps->state = EPS_STATE_INITIAL;
499 549 : eps->which = which;
500 : }
501 630 : break;
502 : #if !defined(PETSC_USE_COMPLEX)
503 0 : case EPS_TARGET_IMAGINARY:
504 0 : SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_SUP,"EPS_TARGET_IMAGINARY can be used only with complex scalars");
505 : #endif
506 0 : default:
507 0 : SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value");
508 : }
509 630 : PetscFunctionReturn(PETSC_SUCCESS);
510 : }
511 :
512 : /*@
513 : EPSGetWhichEigenpairs - Returns which portion of the spectrum is to be
514 : sought.
515 :
516 : Not Collective
517 :
518 : Input Parameter:
519 : . eps - eigensolver context obtained from EPSCreate()
520 :
521 : Output Parameter:
522 : . which - the portion of the spectrum to be sought
523 :
524 : Notes:
525 : See EPSSetWhichEigenpairs() for possible values of 'which'.
526 :
527 : Level: intermediate
528 :
529 : .seealso: EPSSetWhichEigenpairs(), EPSWhich
530 : @*/
531 1 : PetscErrorCode EPSGetWhichEigenpairs(EPS eps,EPSWhich *which)
532 : {
533 1 : PetscFunctionBegin;
534 1 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
535 1 : PetscAssertPointer(which,2);
536 1 : *which = eps->which;
537 1 : PetscFunctionReturn(PETSC_SUCCESS);
538 : }
539 :
540 : /*@C
541 : EPSSetEigenvalueComparison - Specifies the eigenvalue comparison function
542 : when EPSSetWhichEigenpairs() is set to EPS_WHICH_USER.
543 :
544 : Logically Collective
545 :
546 : Input Parameters:
547 : + eps - eigensolver context obtained from EPSCreate()
548 : . func - the comparison function, see EPSEigenvalueComparisonFn for the calling sequence
549 : - ctx - a context pointer (the last parameter to the comparison function)
550 :
551 : Note:
552 : The returning parameter 'res' can be
553 : + negative - if the 1st eigenvalue is preferred to the 2st one
554 : . zero - if both eigenvalues are equally preferred
555 : - positive - if the 2st eigenvalue is preferred to the 1st one
556 :
557 : Level: advanced
558 :
559 : .seealso: EPSSetWhichEigenpairs(), EPSWhich
560 : @*/
561 36 : PetscErrorCode EPSSetEigenvalueComparison(EPS eps,SlepcEigenvalueComparisonFn *func,void* ctx)
562 : {
563 36 : PetscFunctionBegin;
564 36 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
565 36 : eps->sc->comparison = func;
566 36 : eps->sc->comparisonctx = ctx;
567 36 : eps->which = EPS_WHICH_USER;
568 36 : PetscFunctionReturn(PETSC_SUCCESS);
569 : }
570 :
571 : /*@C
572 : EPSSetArbitrarySelection - Specifies a function intended to look for
573 : eigenvalues according to an arbitrary selection criterion. This criterion
574 : can be based on a computation involving the current eigenvector approximation.
575 :
576 : Logically Collective
577 :
578 : Input Parameters:
579 : + eps - eigensolver context obtained from EPSCreate()
580 : . func - the arbitrary selection function, see SlepcArbitrarySelectionFn for a calling sequence
581 : - ctx - a context pointer (the last parameter to the arbitrary selection function)
582 :
583 : Notes:
584 : This provides a mechanism to select eigenpairs by evaluating a user-defined
585 : function. When a function has been provided, the default selection based on
586 : sorting the eigenvalues is replaced by the sorting of the results of this
587 : function (with the same sorting criterion given in EPSSetWhichEigenpairs()).
588 :
589 : For instance, suppose you want to compute those eigenvectors that maximize
590 : a certain computable expression. Then implement the computation using
591 : the arguments xr and xi, and return the result in rr. Then set the standard
592 : sorting by magnitude so that the eigenpair with largest value of rr is
593 : selected.
594 :
595 : This evaluation function is collective, that is, all processes call it and
596 : it can use collective operations; furthermore, the computed result must
597 : be the same in all processes.
598 :
599 : The result of func is expressed as a complex number so that it is possible to
600 : use the standard eigenvalue sorting functions, but normally only rr is used.
601 : Set ri to zero unless it is meaningful in your application.
602 :
603 : Level: advanced
604 :
605 : .seealso: EPSSetWhichEigenpairs()
606 : @*/
607 8 : PetscErrorCode EPSSetArbitrarySelection(EPS eps,SlepcArbitrarySelectionFn *func,void* ctx)
608 : {
609 8 : PetscFunctionBegin;
610 8 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
611 8 : eps->arbitrary = func;
612 8 : eps->arbitraryctx = ctx;
613 8 : eps->state = EPS_STATE_INITIAL;
614 8 : PetscFunctionReturn(PETSC_SUCCESS);
615 : }
616 :
617 : /*@C
618 : EPSSetConvergenceTestFunction - Sets a function to compute the error estimate
619 : used in the convergence test.
620 :
621 : Logically Collective
622 :
623 : Input Parameters:
624 : + eps - eigensolver context obtained from EPSCreate()
625 : . func - convergence test function, see EPSConvergenceTestFn for the calling sequence
626 : . ctx - context for private data for the convergence routine (may be NULL)
627 : - destroy - a routine for destroying the context (may be NULL), see PetscCtxDestroyFn for the calling sequence
628 :
629 : Note:
630 : If the error estimate returned by the convergence test function is less than
631 : the tolerance, then the eigenvalue is accepted as converged.
632 :
633 : Level: advanced
634 :
635 : .seealso: EPSSetConvergenceTest(), EPSSetTolerances()
636 : @*/
637 37 : PetscErrorCode EPSSetConvergenceTestFunction(EPS eps,EPSConvergenceTestFn *func,void* ctx,PetscCtxDestroyFn *destroy)
638 : {
639 37 : PetscFunctionBegin;
640 37 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
641 37 : if (eps->convergeddestroy) PetscCall((*eps->convergeddestroy)(&eps->convergedctx));
642 37 : eps->convergeduser = func;
643 37 : eps->convergeddestroy = destroy;
644 37 : eps->convergedctx = ctx;
645 37 : if (func == EPSConvergedRelative) eps->conv = EPS_CONV_REL;
646 37 : else if (func == EPSConvergedNorm) eps->conv = EPS_CONV_NORM;
647 37 : else if (func == EPSConvergedAbsolute) eps->conv = EPS_CONV_ABS;
648 : else {
649 37 : eps->conv = EPS_CONV_USER;
650 37 : eps->converged = eps->convergeduser;
651 : }
652 37 : PetscFunctionReturn(PETSC_SUCCESS);
653 : }
654 :
655 : /*@
656 : EPSSetConvergenceTest - Specifies how to compute the error estimate
657 : used in the convergence test.
658 :
659 : Logically Collective
660 :
661 : Input Parameters:
662 : + eps - eigensolver context obtained from EPSCreate()
663 : - conv - the type of convergence test
664 :
665 : Options Database Keys:
666 : + -eps_conv_abs - Sets the absolute convergence test
667 : . -eps_conv_rel - Sets the convergence test relative to the eigenvalue
668 : . -eps_conv_norm - Sets the convergence test relative to the matrix norms
669 : - -eps_conv_user - Selects the user-defined convergence test
670 :
671 : Note:
672 : The parameter 'conv' can have one of these values
673 : + EPS_CONV_ABS - absolute error ||r||
674 : . EPS_CONV_REL - error relative to the eigenvalue l, ||r||/|l|
675 : . EPS_CONV_NORM - error relative to the matrix norms, ||r||/(||A||+|l|*||B||)
676 : - EPS_CONV_USER - function set by EPSSetConvergenceTestFunction()
677 :
678 : Level: intermediate
679 :
680 : .seealso: EPSGetConvergenceTest(), EPSSetConvergenceTestFunction(), EPSSetStoppingTest(), EPSConv
681 : @*/
682 160 : PetscErrorCode EPSSetConvergenceTest(EPS eps,EPSConv conv)
683 : {
684 160 : PetscFunctionBegin;
685 160 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
686 480 : PetscValidLogicalCollectiveEnum(eps,conv,2);
687 160 : switch (conv) {
688 20 : case EPS_CONV_ABS: eps->converged = EPSConvergedAbsolute; break;
689 90 : case EPS_CONV_REL: eps->converged = EPSConvergedRelative; break;
690 50 : case EPS_CONV_NORM: eps->converged = EPSConvergedNorm; break;
691 0 : case EPS_CONV_USER:
692 0 : PetscCheck(eps->convergeduser,PetscObjectComm((PetscObject)eps),PETSC_ERR_ORDER,"Must call EPSSetConvergenceTestFunction() first");
693 0 : eps->converged = eps->convergeduser;
694 0 : break;
695 0 : default:
696 0 : SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'conv' value");
697 : }
698 160 : eps->conv = conv;
699 160 : PetscFunctionReturn(PETSC_SUCCESS);
700 : }
701 :
702 : /*@
703 : EPSGetConvergenceTest - Gets the method used to compute the error estimate
704 : used in the convergence test.
705 :
706 : Not Collective
707 :
708 : Input Parameters:
709 : . eps - eigensolver context obtained from EPSCreate()
710 :
711 : Output Parameters:
712 : . conv - the type of convergence test
713 :
714 : Level: intermediate
715 :
716 : .seealso: EPSSetConvergenceTest(), EPSConv
717 : @*/
718 1 : PetscErrorCode EPSGetConvergenceTest(EPS eps,EPSConv *conv)
719 : {
720 1 : PetscFunctionBegin;
721 1 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
722 1 : PetscAssertPointer(conv,2);
723 1 : *conv = eps->conv;
724 1 : PetscFunctionReturn(PETSC_SUCCESS);
725 : }
726 :
727 : /*@C
728 : EPSSetStoppingTestFunction - Sets a function to decide when to stop the outer
729 : iteration of the eigensolver.
730 :
731 : Logically Collective
732 :
733 : Input Parameters:
734 : + eps - eigensolver context obtained from EPSCreate()
735 : . func - stopping test function, see EPSStoppingTestFn for the calling sequence
736 : . ctx - context for private data for the stopping routine (may be NULL)
737 : - destroy - a routine for destroying the context (may be NULL), see PetscCtxDestroyFn for the calling sequence
738 :
739 : Note:
740 : Normal usage is to first call the default routine EPSStoppingBasic() and then
741 : set reason to EPS_CONVERGED_USER if some user-defined conditions have been
742 : met. To let the eigensolver continue iterating, the result must be left as
743 : EPS_CONVERGED_ITERATING.
744 :
745 : Level: advanced
746 :
747 : .seealso: EPSSetStoppingTest(), EPSStoppingBasic()
748 : @*/
749 2 : PetscErrorCode EPSSetStoppingTestFunction(EPS eps,EPSStoppingTestFn *func,void* ctx,PetscCtxDestroyFn *destroy)
750 : {
751 2 : PetscFunctionBegin;
752 2 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
753 2 : if (eps->stoppingdestroy) PetscCall((*eps->stoppingdestroy)(&eps->stoppingctx));
754 2 : eps->stoppinguser = func;
755 2 : eps->stoppingdestroy = destroy;
756 2 : eps->stoppingctx = ctx;
757 2 : if (func == EPSStoppingBasic) eps->stop = EPS_STOP_BASIC;
758 : else {
759 2 : eps->stop = EPS_STOP_USER;
760 2 : eps->stopping = eps->stoppinguser;
761 : }
762 2 : PetscFunctionReturn(PETSC_SUCCESS);
763 : }
764 :
765 : /*@
766 : EPSSetStoppingTest - Specifies how to decide the termination of the outer
767 : loop of the eigensolver.
768 :
769 : Logically Collective
770 :
771 : Input Parameters:
772 : + eps - eigensolver context obtained from EPSCreate()
773 : - stop - the type of stopping test
774 :
775 : Options Database Keys:
776 : + -eps_stop_basic - Sets the default stopping test
777 : - -eps_stop_user - Selects the user-defined stopping test
778 :
779 : Note:
780 : The parameter 'stop' can have one of these values
781 : + EPS_STOP_BASIC - default stopping test
782 : - EPS_STOP_USER - function set by EPSSetStoppingTestFunction()
783 :
784 : Level: advanced
785 :
786 : .seealso: EPSGetStoppingTest(), EPSSetStoppingTestFunction(), EPSSetConvergenceTest(), EPSStop
787 : @*/
788 1 : PetscErrorCode EPSSetStoppingTest(EPS eps,EPSStop stop)
789 : {
790 1 : PetscFunctionBegin;
791 1 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
792 3 : PetscValidLogicalCollectiveEnum(eps,stop,2);
793 1 : switch (stop) {
794 1 : case EPS_STOP_BASIC: eps->stopping = EPSStoppingBasic; break;
795 0 : case EPS_STOP_USER:
796 0 : PetscCheck(eps->stoppinguser,PetscObjectComm((PetscObject)eps),PETSC_ERR_ORDER,"Must call EPSSetStoppingTestFunction() first");
797 0 : eps->stopping = eps->stoppinguser;
798 0 : break;
799 0 : default:
800 0 : SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'stop' value");
801 : }
802 1 : eps->stop = stop;
803 1 : PetscFunctionReturn(PETSC_SUCCESS);
804 : }
805 :
806 : /*@
807 : EPSGetStoppingTest - Gets the method used to decide the termination of the outer
808 : loop of the eigensolver.
809 :
810 : Not Collective
811 :
812 : Input Parameters:
813 : . eps - eigensolver context obtained from EPSCreate()
814 :
815 : Output Parameters:
816 : . stop - the type of stopping test
817 :
818 : Level: advanced
819 :
820 : .seealso: EPSSetStoppingTest(), EPSStop
821 : @*/
822 1 : PetscErrorCode EPSGetStoppingTest(EPS eps,EPSStop *stop)
823 : {
824 1 : PetscFunctionBegin;
825 1 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
826 1 : PetscAssertPointer(stop,2);
827 1 : *stop = eps->stop;
828 1 : PetscFunctionReturn(PETSC_SUCCESS);
829 : }
830 :
831 : /*@
832 : EPSSetProblemType - Specifies the type of the eigenvalue problem.
833 :
834 : Logically Collective
835 :
836 : Input Parameters:
837 : + eps - the eigensolver context
838 : - type - a known type of eigenvalue problem
839 :
840 : Options Database Keys:
841 : + -eps_hermitian - Hermitian eigenvalue problem
842 : . -eps_gen_hermitian - generalized Hermitian eigenvalue problem
843 : . -eps_non_hermitian - non-Hermitian eigenvalue problem
844 : . -eps_gen_non_hermitian - generalized non-Hermitian eigenvalue problem
845 : . -eps_pos_gen_non_hermitian - generalized non-Hermitian eigenvalue problem
846 : with positive semi-definite B
847 : . -eps_gen_indefinite - generalized Hermitian-indefinite eigenvalue problem
848 : - -eps_bse - structured Bethe-Salpeter eigenvalue problem
849 :
850 : Notes:
851 : This function must be used to instruct SLEPc to exploit symmetry or other
852 : kind of structure. If no
853 : problem type is specified, by default a non-Hermitian problem is assumed
854 : (either standard or generalized). If the user knows that the problem is
855 : Hermitian (i.e. A=A^H) or generalized Hermitian (i.e. A=A^H, B=B^H, and
856 : B positive definite) then it is recommended to set the problem type so
857 : that eigensolver can exploit these properties.
858 :
859 : If the user does not call this function, the solver will use a reasonable
860 : guess.
861 :
862 : For structured problem types such as EPS_BSE, the matrices passed in via
863 : EPSSetOperators() must have been created with the corresponding helper
864 : function, i.e., MatCreateBSE().
865 :
866 : Level: intermediate
867 :
868 : .seealso: EPSSetOperators(), EPSSetType(), EPSGetProblemType(), EPSProblemType
869 : @*/
870 686 : PetscErrorCode EPSSetProblemType(EPS eps,EPSProblemType type)
871 : {
872 686 : PetscFunctionBegin;
873 686 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
874 2058 : PetscValidLogicalCollectiveEnum(eps,type,2);
875 686 : if (type == eps->problem_type) PetscFunctionReturn(PETSC_SUCCESS);
876 661 : switch (type) {
877 256 : case EPS_HEP:
878 256 : eps->isgeneralized = PETSC_FALSE;
879 256 : eps->ishermitian = PETSC_TRUE;
880 256 : eps->ispositive = PETSC_FALSE;
881 256 : eps->isstructured = PETSC_FALSE;
882 256 : break;
883 161 : case EPS_NHEP:
884 161 : eps->isgeneralized = PETSC_FALSE;
885 161 : eps->ishermitian = PETSC_FALSE;
886 161 : eps->ispositive = PETSC_FALSE;
887 161 : eps->isstructured = PETSC_FALSE;
888 161 : break;
889 142 : case EPS_GHEP:
890 142 : eps->isgeneralized = PETSC_TRUE;
891 142 : eps->ishermitian = PETSC_TRUE;
892 142 : eps->ispositive = PETSC_TRUE;
893 142 : eps->isstructured = PETSC_FALSE;
894 142 : break;
895 66 : case EPS_GNHEP:
896 66 : eps->isgeneralized = PETSC_TRUE;
897 66 : eps->ishermitian = PETSC_FALSE;
898 66 : eps->ispositive = PETSC_FALSE;
899 66 : eps->isstructured = PETSC_FALSE;
900 66 : break;
901 3 : case EPS_PGNHEP:
902 3 : eps->isgeneralized = PETSC_TRUE;
903 3 : eps->ishermitian = PETSC_FALSE;
904 3 : eps->ispositive = PETSC_TRUE;
905 3 : eps->isstructured = PETSC_FALSE;
906 3 : break;
907 19 : case EPS_GHIEP:
908 19 : eps->isgeneralized = PETSC_TRUE;
909 19 : eps->ishermitian = PETSC_TRUE;
910 19 : eps->ispositive = PETSC_FALSE;
911 19 : eps->isstructured = PETSC_FALSE;
912 19 : break;
913 14 : case EPS_BSE:
914 14 : eps->isgeneralized = PETSC_FALSE;
915 14 : eps->ishermitian = PETSC_FALSE;
916 14 : eps->ispositive = PETSC_FALSE;
917 14 : eps->isstructured = PETSC_TRUE;
918 14 : break;
919 0 : default:
920 0 : SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type");
921 : }
922 661 : eps->problem_type = type;
923 661 : eps->state = EPS_STATE_INITIAL;
924 661 : PetscFunctionReturn(PETSC_SUCCESS);
925 : }
926 :
927 : /*@
928 : EPSGetProblemType - Gets the problem type from the EPS object.
929 :
930 : Not Collective
931 :
932 : Input Parameter:
933 : . eps - the eigensolver context
934 :
935 : Output Parameter:
936 : . type - the problem type
937 :
938 : Level: intermediate
939 :
940 : .seealso: EPSSetProblemType(), EPSProblemType
941 : @*/
942 63 : PetscErrorCode EPSGetProblemType(EPS eps,EPSProblemType *type)
943 : {
944 63 : PetscFunctionBegin;
945 63 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
946 63 : PetscAssertPointer(type,2);
947 63 : *type = eps->problem_type;
948 63 : PetscFunctionReturn(PETSC_SUCCESS);
949 : }
950 :
951 : /*@
952 : EPSSetExtraction - Specifies the type of extraction technique to be employed
953 : by the eigensolver.
954 :
955 : Logically Collective
956 :
957 : Input Parameters:
958 : + eps - the eigensolver context
959 : - extr - a known type of extraction
960 :
961 : Options Database Keys:
962 : + -eps_ritz - Rayleigh-Ritz extraction
963 : . -eps_harmonic - harmonic Ritz extraction
964 : . -eps_harmonic_relative - harmonic Ritz extraction relative to the eigenvalue
965 : . -eps_harmonic_right - harmonic Ritz extraction for rightmost eigenvalues
966 : . -eps_harmonic_largest - harmonic Ritz extraction for largest magnitude
967 : (without target)
968 : . -eps_refined - refined Ritz extraction
969 : - -eps_refined_harmonic - refined harmonic Ritz extraction
970 :
971 : Notes:
972 : Not all eigensolvers support all types of extraction. See the SLEPc
973 : Users Manual for details.
974 :
975 : By default, a standard Rayleigh-Ritz extraction is used. Other extractions
976 : may be useful when computing interior eigenvalues.
977 :
978 : Harmonic-type extractions are used in combination with a 'target'.
979 :
980 : Level: advanced
981 :
982 : .seealso: EPSSetTarget(), EPSGetExtraction(), EPSExtraction
983 : @*/
984 14 : PetscErrorCode EPSSetExtraction(EPS eps,EPSExtraction extr)
985 : {
986 14 : PetscFunctionBegin;
987 14 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
988 42 : PetscValidLogicalCollectiveEnum(eps,extr,2);
989 14 : if (eps->extraction != extr) {
990 14 : eps->state = EPS_STATE_INITIAL;
991 14 : eps->extraction = extr;
992 : }
993 14 : PetscFunctionReturn(PETSC_SUCCESS);
994 : }
995 :
996 : /*@
997 : EPSGetExtraction - Gets the extraction type used by the EPS object.
998 :
999 : Not Collective
1000 :
1001 : Input Parameter:
1002 : . eps - the eigensolver context
1003 :
1004 : Output Parameter:
1005 : . extr - name of extraction type
1006 :
1007 : Level: advanced
1008 :
1009 : .seealso: EPSSetExtraction(), EPSExtraction
1010 : @*/
1011 2 : PetscErrorCode EPSGetExtraction(EPS eps,EPSExtraction *extr)
1012 : {
1013 2 : PetscFunctionBegin;
1014 2 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1015 2 : PetscAssertPointer(extr,2);
1016 2 : *extr = eps->extraction;
1017 2 : PetscFunctionReturn(PETSC_SUCCESS);
1018 : }
1019 :
1020 : /*@
1021 : EPSSetBalance - Specifies the balancing technique to be employed by the
1022 : eigensolver, and some parameters associated to it.
1023 :
1024 : Logically Collective
1025 :
1026 : Input Parameters:
1027 : + eps - the eigensolver context
1028 : . bal - the balancing method, one of EPS_BALANCE_NONE, EPS_BALANCE_ONESIDE,
1029 : EPS_BALANCE_TWOSIDE, or EPS_BALANCE_USER
1030 : . its - number of iterations of the balancing algorithm
1031 : - cutoff - cutoff value
1032 :
1033 : Options Database Keys:
1034 : + -eps_balance <method> - the balancing method, where <method> is one of
1035 : 'none', 'oneside', 'twoside', or 'user'
1036 : . -eps_balance_its <its> - number of iterations
1037 : - -eps_balance_cutoff <cutoff> - cutoff value
1038 :
1039 : Notes:
1040 : When balancing is enabled, the solver works implicitly with matrix DAD^-1,
1041 : where D is an appropriate diagonal matrix. This improves the accuracy of
1042 : the computed results in some cases. See the SLEPc Users Manual for details.
1043 :
1044 : Balancing makes sense only for non-Hermitian problems when the required
1045 : precision is high (i.e. a small tolerance such as 1e-15).
1046 :
1047 : By default, balancing is disabled. The two-sided method is much more
1048 : effective than the one-sided counterpart, but it requires the system
1049 : matrices to have the MatMultTranspose operation defined.
1050 :
1051 : The parameter 'its' is the number of iterations performed by the method. The
1052 : cutoff value is used only in the two-side variant. Use PETSC_DETERMINE to assign
1053 : a reasonably good value, or PETSC_CURRENT to leave the value unchanged.
1054 :
1055 : User-defined balancing is allowed provided that the corresponding matrix
1056 : is set via STSetBalanceMatrix.
1057 :
1058 : Level: intermediate
1059 :
1060 : .seealso: EPSGetBalance(), EPSBalance, STSetBalanceMatrix()
1061 : @*/
1062 16 : PetscErrorCode EPSSetBalance(EPS eps,EPSBalance bal,PetscInt its,PetscReal cutoff)
1063 : {
1064 16 : PetscFunctionBegin;
1065 16 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1066 48 : PetscValidLogicalCollectiveEnum(eps,bal,2);
1067 48 : PetscValidLogicalCollectiveInt(eps,its,3);
1068 48 : PetscValidLogicalCollectiveReal(eps,cutoff,4);
1069 16 : switch (bal) {
1070 16 : case EPS_BALANCE_NONE:
1071 : case EPS_BALANCE_ONESIDE:
1072 : case EPS_BALANCE_TWOSIDE:
1073 : case EPS_BALANCE_USER:
1074 16 : if (eps->balance != bal) {
1075 14 : eps->state = EPS_STATE_INITIAL;
1076 14 : eps->balance = bal;
1077 : }
1078 16 : break;
1079 0 : default:
1080 0 : SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Invalid value of argument 'bal'");
1081 : }
1082 16 : if (its==PETSC_DETERMINE) eps->balance_its = 5;
1083 16 : else if (its!=PETSC_CURRENT) {
1084 16 : PetscCheck(its>0,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of its. Must be > 0");
1085 16 : eps->balance_its = its;
1086 : }
1087 16 : if (cutoff==(PetscReal)PETSC_DETERMINE) eps->balance_cutoff = 1e-8;
1088 16 : else if (cutoff!=(PetscReal)PETSC_CURRENT) {
1089 16 : PetscCheck(cutoff>0.0,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of cutoff. Must be > 0");
1090 16 : eps->balance_cutoff = cutoff;
1091 : }
1092 16 : PetscFunctionReturn(PETSC_SUCCESS);
1093 : }
1094 :
1095 : /*@
1096 : EPSGetBalance - Gets the balancing type used by the EPS object, and the
1097 : associated parameters.
1098 :
1099 : Not Collective
1100 :
1101 : Input Parameter:
1102 : . eps - the eigensolver context
1103 :
1104 : Output Parameters:
1105 : + bal - the balancing method
1106 : . its - number of iterations of the balancing algorithm
1107 : - cutoff - cutoff value
1108 :
1109 : Level: intermediate
1110 :
1111 : Note:
1112 : The user can specify NULL for any parameter that is not needed.
1113 :
1114 : .seealso: EPSSetBalance(), EPSBalance
1115 : @*/
1116 1 : PetscErrorCode EPSGetBalance(EPS eps,EPSBalance *bal,PetscInt *its,PetscReal *cutoff)
1117 : {
1118 1 : PetscFunctionBegin;
1119 1 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1120 1 : if (bal) *bal = eps->balance;
1121 1 : if (its) *its = eps->balance_its;
1122 1 : if (cutoff) *cutoff = eps->balance_cutoff;
1123 1 : PetscFunctionReturn(PETSC_SUCCESS);
1124 : }
1125 :
1126 : /*@
1127 : EPSSetTwoSided - Sets the solver to use a two-sided variant so that left
1128 : eigenvectors are also computed.
1129 :
1130 : Logically Collective
1131 :
1132 : Input Parameters:
1133 : + eps - the eigensolver context
1134 : - twosided - whether the two-sided variant is to be used or not
1135 :
1136 : Options Database Keys:
1137 : . -eps_two_sided <boolean> - Sets/resets the twosided flag
1138 :
1139 : Notes:
1140 : If the user sets twosided=PETSC_TRUE then the solver uses a variant of
1141 : the algorithm that computes both right and left eigenvectors. This is
1142 : usually much more costly. This option is not available in all solvers.
1143 :
1144 : When using two-sided solvers, the problem matrices must have both the
1145 : MatMult and MatMultTranspose operations defined.
1146 :
1147 : Level: advanced
1148 :
1149 : .seealso: EPSGetTwoSided(), EPSGetLeftEigenvector()
1150 : @*/
1151 28 : PetscErrorCode EPSSetTwoSided(EPS eps,PetscBool twosided)
1152 : {
1153 28 : PetscFunctionBegin;
1154 28 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1155 84 : PetscValidLogicalCollectiveBool(eps,twosided,2);
1156 28 : if (twosided!=eps->twosided) {
1157 19 : eps->twosided = twosided;
1158 19 : eps->state = EPS_STATE_INITIAL;
1159 : }
1160 28 : PetscFunctionReturn(PETSC_SUCCESS);
1161 : }
1162 :
1163 : /*@
1164 : EPSGetTwoSided - Returns the flag indicating whether a two-sided variant
1165 : of the algorithm is being used or not.
1166 :
1167 : Not Collective
1168 :
1169 : Input Parameter:
1170 : . eps - the eigensolver context
1171 :
1172 : Output Parameter:
1173 : . twosided - the returned flag
1174 :
1175 : Level: advanced
1176 :
1177 : .seealso: EPSSetTwoSided()
1178 : @*/
1179 7 : PetscErrorCode EPSGetTwoSided(EPS eps,PetscBool *twosided)
1180 : {
1181 7 : PetscFunctionBegin;
1182 7 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1183 7 : PetscAssertPointer(twosided,2);
1184 7 : *twosided = eps->twosided;
1185 7 : PetscFunctionReturn(PETSC_SUCCESS);
1186 : }
1187 :
1188 : /*@
1189 : EPSSetTrueResidual - Specifies if the solver must compute the true residual
1190 : explicitly or not.
1191 :
1192 : Logically Collective
1193 :
1194 : Input Parameters:
1195 : + eps - the eigensolver context
1196 : - trueres - whether true residuals are required or not
1197 :
1198 : Options Database Keys:
1199 : . -eps_true_residual <boolean> - Sets/resets the boolean flag 'trueres'
1200 :
1201 : Notes:
1202 : If the user sets trueres=PETSC_TRUE then the solver explicitly computes
1203 : the true residual for each eigenpair approximation, and uses it for
1204 : convergence testing. Computing the residual is usually an expensive
1205 : operation. Some solvers (e.g., Krylov solvers) can avoid this computation
1206 : by using a cheap estimate of the residual norm, but this may sometimes
1207 : give inaccurate results (especially if a spectral transform is being
1208 : used). On the contrary, preconditioned eigensolvers (e.g., Davidson solvers)
1209 : do rely on computing the true residual, so this option is irrelevant for them.
1210 :
1211 : Level: advanced
1212 :
1213 : .seealso: EPSGetTrueResidual()
1214 : @*/
1215 9 : PetscErrorCode EPSSetTrueResidual(EPS eps,PetscBool trueres)
1216 : {
1217 9 : PetscFunctionBegin;
1218 9 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1219 27 : PetscValidLogicalCollectiveBool(eps,trueres,2);
1220 9 : eps->trueres = trueres;
1221 9 : PetscFunctionReturn(PETSC_SUCCESS);
1222 : }
1223 :
1224 : /*@
1225 : EPSGetTrueResidual - Returns the flag indicating whether true
1226 : residuals must be computed explicitly or not.
1227 :
1228 : Not Collective
1229 :
1230 : Input Parameter:
1231 : . eps - the eigensolver context
1232 :
1233 : Output Parameter:
1234 : . trueres - the returned flag
1235 :
1236 : Level: advanced
1237 :
1238 : .seealso: EPSSetTrueResidual()
1239 : @*/
1240 8 : PetscErrorCode EPSGetTrueResidual(EPS eps,PetscBool *trueres)
1241 : {
1242 8 : PetscFunctionBegin;
1243 8 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1244 8 : PetscAssertPointer(trueres,2);
1245 8 : *trueres = eps->trueres;
1246 8 : PetscFunctionReturn(PETSC_SUCCESS);
1247 : }
1248 :
1249 : /*@
1250 : EPSSetTrackAll - Specifies if the solver must compute the residual norm of all
1251 : approximate eigenpairs or not.
1252 :
1253 : Logically Collective
1254 :
1255 : Input Parameters:
1256 : + eps - the eigensolver context
1257 : - trackall - whether to compute all residuals or not
1258 :
1259 : Notes:
1260 : If the user sets trackall=PETSC_TRUE then the solver computes (or estimates)
1261 : the residual norm for each eigenpair approximation. Computing the residual is
1262 : usually an expensive operation and solvers commonly compute only the residual
1263 : associated to the first unconverged eigenpair.
1264 :
1265 : The option '-eps_monitor_all' automatically activates this option.
1266 :
1267 : Level: developer
1268 :
1269 : .seealso: EPSGetTrackAll()
1270 : @*/
1271 144 : PetscErrorCode EPSSetTrackAll(EPS eps,PetscBool trackall)
1272 : {
1273 144 : PetscFunctionBegin;
1274 144 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1275 432 : PetscValidLogicalCollectiveBool(eps,trackall,2);
1276 144 : eps->trackall = trackall;
1277 144 : PetscFunctionReturn(PETSC_SUCCESS);
1278 : }
1279 :
1280 : /*@
1281 : EPSGetTrackAll - Returns the flag indicating whether all residual norms must
1282 : be computed or not.
1283 :
1284 : Not Collective
1285 :
1286 : Input Parameter:
1287 : . eps - the eigensolver context
1288 :
1289 : Output Parameter:
1290 : . trackall - the returned flag
1291 :
1292 : Level: developer
1293 :
1294 : .seealso: EPSSetTrackAll()
1295 : @*/
1296 1 : PetscErrorCode EPSGetTrackAll(EPS eps,PetscBool *trackall)
1297 : {
1298 1 : PetscFunctionBegin;
1299 1 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1300 1 : PetscAssertPointer(trackall,2);
1301 1 : *trackall = eps->trackall;
1302 1 : PetscFunctionReturn(PETSC_SUCCESS);
1303 : }
1304 :
1305 : /*@
1306 : EPSSetPurify - Deactivate eigenvector purification (which is activated by default).
1307 :
1308 : Logically Collective
1309 :
1310 : Input Parameters:
1311 : + eps - the eigensolver context
1312 : - purify - whether purification is required or not
1313 :
1314 : Options Database Keys:
1315 : . -eps_purify <boolean> - Sets/resets the boolean flag 'purify'
1316 :
1317 : Notes:
1318 : By default, eigenvectors of generalized symmetric eigenproblems are purified
1319 : in order to purge directions in the nullspace of matrix B. If the user knows
1320 : that B is non-singular, then purification can be safely deactivated and some
1321 : computational cost is avoided (this is particularly important in interval computations).
1322 :
1323 : Level: intermediate
1324 :
1325 : .seealso: EPSGetPurify(), EPSSetInterval()
1326 : @*/
1327 4 : PetscErrorCode EPSSetPurify(EPS eps,PetscBool purify)
1328 : {
1329 4 : PetscFunctionBegin;
1330 4 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1331 12 : PetscValidLogicalCollectiveBool(eps,purify,2);
1332 4 : if (purify!=eps->purify) {
1333 2 : eps->purify = purify;
1334 2 : eps->state = EPS_STATE_INITIAL;
1335 : }
1336 4 : PetscFunctionReturn(PETSC_SUCCESS);
1337 : }
1338 :
1339 : /*@
1340 : EPSGetPurify - Returns the flag indicating whether purification is activated
1341 : or not.
1342 :
1343 : Not Collective
1344 :
1345 : Input Parameter:
1346 : . eps - the eigensolver context
1347 :
1348 : Output Parameter:
1349 : . purify - the returned flag
1350 :
1351 : Level: intermediate
1352 :
1353 : .seealso: EPSSetPurify()
1354 : @*/
1355 1 : PetscErrorCode EPSGetPurify(EPS eps,PetscBool *purify)
1356 : {
1357 1 : PetscFunctionBegin;
1358 1 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1359 1 : PetscAssertPointer(purify,2);
1360 1 : *purify = eps->purify;
1361 1 : PetscFunctionReturn(PETSC_SUCCESS);
1362 : }
1363 :
1364 : /*@
1365 : EPSSetOptionsPrefix - Sets the prefix used for searching for all
1366 : EPS options in the database.
1367 :
1368 : Logically Collective
1369 :
1370 : Input Parameters:
1371 : + eps - the eigensolver context
1372 : - prefix - the prefix string to prepend to all EPS option requests
1373 :
1374 : Notes:
1375 : A hyphen (-) must NOT be given at the beginning of the prefix name.
1376 : The first character of all runtime options is AUTOMATICALLY the
1377 : hyphen.
1378 :
1379 : For example, to distinguish between the runtime options for two
1380 : different EPS contexts, one could call
1381 : .vb
1382 : EPSSetOptionsPrefix(eps1,"eig1_")
1383 : EPSSetOptionsPrefix(eps2,"eig2_")
1384 : .ve
1385 :
1386 : Level: advanced
1387 :
1388 : .seealso: EPSAppendOptionsPrefix(), EPSGetOptionsPrefix()
1389 : @*/
1390 201 : PetscErrorCode EPSSetOptionsPrefix(EPS eps,const char *prefix)
1391 : {
1392 201 : PetscFunctionBegin;
1393 201 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1394 201 : if (!eps->st) PetscCall(EPSGetST(eps,&eps->st));
1395 201 : PetscCall(STSetOptionsPrefix(eps->st,prefix));
1396 201 : if (!eps->V) PetscCall(EPSGetBV(eps,&eps->V));
1397 201 : PetscCall(BVSetOptionsPrefix(eps->V,prefix));
1398 201 : if (!eps->ds) PetscCall(EPSGetDS(eps,&eps->ds));
1399 201 : PetscCall(DSSetOptionsPrefix(eps->ds,prefix));
1400 201 : if (!eps->rg) PetscCall(EPSGetRG(eps,&eps->rg));
1401 201 : PetscCall(RGSetOptionsPrefix(eps->rg,prefix));
1402 201 : PetscCall(PetscObjectSetOptionsPrefix((PetscObject)eps,prefix));
1403 201 : PetscFunctionReturn(PETSC_SUCCESS);
1404 : }
1405 :
1406 : /*@
1407 : EPSAppendOptionsPrefix - Appends to the prefix used for searching for all
1408 : EPS options in the database.
1409 :
1410 : Logically Collective
1411 :
1412 : Input Parameters:
1413 : + eps - the eigensolver context
1414 : - prefix - the prefix string to prepend to all EPS option requests
1415 :
1416 : Notes:
1417 : A hyphen (-) must NOT be given at the beginning of the prefix name.
1418 : The first character of all runtime options is AUTOMATICALLY the hyphen.
1419 :
1420 : Level: advanced
1421 :
1422 : .seealso: EPSSetOptionsPrefix(), EPSGetOptionsPrefix()
1423 : @*/
1424 161 : PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix)
1425 : {
1426 161 : PetscFunctionBegin;
1427 161 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1428 161 : if (!eps->st) PetscCall(EPSGetST(eps,&eps->st));
1429 161 : PetscCall(STAppendOptionsPrefix(eps->st,prefix));
1430 161 : if (!eps->V) PetscCall(EPSGetBV(eps,&eps->V));
1431 161 : PetscCall(BVAppendOptionsPrefix(eps->V,prefix));
1432 161 : if (!eps->ds) PetscCall(EPSGetDS(eps,&eps->ds));
1433 161 : PetscCall(DSAppendOptionsPrefix(eps->ds,prefix));
1434 161 : if (!eps->rg) PetscCall(EPSGetRG(eps,&eps->rg));
1435 161 : PetscCall(RGAppendOptionsPrefix(eps->rg,prefix));
1436 161 : PetscCall(PetscObjectAppendOptionsPrefix((PetscObject)eps,prefix));
1437 161 : PetscFunctionReturn(PETSC_SUCCESS);
1438 : }
1439 :
1440 : /*@
1441 : EPSGetOptionsPrefix - Gets the prefix used for searching for all
1442 : EPS options in the database.
1443 :
1444 : Not Collective
1445 :
1446 : Input Parameters:
1447 : . eps - the eigensolver context
1448 :
1449 : Output Parameters:
1450 : . prefix - pointer to the prefix string used is returned
1451 :
1452 : Note:
1453 : On the Fortran side, the user should pass in a string 'prefix' of
1454 : sufficient length to hold the prefix.
1455 :
1456 : Level: advanced
1457 :
1458 : .seealso: EPSSetOptionsPrefix(), EPSAppendOptionsPrefix()
1459 : @*/
1460 30 : PetscErrorCode EPSGetOptionsPrefix(EPS eps,const char *prefix[])
1461 : {
1462 30 : PetscFunctionBegin;
1463 30 : PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1464 30 : PetscAssertPointer(prefix,2);
1465 30 : PetscCall(PetscObjectGetOptionsPrefix((PetscObject)eps,prefix));
1466 30 : PetscFunctionReturn(PETSC_SUCCESS);
1467 : }
|