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
519 dsic.upv.es!antodo 1
/*
2
     The basic EPS routines, Create, View, etc. are here.
1376 slepc 3
 
4
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1672 slepc 5
   SLEPc - Scalable Library for Eigenvalue Problem Computations
2116 eromero 6
   Copyright (c) 2002-2010, Universidad Politecnica de Valencia, Spain
1376 slepc 7
 
1672 slepc 8
   This file is part of SLEPc.
9
 
10
   SLEPc is free software: you can redistribute it and/or modify it under  the
11
   terms of version 3 of the GNU Lesser General Public License as published by
12
   the Free Software Foundation.
13
 
14
   SLEPc  is  distributed in the hope that it will be useful, but WITHOUT  ANY
15
   WARRANTY;  without even the implied warranty of MERCHANTABILITY or  FITNESS
16
   FOR  A  PARTICULAR PURPOSE. See the GNU Lesser General Public  License  for
17
   more details.
18
 
19
   You  should have received a copy of the GNU Lesser General  Public  License
20
   along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
1376 slepc 21
   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
519 dsic.upv.es!antodo 22
*/
1376 slepc 23
 
2283 jroman 24
#include <private/epsimpl.h>      /*I "slepceps.h" I*/
519 dsic.upv.es!antodo 25
 
2376 jroman 26
PetscFList       EPSList = 0;
27
PetscBool        EPSRegisterAllCalled = PETSC_FALSE;
28
PetscClassId     EPS_CLASSID = 0;
29
PetscLogEvent    EPS_SetUp = 0,EPS_Solve = 0,EPS_Dense = 0;
2216 jroman 30
static PetscBool EPSPackageInitialized = PETSC_FALSE;
519 dsic.upv.es!antodo 31
 
2322 jroman 32
const char *EPSPowerShiftTypes[] = {"CONSTANT","RAYLEIGH","WILKINSON","EPSPowerShiftType","EPS_POWER_SHIFT_",0};
33
const char *EPSLanczosReorthogTypes[] = {"LOCAL","FULL","SELECTIVE","PERIODIC","PARTIAL","DELAYED","EPSLanczosReorthogType","EPS_LANCZOS_REORTHOG_",0};
34
const char *EPSPRIMMEMethods[] = {"DYNAMIC","DEFAULT_MIN_TIME","DEFAULT_MIN_MATVECS","ARNOLDI","GD","GD_PLUSK","GD_OLSEN_PLUSK","JD_OLSEN_PLUSK","RQI","JDQR","JDQMR","JDQMR_ETOL","SUBSPACE_ITERATION","LOBPCG_ORTHOBASIS","LOBPCG_ORTHOBASISW","EPSPRIMMEMethod","EPS_PRIMME_",0};
2321 jroman 35
 
2489 jroman 36
#undef __FUNCT__
1851 antodo 37
#define __FUNCT__ "EPSFinalizePackage"
38
/*@C
1853 antodo 39
  EPSFinalizePackage - This function destroys everything in the Slepc interface to the EPS package. It is
40
  called from SlepcFinalize().
1851 antodo 41
 
42
  Level: developer
43
 
1853 antodo 44
.seealso: SlepcFinalize()
1851 antodo 45
@*/
46
PetscErrorCode EPSFinalizePackage(void)
47
{
48
  PetscFunctionBegin;
49
  EPSPackageInitialized = PETSC_FALSE;
50
  EPSList               = 0;
2376 jroman 51
  EPSRegisterAllCalled  = PETSC_FALSE;
1851 antodo 52
  PetscFunctionReturn(0);
53
}
54
 
2489 jroman 55
#undef __FUNCT__
842 dsic.upv.es!antodo 56
#define __FUNCT__ "EPSInitializePackage"
57
/*@C
58
  EPSInitializePackage - This function initializes everything in the EPS package. It is called
59
  from PetscDLLibraryRegister() when using dynamic libraries, and on the first call to EPSCreate()
60
  when using static libraries.
61
 
62
  Input Parameter:
63
  path - The dynamic library path, or PETSC_NULL
64
 
65
  Level: developer
66
 
67
.seealso: SlepcInitialize()
68
@*/
2212 jroman 69
PetscErrorCode EPSInitializePackage(const char *path) {
2317 jroman 70
  char           logList[256];
71
  char           *className;
72
  PetscBool      opt;
842 dsic.upv.es!antodo 73
  PetscErrorCode ierr;
74
 
75
  PetscFunctionBegin;
1851 antodo 76
  if (EPSPackageInitialized) PetscFunctionReturn(0);
77
  EPSPackageInitialized = PETSC_TRUE;
842 dsic.upv.es!antodo 78
  /* Register Classes */
2213 jroman 79
  ierr = PetscClassIdRegister("Eigenproblem Solver",&EPS_CLASSID);CHKERRQ(ierr);
842 dsic.upv.es!antodo 80
  /* Register Constructors */
81
  ierr = EPSRegisterAll(path);CHKERRQ(ierr);
82
  /* Register Events */
2213 jroman 83
  ierr = PetscLogEventRegister("EPSSetUp",EPS_CLASSID,&EPS_SetUp);CHKERRQ(ierr);
84
  ierr = PetscLogEventRegister("EPSSolve",EPS_CLASSID,&EPS_Solve);CHKERRQ(ierr);
2330 jroman 85
  ierr = PetscLogEventRegister("EPSDense",EPS_CLASSID,&EPS_Dense);CHKERRQ(ierr);
842 dsic.upv.es!antodo 86
  /* Process info exclusions */
2331 jroman 87
  ierr = PetscOptionsGetString(PETSC_NULL,"-info_exclude",logList,256,&opt);CHKERRQ(ierr);
842 dsic.upv.es!antodo 88
  if (opt) {
2331 jroman 89
    ierr = PetscStrstr(logList,"eps",&className);CHKERRQ(ierr);
842 dsic.upv.es!antodo 90
    if (className) {
2213 jroman 91
      ierr = PetscInfoDeactivateClass(EPS_CLASSID);CHKERRQ(ierr);
842 dsic.upv.es!antodo 92
    }
93
  }
94
  /* Process summary exclusions */
2331 jroman 95
  ierr = PetscOptionsGetString(PETSC_NULL,"-log_summary_exclude",logList,256,&opt);CHKERRQ(ierr);
842 dsic.upv.es!antodo 96
  if (opt) {
2331 jroman 97
    ierr = PetscStrstr(logList,"eps",&className);CHKERRQ(ierr);
842 dsic.upv.es!antodo 98
    if (className) {
2213 jroman 99
      ierr = PetscLogEventDeactivateClass(EPS_CLASSID);CHKERRQ(ierr);
842 dsic.upv.es!antodo 100
    }
101
  }
1851 antodo 102
  ierr = PetscRegisterFinalize(EPSFinalizePackage);CHKERRQ(ierr);
842 dsic.upv.es!antodo 103
  PetscFunctionReturn(0);
104
}
105
 
