Subversion Repositories slepc-dev

Rev

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
 
519 dsic.upv.es!antodo 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
 
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
 
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
 
301
#undef __FUNCT__  
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
 
2213 jroman 330
  ierr = PetscHeaderCreate(eps,_p_EPS,struct _EPSOps,EPS_CLASSID,-1,"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);
2407 jroman 394
  ierr = PetscRandomSetFromOptions(eps->rand);CHKERRQ(ierr);
2348 jroman 395
  ierr = PetscLogObjectParent(eps,eps->rand);CHKERRQ(ierr);
396
  *outeps = eps;
519 dsic.upv.es!antodo 397
  PetscFunctionReturn(0);
398
}
399
 
400
#undef __FUNCT__  
401
#define __FUNCT__ "EPSSetType"
402
/*@C
403
   EPSSetType - Selects the particular solver to be used in the EPS object.
404
 
2328 jroman 405
   Logically Collective on EPS
519 dsic.upv.es!antodo 406
 
407
   Input Parameters:
2327 jroman 408
+  eps  - the eigensolver context
409
-  type - a known method
519 dsic.upv.es!antodo 410
 
411
   Options Database Key:
412
.  -eps_type <method> - Sets the method; use -help for a list
413
    of available methods
414
 
415
   Notes:  
545 dsic.upv.es!jroman 416
   See "slepc/include/slepceps.h" for available methods. The default
1198 slepc 417
   is EPSKRYLOVSCHUR.
519 dsic.upv.es!antodo 418
 
419
   Normally, it is best to use the EPSSetFromOptions() command and
420
   then set the EPS type from the options database rather than by using
421
   this routine.  Using the options database provides the user with
422
   maximum flexibility in evaluating the different available methods.
423
   The EPSSetType() routine is provided for those situations where it
424
   is necessary to set the iterative solver independently of the command
425
   line or options database.
426
 
427
   Level: intermediate
428
 
429
.seealso: STSetType(), EPSType
430
@*/
1502 slepc 431
PetscErrorCode EPSSetType(EPS eps,const EPSType type)
519 dsic.upv.es!antodo 432
{
433
  PetscErrorCode ierr,(*r)(EPS);
2216 jroman 434
  PetscBool      match;
519 dsic.upv.es!antodo 435
 
436
  PetscFunctionBegin;
2213 jroman 437
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
519 dsic.upv.es!antodo 438
  PetscValidCharPointer(type,2);
439
 
440
  ierr = PetscTypeCompare((PetscObject)eps,type,&match);CHKERRQ(ierr);
441
  if (match) PetscFunctionReturn(0);
442
 
2300 jroman 443
  ierr = PetscFListFind(EPSList,((PetscObject)eps)->comm,type,PETSC_TRUE,(void (**)(void)) &r);CHKERRQ(ierr);
2348 jroman 444
  if (!r) SETERRQ1(((PetscObject)eps)->comm,PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown EPS type given: %s",type);
519 dsic.upv.es!antodo 445
 
2348 jroman 446
  if (eps->ops->destroy) { ierr = (*eps->ops->destroy)(eps);CHKERRQ(ierr); }
447
  ierr = PetscMemzero(eps->ops,sizeof(struct _EPSOps));CHKERRQ(ierr);
519 dsic.upv.es!antodo 448
 
449
  eps->setupcalled = 0;
2348 jroman 450
  ierr = PetscObjectChangeTypeName((PetscObject)eps,type);CHKERRQ(ierr);
2330 jroman 451
  ierr = (*r)(eps);CHKERRQ(ierr);
519 dsic.upv.es!antodo 452
  PetscFunctionReturn(0);
453
}
454
 
455
#undef __FUNCT__  
456
#define __FUNCT__ "EPSGetType"
457
/*@C
458
   EPSGetType - Gets the EPS type as a string from the EPS object.
459
 
460
   Not Collective
461
 
462
   Input Parameter:
463
.  eps - the eigensolver context
464
 
465
   Output Parameter:
466
.  name - name of EPS method
467
 
468
   Level: intermediate
469
 
470
.seealso: EPSSetType()
471
@*/
1501 slepc 472
PetscErrorCode EPSGetType(EPS eps,const EPSType *type)
519 dsic.upv.es!antodo 473
{
474
  PetscFunctionBegin;
2213 jroman 475
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1501 slepc 476
  PetscValidPointer(type,2);
1422 slepc 477
  *type = ((PetscObject)eps)->type_name;
519 dsic.upv.es!antodo 478
  PetscFunctionReturn(0);
479
}
480
 
481
#undef __FUNCT__  
482
#define __FUNCT__ "EPSRegister"
1389 slepc 483
/*@C
484
  EPSRegister - See EPSRegisterDynamic()
485
 
486
  Level: advanced
487
@*/
1509 slepc 488
PetscErrorCode EPSRegister(const char *sname,const char *path,const char *name,PetscErrorCode (*function)(EPS))
519 dsic.upv.es!antodo 489
{
490
  PetscErrorCode ierr;
2374 jroman 491
  char           fullname[PETSC_MAX_PATH_LEN];
519 dsic.upv.es!antodo 492
 
493
  PetscFunctionBegin;
494
  ierr = PetscFListConcat(path,name,fullname);CHKERRQ(ierr);
495
  ierr = PetscFListAdd(&EPSList,sname,fullname,(void (*)(void))function);CHKERRQ(ierr);
496
  PetscFunctionReturn(0);
497
}
498
 
499
#undef __FUNCT__  
1389 slepc 500
#define __FUNCT__ "EPSRegisterDestroy"
501
/*@
502
   EPSRegisterDestroy - Frees the list of EPS methods that were
503
   registered by EPSRegisterDynamic().
504
 
505
   Not Collective
506
 
507
   Level: advanced
508
 
509
.seealso: EPSRegisterDynamic(), EPSRegisterAll()
510
@*/
511
PetscErrorCode EPSRegisterDestroy(void)
512
{
513
  PetscErrorCode ierr;
514
 
515
  PetscFunctionBegin;
516
  ierr = PetscFListDestroy(&EPSList);CHKERRQ(ierr);
2376 jroman 517
  EPSRegisterAllCalled = PETSC_FALSE;
1389 slepc 518
  PetscFunctionReturn(0);
519
}
520
 
521
#undef __FUNCT__  
2348 jroman 522
#define __FUNCT__ "EPSReset"
523
/*@
524
   EPSReset - Resets the EPS context to the setupcalled=0 state and removes any
525
   allocated objects.
526
 
527
   Collective on EPS
528
 
529
   Input Parameter:
530
.  eps - eigensolver context obtained from EPSCreate()
531
 
532
   Level: advanced
533
 
534
.seealso: EPSDestroy()
535
@*/
536
PetscErrorCode EPSReset(EPS eps)
537
{
538
  PetscErrorCode ierr;
539
 
540
  PetscFunctionBegin;
541
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
542
  if (eps->ops->reset) { ierr = (eps->ops->reset)(eps);CHKERRQ(ierr); }
543
  if (eps->OP) { ierr = STReset(eps->OP);CHKERRQ(ierr); }
544
  if (eps->ip) { ierr = IPReset(eps->ip);CHKERRQ(ierr); }
2410 jroman 545
  ierr = VecDestroy(&eps->t);CHKERRQ(ierr);
2348 jroman 546
  ierr = VecDestroy(&eps->D);CHKERRQ(ierr);
547
  eps->setupcalled = 0;
548
  PetscFunctionReturn(0);
549
}
550
 
551
#undef __FUNCT__  
519 dsic.upv.es!antodo 552
#define __FUNCT__ "EPSDestroy"
2310 jroman 553
/*@C
519 dsic.upv.es!antodo 554
   EPSDestroy - Destroys the EPS context.
555
 
556
   Collective on EPS
557
 
558
   Input Parameter:
559
.  eps - eigensolver context obtained from EPSCreate()
560
 
561
   Level: beginner
562
 
563
.seealso: EPSCreate(), EPSSetUp(), EPSSolve()
564
@*/
2308 jroman 565
PetscErrorCode EPSDestroy(EPS *eps)
519 dsic.upv.es!antodo 566
{
567
  PetscErrorCode ierr;
568
 
569
  PetscFunctionBegin;
2308 jroman 570
  if (!*eps) PetscFunctionReturn(0);
571
  PetscValidHeaderSpecific(*eps,EPS_CLASSID,1);
572
  if (--((PetscObject)(*eps))->refct > 0) { *eps = 0; PetscFunctionReturn(0); }
2348 jroman 573
  ierr = EPSReset(*eps);CHKERRQ(ierr);
2308 jroman 574
  ierr = PetscObjectDepublish(*eps);CHKERRQ(ierr);
2348 jroman 575
  if ((*eps)->ops->destroy) { ierr = (*(*eps)->ops->destroy)(*eps);CHKERRQ(ierr); }
2312 jroman 576
  ierr = STDestroy(&(*eps)->OP);CHKERRQ(ierr);
577
  ierr = IPDestroy(&(*eps)->ip);CHKERRQ(ierr);
2308 jroman 578
  ierr = PetscRandomDestroy(&(*eps)->rand);CHKERRQ(ierr);
579
  ierr = EPSRemoveDeflationSpace(*eps);CHKERRQ(ierr);
580
  ierr = EPSMonitorCancel(*eps);CHKERRQ(ierr);
581
  ierr = PetscHeaderDestroy(eps);CHKERRQ(ierr);
519 dsic.upv.es!antodo 582
  PetscFunctionReturn(0);
583
}
584
 
585
#undef __FUNCT__  
1425 slepc 586
#define __FUNCT__ "EPSSetTarget"
587
/*@
588
   EPSSetTarget - Sets the value of the target.
589
 
2328 jroman 590
   Logically Collective on EPS
1425 slepc 591
 
592
   Input Parameters:
593
+  eps    - eigensolver context
594
-  target - the value of the target
595
 
596
   Notes:
597
   The target is a scalar value used to determine the portion of the spectrum
1811 jroman 598
   of interest. It is used in combination with EPSSetWhichEigenpairs().
1425 slepc 599
 
600
   Level: beginner
601
 
602
.seealso: EPSGetTarget(), EPSSetWhichEigenpairs()
603
@*/
604
PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target)
605
{
2074 jroman 606
  PetscErrorCode ierr;
607
 
1425 slepc 608
  PetscFunctionBegin;
2213 jroman 609
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 610
  PetscValidLogicalCollectiveScalar(eps,target,2);
1425 slepc 611
  eps->target = target;
2371 jroman 612
  if (!eps->OP) { ierr = EPSGetST(eps,&eps->OP);CHKERRQ(ierr); }
2074 jroman 613
  ierr = STSetDefaultShift(eps->OP,target);CHKERRQ(ierr);
1425 slepc 614
  PetscFunctionReturn(0);
615
}
616
 
