Subversion Repositories slepc-dev

Rev

Go to most recent revision | 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:
339
      eps->which = which;
340
      break;
341
    default:
342
      SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,"Invalid 'which' value");
343
  }  
526 dsic.upv.es!antodo 344
  PetscFunctionReturn(0);
345
}
346
 
347
#undef __FUNCT__  
348
#define __FUNCT__ "EPSGetWhichEigenpairs"
707 dsic.upv.es!antodo 349
/*@C
526 dsic.upv.es!antodo 350
    EPSGetWhichEigenpairs - Returns which portion of the spectrum is to be
351
    sought.
352
 
353
    Not Collective
354
 
355
    Input Parameter:
356
.   eps - eigensolver context obtained from EPSCreate()
357
 
358
    Output Parameter:
359
.   which - the portion of the spectrum to be sought
360
 
361
    Notes:
362
    See EPSSetWhichEigenpairs() for possible values of which
363
 
364
    Level: intermediate
365
 
1364 slepc 366
.seealso: EPSSetWhichEigenpairs(), EPSWhich
526 dsic.upv.es!antodo 367
@*/
368
PetscErrorCode EPSGetWhichEigenpairs(EPS eps,EPSWhich *which)
369
{
370
  PetscFunctionBegin;
371
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 372
  PetscValidPointer(which,2);
526 dsic.upv.es!antodo 373
  *which = eps->which;
374
  PetscFunctionReturn(0);
375
}
376
 
377
#undef __FUNCT__  
378
#define __FUNCT__ "EPSSetProblemType"
379
/*@
380
   EPSSetProblemType - Specifies the type of the eigenvalue problem.
381
 
382
   Collective on EPS
383
 
384
   Input Parameters:
385
+  eps      - the eigensolver context
386
-  type     - a known type of eigenvalue problem
387
 
388
   Options Database Keys:
389
+  -eps_hermitian - Hermitian eigenvalue problem
390
.  -eps_gen_hermitian - generalized Hermitian eigenvalue problem
391
.  -eps_non_hermitian - non-Hermitian eigenvalue problem
392
-  -eps_gen_non_hermitian - generalized non-Hermitian eigenvalue problem
393
 
394
   Note:  
395
   Allowed values for the problem type are: Hermitian (EPS_HEP), non-Hermitian
396
   (EPS_NHEP), generalized Hermitian (EPS_GHEP) and generalized non-Hermitian
397
   (EPS_GNHEP).
398
 
399
   This function must be used to instruct SLEPc to exploit symmetry. If no
400
   problem type is specified, by default a non-Hermitian problem is assumed
401
   (either standard or generalized). If the user knows that the problem is
402
   Hermitian (i.e. A=A^H) of generalized Hermitian (i.e. A=A^H, B=B^H, and
403
   B positive definite) then it is recommended to set the problem type so
404
   that eigensolver can exploit these properties.
405
 
406
   Level: beginner
407
 
1364 slepc 408
.seealso: EPSSetOperators(), EPSSetType(), EPSGetProblemType(), EPSProblemType
526 dsic.upv.es!antodo 409
@*/
410
PetscErrorCode EPSSetProblemType(EPS eps,EPSProblemType type)
411
{
412
  PetscFunctionBegin;
413
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
414
 
415
  switch (type) {
416
    case EPS_HEP:
417
      eps->isgeneralized = PETSC_FALSE;
418
      eps->ishermitian = PETSC_TRUE;
1358 slepc 419
      eps->ispositive = PETSC_FALSE;
526 dsic.upv.es!antodo 420
      break;      
421
    case EPS_NHEP:
422
      eps->isgeneralized = PETSC_FALSE;
423
      eps->ishermitian = PETSC_FALSE;
1358 slepc 424
      eps->ispositive = PETSC_FALSE;
526 dsic.upv.es!antodo 425
      break;
426
    case EPS_GHEP:
427
      eps->isgeneralized = PETSC_TRUE;
428
      eps->ishermitian = PETSC_TRUE;
1358 slepc 429
      eps->ispositive = PETSC_TRUE;
526 dsic.upv.es!antodo 430
      break;
431
    case EPS_GNHEP:
432
      eps->isgeneralized = PETSC_TRUE;
433
      eps->ishermitian = PETSC_FALSE;
1358 slepc 434
      eps->ispositive = PETSC_FALSE;
526 dsic.upv.es!antodo 435
      break;
1358 slepc 436
    case EPS_PGNHEP:
437
      eps->isgeneralized = PETSC_TRUE;
438
      eps->ishermitian = PETSC_FALSE;
439
      eps->ispositive = PETSC_TRUE;
440
      break;
526 dsic.upv.es!antodo 441
/*
442
    case EPS_CSEP:
443
      eps->isgeneralized = PETSC_FALSE;
444
      eps->ishermitian = PETSC_FALSE;
445
      ierr = STSetBilinearForm(eps->OP,STINNER_SYMMETRIC);CHKERRQ(ierr);
446
      break;
447
    case EPS_GCSEP:
448
      eps->isgeneralized = PETSC_TRUE;
449
      eps->ishermitian = PETSC_FALSE;
450
      ierr = STSetBilinearForm(eps->OP,STINNER_B_SYMMETRIC);CHKERRQ(ierr);
451
      break;
452
*/
453
    default:
454
      SETERRQ(PETSC_ERR_ARG_WRONG,"Unknown eigenvalue problem type");
455
  }
456
  eps->problem_type = type;
457
 
458
  PetscFunctionReturn(0);
459
}
460
 