2489 jroman 106
#undef __FUNCT__
519 dsic.upv.es!antodo 107
#define __FUNCT__ "EPSView"
108
/*@C
109
   EPSView - Prints the EPS data structure.
110
 
111
   Collective on EPS
112
 
113
   Input Parameters:
114
+  eps - the eigenproblem solver context
115
-  viewer - optional visualization context
116
 
117
   Options Database Key:
118
.  -eps_view -  Calls EPSView() at end of EPSSolve()
119
 
120
   Note:
121
   The available visualization contexts include
122
+     PETSC_VIEWER_STDOUT_SELF - standard output (default)
123
-     PETSC_VIEWER_STDOUT_WORLD - synchronized standard
124
         output where only the first processor opens
125
         the file.  All other processors send their
126
         data to the first processor to print.
127
 
128
   The user can open an alternative visualization context with
129
   PetscViewerASCIIOpen() - output to a specified file.
130
 
131
   Level: beginner
132
 
133
.seealso: STView(), PetscViewerASCIIOpen()
134
@*/
135
PetscErrorCode EPSView(EPS eps,PetscViewer viewer)
136
{
137
  PetscErrorCode ierr;
1818 jroman 138
  const char     *type,*extr,*bal;
2216 jroman 139
  PetscBool      isascii;
519 dsic.upv.es!antodo 140
 
141
  PetscFunctionBegin;
2213 jroman 142
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1422 slepc 143
  if (!viewer) viewer = PETSC_VIEWER_STDOUT_(((PetscObject)eps)->comm);
2213 jroman 144
  PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,2);
519 dsic.upv.es!antodo 145
  PetscCheckSameComm(eps,1,viewer,2);
146
 
147
#if defined(PETSC_USE_COMPLEX)
148
#define HERM "hermitian"
149
#else
150
#define HERM "symmetric"
151
#endif
2215 jroman 152
  ierr = PetscTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&isascii);CHKERRQ(ierr);
519 dsic.upv.es!antodo 153
  if (isascii) {
2224 jroman 154
    ierr = PetscObjectPrintClassNamePrefixType((PetscObject)eps,viewer,"EPS Object");CHKERRQ(ierr);
2365 jroman 155
    if (eps->ops->view) {
156
      ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);
157
      ierr = (*eps->ops->view)(eps,viewer);CHKERRQ(ierr);
158
      ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);
159
    }
2231 jroman 160
    if (eps->problem_type) {
161
      switch (eps->problem_type) {
162
        case EPS_HEP:   type = HERM " eigenvalue problem"; break;
163
        case EPS_GHEP:  type = "generalized " HERM " eigenvalue problem"; break;
164
        case EPS_NHEP:  type = "non-" HERM " eigenvalue problem"; break;
165
        case EPS_GNHEP: type = "generalized non-" HERM " eigenvalue problem"; break;
166
        case EPS_PGNHEP: type = "generalized non-" HERM " eigenvalue problem with " HERM " positive definite B"; break;
167
        case EPS_GHIEP: type = "generalized " HERM "-indefinite eigenvalue problem"; break;
168
        default: SETERRQ(((PetscObject)eps)->comm,1,"Wrong value of eps->problem_type");
169
      }
170
    } else type = "not yet set";
519 dsic.upv.es!antodo 171
    ierr = PetscViewerASCIIPrintf(viewer,"  problem type: %s\n",type);CHKERRQ(ierr);
1560 slepc 172
    if (eps->extraction) {
173
      switch (eps->extraction) {
174
        case EPS_RITZ:             extr = "Rayleigh-Ritz"; break;
175
        case EPS_HARMONIC:         extr = "harmonic Ritz"; break;
2040 eromero 176
        case EPS_HARMONIC_RELATIVE:extr = "relative harmonic Ritz"; break;
177
        case EPS_HARMONIC_RIGHT:   extr = "right harmonic Ritz"; break;
178
        case EPS_HARMONIC_LARGEST: extr = "largest harmonic Ritz"; break;
1560 slepc 179
        case EPS_REFINED:          extr = "refined Ritz"; break;
180
        case EPS_REFINED_HARMONIC: extr = "refined harmonic Ritz"; break;
2214 jroman 181
        default: SETERRQ(((PetscObject)eps)->comm,1,"Wrong value of eps->extraction");
1426 slepc 182
      }
1560 slepc 183
      ierr = PetscViewerASCIIPrintf(viewer,"  extraction type: %s\n",extr);CHKERRQ(ierr);
1426 slepc 184
    }
