LCOV - code coverage report
Current view: top level - eps/interface - epsbasic.c (source / functions) Hit Total Coverage
Test: SLEPc Lines: 249 268 92.9 %
Date: 2024-03-28 00:28:38 Functions: 20 22 90.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       3             :    SLEPc - Scalable Library for Eigenvalue Problem Computations
       4             :    Copyright (c) 2002-, Universitat Politecnica de Valencia, Spain
       5             : 
       6             :    This file is part of SLEPc.
       7             :    SLEPc is distributed under a 2-clause BSD license (see LICENSE).
       8             :    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
       9             : */
      10             : /*
      11             :    Basic EPS routines
      12             : */
      13             : 
      14             : #include <slepc/private/epsimpl.h>      /*I "slepceps.h" I*/
      15             : 
      16             : /* Logging support */
      17             : PetscClassId      EPS_CLASSID = 0;
      18             : PetscLogEvent     EPS_SetUp = 0,EPS_Solve = 0,EPS_CISS_SVD = 0;
      19             : 
      20             : /* List of registered EPS routines */
      21             : PetscFunctionList EPSList = NULL;
      22             : PetscBool         EPSRegisterAllCalled = PETSC_FALSE;
      23             : 
      24             : /* List of registered EPS monitors */
      25             : PetscFunctionList EPSMonitorList              = NULL;
      26             : PetscFunctionList EPSMonitorCreateList        = NULL;
      27             : PetscFunctionList EPSMonitorDestroyList       = NULL;
      28             : PetscBool         EPSMonitorRegisterAllCalled = PETSC_FALSE;
      29             : 
      30             : /*@
      31             :    EPSCreate - Creates the default EPS context.
      32             : 
      33             :    Collective
      34             : 
      35             :    Input Parameter:
      36             : .  comm - MPI communicator
      37             : 
      38             :    Output Parameter:
      39             : .  outeps - location to put the EPS context
      40             : 
      41             :    Note:
      42             :    The default EPS type is EPSKRYLOVSCHUR
      43             : 
      44             :    Level: beginner
      45             : 
      46             : .seealso: EPSSetUp(), EPSSolve(), EPSDestroy(), EPS
      47             : @*/
      48         590 : PetscErrorCode EPSCreate(MPI_Comm comm,EPS *outeps)
      49             : {
      50         590 :   EPS            eps;
      51             : 
      52         590 :   PetscFunctionBegin;
      53         590 :   PetscAssertPointer(outeps,2);
      54         590 :   *outeps = NULL;
      55         590 :   PetscCall(EPSInitializePackage());
      56         590 :   PetscCall(SlepcHeaderCreate(eps,EPS_CLASSID,"EPS","Eigenvalue Problem Solver","EPS",comm,EPSDestroy,EPSView));
      57             : 
      58         590 :   eps->max_it          = PETSC_DEFAULT;
      59         590 :   eps->nev             = 1;
      60         590 :   eps->ncv             = PETSC_DEFAULT;
      61         590 :   eps->mpd             = PETSC_DEFAULT;
      62         590 :   eps->nini            = 0;
      63         590 :   eps->nds             = 0;
      64         590 :   eps->target          = 0.0;
      65         590 :   eps->tol             = PETSC_DEFAULT;
      66         590 :   eps->conv            = EPS_CONV_REL;
      67         590 :   eps->stop            = EPS_STOP_BASIC;
      68         590 :   eps->which           = (EPSWhich)0;
      69         590 :   eps->inta            = 0.0;
      70         590 :   eps->intb            = 0.0;
      71         590 :   eps->problem_type    = (EPSProblemType)0;
      72         590 :   eps->extraction      = EPS_RITZ;
      73         590 :   eps->balance         = EPS_BALANCE_NONE;
      74         590 :   eps->balance_its     = 5;
      75         590 :   eps->balance_cutoff  = 1e-8;
      76         590 :   eps->trueres         = PETSC_FALSE;
      77         590 :   eps->trackall        = PETSC_FALSE;
      78         590 :   eps->purify          = PETSC_TRUE;
      79         590 :   eps->twosided        = PETSC_FALSE;
      80             : 
      81         590 :   eps->converged       = EPSConvergedRelative;
      82         590 :   eps->convergeduser   = NULL;
      83         590 :   eps->convergeddestroy= NULL;
      84         590 :   eps->stopping        = EPSStoppingBasic;
      85         590 :   eps->stoppinguser    = NULL;
      86         590 :   eps->stoppingdestroy = NULL;
      87         590 :   eps->arbitrary       = NULL;
      88         590 :   eps->convergedctx    = NULL;
      89         590 :   eps->stoppingctx     = NULL;
      90         590 :   eps->arbitraryctx    = NULL;
      91         590 :   eps->numbermonitors  = 0;
      92             : 
      93         590 :   eps->st              = NULL;
      94         590 :   eps->ds              = NULL;
      95         590 :   eps->V               = NULL;
      96         590 :   eps->W               = NULL;
      97         590 :   eps->rg              = NULL;
      98         590 :   eps->D               = NULL;
      99         590 :   eps->IS              = NULL;
     100         590 :   eps->ISL             = NULL;
     101         590 :   eps->defl            = NULL;
     102         590 :   eps->eigr            = NULL;
     103         590 :   eps->eigi            = NULL;
     104         590 :   eps->errest          = NULL;
     105         590 :   eps->rr              = NULL;
     106         590 :   eps->ri              = NULL;
     107         590 :   eps->perm            = NULL;
     108         590 :   eps->nwork           = 0;
     109         590 :   eps->work            = NULL;
     110         590 :   eps->data            = NULL;
     111             : 
     112         590 :   eps->state           = EPS_STATE_INITIAL;
     113         590 :   eps->categ           = EPS_CATEGORY_KRYLOV;
     114         590 :   eps->nconv           = 0;
     115         590 :   eps->its             = 0;
     116         590 :   eps->nloc            = 0;
     117         590 :   eps->nrma            = 0.0;
     118         590 :   eps->nrmb            = 0.0;
     119         590 :   eps->useds           = PETSC_FALSE;
     120         590 :   eps->isgeneralized   = PETSC_FALSE;
     121         590 :   eps->ispositive      = PETSC_FALSE;
     122         590 :   eps->ishermitian     = PETSC_FALSE;
     123         590 :   eps->reason          = EPS_CONVERGED_ITERATING;
     124             : 
     125         590 :   PetscCall(PetscNew(&eps->sc));
     126         590 :   *outeps = eps;
     127         590 :   PetscFunctionReturn(PETSC_SUCCESS);
     128             : }
     129             : 
     130             : /*@C
     131             :    EPSSetType - Selects the particular solver to be used in the EPS object.
     132             : 
     133             :    Logically Collective
     134             : 
     135             :    Input Parameters:
     136             : +  eps  - the eigensolver context
     137             : -  type - a known method
     138             : 
     139             :    Options Database Key:
     140             : .  -eps_type <method> - Sets the method; use -help for a list
     141             :     of available methods
     142             : 
     143             :    Notes:
     144             :    See "slepc/include/slepceps.h" for available methods. The default
     145             :    is EPSKRYLOVSCHUR.
     146             : 
     147             :    Normally, it is best to use the EPSSetFromOptions() command and
     148             :    then set the EPS type from the options database rather than by using
     149             :    this routine.  Using the options database provides the user with
     150             :    maximum flexibility in evaluating the different available methods.
     151             :    The EPSSetType() routine is provided for those situations where it
     152             :    is necessary to set the iterative solver independently of the command
     153             :    line or options database.
     154             : 
     155             :    Level: intermediate
     156             : 
     157             : .seealso: STSetType(), EPSType
     158             : @*/
     159         617 : PetscErrorCode EPSSetType(EPS eps,EPSType type)
     160             : {
     161         617 :   PetscErrorCode (*r)(EPS);
     162         617 :   PetscBool      match;
     163             : 
     164         617 :   PetscFunctionBegin;
     165         617 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     166         617 :   PetscAssertPointer(type,2);
     167             : 
     168         617 :   PetscCall(PetscObjectTypeCompare((PetscObject)eps,type,&match));
     169         617 :   if (match) PetscFunctionReturn(PETSC_SUCCESS);
     170             : 
     171         591 :   PetscCall(PetscFunctionListFind(EPSList,type,&r));
     172         591 :   PetscCheck(r,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_UNKNOWN_TYPE,"Unknown EPS type given: %s",type);
     173             : 
     174         591 :   PetscTryTypeMethod(eps,destroy);
     175         591 :   PetscCall(PetscMemzero(eps->ops,sizeof(struct _EPSOps)));
     176             : 
     177         591 :   eps->state = EPS_STATE_INITIAL;
     178         591 :   PetscCall(PetscObjectChangeTypeName((PetscObject)eps,type));
     179         591 :   PetscCall((*r)(eps));
     180         591 :   PetscFunctionReturn(PETSC_SUCCESS);
     181             : }
     182             : 
     183             : /*@C
     184             :    EPSGetType - Gets the EPS type as a string from the EPS object.
     185             : 
     186             :    Not Collective
     187             : 
     188             :    Input Parameter:
     189             : .  eps - the eigensolver context
     190             : 
     191             :    Output Parameter:
     192             : .  type - name of EPS method
     193             : 
     194             :    Level: intermediate
     195             : 
     196             : .seealso: EPSSetType()
     197             : @*/
     198          97 : PetscErrorCode EPSGetType(EPS eps,EPSType *type)
     199             : {
     200          97 :   PetscFunctionBegin;
     201          97 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     202          97 :   PetscAssertPointer(type,2);
     203          97 :   *type = ((PetscObject)eps)->type_name;
     204          97 :   PetscFunctionReturn(PETSC_SUCCESS);
     205             : }
     206             : 
     207             : /*@C
     208             :    EPSRegister - Adds a method to the eigenproblem solver package.
     209             : 
     210             :    Not Collective
     211             : 
     212             :    Input Parameters:
     213             : +  name - name of a new user-defined solver
     214             : -  function - routine to create the solver context
     215             : 
     216             :    Notes:
     217             :    EPSRegister() may be called multiple times to add several user-defined solvers.
     218             : 
     219             :    Example Usage:
     220             : .vb
     221             :     EPSRegister("my_solver",MySolverCreate);
     222             : .ve
     223             : 
     224             :    Then, your solver can be chosen with the procedural interface via
     225             : $     EPSSetType(eps,"my_solver")
     226             :    or at runtime via the option
     227             : $     -eps_type my_solver
     228             : 
     229             :    Level: advanced
     230             : 
     231             : .seealso: EPSRegisterAll()
     232             : @*/
     233        8235 : PetscErrorCode EPSRegister(const char *name,PetscErrorCode (*function)(EPS))
     234             : {
     235        8235 :   PetscFunctionBegin;
     236        8235 :   PetscCall(EPSInitializePackage());
     237        8235 :   PetscCall(PetscFunctionListAdd(&EPSList,name,function));
     238        8235 :   PetscFunctionReturn(PETSC_SUCCESS);
     239             : }
     240             : 
     241             : /*@C
     242             :    EPSMonitorRegister - Adds EPS monitor routine.
     243             : 
     244             :    Not Collective
     245             : 
     246             :    Input Parameters:
     247             : +  name    - name of a new monitor routine
     248             : .  vtype   - a PetscViewerType for the output
     249             : .  format  - a PetscViewerFormat for the output
     250             : .  monitor - monitor routine
     251             : .  create  - creation routine, or NULL
     252             : -  destroy - destruction routine, or NULL
     253             : 
     254             :    Notes:
     255             :    EPSMonitorRegister() may be called multiple times to add several user-defined monitors.
     256             : 
     257             :    Example Usage:
     258             : .vb
     259             :    EPSMonitorRegister("my_monitor",PETSCVIEWERASCII,PETSC_VIEWER_ASCII_INFO_DETAIL,MyMonitor,NULL,NULL);
     260             : .ve
     261             : 
     262             :    Then, your monitor can be chosen with the procedural interface via
     263             : $      EPSMonitorSetFromOptions(eps,"-eps_monitor_my_monitor","my_monitor",NULL)
     264             :    or at runtime via the option
     265             : $      -eps_monitor_my_monitor
     266             : 
     267             :    Level: advanced
     268             : 
     269             : .seealso: EPSMonitorRegisterAll()
     270             : @*/
     271        3294 : PetscErrorCode EPSMonitorRegister(const char name[],PetscViewerType vtype,PetscViewerFormat format,PetscErrorCode (*monitor)(EPS,PetscInt,PetscInt,PetscScalar*,PetscScalar*,PetscReal*,PetscInt,PetscViewerAndFormat*),PetscErrorCode (*create)(PetscViewer,PetscViewerFormat,void*,PetscViewerAndFormat**),PetscErrorCode (*destroy)(PetscViewerAndFormat**))
     272             : {
     273        3294 :   char           key[PETSC_MAX_PATH_LEN];
     274             : 
     275        3294 :   PetscFunctionBegin;
     276        3294 :   PetscCall(EPSInitializePackage());
     277        3294 :   PetscCall(SlepcMonitorMakeKey_Internal(name,vtype,format,key));
     278        3294 :   PetscCall(PetscFunctionListAdd(&EPSMonitorList,key,monitor));
     279        3294 :   if (create)  PetscCall(PetscFunctionListAdd(&EPSMonitorCreateList,key,create));
     280        3294 :   if (destroy) PetscCall(PetscFunctionListAdd(&EPSMonitorDestroyList,key,destroy));
     281        3294 :   PetscFunctionReturn(PETSC_SUCCESS);
     282             : }
     283             : 
     284             : /*@
     285             :    EPSReset - Resets the EPS context to the initial state (prior to setup)
     286             :    and destroys any allocated Vecs and Mats.
     287             : 
     288             :    Collective
     289             : 
     290             :    Input Parameter:
     291             : .  eps - eigensolver context obtained from EPSCreate()
     292             : 
     293             :    Note:
     294             :    This can be used when a problem of different matrix size wants to be solved.
     295             :    All options that have previously been set are preserved, so in a next use
     296             :    the solver configuration is the same, but new sizes for matrices and vectors
     297             :    are allowed.
     298             : 
     299             :    Level: advanced
     300             : 
     301             : .seealso: EPSDestroy()
     302             : @*/
     303         752 : PetscErrorCode EPSReset(EPS eps)
     304             : {
     305         752 :   PetscFunctionBegin;
     306         752 :   if (eps) PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     307           0 :   if (!eps) PetscFunctionReturn(PETSC_SUCCESS);
     308         752 :   PetscTryTypeMethod(eps,reset);
     309         752 :   if (eps->st) PetscCall(STReset(eps->st));
     310         752 :   PetscCall(VecDestroy(&eps->D));
     311         752 :   PetscCall(BVDestroy(&eps->V));
     312         752 :   PetscCall(BVDestroy(&eps->W));
     313         752 :   PetscCall(VecDestroyVecs(eps->nwork,&eps->work));
     314         752 :   eps->nwork = 0;
     315         752 :   eps->state = EPS_STATE_INITIAL;
     316         752 :   PetscFunctionReturn(PETSC_SUCCESS);
     317             : }
     318             : 
     319             : /*@C
     320             :    EPSDestroy - Destroys the EPS context.
     321             : 
     322             :    Collective
     323             : 
     324             :    Input Parameter:
     325             : .  eps - eigensolver context obtained from EPSCreate()
     326             : 
     327             :    Level: beginner
     328             : 
     329             : .seealso: EPSCreate(), EPSSetUp(), EPSSolve()
     330             : @*/
     331         662 : PetscErrorCode EPSDestroy(EPS *eps)
     332             : {
     333         662 :   PetscFunctionBegin;
     334         662 :   if (!*eps) PetscFunctionReturn(PETSC_SUCCESS);
     335         627 :   PetscValidHeaderSpecific(*eps,EPS_CLASSID,1);
     336         627 :   if (--((PetscObject)*eps)->refct > 0) { *eps = NULL; PetscFunctionReturn(PETSC_SUCCESS); }
     337         590 :   PetscCall(EPSReset(*eps));
     338         590 :   PetscTryTypeMethod(*eps,destroy);
     339         590 :   if ((*eps)->eigr) PetscCall(PetscFree4((*eps)->eigr,(*eps)->eigi,(*eps)->errest,(*eps)->perm));
     340         590 :   if ((*eps)->rr) PetscCall(PetscFree2((*eps)->rr,(*eps)->ri));
     341         590 :   PetscCall(STDestroy(&(*eps)->st));
     342         590 :   PetscCall(RGDestroy(&(*eps)->rg));
     343         590 :   PetscCall(DSDestroy(&(*eps)->ds));
     344         590 :   PetscCall(PetscFree((*eps)->sc));
     345             :   /* just in case the initial vectors have not been used */
     346         590 :   PetscCall(SlepcBasisDestroy_Private(&(*eps)->nds,&(*eps)->defl));
     347         590 :   PetscCall(SlepcBasisDestroy_Private(&(*eps)->nini,&(*eps)->IS));
     348         590 :   PetscCall(SlepcBasisDestroy_Private(&(*eps)->ninil,&(*eps)->ISL));
     349         590 :   if ((*eps)->convergeddestroy) PetscCall((*(*eps)->convergeddestroy)((*eps)->convergedctx));
     350         590 :   PetscCall(EPSMonitorCancel(*eps));
     351         590 :   PetscCall(PetscHeaderDestroy(eps));
     352         590 :   PetscFunctionReturn(PETSC_SUCCESS);
     353             : }
     354             : 
     355             : /*@
     356             :    EPSSetTarget - Sets the value of the target.
     357             : 
     358             :    Logically Collective
     359             : 
     360             :    Input Parameters:
     361             : +  eps    - eigensolver context
     362             : -  target - the value of the target
     363             : 
     364             :    Options Database Key:
     365             : .  -eps_target <scalar> - the value of the target
     366             : 
     367             :    Notes:
     368             :    The target is a scalar value used to determine the portion of the spectrum
     369             :    of interest. It is used in combination with EPSSetWhichEigenpairs().
     370             : 
     371             :    In the case of complex scalars, a complex value can be provided in the
     372             :    command line with [+/-][realnumber][+/-]realnumberi with no spaces, e.g.
     373             :    -eps_target 1.0+2.0i
     374             : 
     375             :    Level: intermediate
     376             : 
     377             : .seealso: EPSGetTarget(), EPSSetWhichEigenpairs()
     378             : @*/
     379         147 : PetscErrorCode EPSSetTarget(EPS eps,PetscScalar target)
     380             : {
     381         147 :   PetscFunctionBegin;
     382         147 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     383         588 :   PetscValidLogicalCollectiveScalar(eps,target,2);
     384         147 :   eps->target = target;
     385         147 :   if (!eps->st) PetscCall(EPSGetST(eps,&eps->st));
     386         147 :   PetscCall(STSetDefaultShift(eps->st,target));
     387         147 :   PetscFunctionReturn(PETSC_SUCCESS);
     388             : }
     389             : 
     390             : /*@
     391             :    EPSGetTarget - Gets the value of the target.
     392             : 
     393             :    Not Collective
     394             : 
     395             :    Input Parameter:
     396             : .  eps - eigensolver context
     397             : 
     398             :    Output Parameter:
     399             : .  target - the value of the target
     400             : 
     401             :    Note:
     402             :    If the target was not set by the user, then zero is returned.
     403             : 
     404             :    Level: intermediate
     405             : 
     406             : .seealso: EPSSetTarget()
     407             : @*/
     408        1397 : PetscErrorCode EPSGetTarget(EPS eps,PetscScalar* target)
     409             : {
     410        1397 :   PetscFunctionBegin;
     411        1397 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     412        1397 :   PetscAssertPointer(target,2);
     413        1397 :   *target = eps->target;
     414        1397 :   PetscFunctionReturn(PETSC_SUCCESS);
     415             : }
     416             : 
     417             : /*@
     418             :    EPSSetInterval - Defines the computational interval for spectrum slicing.
     419             : 
     420             :    Logically Collective
     421             : 
     422             :    Input Parameters:
     423             : +  eps  - eigensolver context
     424             : .  inta - left end of the interval
     425             : -  intb - right end of the interval
     426             : 
     427             :    Options Database Key:
     428             : .  -eps_interval <a,b> - set [a,b] as the interval of interest
     429             : 
     430             :    Notes:
     431             :    Spectrum slicing is a technique employed for computing all eigenvalues of
     432             :    symmetric eigenproblems in a given interval. This function provides the
     433             :    interval to be considered. It must be used in combination with EPS_ALL, see
     434             :    EPSSetWhichEigenpairs().
     435             : 
     436             :    In the command-line option, two values must be provided. For an open interval,
     437             :    one can give an infinite, e.g., -eps_interval 1.0,inf or -eps_interval -inf,1.0.
     438             :    An open interval in the programmatic interface can be specified with
     439             :    PETSC_MAX_REAL and -PETSC_MAX_REAL.
     440             : 
     441             :    Level: intermediate
     442             : 
     443             : .seealso: EPSGetInterval(), EPSSetWhichEigenpairs()
     444             : @*/
     445          39 : PetscErrorCode EPSSetInterval(EPS eps,PetscReal inta,PetscReal intb)
     446             : {
     447          39 :   PetscFunctionBegin;
     448          39 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     449         156 :   PetscValidLogicalCollectiveReal(eps,inta,2);
     450         156 :   PetscValidLogicalCollectiveReal(eps,intb,3);
     451          39 :   PetscCheck(inta<intb,PetscObjectComm((PetscObject)eps),PETSC_ERR_ARG_WRONG,"Badly defined interval, must be inta<intb");
     452          39 :   if (eps->inta != inta || eps->intb != intb) {
     453          36 :     eps->inta = inta;
     454          36 :     eps->intb = intb;
     455          36 :     eps->state = EPS_STATE_INITIAL;
     456             :   }
     457          39 :   PetscFunctionReturn(PETSC_SUCCESS);
     458             : }
     459             : 
     460             : /*@
     461             :    EPSGetInterval - Gets the computational interval for spectrum slicing.
     462             : 
     463             :    Not Collective
     464             : 
     465             :    Input Parameter:
     466             : .  eps - eigensolver context
     467             : 
     468             :    Output Parameters:
     469             : +  inta - left end of the interval
     470             : -  intb - right end of the interval
     471             : 
     472             :    Level: intermediate
     473             : 
     474             :    Note:
     475             :    If the interval was not set by the user, then zeros are returned.
     476             : 
     477             : .seealso: EPSSetInterval()
     478             : @*/
     479           9 : PetscErrorCode EPSGetInterval(EPS eps,PetscReal* inta,PetscReal* intb)
     480             : {
     481           9 :   PetscFunctionBegin;
     482           9 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     483           9 :   if (inta) *inta = eps->inta;
     484           9 :   if (intb) *intb = eps->intb;
     485           9 :   PetscFunctionReturn(PETSC_SUCCESS);
     486             : }
     487             : 
     488             : /*@
     489             :    EPSSetST - Associates a spectral transformation object to the eigensolver.
     490             : 
     491             :    Collective
     492             : 
     493             :    Input Parameters:
     494             : +  eps - eigensolver context obtained from EPSCreate()
     495             : -  st   - the spectral transformation object
     496             : 
     497             :    Note:
     498             :    Use EPSGetST() to retrieve the spectral transformation context (for example,
     499             :    to free it at the end of the computations).
     500             : 
     501             :    Level: advanced
     502             : 
     503             : .seealso: EPSGetST()
     504             : @*/
     505           1 : PetscErrorCode EPSSetST(EPS eps,ST st)
     506             : {
     507           1 :   PetscFunctionBegin;
     508           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     509           1 :   PetscValidHeaderSpecific(st,ST_CLASSID,2);
     510           1 :   PetscCheckSameComm(eps,1,st,2);
     511           1 :   PetscCall(PetscObjectReference((PetscObject)st));
     512           1 :   PetscCall(STDestroy(&eps->st));
     513           1 :   eps->st = st;
     514           1 :   PetscFunctionReturn(PETSC_SUCCESS);
     515             : }
     516             : 
     517             : /*@
     518             :    EPSGetST - Obtain the spectral transformation (ST) object associated
     519             :    to the eigensolver object.
     520             : 
     521             :    Not Collective
     522             : 
     523             :    Input Parameters:
     524             : .  eps - eigensolver context obtained from EPSCreate()
     525             : 
     526             :    Output Parameter:
     527             : .  st - spectral transformation context
     528             : 
     529             :    Level: intermediate
     530             : 
     531             : .seealso: EPSSetST()
     532             : @*/
     533        2972 : PetscErrorCode EPSGetST(EPS eps,ST *st)
     534             : {
     535        2972 :   PetscFunctionBegin;
     536        2972 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     537        2972 :   PetscAssertPointer(st,2);
     538        2972 :   if (!eps->st) {
     539         589 :     PetscCall(STCreate(PetscObjectComm((PetscObject)eps),&eps->st));
     540         589 :     PetscCall(PetscObjectIncrementTabLevel((PetscObject)eps->st,(PetscObject)eps,0));
     541         589 :     PetscCall(PetscObjectSetOptions((PetscObject)eps->st,((PetscObject)eps)->options));
     542             :   }
     543        2972 :   *st = eps->st;
     544        2972 :   PetscFunctionReturn(PETSC_SUCCESS);
     545             : }
     546             : 
     547             : /*@
     548             :    EPSSetBV - Associates a basis vectors object to the eigensolver.
     549             : 
     550             :    Collective
     551             : 
     552             :    Input Parameters:
     553             : +  eps - eigensolver context obtained from EPSCreate()
     554             : -  V   - the basis vectors object
     555             : 
     556             :    Level: advanced
     557             : 
     558             : .seealso: EPSGetBV()
     559             : @*/
     560           0 : PetscErrorCode EPSSetBV(EPS eps,BV V)
     561             : {
     562           0 :   PetscFunctionBegin;
     563           0 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     564           0 :   PetscValidHeaderSpecific(V,BV_CLASSID,2);
     565           0 :   PetscCheckSameComm(eps,1,V,2);
     566           0 :   PetscCall(PetscObjectReference((PetscObject)V));
     567           0 :   PetscCall(BVDestroy(&eps->V));
     568           0 :   eps->V = V;
     569           0 :   PetscFunctionReturn(PETSC_SUCCESS);
     570             : }
     571             : 
     572             : /*@
     573             :    EPSGetBV - Obtain the basis vectors object associated to the eigensolver object.
     574             : 
     575             :    Not Collective
     576             : 
     577             :    Input Parameters:
     578             : .  eps - eigensolver context obtained from EPSCreate()
     579             : 
     580             :    Output Parameter:
     581             : .  V - basis vectors context
     582             : 
     583             :    Level: advanced
     584             : 
     585             : .seealso: EPSSetBV()
     586             : @*/
     587         638 : PetscErrorCode EPSGetBV(EPS eps,BV *V)
     588             : {
     589         638 :   PetscFunctionBegin;
     590         638 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     591         638 :   PetscAssertPointer(V,2);
     592         638 :   if (!eps->V) {
     593         619 :     PetscCall(BVCreate(PetscObjectComm((PetscObject)eps),&eps->V));
     594         619 :     PetscCall(PetscObjectIncrementTabLevel((PetscObject)eps->V,(PetscObject)eps,0));
     595         619 :     PetscCall(PetscObjectSetOptions((PetscObject)eps->V,((PetscObject)eps)->options));
     596             :   }
     597         638 :   *V = eps->V;
     598         638 :   PetscFunctionReturn(PETSC_SUCCESS);
     599             : }
     600             : 
     601             : /*@
     602             :    EPSSetRG - Associates a region object to the eigensolver.
     603             : 
     604             :    Collective
     605             : 
     606             :    Input Parameters:
     607             : +  eps - eigensolver context obtained from EPSCreate()
     608             : -  rg  - the region object
     609             : 
     610             :    Note:
     611             :    Use EPSGetRG() to retrieve the region context (for example,
     612             :    to free it at the end of the computations).
     613             : 
     614             :    Level: advanced
     615             : 
     616             : .seealso: EPSGetRG()
     617             : @*/
     618           5 : PetscErrorCode EPSSetRG(EPS eps,RG rg)
     619             : {
     620           5 :   PetscFunctionBegin;
     621           5 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     622           5 :   if (rg) {
     623           5 :     PetscValidHeaderSpecific(rg,RG_CLASSID,2);
     624           5 :     PetscCheckSameComm(eps,1,rg,2);
     625             :   }
     626           5 :   PetscCall(PetscObjectReference((PetscObject)rg));
     627           5 :   PetscCall(RGDestroy(&eps->rg));
     628           5 :   eps->rg = rg;
     629           5 :   PetscFunctionReturn(PETSC_SUCCESS);
     630             : }
     631             : 
     632             : /*@
     633             :    EPSGetRG - Obtain the region object associated to the eigensolver.
     634             : 
     635             :    Not Collective
     636             : 
     637             :    Input Parameters:
     638             : .  eps - eigensolver context obtained from EPSCreate()
     639             : 
     640             :    Output Parameter:
     641             : .  rg - region context
     642             : 
     643             :    Level: advanced
     644             : 
     645             : .seealso: EPSSetRG()
     646             : @*/
     647         589 : PetscErrorCode EPSGetRG(EPS eps,RG *rg)
     648             : {
     649         589 :   PetscFunctionBegin;
     650         589 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     651         589 :   PetscAssertPointer(rg,2);
     652         589 :   if (!eps->rg) {
     653         589 :     PetscCall(RGCreate(PetscObjectComm((PetscObject)eps),&eps->rg));
     654         589 :     PetscCall(PetscObjectIncrementTabLevel((PetscObject)eps->rg,(PetscObject)eps,0));
     655         589 :     PetscCall(PetscObjectSetOptions((PetscObject)eps->rg,((PetscObject)eps)->options));
     656             :   }
     657         589 :   *rg = eps->rg;
     658         589 :   PetscFunctionReturn(PETSC_SUCCESS);
     659             : }
     660             : 
     661             : /*@
     662             :    EPSSetDS - Associates a direct solver object to the eigensolver.
     663             : 
     664             :    Collective
     665             : 
     666             :    Input Parameters:
     667             : +  eps - eigensolver context obtained from EPSCreate()
     668             : -  ds  - the direct solver object
     669             : 
     670             :    Note:
     671             :    Use EPSGetDS() to retrieve the direct solver context (for example,
     672             :    to free it at the end of the computations).
     673             : 
     674             :    Level: advanced
     675             : 
     676             : .seealso: EPSGetDS()
     677             : @*/
     678           0 : PetscErrorCode EPSSetDS(EPS eps,DS ds)
     679             : {
     680           0 :   PetscFunctionBegin;
     681           0 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     682           0 :   PetscValidHeaderSpecific(ds,DS_CLASSID,2);
     683           0 :   PetscCheckSameComm(eps,1,ds,2);
     684           0 :   PetscCall(PetscObjectReference((PetscObject)ds));
     685           0 :   PetscCall(DSDestroy(&eps->ds));
     686           0 :   eps->ds = ds;
     687           0 :   PetscFunctionReturn(PETSC_SUCCESS);
     688             : }
     689             : 
     690             : /*@
     691             :    EPSGetDS - Obtain the direct solver object associated to the eigensolver object.
     692             : 
     693             :    Not Collective
     694             : 
     695             :    Input Parameters:
     696             : .  eps - eigensolver context obtained from EPSCreate()
     697             : 
     698             :    Output Parameter:
     699             : .  ds - direct solver context
     700             : 
     701             :    Level: advanced
     702             : 
     703             : .seealso: EPSSetDS()
     704             : @*/
     705         552 : PetscErrorCode EPSGetDS(EPS eps,DS *ds)
     706             : {
     707         552 :   PetscFunctionBegin;
     708         552 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     709         552 :   PetscAssertPointer(ds,2);
     710         552 :   if (!eps->ds) {
     711         552 :     PetscCall(DSCreate(PetscObjectComm((PetscObject)eps),&eps->ds));
     712         552 :     PetscCall(PetscObjectIncrementTabLevel((PetscObject)eps->ds,(PetscObject)eps,0));
     713         552 :     PetscCall(PetscObjectSetOptions((PetscObject)eps->ds,((PetscObject)eps)->options));
     714             :   }
     715         552 :   *ds = eps->ds;
     716         552 :   PetscFunctionReturn(PETSC_SUCCESS);
     717             : }
     718             : 
     719             : /*@
     720             :    EPSIsGeneralized - Ask if the EPS object corresponds to a generalized
     721             :    eigenvalue problem.
     722             : 
     723             :    Not Collective
     724             : 
     725             :    Input Parameter:
     726             : .  eps - the eigenproblem solver context
     727             : 
     728             :    Output Parameter:
     729             : .  is - the answer
     730             : 
     731             :    Level: intermediate
     732             : 
     733             : .seealso: EPSIsHermitian(), EPSIsPositive()
     734             : @*/
     735           1 : PetscErrorCode EPSIsGeneralized(EPS eps,PetscBool* is)
     736             : {
     737           1 :   PetscFunctionBegin;
     738           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     739           1 :   PetscAssertPointer(is,2);
     740           1 :   *is = eps->isgeneralized;
     741           1 :   PetscFunctionReturn(PETSC_SUCCESS);
     742             : }
     743             : 
     744             : /*@
     745             :    EPSIsHermitian - Ask if the EPS object corresponds to a Hermitian
     746             :    eigenvalue problem.
     747             : 
     748             :    Not Collective
     749             : 
     750             :    Input Parameter:
     751             : .  eps - the eigenproblem solver context
     752             : 
     753             :    Output Parameter:
     754             : .  is - the answer
     755             : 
     756             :    Level: intermediate
     757             : 
     758             : .seealso: EPSIsGeneralized(), EPSIsPositive()
     759             : @*/
     760           1 : PetscErrorCode EPSIsHermitian(EPS eps,PetscBool* is)
     761             : {
     762           1 :   PetscFunctionBegin;
     763           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     764           1 :   PetscAssertPointer(is,2);
     765           1 :   *is = eps->ishermitian;
     766           1 :   PetscFunctionReturn(PETSC_SUCCESS);
     767             : }
     768             : 
     769             : /*@
     770             :    EPSIsPositive - Ask if the EPS object corresponds to an eigenvalue
     771             :    problem type that requires a positive (semi-) definite matrix B.
     772             : 
     773             :    Not Collective
     774             : 
     775             :    Input Parameter:
     776             : .  eps - the eigenproblem solver context
     777             : 
     778             :    Output Parameter:
     779             : .  is - the answer
     780             : 
     781             :    Level: intermediate
     782             : 
     783             : .seealso: EPSIsGeneralized(), EPSIsHermitian()
     784             : @*/
     785           1 : PetscErrorCode EPSIsPositive(EPS eps,PetscBool* is)
     786             : {
     787           1 :   PetscFunctionBegin;
     788           1 :   PetscValidHeaderSpecific(eps,EPS_CLASSID,1);
     789           1 :   PetscAssertPointer(is,2);
     790           1 :   *is = eps->ispositive;
     791           1 :   PetscFunctionReturn(PETSC_SUCCESS);
     792             : }

Generated by: LCOV version 1.14