461
#undef __FUNCT__  
462
#define __FUNCT__ "EPSGetProblemType"
707 dsic.upv.es!antodo 463
/*@C
526 dsic.upv.es!antodo 464
   EPSGetProblemType - Gets the problem type from the EPS object.
465
 
466
   Not Collective
467
 
468
   Input Parameter:
469
.  eps - the eigensolver context
470
 
471
   Output Parameter:
472
.  type - name of EPS problem type
473
 
474
   Level: intermediate
475
 
1364 slepc 476
.seealso: EPSSetProblemType(), EPSProblemType
526 dsic.upv.es!antodo 477
@*/
478
PetscErrorCode EPSGetProblemType(EPS eps,EPSProblemType *type)
479
{
480
  PetscFunctionBegin;
481
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 482
  PetscValidPointer(type,2);
526 dsic.upv.es!antodo 483
  *type = eps->problem_type;
484
  PetscFunctionReturn(0);
485
}
486
 
487
#undef __FUNCT__  
780 dsic.upv.es!jroman 488
#define __FUNCT__ "EPSSetClass"
489
/*@
490
   EPSSetClass - Specifies the eigensolver class: either one-sided or two-sided.
491
 
492
   Collective on EPS
493
 
494
   Input Parameters:
495
+  eps      - the eigensolver context
496
-  class    - the class of solver
497
 
498
   Options Database Keys:
499
+  -eps_oneside - one-sided solver
500
-  -eps_twoside - two-sided solver
501
 
502
   Note:  
503
   Allowed solver classes are: one-sided (EPS_ONE_SIDE) and two-sided (EPS_TWO_SIDE).
504
   One-sided eigensolvers are the standard ones, which allow the computation of
505
   eigenvalues and (right) eigenvectors, whereas two-sided eigensolvers compute
506
   left eigenvectors as well.
507
 
1364 slepc 508
   Level: intermediate
780 dsic.upv.es!jroman 509
 
510
.seealso: EPSGetLeftVector(), EPSComputeRelativeErrorLeft(), EPSSetLeftInitialVector(),
1364 slepc 511
   EPSGetClass(), EPSClass
780 dsic.upv.es!jroman 512
@*/
796 dsic.upv.es!antodo 513
PetscErrorCode EPSSetClass(EPS eps,EPSClass cl)
780 dsic.upv.es!jroman 514
{
515
  PetscErrorCode ierr;
516
 
517
  PetscFunctionBegin;
518
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
519
 
796 dsic.upv.es!antodo 520
  if (cl != EPS_ONE_SIDE && cl != EPS_TWO_SIDE) SETERRQ(PETSC_ERR_ARG_WRONG,"Unknown eigensolver class");
521
  if (eps->solverclass!=cl) {
780 dsic.upv.es!jroman 522
    if (eps->solverclass == EPS_TWO_SIDE) { ierr = EPSFreeSolution(eps);CHKERRQ(ierr); }
796 dsic.upv.es!antodo 523
    eps->solverclass = cl;
780 dsic.upv.es!jroman 524
  }
525
 
526
  PetscFunctionReturn(0);
527
}
528
 
529
#undef __FUNCT__  
530
#define __FUNCT__ "EPSGetClass"
531
/*@C
532
   EPSGetClass - Gets the eigensolver class from the EPS object.
533
 
534
   Not Collective
535
 
536
   Input Parameter:
537
.  eps - the eigensolver context
538
 
539
   Output Parameter:
540
.  class - class of EPS solver (either one-sided or two-sided)
541
 
542
   Level: intermediate
543
 
1364 slepc 544
.seealso: EPSSetClass(), EPSClass
780 dsic.upv.es!jroman 545
@*/
796 dsic.upv.es!antodo 546
PetscErrorCode EPSGetClass(EPS eps,EPSClass *cl)
780 dsic.upv.es!jroman 547
{
548
  PetscFunctionBegin;
549
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 550
  PetscValidPointer(cl,2);
796 dsic.upv.es!antodo 551
  *cl = eps->solverclass;
780 dsic.upv.es!jroman 552
  PetscFunctionReturn(0);
553
}
554
 