1940 jroman 185
    if (eps->balance && !eps->ishermitian && eps->balance!=EPS_BALANCE_NONE) {
1799 jroman 186
      switch (eps->balance) {
1940 jroman 187
        case EPS_BALANCE_ONESIDE:   bal = "one-sided Krylov"; break;
188
        case EPS_BALANCE_TWOSIDE:   bal = "two-sided Krylov"; break;
189
        case EPS_BALANCE_USER:      bal = "user-defined matrix"; break;
2214 jroman 190
        default: SETERRQ(((PetscObject)eps)->comm,1,"Wrong value of eps->balance");
1799 jroman 191
      }
1804 jroman 192
      ierr = PetscViewerASCIIPrintf(viewer,"  balancing enabled: %s",bal);CHKERRQ(ierr);
1940 jroman 193
      if (eps->balance==EPS_BALANCE_ONESIDE || eps->balance==EPS_BALANCE_TWOSIDE) {
2394 jroman 194
        ierr = PetscViewerASCIIPrintf(viewer,", with its=%D",eps->balance_its);CHKERRQ(ierr);
1804 jroman 195
      }
1940 jroman 196
      if (eps->balance==EPS_BALANCE_TWOSIDE && eps->balance_cutoff!=0.0) {
2394 jroman 197
        ierr = PetscViewerASCIIPrintf(viewer," and cutoff=%G",eps->balance_cutoff);CHKERRQ(ierr);
1799 jroman 198
      }
199
      ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr);
200
    }
1425 slepc 201
    ierr = PetscViewerASCIIPrintf(viewer,"  selected portion of the spectrum: ");CHKERRQ(ierr);
1942 jroman 202
    if (!eps->which) {
203
      ierr = PetscViewerASCIIPrintf(viewer,"not yet set\n");CHKERRQ(ierr);
204
    } else switch (eps->which) {
1945 jroman 205
      case EPS_WHICH_USER:
1782 antodo 206
        ierr = PetscViewerASCIIPrintf(viewer,"user defined\n");CHKERRQ(ierr);
207
        break;
208
      case EPS_TARGET_MAGNITUDE:
1818 jroman 209
#if !defined(PETSC_USE_COMPLEX)
2394 jroman 210
        ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %G (in magnitude)\n",eps->target);CHKERRQ(ierr);
1818 jroman 211
#else
2394 jroman 212
        ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %G+%G i (in magnitude)\n",PetscRealPart(eps->target),PetscImaginaryPart(eps->target));CHKERRQ(ierr);
1818 jroman 213
#endif
214
        break;
1782 antodo 215
      case EPS_TARGET_REAL:
1425 slepc 216
#if !defined(PETSC_USE_COMPLEX)
2394 jroman 217
        ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %G (along the real axis)\n",eps->target);CHKERRQ(ierr);
1425 slepc 218
#else
2394 jroman 219
        ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %G+%G i (along the real axis)\n",PetscRealPart(eps->target),PetscImaginaryPart(eps->target));CHKERRQ(ierr);
1425 slepc 220
#endif
1782 antodo 221
        break;
1818 jroman 222
#if defined(PETSC_USE_COMPLEX)
223
      case EPS_TARGET_IMAGINARY:
2394 jroman 224
        ierr = PetscViewerASCIIPrintf(viewer,"closest to target: %G+%G i (along the imaginary axis)\n",PetscRealPart(eps->target),PetscImaginaryPart(eps->target));CHKERRQ(ierr);
1818 jroman 225
        break;
226
#endif
227
      case EPS_LARGEST_MAGNITUDE:
228
        ierr = PetscViewerASCIIPrintf(viewer,"largest eigenvalues in magnitude\n");CHKERRQ(ierr);
229
        break;
230
      case EPS_SMALLEST_MAGNITUDE:
231
        ierr = PetscViewerASCIIPrintf(viewer,"smallest eigenvalues in magnitude\n");CHKERRQ(ierr);
232
        break;
233
      case EPS_LARGEST_REAL:
234
        ierr = PetscViewerASCIIPrintf(viewer,"largest real parts\n");CHKERRQ(ierr);
235
        break;
236
      case EPS_SMALLEST_REAL:
237
        ierr = PetscViewerASCIIPrintf(viewer,"smallest real parts\n");CHKERRQ(ierr);
238
        break;
239
      case EPS_LARGEST_IMAGINARY:
240
        ierr = PetscViewerASCIIPrintf(viewer,"largest imaginary parts\n");CHKERRQ(ierr);
241
        break;
242
      case EPS_SMALLEST_IMAGINARY:
243
        ierr = PetscViewerASCIIPrintf(viewer,"smallest imaginary parts\n");CHKERRQ(ierr);
244
        break;
2403 jroman 245
      case EPS_ALL:
246
        ierr = PetscViewerASCIIPrintf(viewer,"all eigenvalues in interval [%g,%g]\n",eps->inta,eps->intb);CHKERRQ(ierr);
247
        break;
2214 jroman 248
      default: SETERRQ(((PetscObject)eps)->comm,1,"Wrong value of eps->which");
1782 antodo 249
    }    
1944 jroman 250
    if (eps->leftvecs) {
251
      ierr = PetscViewerASCIIPrintf(viewer,"  computing left eigenvectors also\n");CHKERRQ(ierr);
252
    }
2031 jroman 253
    if (eps->trueres) {
254
      ierr = PetscViewerASCIIPrintf(viewer,"  computing true residuals explicitly\n");CHKERRQ(ierr);
255
    }
2041 eromero 256
    if (eps->trackall) {
2046 jroman 257
      ierr = PetscViewerASCIIPrintf(viewer,"  computing all residuals (for tracking convergence)\n");CHKERRQ(ierr);
2041 eromero 258
    }
2394 jroman 259
    ierr = PetscViewerASCIIPrintf(viewer,"  number of eigenvalues (nev): %D\n",eps->nev);CHKERRQ(ierr);
260
    ierr = PetscViewerASCIIPrintf(viewer,"  number of column vectors (ncv): %D\n",eps->ncv);CHKERRQ(ierr);
1575 slepc 261
    ierr = PetscViewerASCIIPrintf(viewer,"  maximum dimension of projected problem (mpd): %d\n",eps->mpd);CHKERRQ(ierr);
2394 jroman 262
    ierr = PetscViewerASCIIPrintf(viewer,"  maximum number of iterations: %D\n",eps->max_it);
263
    ierr = PetscViewerASCIIPrintf(viewer,"  tolerance: %G\n",eps->tol);CHKERRQ(ierr);
2175 jroman 264
    ierr = PetscViewerASCIIPrintf(viewer,"  convergence test: ");CHKERRQ(ierr);
