Subversion Repositories slepc-dev

Rev

Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
545 dsic.upv.es!jroman 1
/*
2
      EPS routines related to options that can be set via the command-line
3
      or procedurally.
4
*/
526 dsic.upv.es!antodo 5
#include "src/eps/epsimpl.h"   /*I "slepceps.h" I*/
6
 
7
#undef __FUNCT__  
8
#define __FUNCT__ "EPSSetFromOptions"
9
/*@
10
   EPSSetFromOptions - Sets EPS options from the options database.
11
   This routine must be called before EPSSetUp() if the user is to be
12
   allowed to set the solver type.
13
 
14
   Collective on EPS
15
 
16
   Input Parameters:
17
.  eps - the eigensolver context
18
 
19
   Notes:  
20
   To see all options, run your program with the -help option.
21
 
22
   Level: beginner
23
 
24
.seealso:
25
@*/
26
PetscErrorCode EPSSetFromOptions(EPS eps)
27
{
28
  PetscErrorCode ierr;
1076 slepc 29
  char           type[256],monfilename[PETSC_MAX_PATH_LEN];
526 dsic.upv.es!antodo 30
  PetscTruth     flg;
1282 slepc 31
  PetscReal      r;
32
  PetscInt       i,j;
1076 slepc 33
  PetscViewer    monviewer;
526 dsic.upv.es!antodo 34
 
35
  PetscFunctionBegin;
36
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
37
  ierr = PetscOptionsBegin(eps->comm,eps->prefix,"Eigenproblem Solver (EPS) Options","EPS");CHKERRQ(ierr);
1198 slepc 38
    ierr = PetscOptionsList("-eps_type","Eigenproblem Solver method","EPSSetType",EPSList,(char*)(eps->type_name?eps->type_name:EPSKRYLOVSCHUR),type,256,&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 39
    if (flg) {
40
      ierr = EPSSetType(eps,type);CHKERRQ(ierr);
41
    }
42
 
830 dsic.upv.es!antodo 43
    ierr = PetscOptionsTruthGroupBegin("-eps_hermitian","hermitian eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 44
    if (flg) {ierr = EPSSetProblemType(eps,EPS_HEP);CHKERRQ(ierr);}
830 dsic.upv.es!antodo 45
    ierr = PetscOptionsTruthGroup("-eps_gen_hermitian","generalized hermitian eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 46
    if (flg) {ierr = EPSSetProblemType(eps,EPS_GHEP);CHKERRQ(ierr);}
830 dsic.upv.es!antodo 47
    ierr = PetscOptionsTruthGroup("-eps_non_hermitian","non-hermitian eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 48
    if (flg) {ierr = EPSSetProblemType(eps,EPS_NHEP);CHKERRQ(ierr);}
1358 slepc 49
    ierr = PetscOptionsTruthGroup("-eps_gen_non_hermitian","generalized non-hermitian eigenvalue problem","EPSSetProblemType",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 50
    if (flg) {ierr = EPSSetProblemType(eps,EPS_GNHEP);CHKERRQ(ierr);}
1360 slepc 51
    ierr = PetscOptionsTruthGroupEnd("-eps_pos_gen_non_hermitian","generalized non-hermitian eigenvalue problem with positive semi-definite B","EPSSetProblemType",&flg);CHKERRQ(ierr);
1358 slepc 52
    if (flg) {ierr = EPSSetProblemType(eps,EPS_PGNHEP);CHKERRQ(ierr);}
526 dsic.upv.es!antodo 53
 
657 dsic.upv.es!antodo 54
    /*
55
      Set the type if it was never set.
56
    */
57
    if (!eps->type_name) {
1198 slepc 58
      ierr = EPSSetType(eps,EPSKRYLOVSCHUR);CHKERRQ(ierr);
657 dsic.upv.es!antodo 59
    }
60
 
830 dsic.upv.es!antodo 61
    ierr = PetscOptionsTruthGroupBegin("-eps_oneside","one-sided eigensolver","EPSSetClass",&flg);CHKERRQ(ierr);
780 dsic.upv.es!jroman 62
    if (flg) {ierr = EPSSetClass(eps,EPS_ONE_SIDE);CHKERRQ(ierr);}
830 dsic.upv.es!antodo 63
    ierr = PetscOptionsTruthGroupEnd("-eps_twoside","two-sided eigensolver","EPSSetClass",&flg);CHKERRQ(ierr);
780 dsic.upv.es!jroman 64
    if (flg) {ierr = EPSSetClass(eps,EPS_TWO_SIDE);CHKERRQ(ierr);}
65
 
1282 slepc 66
    r = i = PETSC_IGNORE;
67
    ierr = PetscOptionsInt("-eps_max_it","Maximum number of iterations","EPSSetTolerances",eps->max_it,&i,PETSC_NULL);CHKERRQ(ierr);
68
    ierr = PetscOptionsReal("-eps_tol","Tolerance","EPSSetTolerances",eps->tol,&r,PETSC_NULL);CHKERRQ(ierr);
1284 slepc 69
    ierr = EPSSetTolerances(eps,r,i);CHKERRQ(ierr);
526 dsic.upv.es!antodo 70
 
1282 slepc 71
    i = j = PETSC_IGNORE;
72
    ierr = PetscOptionsInt("-eps_nev","Number of eigenvalues to compute","EPSSetDimensions",eps->nev,&i,PETSC_NULL);CHKERRQ(ierr);
73
    ierr = PetscOptionsInt("-eps_ncv","Number of basis vectors","EPSSetDimensions",eps->ncv,&j,PETSC_NULL);CHKERRQ(ierr);
74
    ierr = EPSSetDimensions(eps,i,j);CHKERRQ(ierr);
75
 
526 dsic.upv.es!antodo 76
    /* -----------------------------------------------------------------------*/
77
    /*
78
      Cancels all monitors hardwired into code before call to EPSSetFromOptions()
79
    */
1331 slepc 80
    ierr = PetscOptionsName("-eps_monitor_cancel","Remove any hardwired monitor routines","EPSMonitorCancel",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 81
    if (flg) {
1331 slepc 82
      ierr = EPSMonitorCancel(eps); CHKERRQ(ierr);
526 dsic.upv.es!antodo 83
    }
84
    /*
85
      Prints approximate eigenvalues and error estimates at each iteration
86
    */
1331 slepc 87
    ierr = PetscOptionsString("-eps_monitor","Monitor approximate eigenvalues and error estimates","EPSMonitorSet","stdout",monfilename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 88
    if (flg) {
1076 slepc 89
      ierr = PetscViewerASCIIOpen(eps->comm,monfilename,&monviewer);CHKERRQ(ierr);
1331 slepc 90
      ierr = EPSMonitorSet(eps,EPSMonitorDefault,monviewer,(PetscErrorCode (*)(void*))PetscViewerDestroy);CHKERRQ(ierr);
526 dsic.upv.es!antodo 91
    }
1331 slepc 92
    ierr = PetscOptionsName("-eps_monitor_draw","Monitor error estimates graphically","EPSMonitorSet",&flg);CHKERRQ(ierr);
623 dsic.upv.es!antodo 93
    if (flg) {
1331 slepc 94
      ierr = EPSMonitorSet(eps,EPSMonitorLG,PETSC_NULL,PETSC_NULL);CHKERRQ(ierr);
623 dsic.upv.es!antodo 95
    }
526 dsic.upv.es!antodo 96
  /* -----------------------------------------------------------------------*/
830 dsic.upv.es!antodo 97
    ierr = PetscOptionsTruthGroupBegin("-eps_largest_magnitude","compute largest eigenvalues in magnitude","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 98
    if (flg) {ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_MAGNITUDE);CHKERRQ(ierr);}
830 dsic.upv.es!antodo 99
    ierr = PetscOptionsTruthGroup("-eps_smallest_magnitude","compute smallest eigenvalues in magnitude","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 100
    if (flg) {ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_MAGNITUDE);CHKERRQ(ierr);}
830 dsic.upv.es!antodo 101
    ierr = PetscOptionsTruthGroup("-eps_largest_real","compute largest real parts","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 102
    if (flg) {ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_REAL);CHKERRQ(ierr);}
830 dsic.upv.es!antodo 103
    ierr = PetscOptionsTruthGroup("-eps_smallest_real","compute smallest real parts","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 104
    if (flg) {ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_REAL);CHKERRQ(ierr);}
830 dsic.upv.es!antodo 105
    ierr = PetscOptionsTruthGroup("-eps_largest_imaginary","compute largest imaginary parts","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 106
    if (flg) {ierr = EPSSetWhichEigenpairs(eps,EPS_LARGEST_IMAGINARY);CHKERRQ(ierr);}
830 dsic.upv.es!antodo 107
    ierr = PetscOptionsTruthGroupEnd("-eps_smallest_imaginary","compute smallest imaginary parts","EPSSetWhichEigenpairs",&flg);CHKERRQ(ierr);
526 dsic.upv.es!antodo 108
    if (flg) {ierr = EPSSetWhichEigenpairs(eps,EPS_SMALLEST_IMAGINARY);CHKERRQ(ierr);}
109
 
110
    ierr = PetscOptionsName("-eps_view","Print detailed information on solver used","EPSView",0);CHKERRQ(ierr);
111
    ierr = PetscOptionsName("-eps_view_binary","Save the matrices associated to the eigenproblem","EPSSetFromOptions",0);CHKERRQ(ierr);
112
    ierr = PetscOptionsName("-eps_plot_eigs","Make a plot of the computed eigenvalues","EPSSolve",0);CHKERRQ(ierr);
1209 slepc 113
 
526 dsic.upv.es!antodo 114
    if (eps->ops->setfromoptions) {
115
      ierr = (*eps->ops->setfromoptions)(eps);CHKERRQ(ierr);
116
    }
117
  ierr = PetscOptionsEnd();CHKERRQ(ierr);
118
 
1345 slepc 119
  ierr = IPSetFromOptions(eps->ip); CHKERRQ(ierr);
526 dsic.upv.es!antodo 120
  ierr = STSetFromOptions(eps->OP); CHKERRQ(ierr);
121
  PetscFunctionReturn(0);
122
}
123
 
124
#undef __FUNCT__  
125
#define __FUNCT__ "EPSGetTolerances"
126
/*@
127
   EPSGetTolerances - Gets the tolerance and maximum
128
   iteration count used by the default EPS convergence tests.
129
 
130
   Not Collective
131
 
132
   Input Parameter:
133
.  eps - the eigensolver context
134
 
135
   Output Parameters:
136
+  tol - the convergence tolerance
137
-  maxits - maximum number of iterations
138
 
139
   Notes:
140
   The user can specify PETSC_NULL for any parameter that is not needed.
141
 
142
   Level: intermediate
143
 
144
.seealso: EPSSetTolerances()
145
@*/
146
PetscErrorCode EPSGetTolerances(EPS eps,PetscReal *tol,int *maxits)
147
{
148
  PetscFunctionBegin;
149
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
150
  if (tol)    *tol    = eps->tol;
151
  if (maxits) *maxits = eps->max_it;
152
  PetscFunctionReturn(0);
153
}
154
 
155
#undef __FUNCT__  
156
#define __FUNCT__ "EPSSetTolerances"
157
/*@
158
   EPSSetTolerances - Sets the tolerance and maximum
159
   iteration count used by the default EPS convergence testers.
160
 
161
   Collective on EPS
162
 
163
   Input Parameters:
164
+  eps - the eigensolver context
165
.  tol - the convergence tolerance
166
-  maxits - maximum number of iterations to use
167
 
168
   Options Database Keys:
169
+  -eps_tol <tol> - Sets the convergence tolerance
170
-  -eps_max_it <maxits> - Sets the maximum number of iterations allowed
171
 
172
   Notes:
1284 slepc 173
   Use PETSC_IGNORE for an argument that need not be changed.
526 dsic.upv.es!antodo 174
 
1282 slepc 175
   Use PETSC_DECIDE for maxits to assign a reasonably good value, which is
176
   dependent on the solution method.
177
 
526 dsic.upv.es!antodo 178
   Level: intermediate
179
 
180
.seealso: EPSGetTolerances()
181
@*/
182
PetscErrorCode EPSSetTolerances(EPS eps,PetscReal tol,int maxits)
183
{
184
  PetscFunctionBegin;
185
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1282 slepc 186
  if (tol != PETSC_IGNORE) {
187
    if (tol == PETSC_DEFAULT) {
188
      eps->tol = 1e-7;
189
    } else {
190
      if (tol < 0.0) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of tol. Must be > 0");
191
      eps->tol = tol;
192
    }
1276 slepc 193
  }
1282 slepc 194
  if (maxits != PETSC_IGNORE) {
195
    if (maxits == PETSC_DEFAULT || maxits == PETSC_DECIDE) {
196
      eps->max_it = 0;
197
    } else {
198
      if (maxits < 0) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of maxits. Must be > 0");
199
      eps->max_it = maxits;
200
    }
1276 slepc 201
  }
526 dsic.upv.es!antodo 202
  PetscFunctionReturn(0);
203
}
204
 
205
#undef __FUNCT__  
206
#define __FUNCT__ "EPSGetDimensions"
207
/*@
208
   EPSGetDimensions - Gets the number of eigenvalues to compute
209
   and the dimension of the subspace.
210
 
211
   Not Collective
212
 
213
   Input Parameter:
214
.  eps - the eigensolver context
215
 
216
   Output Parameters:
217
+  nev - number of eigenvalues to compute
218
-  ncv - the maximum dimension of the subspace to be used by the solver
219
 
220
   Notes:
221
   The user can specify PETSC_NULL for any parameter that is not needed.
222
 
223
   Level: intermediate
224
 
225
.seealso: EPSSetDimensions()
226
@*/
227
PetscErrorCode EPSGetDimensions(EPS eps,int *nev,int *ncv)
228
{
229
  PetscFunctionBegin;
230
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
231
  if( nev )   *nev = eps->nev;
232
  if( ncv )   *ncv = eps->ncv;
233
  PetscFunctionReturn(0);
234
}
235
 
236
#undef __FUNCT__  
237
#define __FUNCT__ "EPSSetDimensions"
238
/*@
239
   EPSSetDimensions - Sets the number of eigenvalues to compute
240
   and the dimension of the subspace.
241
 
242
   Collective on EPS
243
 
244
   Input Parameters:
245
+  eps - the eigensolver context
246
.  nev - number of eigenvalues to compute
247
-  ncv - the maximum dimension of the subspace to be used by the solver
248
 
249
   Options Database Keys:
250
+  -eps_nev <nev> - Sets the number of eigenvalues
251
-  -eps_ncv <ncv> - Sets the dimension of the subspace
252
 
253
   Notes:
1282 slepc 254
   Use PETSC_IGNORE to retain the previous value of any parameter.
526 dsic.upv.es!antodo 255
 
256
   Use PETSC_DECIDE for ncv to assign a reasonably good value, which is
257
   dependent on the solution method.
258
 
259
   Level: intermediate
260
 
261
.seealso: EPSGetDimensions()
262
@*/
263
PetscErrorCode EPSSetDimensions(EPS eps,int nev,int ncv)
264
{
265
  PetscFunctionBegin;
266
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
267
 
1282 slepc 268
  if( nev != PETSC_IGNORE ) {
269
    if (nev<1) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of nev. Must be > 0");
526 dsic.upv.es!antodo 270
    eps->nev = nev;
271
    eps->setupcalled = 0;
272
  }
1282 slepc 273
  if( ncv != PETSC_IGNORE ) {
274
    if (ncv == PETSC_DECIDE || ncv == PETSC_DEFAULT) {
275
      eps->ncv = 0;
276
    } else {
277
      if (ncv<1) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Illegal value of ncv. Must be > 0");
526 dsic.upv.es!antodo 278
      eps->ncv = ncv;
279
    }
280
    eps->setupcalled = 0;
281
  }
282
  PetscFunctionReturn(0);
283
}
284
 
285
#undef __FUNCT__  
286
#define __FUNCT__ "EPSSetWhichEigenpairs"
287
/*@
288
    EPSSetWhichEigenpairs - Specifies which portion of the spectrum is
289
    to be sought.
290
 
291
    Collective on EPS
292
 
293
    Input Parameter:
294
.   eps - eigensolver context obtained from EPSCreate()
295
 
296
    Output Parameter:
297
.   which - the portion of the spectrum to be sought
298
 
299
    Possible values:
300
    The parameter 'which' can have one of these values:
301
 
302
+     EPS_LARGEST_MAGNITUDE - largest eigenvalues in magnitude (default)
303
.     EPS_SMALLEST_MAGNITUDE - smallest eigenvalues in magnitude
304
.     EPS_LARGEST_REAL - largest real parts
305
.     EPS_SMALLEST_REAL - smallest real parts
306
.     EPS_LARGEST_IMAGINARY - largest imaginary parts
307
-     EPS_SMALLEST_IMAGINARY - smallest imaginary parts
308
 
309
    Options Database Keys:
310
+   -eps_largest_magnitude - Sets largest eigenvalues in magnitude
311
.   -eps_smallest_magnitude - Sets smallest eigenvalues in magnitude
312
.   -eps_largest_real - Sets largest real parts
313
.   -eps_smallest_real - Sets smallest real parts
314
.   -eps_largest_imaginary - Sets largest imaginary parts in magnitude
315
-   -eps_smallest_imaginary - Sets smallest imaginary parts in magnitude
316
 
317
    Notes:
318
    Not all eigensolvers implemented in EPS account for all the possible values
319
    stated above. Also, some values make sense only for certain types of
320
    problems. If SLEPc is compiled for real numbers EPS_LARGEST_IMAGINARY
321
    and EPS_SMALLEST_IMAGINARY use the absolute value of the imaginary part
322
    for eigenvalue selection.    
323
 
324
    Level: intermediate
325
 
1364 slepc 326
.seealso: EPSGetWhichEigenpairs(), EPSSortEigenvalues(), EPSWhich
526 dsic.upv.es!antodo 327
@*/
328
PetscErrorCode EPSSetWhichEigenpairs(EPS eps,EPSWhich which)
329
{
330
  PetscFunctionBegin;
331
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 332
  switch (which) {
333
    case EPS_LARGEST_MAGNITUDE:
334
    case EPS_SMALLEST_MAGNITUDE:
335
    case EPS_LARGEST_REAL:
336
    case EPS_SMALLEST_REAL:
337
    case EPS_LARGEST_IMAGINARY:
338
    case EPS_SMALLEST_IMAGINARY:
1373 slepc 339
      if (eps->which != which) {
340
        eps->setupcalled = 0;
341
        eps->which = which;
342
      }
1273 slepc 343
      break;
344
    default:
345
      SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value");
346
  }  
526 dsic.upv.es!antodo 347
  PetscFunctionReturn(0);
348
}
349
 
350
#undef __FUNCT__  
351
#define __FUNCT__ "EPSGetWhichEigenpairs"
707 dsic.upv.es!antodo 352
/*@C
526 dsic.upv.es!antodo 353
    EPSGetWhichEigenpairs - Returns which portion of the spectrum is to be
354
    sought.
355
 
356
    Not Collective
357
 
358
    Input Parameter:
359
.   eps - eigensolver context obtained from EPSCreate()
360
 
361
    Output Parameter:
362
.   which - the portion of the spectrum to be sought
363
 
364
    Notes:
365
    See EPSSetWhichEigenpairs() for possible values of which
366
 
367
    Level: intermediate
368
 
1364 slepc 369
.seealso: EPSSetWhichEigenpairs(), EPSWhich
526 dsic.upv.es!antodo 370
@*/
371
PetscErrorCode EPSGetWhichEigenpairs(EPS eps,EPSWhich *which)
372
{
373
  PetscFunctionBegin;
374
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 375
  PetscValidPointer(which,2);
526 dsic.upv.es!antodo 376
  *which = eps->which;
377
  PetscFunctionReturn(0);
378
}
379
 
380
#undef __FUNCT__  
381
#define __FUNCT__ "EPSSetProblemType"
382
/*@
383
   EPSSetProblemType - Specifies the type of the eigenvalue problem.
384
 
385
   Collective on EPS
386
 
387
   Input Parameters:
388
+  eps      - the eigensolver context
389
-  type     - a known type of eigenvalue problem
390
 
391
   Options Database Keys:
392
+  -eps_hermitian - Hermitian eigenvalue problem
393
.  -eps_gen_hermitian - generalized Hermitian eigenvalue problem
394
.  -eps_non_hermitian - non-Hermitian eigenvalue problem
395
-  -eps_gen_non_hermitian - generalized non-Hermitian eigenvalue problem
396
 
397
   Note:  
398
   Allowed values for the problem type are: Hermitian (EPS_HEP), non-Hermitian
399
   (EPS_NHEP), generalized Hermitian (EPS_GHEP) and generalized non-Hermitian
400
   (EPS_GNHEP).
401
 
402
   This function must be used to instruct SLEPc to exploit symmetry. If no
403
   problem type is specified, by default a non-Hermitian problem is assumed
404
   (either standard or generalized). If the user knows that the problem is
405
   Hermitian (i.e. A=A^H) of generalized Hermitian (i.e. A=A^H, B=B^H, and
406
   B positive definite) then it is recommended to set the problem type so
407
   that eigensolver can exploit these properties.
408
 
409
   Level: beginner
410
 
1364 slepc 411
.seealso: EPSSetOperators(), EPSSetType(), EPSGetProblemType(), EPSProblemType
526 dsic.upv.es!antodo 412
@*/
413
PetscErrorCode EPSSetProblemType(EPS eps,EPSProblemType type)
414
{
415
  PetscFunctionBegin;
416
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
417
 
418
  switch (type) {
419
    case EPS_HEP:
420
      eps->isgeneralized = PETSC_FALSE;
421
      eps->ishermitian = PETSC_TRUE;
1358 slepc 422
      eps->ispositive = PETSC_FALSE;
526 dsic.upv.es!antodo 423
      break;      
424
    case EPS_NHEP:
425
      eps->isgeneralized = PETSC_FALSE;
426
      eps->ishermitian = PETSC_FALSE;
1358 slepc 427
      eps->ispositive = PETSC_FALSE;
526 dsic.upv.es!antodo 428
      break;
429
    case EPS_GHEP:
430
      eps->isgeneralized = PETSC_TRUE;
431
      eps->ishermitian = PETSC_TRUE;
1358 slepc 432
      eps->ispositive = PETSC_TRUE;
526 dsic.upv.es!antodo 433
      break;
434
    case EPS_GNHEP:
435
      eps->isgeneralized = PETSC_TRUE;
436
      eps->ishermitian = PETSC_FALSE;
1358 slepc 437
      eps->ispositive = PETSC_FALSE;
526 dsic.upv.es!antodo 438
      break;
1358 slepc 439
    case EPS_PGNHEP:
440
      eps->isgeneralized = PETSC_TRUE;
441
      eps->ishermitian = PETSC_FALSE;
442
      eps->ispositive = PETSC_TRUE;
443
      break;
526 dsic.upv.es!antodo 444
/*
445
    case EPS_CSEP:
446
      eps->isgeneralized = PETSC_FALSE;
447
      eps->ishermitian = PETSC_FALSE;
448
      ierr = STSetBilinearForm(eps->OP,STINNER_SYMMETRIC);CHKERRQ(ierr);
449
      break;
450
    case EPS_GCSEP:
451
      eps->isgeneralized = PETSC_TRUE;
452
      eps->ishermitian = PETSC_FALSE;
453
      ierr = STSetBilinearForm(eps->OP,STINNER_B_SYMMETRIC);CHKERRQ(ierr);
454
      break;
455
*/
456
    default:
457
      SETERRQ(PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type");
458
  }
459
  eps->problem_type = type;
460
 
461
  PetscFunctionReturn(0);
462
}
463
 
464
#undef __FUNCT__  
465
#define __FUNCT__ "EPSGetProblemType"
707 dsic.upv.es!antodo 466
/*@C
526 dsic.upv.es!antodo 467
   EPSGetProblemType - Gets the problem type from the EPS object.
468
 
469
   Not Collective
470
 
471
   Input Parameter:
472
.  eps - the eigensolver context
473
 
474
   Output Parameter:
475
.  type - name of EPS problem type
476
 
477
   Level: intermediate
478
 
1364 slepc 479
.seealso: EPSSetProblemType(), EPSProblemType
526 dsic.upv.es!antodo 480
@*/
481
PetscErrorCode EPSGetProblemType(EPS eps,EPSProblemType *type)
482
{
483
  PetscFunctionBegin;
484
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 485
  PetscValidPointer(type,2);
526 dsic.upv.es!antodo 486
  *type = eps->problem_type;
487
  PetscFunctionReturn(0);
488
}
489
 
490
#undef __FUNCT__  
780 dsic.upv.es!jroman 491
#define __FUNCT__ "EPSSetClass"
492
/*@
493
   EPSSetClass - Specifies the eigensolver class: either one-sided or two-sided.
494
 
495
   Collective on EPS
496
 
497
   Input Parameters:
498
+  eps      - the eigensolver context
499
-  class    - the class of solver
500
 
501
   Options Database Keys:
502
+  -eps_oneside - one-sided solver
503
-  -eps_twoside - two-sided solver
504
 
505
   Note:  
506
   Allowed solver classes are: one-sided (EPS_ONE_SIDE) and two-sided (EPS_TWO_SIDE).
507
   One-sided eigensolvers are the standard ones, which allow the computation of
508
   eigenvalues and (right) eigenvectors, whereas two-sided eigensolvers compute
509
   left eigenvectors as well.
510
 
1364 slepc 511
   Level: intermediate
780 dsic.upv.es!jroman 512
 
513
.seealso: EPSGetLeftVector(), EPSComputeRelativeErrorLeft(), EPSSetLeftInitialVector(),
1364 slepc 514
   EPSGetClass(), EPSClass
780 dsic.upv.es!jroman 515
@*/
796 dsic.upv.es!antodo 516
PetscErrorCode EPSSetClass(EPS eps,EPSClass cl)
780 dsic.upv.es!jroman 517
{
518
  PetscErrorCode ierr;
519
 
520
  PetscFunctionBegin;
521
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
522
 
796 dsic.upv.es!antodo 523
  if (cl != EPS_ONE_SIDE && cl != EPS_TWO_SIDE) SETERRQ(PETSC_ERR_ARG_WRONG,"Unknown eigensolver class");
524
  if (eps->solverclass!=cl) {
780 dsic.upv.es!jroman 525
    if (eps->solverclass == EPS_TWO_SIDE) { ierr = EPSFreeSolution(eps);CHKERRQ(ierr); }
796 dsic.upv.es!antodo 526
    eps->solverclass = cl;
780 dsic.upv.es!jroman 527
  }
528
 
529
  PetscFunctionReturn(0);
530
}
531
 
532
#undef __FUNCT__  
533
#define __FUNCT__ "EPSGetClass"
534
/*@C
535
   EPSGetClass - Gets the eigensolver class from the EPS object.
536
 
537
   Not Collective
538
 
539
   Input Parameter:
540
.  eps - the eigensolver context
541
 
542
   Output Parameter:
543
.  class - class of EPS solver (either one-sided or two-sided)
544
 
545
   Level: intermediate
546
 
1364 slepc 547
.seealso: EPSSetClass(), EPSClass
780 dsic.upv.es!jroman 548
@*/
796 dsic.upv.es!antodo 549
PetscErrorCode EPSGetClass(EPS eps,EPSClass *cl)
780 dsic.upv.es!jroman 550
{
551
  PetscFunctionBegin;
552
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 553
  PetscValidPointer(cl,2);
796 dsic.upv.es!antodo 554
  *cl = eps->solverclass;
780 dsic.upv.es!jroman 555
  PetscFunctionReturn(0);
556
}
557
 
558
#undef __FUNCT__  
526 dsic.upv.es!antodo 559
#define __FUNCT__ "EPSSetOptionsPrefix"
560
/*@C
561
   EPSSetOptionsPrefix - Sets the prefix used for searching for all
562
   EPS options in the database.
563
 
564
   Collective on EPS
565
 
566
   Input Parameters:
567
+  eps - the eigensolver context
568
-  prefix - the prefix string to prepend to all EPS option requests
569
 
570
   Notes:
571
   A hyphen (-) must NOT be given at the beginning of the prefix name.
572
   The first character of all runtime options is AUTOMATICALLY the
573
   hyphen.
574
 
575
   For example, to distinguish between the runtime options for two
576
   different EPS contexts, one could call
577
.vb
578
      EPSSetOptionsPrefix(eps1,"eig1_")
579
      EPSSetOptionsPrefix(eps2,"eig2_")
580
.ve
581
 
582
   Level: advanced
583
 
584
.seealso: EPSAppendOptionsPrefix(), EPSGetOptionsPrefix()
585
@*/
1248 slepc 586
PetscErrorCode EPSSetOptionsPrefix(EPS eps,const char *prefix)
526 dsic.upv.es!antodo 587
{
588
  PetscErrorCode ierr;
589
  PetscFunctionBegin;
590
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
591
  ierr = PetscObjectSetOptionsPrefix((PetscObject)eps, prefix);CHKERRQ(ierr);
592
  ierr = STSetOptionsPrefix(eps->OP,prefix);CHKERRQ(ierr);
1345 slepc 593
  ierr = IPSetOptionsPrefix(eps->ip,prefix);CHKERRQ(ierr);
594
  ierr = IPAppendOptionsPrefix(eps->ip,"eps_");CHKERRQ(ierr);
526 dsic.upv.es!antodo 595
  PetscFunctionReturn(0);  
596
}
597
 
598
#undef __FUNCT__  
599
#define __FUNCT__ "EPSAppendOptionsPrefix"
600
/*@C
601
   EPSAppendOptionsPrefix - Appends to the prefix used for searching for all
602
   EPS options in the database.
603
 
604
   Collective on EPS
605
 
606
   Input Parameters:
607
+  eps - the eigensolver context
608
-  prefix - the prefix string to prepend to all EPS option requests
609
 
610
   Notes:
611
   A hyphen (-) must NOT be given at the beginning of the prefix name.
612
   The first character of all runtime options is AUTOMATICALLY the hyphen.
613
 
614
   Level: advanced
615
 
616
.seealso: EPSSetOptionsPrefix(), EPSGetOptionsPrefix()
617
@*/
1248 slepc 618
PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix)
526 dsic.upv.es!antodo 619
{
620
  PetscErrorCode ierr;
621
  PetscFunctionBegin;
622
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
623
  ierr = PetscObjectAppendOptionsPrefix((PetscObject)eps, prefix);CHKERRQ(ierr);
624
  ierr = STAppendOptionsPrefix(eps->OP,prefix); CHKERRQ(ierr);
1345 slepc 625
  ierr = IPSetOptionsPrefix(eps->ip,prefix);CHKERRQ(ierr);
626
  ierr = IPAppendOptionsPrefix(eps->ip,"eps_");CHKERRQ(ierr);
526 dsic.upv.es!antodo 627
  PetscFunctionReturn(0);
628
}
629
 
630
#undef __FUNCT__  
631
#define __FUNCT__ "EPSGetOptionsPrefix"
632
/*@C
633
   EPSGetOptionsPrefix - Gets the prefix used for searching for all
634
   EPS options in the database.
635
 
636
   Not Collective
637
 
638
   Input Parameters:
639
.  eps - the eigensolver context
640
 
641
   Output Parameters:
642
.  prefix - pointer to the prefix string used is returned
643
 
644
   Notes: On the fortran side, the user should pass in a string 'prefix' of
645
   sufficient length to hold the prefix.
646
 
647
   Level: advanced
648
 
649
.seealso: EPSSetOptionsPrefix(), EPSAppendOptionsPrefix()
650
@*/
812 dsic.upv.es!antodo 651
PetscErrorCode EPSGetOptionsPrefix(EPS eps,const char *prefix[])
526 dsic.upv.es!antodo 652
{
653
  PetscErrorCode ierr;
654
  PetscFunctionBegin;
655
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 656
  PetscValidPointer(prefix,2);
526 dsic.upv.es!antodo 657
  ierr = PetscObjectGetOptionsPrefix((PetscObject)eps, prefix);CHKERRQ(ierr);
658
  PetscFunctionReturn(0);
659
}