617
#undef __FUNCT__  
618
#define __FUNCT__ "EPSGetTarget"
619
/*@
620
   EPSGetTarget - Gets the value of the target.
621
 
2328 jroman 622
   Not Collective
1425 slepc 623
 
624
   Input Parameter:
625
.  eps - eigensolver context
626
 
627
   Output Parameter:
628
.  target - the value of the target
629
 
630
   Level: beginner
631
 
632
   Note:
633
   If the target was not set by the user, then zero is returned.
634
 
635
.seealso: EPSSetTarget()
636
@*/
637
PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target)
638
{
639
  PetscFunctionBegin;
2213 jroman 640
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2326 jroman 641
  PetscValidScalarPointer(target,2);
2319 jroman 642
  *target = eps->target;
1425 slepc 643
  PetscFunctionReturn(0);
644
}
645
 
646
#undef __FUNCT__  
2403 jroman 647
#define __FUNCT__ "EPSSetInterval"
648
/*@
649
   EPSSetInterval - Defines the computational interval for spectrum slicing.
650
 
651
   Logically Collective on EPS
652
 
653
   Input Parameters:
654
+  eps  - eigensolver context
655
.  inta - left end of the interval
656
-  intb - right end of the interval
657
 
658
   Note:
659
   Spectrum slicing is a technique employed for computing all eigenvalues of
660
   symmetric eigenproblems in a given interval. This function provides the
661
   interval to be considered. It must be used in combination with EPS_ALL, see
662
   EPSSetWhichEigenpairs()
663
 
664
   Level: intermediate
665
 
666
.seealso: EPSGetInterval(), EPSSetWhichEigenpairs()
667
@*/
668
PetscErrorCode EPSSetInterval(EPS eps,PetscReal inta,PetscReal intb)
669
{
670
  PetscFunctionBegin;
671
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
672
  PetscValidLogicalCollectiveReal(eps,inta,2);
673
  PetscValidLogicalCollectiveReal(eps,intb,3);
674
  if (inta>=intb) SETERRQ(((PetscObject)eps)->comm,PETSC_ERR_ARG_WRONG,"Badly defined interval, must be inta<intb");
675
  eps->inta = inta;
676
  eps->intb = intb;
677
  PetscFunctionReturn(0);
678
}
679
 