2083 eromero 265
    switch(eps->conv) {
266
    case EPS_CONV_ABS:
2175 jroman 267
      ierr = PetscViewerASCIIPrintf(viewer,"absolute\n");CHKERRQ(ierr);break;
2083 eromero 268
    case EPS_CONV_EIG:
2175 jroman 269
      ierr = PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue\n");CHKERRQ(ierr);break;
2083 eromero 270
    case EPS_CONV_NORM:
2175 jroman 271
      ierr = PetscViewerASCIIPrintf(viewer,"relative to the eigenvalue and matrix norms\n");CHKERRQ(ierr);break;
2083 eromero 272
    default:
2175 jroman 273
      ierr = PetscViewerASCIIPrintf(viewer,"user-defined\n");CHKERRQ(ierr);break;
2083 eromero 274
    }
1938 jroman 275
    if (eps->nini!=0) {
2394 jroman 276
      ierr = PetscViewerASCIIPrintf(viewer,"  dimension of user-provided initial space: %D\n",PetscAbs(eps->nini));CHKERRQ(ierr);
1938 jroman 277
    }
278
    if (eps->ninil!=0) {
2394 jroman 279
      ierr = PetscViewerASCIIPrintf(viewer,"  dimension of user-provided initial left space: %D\n",PetscAbs(eps->ninil));CHKERRQ(ierr);
1938 jroman 280
    }
281
    if (eps->nds>0) {
2394 jroman 282
      ierr = PetscViewerASCIIPrintf(viewer,"  dimension of user-provided deflation space: %D\n",eps->nds);CHKERRQ(ierr);
1938 jroman 283
    }
2394 jroman 284
    ierr = PetscViewerASCIIPrintf(viewer,"  estimates of matrix norms (%s): norm(A)=%G",eps->adaptive?"adaptive":"constant",eps->nrma);CHKERRQ(ierr);
1957 jroman 285
    if (eps->isgeneralized) {
2394 jroman 286
      ierr = PetscViewerASCIIPrintf(viewer,", norm(B)=%G",eps->nrmb);CHKERRQ(ierr);
1957 jroman 287
    }
288
    ierr = PetscViewerASCIIPrintf(viewer,"\n");CHKERRQ(ierr);
519 dsic.upv.es!antodo 289
  } else {
290
    if (eps->ops->view) {
291
      ierr = (*eps->ops->view)(eps,viewer);CHKERRQ(ierr);
292
    }
293
  }
2381 jroman 294
  if (!eps->ip) { ierr = EPSGetIP(eps,&eps->ip);CHKERRQ(ierr); }
2365 jroman 295
  ierr = IPView(eps->ip,viewer);CHKERRQ(ierr);
2371 jroman 296
  if (!eps->OP) { ierr = EPSGetST(eps,&eps->OP);CHKERRQ(ierr); }
2365 jroman 297
  ierr = STView(eps->OP,viewer);CHKERRQ(ierr);
519 dsic.upv.es!antodo 298
  PetscFunctionReturn(0);
299
}
300
 
2489 jroman 301
#undef __FUNCT__
519 dsic.upv.es!antodo 302
#define __FUNCT__ "EPSCreate"
303
/*@C
304
   EPSCreate - Creates the default EPS context.
305
 
306
   Collective on MPI_Comm
307
 
308
   Input Parameter:
309
.  comm - MPI communicator
310
 
311
   Output Parameter:
312
.  eps - location to put the EPS context
313
 
314
   Note:
1198 slepc 315
   The default EPS type is EPSKRYLOVSCHUR
519 dsic.upv.es!antodo 316
 
317
   Level: beginner
318
 
319
.seealso: EPSSetUp(), EPSSolve(), EPSDestroy(), EPS
320
@*/
321
PetscErrorCode EPSCreate(MPI_Comm comm,EPS *outeps)
322
{
323
  PetscErrorCode ierr;
324
  EPS            eps;
325
 
326
  PetscFunctionBegin;
327
  PetscValidPointer(outeps,2);
328
  *outeps = 0;
329
 
2469 jroman 330
  ierr = PetscHeaderCreate(eps,_p_EPS,struct _EPSOps,EPS_CLASSID,-1,"EPS","Eigenvalue Problem Solver","EPS",comm,EPSDestroy,EPSView);CHKERRQ(ierr);
519 dsic.upv.es!antodo 331
 
332
  eps->max_it          = 0;
333
  eps->nev             = 1;
334
  eps->ncv             = 0;
1575 slepc 335
  eps->mpd             = 0;
519 dsic.upv.es!antodo 336
  eps->allocated_ncv   = 0;
1932 jroman 337
  eps->nini            = 0;
1937 jroman 338
  eps->ninil           = 0;
519 dsic.upv.es!antodo 339
  eps->nds             = 0;
1282 slepc 340
  eps->tol             = 1e-7;
2175 jroman 341
  eps->conv            = EPS_CONV_EIG;
2083 eromero 342
  eps->conv_func       = EPSEigRelativeConverged;
1785 antodo 343
  eps->conv_ctx        = PETSC_NULL;
1942 jroman 344
  eps->which           = (EPSWhich)0;
1782 antodo 345
  eps->which_func      = PETSC_NULL;
346
  eps->which_ctx       = PETSC_NULL;
1944 jroman 347
  eps->leftvecs        = PETSC_FALSE;
2031 jroman 348
  eps->trueres         = PETSC_FALSE;
2041 eromero 349
  eps->trackall        = PETSC_FALSE;
1425 slepc 350
  eps->target          = 0.0;
2403 jroman 351
  eps->inta            = 0.0;
352
  eps->intb            = 0.0;
519 dsic.upv.es!antodo 353
  eps->evecsavailable  = PETSC_FALSE;
354
  eps->problem_type    = (EPSProblemType)0;
1560 slepc 355
  eps->extraction      = (EPSExtraction)0;
1799 jroman 356
  eps->balance         = (EPSBalance)0;
357
  eps->balance_its     = 5;
358
  eps->balance_cutoff  = 1e-8;
1957 jroman 359
  eps->nrma            = 1.0;
360
  eps->nrmb            = 1.0;
361
  eps->adaptive        = PETSC_FALSE;
519 dsic.upv.es!antodo 362
 
363
  eps->V               = 0;
780 dsic.upv.es!jroman 364
  eps->W               = 0;
519 dsic.upv.es!antodo 365
  eps->T               = 0;
2309 jroman 366
  eps->D               = 0;
519 dsic.upv.es!antodo 367
  eps->DS              = 0;
1937 jroman 368
  eps->IS              = 0;
369
  eps->ISL             = 0;
2410 jroman 370
  eps->t               = 0;
1917 jroman 371
  eps->ds_ortho        = PETSC_FALSE;
519 dsic.upv.es!antodo 372
  eps->eigr            = 0;
373
  eps->eigi            = 0;
374
  eps->errest          = 0;
780 dsic.upv.es!jroman 375
  eps->errest_left     = 0;
519 dsic.upv.es!antodo 376
  eps->OP              = 0;
1345 slepc 377
  eps->ip              = 0;
2309 jroman 378
  eps->rand            = 0;
519 dsic.upv.es!antodo 379
  eps->data            = 0;
380
  eps->nconv           = 0;
381
  eps->its             = 0;
382
  eps->perm            = PETSC_NULL;
383
 
384
  eps->nwork           = 0;
385
  eps->work            = 0;
386
  eps->isgeneralized   = PETSC_FALSE;
387
  eps->ishermitian     = PETSC_FALSE;
1358 slepc 388
  eps->ispositive      = PETSC_FALSE;
519 dsic.upv.es!antodo 389
  eps->setupcalled     = 0;
390
  eps->reason          = EPS_CONVERGED_ITERATING;
391
  eps->numbermonitors  = 0;
392
 
2348 jroman 393
  ierr = PetscRandomCreate(comm,&eps->rand);CHKERRQ(ierr);
394
  ierr = PetscLogObjectParent(eps,eps->rand);CHKERRQ(ierr);
395
  *outeps = eps;
519 dsic.upv.es!antodo 396
  PetscFunctionReturn(0);
397
}
398
 