555
#undef __FUNCT__  
526 dsic.upv.es!antodo 556
#define __FUNCT__ "EPSSetOptionsPrefix"
557
/*@C
558
   EPSSetOptionsPrefix - Sets the prefix used for searching for all
559
   EPS options in the database.
560
 
561
   Collective on EPS
562
 
563
   Input Parameters:
564
+  eps - the eigensolver context
565
-  prefix - the prefix string to prepend to all EPS option requests
566
 
567
   Notes:
568
   A hyphen (-) must NOT be given at the beginning of the prefix name.
569
   The first character of all runtime options is AUTOMATICALLY the
570
   hyphen.
571
 
572
   For example, to distinguish between the runtime options for two
573
   different EPS contexts, one could call
574
.vb
575
      EPSSetOptionsPrefix(eps1,"eig1_")
576
      EPSSetOptionsPrefix(eps2,"eig2_")
577
.ve
578
 
579
   Level: advanced
580
 
581
.seealso: EPSAppendOptionsPrefix(), EPSGetOptionsPrefix()
582
@*/
1248 slepc 583
PetscErrorCode EPSSetOptionsPrefix(EPS eps,const char *prefix)
526 dsic.upv.es!antodo 584
{
585
  PetscErrorCode ierr;
586
  PetscFunctionBegin;
587
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
588
  ierr = PetscObjectSetOptionsPrefix((PetscObject)eps, prefix);CHKERRQ(ierr);
589
  ierr = STSetOptionsPrefix(eps->OP,prefix);CHKERRQ(ierr);
1345 slepc 590
  ierr = IPSetOptionsPrefix(eps->ip,prefix);CHKERRQ(ierr);
591
  ierr = IPAppendOptionsPrefix(eps->ip,"eps_");CHKERRQ(ierr);
526 dsic.upv.es!antodo 592
  PetscFunctionReturn(0);  
593
}
594
 
595
#undef __FUNCT__  
596
#define __FUNCT__ "EPSAppendOptionsPrefix"
597
/*@C
598
   EPSAppendOptionsPrefix - Appends to the prefix used for searching for all
599
   EPS options in the database.
600
 
601
   Collective on EPS
602
 
603
   Input Parameters:
604
+  eps - the eigensolver context
605
-  prefix - the prefix string to prepend to all EPS option requests
606
 
607
   Notes:
608
   A hyphen (-) must NOT be given at the beginning of the prefix name.
609
   The first character of all runtime options is AUTOMATICALLY the hyphen.
610
 
611
   Level: advanced
612
 
613
.seealso: EPSSetOptionsPrefix(), EPSGetOptionsPrefix()
614
@*/
1248 slepc 615
PetscErrorCode EPSAppendOptionsPrefix(EPS eps,const char *prefix)
526 dsic.upv.es!antodo 616
{
617
  PetscErrorCode ierr;
618
  PetscFunctionBegin;
619
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
620
  ierr = PetscObjectAppendOptionsPrefix((PetscObject)eps, prefix);CHKERRQ(ierr);
621
  ierr = STAppendOptionsPrefix(eps->OP,prefix); CHKERRQ(ierr);
1345 slepc 622
  ierr = IPSetOptionsPrefix(eps->ip,prefix);CHKERRQ(ierr);
623
  ierr = IPAppendOptionsPrefix(eps->ip,"eps_");CHKERRQ(ierr);
526 dsic.upv.es!antodo 624
  PetscFunctionReturn(0);
625
}
626
 
627
#undef __FUNCT__  
628
#define __FUNCT__ "EPSGetOptionsPrefix"
629
/*@C
630
   EPSGetOptionsPrefix - Gets the prefix used for searching for all
631
   EPS options in the database.
632
 
633
   Not Collective
634
 
635
   Input Parameters:
636
.  eps - the eigensolver context
637
 
638
   Output Parameters:
639
.  prefix - pointer to the prefix string used is returned
640
 
641
   Notes: On the fortran side, the user should pass in a string 'prefix' of
642
   sufficient length to hold the prefix.
643
 
644
   Level: advanced
645
 
646
.seealso: EPSSetOptionsPrefix(), EPSAppendOptionsPrefix()
647
@*/
812 dsic.upv.es!antodo 648
PetscErrorCode EPSGetOptionsPrefix(EPS eps,const char *prefix[])
526 dsic.upv.es!antodo 649
{
650
  PetscErrorCode ierr;
651
  PetscFunctionBegin;
652
  PetscValidHeaderSpecific(eps,EPS_COOKIE,1);
1273 slepc 653
  PetscValidPointer(prefix,2);
526 dsic.upv.es!antodo 654
  ierr = PetscObjectGetOptionsPrefix((PetscObject)eps, prefix);CHKERRQ(ierr);
655
  PetscFunctionReturn(0);
656
}