680
#undef __FUNCT__  
681
#define __FUNCT__ "EPSGetInterval"
682
/*@
683
   EPSGetInterval - Gets the computational interval for spectrum slicing.
684
 
685
   Not Collective
686
 
687
   Input Parameter:
688
.  eps - eigensolver context
689
 
690
   Output Parameters:
691
+  inta - left end of the interval
692
-  intb - right end of the interval
693
 
694
   Level: intermediate
695
 
696
   Note:
697
   If the interval was not set by the user, then zeros are returned.
698
 
699
.seealso: EPSSetInterval()
700
@*/
701
PetscErrorCode EPSGetInterval(EPS eps,PetscReal* inta,PetscReal* intb)
702
{
703
  PetscFunctionBegin;
704
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
705
  PetscValidPointer(inta,2);
706
  PetscValidPointer(intb,3);
707
  if (inta) *inta = eps->inta;
708
  if (intb) *intb = eps->intb;
709
  PetscFunctionReturn(0);
710
}
711
 
712
#undef __FUNCT__  
519 dsic.upv.es!antodo 713
#define __FUNCT__ "EPSSetST"
714
/*@
2327 jroman 715
   EPSSetST - Associates a spectral transformation object to the eigensolver.
519 dsic.upv.es!antodo 716
 
2328 jroman 717
   Collective on EPS
519 dsic.upv.es!antodo 718
 
719
   Input Parameters:
720
+  eps - eigensolver context obtained from EPSCreate()
721
-  st   - the spectral transformation object
722
 
723
   Note:
724
   Use EPSGetST() to retrieve the spectral transformation context (for example,
725
   to free it at the end of the computations).
726
 
2328 jroman 727
   Level: developer
519 dsic.upv.es!antodo 728
 
729
.seealso: EPSGetST()
730
@*/
731
PetscErrorCode EPSSetST(EPS eps,ST st)
732
{
733
  PetscErrorCode ierr;
734
 
735
  PetscFunctionBegin;
2213 jroman 736
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
737
  PetscValidHeaderSpecific(st,ST_CLASSID,2);
519 dsic.upv.es!antodo 738
  PetscCheckSameComm(eps,1,st,2);
1345 slepc 739
  ierr = PetscObjectReference((PetscObject)st);CHKERRQ(ierr);
2330 jroman 740
  ierr = STDestroy(&eps->OP);CHKERRQ(ierr);
519 dsic.upv.es!antodo 741
  eps->OP = st;
2327 jroman 742
  ierr = PetscLogObjectParent(eps,eps->OP);CHKERRQ(ierr);
519 dsic.upv.es!antodo 743
  PetscFunctionReturn(0);
744
}
745
 