2489 jroman 399
#undef __FUNCT__
519 dsic.upv.es!antodo 400
#define __FUNCT__ "EPSSetType"
401
/*@C
402
   EPSSetType - Selects the particular solver to be used in the EPS object.
403
 
2328 jroman 404
   Logically Collective on EPS
519 dsic.upv.es!antodo 405
 
406
   Input Parameters:
2327 jroman 407
+  eps  - the eigensolver context
408
-  type - a known method
519 dsic.upv.es!antodo 409
 
410
   Options Database Key:
411
.  -eps_type <method> - Sets the method; use -help for a list
412
    of available methods
413
 
414
   Notes:  
545 dsic.upv.es!jroman 415
   See "slepc/include/slepceps.h" for available methods. The default
1198 slepc 416
   is EPSKRYLOVSCHUR.
519 dsic.upv.es!antodo 417
 
418
   Normally, it is best to use the EPSSetFromOptions() command and
419
   then set the EPS type from the options database rather than by using
420
   this routine.  Using the options database provides the user with
421
   maximum flexibility in evaluating the different available methods.
422
   The EPSSetType() routine is provided for those situations where it
423
   is necessary to set the iterative solver independently of the command
424
   line or options database.
425
 
426
   Level: intermediate
427
 
428
.seealso: STSetType(), EPSType
429
@*/
1502 slepc 430
PetscErrorCode EPSSetType(EPS eps,const EPSType type)
519 dsic.upv.es!antodo 431
{
432
  PetscErrorCode ierr,(*r)(EPS);
2216 jroman 433
  PetscBool      match;
519 dsic.upv.es!antodo 434
 
435
  PetscFunctionBegin;
2213 jroman 436
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
519 dsic.upv.es!antodo 437
  PetscValidCharPointer(type,2);
438
 
439
  ierr = PetscTypeCompare((PetscObject)eps,type,&match);CHKERRQ(ierr);
440
  if (match) PetscFunctionReturn(0);
441
 
2300 jroman 442
  ierr = PetscFListFind(EPSList,((PetscObject)eps)->comm,type,PETSC_TRUE,(void (**)(void)) &r);CHKERRQ(ierr);
2348 jroman 443
  if (!r) SETERRQ1(((PetscObject)eps)->comm,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown EPS type given: %s",type);
519 dsic.upv.es!antodo 444
 
2348 jroman 445
  if (eps->ops->destroy) { ierr = (*eps->ops->destroy)(eps);CHKERRQ(ierr); }
446
  ierr = PetscMemzero(eps->ops,sizeof(struct _EPSOps));CHKERRQ(ierr);
519 dsic.upv.es!antodo 447
 
448
  eps->setupcalled = 0;
2348 jroman 449
  ierr = PetscObjectChangeTypeName((PetscObject)eps,type);CHKERRQ(ierr);
2330 jroman 450
  ierr = (*r)(eps);CHKERRQ(ierr);
519 dsic.upv.es!antodo 451
  PetscFunctionReturn(0);
452
}
453
 
2489 jroman 454
#undef __FUNCT__
519 dsic.upv.es!antodo 455
#define __FUNCT__ "EPSGetType"
456
/*@C
457
   EPSGetType - Gets the EPS type as a string from the EPS object.
458
 
459
   Not Collective
460
 
461
   Input Parameter:
462
.  eps - the eigensolver context
463
 
464
   Output Parameter:
465
.  name - name of EPS method
466
 
467
   Level: intermediate
468
 
469
.seealso: EPSSetType()
470
@*/
1501 slepc 471
PetscErrorCode EPSGetType(EPS eps,const EPSType *type)
519 dsic.upv.es!antodo 472
{
473
  PetscFunctionBegin;
2213 jroman 474
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1501 slepc 475
  PetscValidPointer(type,2);
1422 slepc 476
  *type = ((PetscObject)eps)->type_name;
519 dsic.upv.es!antodo 477
  PetscFunctionReturn(0);
478
}
479
 
2489 jroman 480
#undef __FUNCT__
519 dsic.upv.es!antodo 481
#define __FUNCT__ "EPSRegister"
1389 slepc 482
/*@C
483
  EPSRegister - See EPSRegisterDynamic()
484
 
485
  Level: advanced
486
@*/
1509 slepc 487
PetscErrorCode EPSRegister(const char *sname,const char *path,const char *name,PetscErrorCode (*function)(EPS))
519 dsic.upv.es!antodo 488
{
489
  PetscErrorCode ierr;
2374 jroman 490
  char           fullname[PETSC_MAX_PATH_LEN];
519 dsic.upv.es!antodo 491
 
492
  PetscFunctionBegin;
493
  ierr = PetscFListConcat(path,name,fullname);CHKERRQ(ierr);
494
  ierr = PetscFListAdd(&EPSList,sname,fullname,(void (*)(void))function);CHKERRQ(ierr);
495
  PetscFunctionReturn(0);
496
}
497
 
2489 jroman 498
#undef __FUNCT__
1389 slepc 499
#define __FUNCT__ "EPSRegisterDestroy"
500
/*@
501
   EPSRegisterDestroy - Frees the list of EPS methods that were
502
   registered by EPSRegisterDynamic().
503
 
504
   Not Collective
505
 
506
   Level: advanced
507
 
508
.seealso: EPSRegisterDynamic(), EPSRegisterAll()
509
@*/
510
PetscErrorCode EPSRegisterDestroy(void)
511
{
512
  PetscErrorCode ierr;
513
 
514
  PetscFunctionBegin;
515
  ierr = PetscFListDestroy(&EPSList);CHKERRQ(ierr);
2376 jroman 516
  EPSRegisterAllCalled = PETSC_FALSE;
1389 slepc 517
  PetscFunctionReturn(0);
518
}
519
 
2489 jroman 520
#undef __FUNCT__
2348 jroman 521
#define __FUNCT__ "EPSReset"
522
/*@
523
   EPSReset - Resets the EPS context to the setupcalled=0 state and removes any
524
   allocated objects.
525
 
526
   Collective on EPS
527
 
528
   Input Parameter:
529
.  eps - eigensolver context obtained from EPSCreate()
530
 
531
   Level: advanced
532
 
533
.seealso: EPSDestroy()
534
@*/
535
PetscErrorCode EPSReset(EPS eps)
536
{
537
  PetscErrorCode ierr;
538
 
539
  PetscFunctionBegin;
540
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
541
  if (eps->ops->reset) { ierr = (eps->ops->reset)(eps);CHKERRQ(ierr); }
542
  if (eps->OP) { ierr = STReset(eps->OP);CHKERRQ(ierr); }
543
  if (eps->ip) { ierr = IPReset(eps->ip);CHKERRQ(ierr); }
2410 jroman 544
  ierr = VecDestroy(&eps->t);CHKERRQ(ierr);
2348 jroman 545
  ierr = VecDestroy(&eps->D);CHKERRQ(ierr);
546
  eps->setupcalled = 0;
547
  PetscFunctionReturn(0);
548
}
549
 
2489 jroman 550
#undef __FUNCT__
519 dsic.upv.es!antodo 551
#define __FUNCT__ "EPSDestroy"
2310 jroman 552
/*@C
519 dsic.upv.es!antodo 553
   EPSDestroy - Destroys the EPS context.
554
 
555
   Collective on EPS
556
 
557
   Input Parameter:
558
.  eps - eigensolver context obtained from EPSCreate()
559
 
560
   Level: beginner
561
 
562
.seealso: EPSCreate(), EPSSetUp(), EPSSolve()
563
@*/
2308 jroman 564
PetscErrorCode EPSDestroy(EPS *eps)
519 dsic.upv.es!antodo 565
{
566
  PetscErrorCode ierr;
567
 
568
  PetscFunctionBegin;
2308 jroman 569
  if (!*eps) PetscFunctionReturn(0);
570
  PetscValidHeaderSpecific(*eps,EPS_CLASSID,1);
571
  if (--((PetscObject)(*eps))->refct > 0) { *eps = 0; PetscFunctionReturn(0); }
2348 jroman 572
  ierr = EPSReset(*eps);CHKERRQ(ierr);
2308 jroman 573
  ierr = PetscObjectDepublish(*eps);CHKERRQ(ierr);
2348 jroman 574
  if ((*eps)->ops->destroy) { ierr = (*(*eps)->ops->destroy)(*eps);CHKERRQ(ierr); }
2312 jroman 575
  ierr = STDestroy(&(*eps)->OP);CHKERRQ(ierr);
576
  ierr = IPDestroy(&(*eps)->ip);CHKERRQ(ierr);
2308 jroman 577
  ierr = PetscRandomDestroy(&(*eps)->rand);CHKERRQ(ierr);
578
  ierr = EPSRemoveDeflationSpace(*eps);CHKERRQ(ierr);
579
  ierr = EPSMonitorCancel(*eps);CHKERRQ(ierr);
580
  ierr = PetscHeaderDestroy(eps);CHKERRQ(ierr);
519 dsic.upv.es!antodo 581
  PetscFunctionReturn(0);
582
}
583
 
2489 jroman 584
#undef __FUNCT__
1425 slepc 585
#define __FUNCT__ "EPSSetTarget"
586
/*@
587
   EPSSetTarget - Sets the value of the target.
588
 
2328 jroman 589
   Logically Collective on EPS
1425 slepc 590
 
591
   Input Parameters:
592
+  eps    - eigensolver context
593
-  target - the value of the target
594
 
595
   Notes:
596
   The target is a scalar value used to determine the portion of the spectrum
1811 jroman 597
   of interest. It is used in combination with EPSSetWhichEigenpairs().
1425 slepc 598
 
599
   Level: beginner
600
 
601
.seealso: EPSGetTarget(), EPSSetWhichEigenpairs()
602
@*/
603
PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target)
604
{
2074 jroman 605
  PetscErrorCode ierr;
606
 
1425 slepc 607
  PetscFunctionBegin;
2213 jroman 608
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 609
  PetscValidLogicalCollectiveScalar(eps,target,2);
1425 slepc 610
  eps->target = target;
2371 jroman 611
  if (!eps->OP) { ierr = EPSGetST(eps,&eps->OP);CHKERRQ(ierr); }
2074 jroman 612
  ierr = STSetDefaultShift(eps->OP,target);CHKERRQ(ierr);
1425 slepc 613
  PetscFunctionReturn(0);
614
}
615
 
2489 jroman 616
#undef __FUNCT__
1425 slepc 617
#define __FUNCT__ "EPSGetTarget"
618
/*@
619
   EPSGetTarget - Gets the value of the target.
620
 
2328 jroman 621
   Not Collective
1425 slepc 622
 
623
   Input Parameter:
624
.  eps - eigensolver context
625
 
626
   Output Parameter:
627
.  target - the value of the target
628
 
629
   Level: beginner
630
 
631
   Note:
632
   If the target was not set by the user, then zero is returned.
633
 
634
.seealso: EPSSetTarget()
635
@*/
636
PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target)
637
{
638
  PetscFunctionBegin;
2213 jroman 639
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 640
  PetscValidScalarPointer(target,2);
2319 jroman 641
  *target = eps->target;
1425 slepc 642
  PetscFunctionReturn(0);
643
}
644
 
2489 jroman 645
#undef __FUNCT__
2403 jroman 646
#define __FUNCT__ "EPSSetInterval"
647
/*@
648
   EPSSetInterval - Defines the computational interval for spectrum slicing.
649
 
650
   Logically Collective on EPS
651
 
652
   Input Parameters:
653
+  eps  - eigensolver context
654
.  inta - left end of the interval
655
-  intb - right end of the interval
656
 
2460 jroman 657
   Options Database Key:
658
.  -eps_interval <a,b> - set [a,b] as the interval of interest
659
 
660
   Notes:
2403 jroman 661
   Spectrum slicing is a technique employed for computing all eigenvalues of
662
   symmetric eigenproblems in a given interval. This function provides the
663
   interval to be considered. It must be used in combination with EPS_ALL, see
2460 jroman 664
   EPSSetWhichEigenpairs().
665
 
666
   In the command-line option, two values must be provided. For an open interval,
667
   one can give an infinite, e.g., -eps_interval 1.0,inf or -eps_interval -inf,1.0.
668
   An open interval in the programmatic intervace can be specified with
669
   PETSC_MAX_REAL and -PETSC_MAX_REAL.
2403 jroman 670
 
671
   Level: intermediate
672
 
673
.seealso: EPSGetInterval(), EPSSetWhichEigenpairs()
674
@*/
675
PetscErrorCode EPSSetInterval(EPS eps,PetscReal inta,PetscReal intb)
676
{
677
  PetscFunctionBegin;
678
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
679
  PetscValidLogicalCollectiveReal(eps,inta,2);
680
  PetscValidLogicalCollectiveReal(eps,intb,3);
681
  if (inta>=intb) SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_ARG_WRONG,"Badly defined interval, must be inta<intb");