746
#undef __FUNCT__  
747
#define __FUNCT__ "EPSGetST"
707 dsic.upv.es!antodo 748
/*@C
519 dsic.upv.es!antodo 749
   EPSGetST - Obtain the spectral transformation (ST) object associated
750
   to the eigensolver object.
751
 
752
   Not Collective
753
 
754
   Input Parameters:
755
.  eps - eigensolver context obtained from EPSCreate()
756
 
757
   Output Parameter:
758
.  st - spectral transformation context
759
 
760
   Level: beginner
761
 
762
.seealso: EPSSetST()
763
@*/
2331 jroman 764
PetscErrorCode EPSGetST(EPS eps,ST *st)
519 dsic.upv.es!antodo 765
{
2371 jroman 766
  PetscErrorCode ierr;
767
 
519 dsic.upv.es!antodo 768
  PetscFunctionBegin;
2213 jroman 769
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1248 slepc 770
  PetscValidPointer(st,2);
2371 jroman 771
  if (!eps->OP) {
772
    ierr = STCreate(((PetscObject)eps)->comm,&eps->OP);CHKERRQ(ierr);
773
    ierr = PetscLogObjectParent(eps,eps->OP);CHKERRQ(ierr);
774
  }
519 dsic.upv.es!antodo 775
  *st = eps->OP;
776
  PetscFunctionReturn(0);
777
}
778
 
779
#undef __FUNCT__  
1345 slepc 780
#define __FUNCT__ "EPSSetIP"
781
/*@
1811 jroman 782
   EPSSetIP - Associates an inner product object to the eigensolver.
1345 slepc 783
 
2328 jroman 784
   Collective on EPS
1345 slepc 785
 
786
   Input Parameters:
787
+  eps - eigensolver context obtained from EPSCreate()
788
-  ip  - the inner product object
789
 
790
   Note:
791
   Use EPSGetIP() to retrieve the inner product context (for example,
792
   to free it at the end of the computations).
793
 
794
   Level: advanced
795
 
796
.seealso: EPSGetIP()
797
@*/
798
PetscErrorCode EPSSetIP(EPS eps,IP ip)
799
{
800
  PetscErrorCode ierr;
801
 
802
  PetscFunctionBegin;
2213 jroman 803
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
804
  PetscValidHeaderSpecific(ip,IP_CLASSID,2);
1345 slepc 805
  PetscCheckSameComm(eps,1,ip,2);
806
  ierr = PetscObjectReference((PetscObject)ip);CHKERRQ(ierr);
2330 jroman 807
  ierr = IPDestroy(&eps->ip);CHKERRQ(ierr);
1345 slepc 808
  eps->ip = ip;
2327 jroman 809
  ierr = PetscLogObjectParent(eps,eps->ip);CHKERRQ(ierr);
1345 slepc 810
  PetscFunctionReturn(0);
811
}
812
 