682
  eps->inta = inta;
683
  eps->intb = intb;
684
  PetscFunctionReturn(0);
685
}
686
 
2489 jroman 687
#undef __FUNCT__
2403 jroman 688
#define __FUNCT__ "EPSGetInterval"
689
/*@
690
   EPSGetInterval - Gets the computational interval for spectrum slicing.
691
 
692
   Not Collective
693
 
694
   Input Parameter:
695
.  eps - eigensolver context
696
 
697
   Output Parameters:
698
+  inta - left end of the interval
699
-  intb - right end of the interval
700
 
701
   Level: intermediate
702
 
703
   Note:
704
   If the interval was not set by the user, then zeros are returned.
705
 
706
.seealso: EPSSetInterval()
707
@*/
708
PetscErrorCode EPSGetInterval(EPS eps,PetscReal* inta,PetscReal* intb)
709
{
710
  PetscFunctionBegin;
711
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
712
  PetscValidPointer(inta,2);
713
  PetscValidPointer(intb,3);
714
  if (inta) *inta = eps->inta;
715
  if (intb) *intb = eps->intb;
716
  PetscFunctionReturn(0);
717
}
718
 
2489 jroman 719
#undef __FUNCT__
519 dsic.upv.es!antodo 720
#define __FUNCT__ "EPSSetST"
721
/*@
2327 jroman 722
   EPSSetST - Associates a spectral transformation object to the eigensolver.
519 dsic.upv.es!antodo 723
 
2328 jroman 724
   Collective on EPS
519 dsic.upv.es!antodo 725
 
726
   Input Parameters:
727
+  eps - eigensolver context obtained from EPSCreate()
728
-  st   - the spectral transformation object
729
 
730
   Note:
731
   Use EPSGetST() to retrieve the spectral transformation context (for example,
732
   to free it at the end of the computations).
733
 
2328 jroman 734
   Level: developer
519 dsic.upv.es!antodo 735
 
736
.seealso: EPSGetST()
737
@*/
738
PetscErrorCode EPSSetST(EPS eps,ST st)
739
{
740
  PetscErrorCode ierr;
741
 
742
  PetscFunctionBegin;
2213 jroman 743
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
744
  PetscValidHeaderSpecific(st,ST_CLASSID,2);
519 dsic.upv.es!antodo 745
  PetscCheckSameComm(eps,1,st,2);
1345 slepc 746
  ierr = PetscObjectReference((PetscObject)st);CHKERRQ(ierr);
2330 jroman 747
  ierr = STDestroy(&eps->OP);CHKERRQ(ierr);
519 dsic.upv.es!antodo 748
  eps->OP = st;
2327 jroman 749
  ierr = PetscLogObjectParent(eps,eps->OP);CHKERRQ(ierr);
519 dsic.upv.es!antodo 750
  PetscFunctionReturn(0);
751
}
752
 
2489 jroman 753
#undef __FUNCT__
519 dsic.upv.es!antodo 754
#define __FUNCT__ "EPSGetST"
707 dsic.upv.es!antodo 755
/*@C
519 dsic.upv.es!antodo 756
   EPSGetST - Obtain the spectral transformation (ST) object associated
757
   to the eigensolver object.
758
 
759
   Not Collective
760
 
761
   Input Parameters:
762
.  eps - eigensolver context obtained from EPSCreate()
763
 
764
   Output Parameter:
765
.  st - spectral transformation context
766
 
767
   Level: beginner
768
 
769
.seealso: EPSSetST()
770
@*/
2331 jroman 771
PetscErrorCode EPSGetST(EPS eps,ST *st)
519 dsic.upv.es!antodo 772
{
2371 jroman 773
  PetscErrorCode ierr;
774
 
519 dsic.upv.es!antodo 775
  PetscFunctionBegin;
2213 jroman 776
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1248 slepc 777
  PetscValidPointer(st,2);
2371 jroman 778
  if (!eps->OP) {
779
    ierr = STCreate(((PetscObject)eps)->comm,&eps->OP);CHKERRQ(ierr);
780
    ierr = PetscLogObjectParent(eps,eps->OP);CHKERRQ(ierr);
781
  }
519 dsic.upv.es!antodo 782
  *st = eps->OP;
783
  PetscFunctionReturn(0);
784
}
785
 
2489 jroman 786
#undef __FUNCT__
1345 slepc 787
#define __FUNCT__ "EPSSetIP"
788
/*@
1811 jroman 789
   EPSSetIP - Associates an inner product object to the eigensolver.
1345 slepc 790
 
2328 jroman 791
   Collective on EPS
1345 slepc 792
 
793
   Input Parameters:
794
+  eps - eigensolver context obtained from EPSCreate()
795
-  ip  - the inner product object
796
 
797
   Note:
798
   Use EPSGetIP() to retrieve the inner product context (for example,
799
   to free it at the end of the computations).
800
 
801
   Level: advanced
802
 
803
.seealso: EPSGetIP()
804
@*/
805
PetscErrorCode EPSSetIP(EPS eps,IP ip)
806
{
807
  PetscErrorCode ierr;
808
 
809
  PetscFunctionBegin;
2213 jroman 810
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
811
  PetscValidHeaderSpecific(ip,IP_CLASSID,2);
1345 slepc 812
  PetscCheckSameComm(eps,1,ip,2);
813
  ierr = PetscObjectReference((PetscObject)ip);CHKERRQ(ierr);
2330 jroman 814
  ierr = IPDestroy(&eps->ip);CHKERRQ(ierr);
1345 slepc 815
  eps->ip = ip;
2327 jroman 816
  ierr = PetscLogObjectParent(eps,eps->ip);CHKERRQ(ierr);
1345 slepc 817
  PetscFunctionReturn(0);
818
}
819
 
2489 jroman 820
#undef __FUNCT__
1345 slepc 821
#define __FUNCT__ "EPSGetIP"
822
/*@C
2328 jroman 823
   EPSGetIP - Obtain the inner product object associated to the eigensolver object.
1345 slepc 824
 
825
   Not Collective
826
 
827
   Input Parameters:
828
.  eps - eigensolver context obtained from EPSCreate()
829
 
830
   Output Parameter:
831
.  ip - inner product context
832
 
1349 slepc 833
   Level: advanced
1345 slepc 834
 
835
.seealso: EPSSetIP()
836
@*/
837
PetscErrorCode EPSGetIP(EPS eps,IP *ip)
838
{
2381 jroman 839
  PetscErrorCode ierr;
840
 
1345 slepc 841
  PetscFunctionBegin;
2213 jroman 842
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1345 slepc 843
  PetscValidPointer(ip,2);
2381 jroman 844
  if (!eps->ip) {
845
    ierr = IPCreate(((PetscObject)eps)->comm,&eps->ip);CHKERRQ(ierr);
846
    ierr = PetscLogObjectParent(eps,eps->ip);CHKERRQ(ierr);
847
  }
1345 slepc 848
  *ip = eps->ip;
849
  PetscFunctionReturn(0);
850
}
851
 
2489 jroman 852
#undef __FUNCT__
519 dsic.upv.es!antodo 853
#define __FUNCT__ "EPSIsGeneralized"
854
/*@
855
   EPSIsGeneralized - Ask if the EPS object corresponds to a generalized
856
   eigenvalue problem.
857
 
858
   Not collective
859
 
860
   Input Parameter:
861
.  eps - the eigenproblem solver context
862
 
863
   Output Parameter:
864
.  is - the answer
865
 
866
   Level: intermediate
867
 
2328 jroman 868
.seealso: EPSIsHermitian()
519 dsic.upv.es!antodo 869
@*/
2216 jroman 870
PetscErrorCode EPSIsGeneralized(EPS eps,PetscBool* is)
519 dsic.upv.es!antodo 871
{
872
  PetscFunctionBegin;
2213 jroman 873
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2498 jroman 874
  *is = eps->isgeneralized;
519 dsic.upv.es!antodo 875
  PetscFunctionReturn(0);
876
}
877
 
2489 jroman 878
#undef __FUNCT__
519 dsic.upv.es!antodo 879
#define __FUNCT__ "EPSIsHermitian"
880
/*@
881
   EPSIsHermitian - Ask if the EPS object corresponds to a Hermitian
882
   eigenvalue problem.
883
 
884
   Not collective
885
 
886
   Input Parameter:
887
.  eps - the eigenproblem solver context
888
 
889
   Output Parameter:
890
.  is - the answer
891
 
892
   Level: intermediate
893
 
2328 jroman 894
.seealso: EPSIsGeneralized()
519 dsic.upv.es!antodo 895
@*/
2216 jroman 896
PetscErrorCode EPSIsHermitian(EPS eps,PetscBool* is)
519 dsic.upv.es!antodo 897
{
898
  PetscFunctionBegin;
2213 jroman 899
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2498 jroman 900
  *is = eps->ishermitian;
519 dsic.upv.es!antodo 901
  PetscFunctionReturn(0);
902
}