813
#undef __FUNCT__  
814
#define __FUNCT__ "EPSGetIP"
815
/*@C
2328 jroman 816
   EPSGetIP - Obtain the inner product object associated to the eigensolver object.
1345 slepc 817
 
818
   Not Collective
819
 
820
   Input Parameters:
821
.  eps - eigensolver context obtained from EPSCreate()
822
 
823
   Output Parameter:
824
.  ip - inner product context
825
 
1349 slepc 826
   Level: advanced
1345 slepc 827
 
828
.seealso: EPSSetIP()
829
@*/
830
PetscErrorCode EPSGetIP(EPS eps,IP *ip)
831
{
2381 jroman 832
  PetscErrorCode ierr;
833
 
1345 slepc 834
  PetscFunctionBegin;
2213 jroman 835
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
1345 slepc 836
  PetscValidPointer(ip,2);
2381 jroman 837
  if (!eps->ip) {
838
    ierr = IPCreate(((PetscObject)eps)->comm,&eps->ip);CHKERRQ(ierr);
839
    ierr = PetscLogObjectParent(eps,eps->ip);CHKERRQ(ierr);
840
  }
1345 slepc 841
  *ip = eps->ip;
842
  PetscFunctionReturn(0);
843
}
844
 
845
#undef __FUNCT__  
519 dsic.upv.es!antodo 846
#define __FUNCT__ "EPSIsGeneralized"
847
/*@
848
   EPSIsGeneralized - Ask if the EPS object corresponds to a generalized
849
   eigenvalue problem.
850
 
851
   Not collective
852
 
853
   Input Parameter:
854
.  eps - the eigenproblem solver context
855
 
856
   Output Parameter:
857
.  is - the answer
858
 
859
   Level: intermediate
860
 
2328 jroman 861
.seealso: EPSIsHermitian()
519 dsic.upv.es!antodo 862
@*/
2216 jroman 863
PetscErrorCode EPSIsGeneralized(EPS eps,PetscBool* is)
519 dsic.upv.es!antodo 864
{
865
  PetscErrorCode ierr;
866
  Mat            B;
867
 
868
  PetscFunctionBegin;
2213 jroman 869
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2371 jroman 870
  if (!eps->OP) { ierr = EPSGetST(eps,&eps->OP);CHKERRQ(ierr); }
519 dsic.upv.es!antodo 871
  ierr = STGetOperators(eps->OP,PETSC_NULL,&B);CHKERRQ(ierr);
2331 jroman 872
  if (B) *is = PETSC_TRUE;
519 dsic.upv.es!antodo 873
  else *is = PETSC_FALSE;
2331 jroman 874
  if (eps->setupcalled) {
875
    if (eps->isgeneralized!=*is) {
2214 jroman 876
      SETERRQ(((PetscObject)eps)->comm,0,"Warning: Inconsistent EPS state");
519 dsic.upv.es!antodo 877
    }
878
  }
879
  PetscFunctionReturn(0);
880
}
881
 
882
#undef __FUNCT__  
883
#define __FUNCT__ "EPSIsHermitian"
884
/*@
885
   EPSIsHermitian - Ask if the EPS object corresponds to a Hermitian
886
   eigenvalue problem.
887
 
888
   Not collective
889
 
890
   Input Parameter:
891
.  eps - the eigenproblem solver context
892
 
893
   Output Parameter:
894
.  is - the answer
895
 
896
   Level: intermediate
897
 
2328 jroman 898
.seealso: EPSIsGeneralized()
519 dsic.upv.es!antodo 899
@*/
2216 jroman 900
PetscErrorCode EPSIsHermitian(EPS eps,PetscBool* is)
519 dsic.upv.es!antodo 901
{
902
  PetscFunctionBegin;
2213 jroman 903
  PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
2331 jroman 904
  if (eps->ishermitian) *is = PETSC_TRUE;
519 dsic.upv.es!antodo 905
  else *is = PETSC_FALSE;
906
  PetscFunctionReturn(0);
907
}