GCC Code Coverage Report


Directory: ./
File: include/slepc/private/epsimpl.h
Date: 2026-10-22 02:08:06
Exec Total Coverage
Lines: 168 177 94.9%
Functions: 8 8 100.0%
Branches: 476 798 59.6%

Line Branch Exec Source
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 #pragma once
12
13 #include <slepceps.h>
14 #include <slepc/private/bvimpl.h>
15
16 /* SUBMANSEC = EPS */
17
18 SLEPC_EXTERN PetscBool EPSRegisterAllCalled;
19 SLEPC_EXTERN PetscBool EPSMonitorRegisterAllCalled;
20 SLEPC_EXTERN PetscErrorCode EPSRegisterAll(void);
21 SLEPC_EXTERN PetscErrorCode EPSMonitorRegisterAll(void);
22 SLEPC_EXTERN PetscLogEvent EPS_SetUp,EPS_Solve,EPS_CISS_SVD;
23
24 typedef struct _EPSOps *EPSOps;
25
26 struct _EPSOps {
27 PetscErrorCode (*solve)(EPS);
28 PetscErrorCode (*setup)(EPS);
29 PetscErrorCode (*setupsort)(EPS);
30 PetscErrorCode (*setfromoptions)(EPS,PetscOptionItems);
31 PetscErrorCode (*publishoptions)(EPS);
32 PetscErrorCode (*destroy)(EPS);
33 PetscErrorCode (*reset)(EPS);
34 PetscErrorCode (*view)(EPS,PetscViewer);
35 PetscErrorCode (*backtransform)(EPS);
36 PetscErrorCode (*computevectors)(EPS);
37 PetscErrorCode (*setdefaultst)(EPS);
38 PetscErrorCode (*setdstype)(EPS);
39 };
40
41 /*
42 Maximum number of monitors you can run with a single EPS
43 */
44 #define MAXEPSMONITORS 5
45
46 /*
47 The solution process goes through several states
48 */
49 typedef enum { EPS_STATE_INITIAL,
50 EPS_STATE_SETUP,
51 EPS_STATE_SOLVED,
52 EPS_STATE_EIGENVECTORS } EPSStateType;
53
54 /*
55 To classify the different solvers into categories
56 */
57 typedef enum { EPS_CATEGORY_KRYLOV, /* Krylov solver: relies on STApply and STBackTransform (same as OTHER) */
58 EPS_CATEGORY_PRECOND, /* Preconditioned solver: uses ST only to manage preconditioner */
59 EPS_CATEGORY_CONTOUR, /* Contour integral: ST used to solve linear systems at integration points */
60 EPS_CATEGORY_OTHER } EPSSolverType;
61
62 /*
63 To check for unsupported features at EPSSetUp_XXX()
64 */
65 typedef enum { EPS_FEATURE_BALANCE=1, /* balancing */
66 EPS_FEATURE_ARBITRARY=2, /* arbitrary selection of eigepairs */
67 EPS_FEATURE_REGION=4, /* nontrivial region for filtering */
68 EPS_FEATURE_EXTRACTION=8, /* extraction technique different from Ritz */
69 EPS_FEATURE_CONVERGENCE=16, /* convergence test selected by user */
70 EPS_FEATURE_STOPPING=32, /* stopping test */
71 EPS_FEATURE_THRESHOLD=64, /* threshold stopping test */
72 EPS_FEATURE_TWOSIDED=128 /* two-sided variant */
73 } EPSFeatureType;
74
75 /*
76 Defines the EPS data structure
77 */
78 struct _p_EPS {
79 PETSCHEADER(struct _EPSOps);
80 /*------------------------- User parameters ---------------------------*/
81 PetscInt max_it; /* maximum number of iterations */
82 PetscInt nev; /* number of eigenvalues to compute */
83 PetscInt ncv; /* number of basis vectors */
84 PetscInt mpd; /* maximum dimension of projected problem */
85 PetscInt nini,ninil; /* number of initial vectors (negative means not copied yet) */
86 PetscInt nds; /* number of basis vectors of deflation space */
87 PetscScalar target; /* target value */
88 PetscReal tol; /* tolerance */
89 PetscReal thres; /* threshold */
90 PetscBool threlative; /* threshold is relative */
91 EPSConv conv; /* convergence test */
92 EPSStop stop; /* stopping test */
93 EPSWhich which; /* which part of the spectrum to be sought */
94 PetscReal inta,intb; /* interval [a,b] for spectrum slicing */
95 EPSProblemType problem_type; /* which kind of problem to be solved */
96 EPSExtraction extraction; /* which kind of extraction to be applied */
97 EPSBalance balance; /* the balancing method */
98 PetscInt balance_its; /* number of iterations of the balancing method */
99 PetscReal balance_cutoff; /* cutoff value for balancing */
100 PetscBool trueres; /* whether the true residual norm must be computed */
101 PetscBool trackall; /* whether all the residuals must be computed */
102 PetscBool purify; /* whether eigenvectors need to be purified */
103 PetscBool twosided; /* whether to compute left eigenvectors (two-sided solver) */
104
105 /*-------------- User-provided functions and contexts -----------------*/
106 EPSConvergenceTestFn *converged;
107 EPSConvergenceTestFn *convergeduser;
108 PetscCtxDestroyFn *convergeddestroy;
109 EPSStoppingTestFn *stopping;
110 EPSStoppingTestFn *stoppinguser;
111 PetscCtxDestroyFn *stoppingdestroy;
112 SlepcArbitrarySelectionFn *arbitrary;
113 PetscCtxDestroyFn *arbitrarydestroy;
114 void *convergedctx;
115 void *stoppingctx;
116 void *arbitraryctx;
117 EPSMonitorFn *monitor[MAXEPSMONITORS];
118 PetscCtxDestroyFn *monitordestroy[MAXEPSMONITORS];
119 void *monitorcontext[MAXEPSMONITORS];
120 PetscInt numbermonitors;
121
122 /*----------------- Child objects and working data -------------------*/
123 ST st; /* spectral transformation object */
124 DS ds; /* direct solver object */
125 BV V; /* set of basis vectors and computed eigenvectors */
126 BV W; /* left basis vectors (if left eigenvectors requested) */
127 RG rg; /* optional region for filtering */
128 SlepcSC sc; /* sorting criterion data */
129 Vec D; /* diagonal matrix for balancing */
130 Vec *IS,*ISL; /* references to user-provided initial spaces */
131 Vec *defl; /* references to user-provided deflation space */
132 PetscScalar *eigr,*eigi; /* real and imaginary parts of eigenvalues */
133 PetscReal *errest; /* error estimates */
134 PetscScalar *rr,*ri; /* values computed by user's arbitrary selection function */
135 PetscInt *perm; /* permutation for eigenvalue ordering */
136 PetscInt nwork; /* number of work vectors */
137 Vec *work; /* work vectors */
138 void *data; /* placeholder for solver-specific stuff */
139
140 /* ----------------------- Status variables --------------------------*/
141 EPSStateType state; /* initial -> setup -> solved -> eigenvectors */
142 EPSSolverType categ; /* solver category */
143 PetscInt nconv; /* number of converged eigenvalues */
144 PetscInt its; /* number of iterations so far computed */
145 PetscInt n,nloc; /* problem dimensions (global, local) */
146 PetscReal nrma,nrmb; /* computed matrix norms */
147 PetscBool useds; /* whether the solver uses the DS object or not */
148 PetscBool isgeneralized;
149 PetscBool ispositive;
150 PetscBool ishermitian;
151 PetscBool isstructured;
152 PetscInt setfromoptionscalled;
153 EPSConvergedReason reason;
154 };
155
156 /*
157 Macros to test valid EPS arguments
158 */
159 #if !PetscDefined(USE_DEBUG)
160
161 #define EPSCheckSolved(h,arg) do {(void)(h);} while (0)
162
163 #else
164
165 #define EPSCheckSolved(h,arg) \
166 do { \
167 PetscCheck((h)->state>=EPS_STATE_SOLVED,PetscObjectComm((PetscObject)(h)),PETSC_ERR_ARG_WRONGSTATE,"Must call EPSSolve() first: Parameter #%d",arg); \
168 } while (0)
169
170 #endif
171
172 /*
173 Macros to check settings at EPSSetUp()
174 */
175
176 /* EPSCheckHermitianDefinite: the problem is HEP or GHEP */
177 #define EPSCheckHermitianDefiniteCondition(eps,condition,msg) \
178 do { \
179 if (condition) { \
180 PetscCheck((eps)->ishermitian,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s cannot be used for non-%s problems",((PetscObject)(eps))->type_name,(msg),SLEPC_STRING_HERMITIAN); \
181 PetscCheck(!(eps)->isgeneralized || (eps)->ispositive,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s requires that the problem is %s-definite",((PetscObject)(eps))->type_name,(msg),SLEPC_STRING_HERMITIAN); \
182 } \
183 } while (0)
184 #define EPSCheckHermitianDefinite(eps) EPSCheckHermitianDefiniteCondition(eps,PETSC_TRUE,"")
185
186 /* EPSCheckHermitian: the problem is HEP, GHEP, or GHIEP */
187 #define EPSCheckHermitianCondition(eps,condition,msg) \
188 do { \
189 if (condition) { \
190 PetscCheck((eps)->ishermitian,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s cannot be used for non-%s problems",((PetscObject)(eps))->type_name,(msg),SLEPC_STRING_HERMITIAN); \
191 } \
192 } while (0)
193 #define EPSCheckHermitian(eps) EPSCheckHermitianCondition(eps,PETSC_TRUE,"")
194
195 /* EPSCheckDefinite: the problem is not GHIEP */
196 #define EPSCheckDefiniteCondition(eps,condition,msg) \
197 do { \
198 if (condition) { \
199 PetscCheck(!(eps)->isgeneralized || !(eps)->ishermitian || (eps)->ispositive,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s cannot be used for %s-indefinite problems",((PetscObject)(eps))->type_name,(msg),SLEPC_STRING_HERMITIAN); \
200 } \
201 } while (0)
202 #define EPSCheckDefinite(eps) EPSCheckDefiniteCondition(eps,PETSC_TRUE,"")
203
204 /* EPSCheckStandard: the problem is HEP or NHEP */
205 #define EPSCheckStandardCondition(eps,condition,msg) \
206 do { \
207 if (condition) { \
208 PetscCheck(!(eps)->isgeneralized,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s cannot be used for generalized problems",((PetscObject)(eps))->type_name,(msg)); \
209 } \
210 } while (0)
211 #define EPSCheckStandard(eps) EPSCheckStandardCondition(eps,PETSC_TRUE,"")
212
213 /* EPSCheckNotStructured: the problem is not structured */
214 #define EPSCheckNotStructuredCondition(eps,condition,msg) \
215 do { \
216 if (condition) { \
217 PetscCheck(!(eps)->isstructured,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s does not provide support for structured eigenproblems",((PetscObject)(eps))->type_name,(msg)); \
218 } \
219 } while (0)
220 #define EPSCheckNotStructured(eps) EPSCheckNotStructuredCondition(eps,PETSC_TRUE,"")
221
222 /* EPSCheckSinvert: shift-and-invert ST */
223 #define EPSCheckSinvertCondition(eps,condition,msg) \
224 do { \
225 if (condition) { \
226 PetscBool __flg; \
227 PetscCall(PetscObjectTypeCompare((PetscObject)(eps)->st,STSINVERT,&__flg)); \
228 PetscCheck(__flg,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s requires a shift-and-invert spectral transform",((PetscObject)(eps))->type_name,(msg)); \
229 } \
230 } while (0)
231 #define EPSCheckSinvert(eps) EPSCheckSinvertCondition(eps,PETSC_TRUE,"")
232
233 /* EPSCheckSinvertCayley: shift-and-invert or Cayley ST */
234 #define EPSCheckSinvertCayleyCondition(eps,condition,msg) \
235 do { \
236 if (condition) { \
237 PetscBool __flg; \
238 PetscCall(PetscObjectTypeCompareAny((PetscObject)(eps)->st,&__flg,STSINVERT,STCAYLEY,"")); \
239 PetscCheck(__flg,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s requires shift-and-invert or Cayley transform",((PetscObject)(eps))->type_name,(msg)); \
240 } \
241 } while (0)
242 #define EPSCheckSinvertCayley(eps) EPSCheckSinvertCayleyCondition(eps,PETSC_TRUE,"")
243
244 /* Check for unsupported features */
245 #define EPSCheckUnsupportedCondition(eps,mask,condition,msg) \
246 do { \
247 if (condition) { \
248 PetscCheck(!((mask) & EPS_FEATURE_BALANCE) || (eps)->balance==EPS_BALANCE_NONE,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s does not support balancing",((PetscObject)(eps))->type_name,(msg)); \
249 PetscCheck(!((mask) & EPS_FEATURE_ARBITRARY) || !(eps)->arbitrary,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s does not support arbitrary selection of eigenpairs",((PetscObject)(eps))->type_name,(msg)); \
250 if ((mask) & EPS_FEATURE_REGION) { \
251 PetscBool __istrivial; \
252 PetscCall(RGIsTrivial((eps)->rg,&__istrivial)); \
253 PetscCheck(__istrivial,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s does not support region filtering",((PetscObject)(eps))->type_name,(msg)); \
254 } \
255 PetscCheck(!((mask) & EPS_FEATURE_EXTRACTION) || (eps)->extraction==EPS_RITZ,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s only supports Ritz extraction",((PetscObject)(eps))->type_name,(msg)); \
256 PetscCheck(!((mask) & EPS_FEATURE_CONVERGENCE) || (eps)->converged==EPSConvergedRelative,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s only supports the default convergence test",((PetscObject)(eps))->type_name,(msg)); \
257 PetscCheck(!((mask) & EPS_FEATURE_STOPPING) || (eps)->stopping==EPSStoppingBasic,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s only supports the default stopping test",((PetscObject)(eps))->type_name,(msg)); \
258 PetscCheck(!((mask) & EPS_FEATURE_THRESHOLD) || (eps)->stopping!=EPSStoppingThreshold,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s does not support the threshold stopping test",((PetscObject)(eps))->type_name,(msg)); \
259 PetscCheck(!((mask) & EPS_FEATURE_TWOSIDED) || !(eps)->twosided,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_SUP,"The solver '%s'%s cannot compute left eigenvectors (no two-sided variant)",((PetscObject)(eps))->type_name,(msg)); \
260 } \
261 } while (0)
262 #define EPSCheckUnsupported(eps,mask) EPSCheckUnsupportedCondition(eps,mask,PETSC_TRUE,"")
263
264 /* Check for ignored features */
265 #define EPSCheckIgnoredCondition(eps,mask,condition,msg) \
266 do { \
267 if (condition) { \
268 if (((mask) & EPS_FEATURE_BALANCE) && (eps)->balance!=EPS_BALANCE_NONE) PetscCall(PetscInfo((eps),"The solver '%s'%s ignores the balancing settings\n",((PetscObject)(eps))->type_name,(msg))); \
269 if (((mask) & EPS_FEATURE_ARBITRARY) && (eps)->arbitrary) PetscCall(PetscInfo((eps),"The solver '%s'%s ignores the settings for arbitrary selection of eigenpairs\n",((PetscObject)(eps))->type_name,(msg))); \
270 if ((mask) & EPS_FEATURE_REGION) { \
271 PetscBool __istrivial; \
272 PetscCall(RGIsTrivial((eps)->rg,&__istrivial)); \
273 if (!__istrivial) PetscCall(PetscInfo((eps),"The solver '%s'%s ignores the specified region\n",((PetscObject)(eps))->type_name,(msg))); \
274 } \
275 if (((mask) & EPS_FEATURE_EXTRACTION) && (eps)->extraction!=EPS_RITZ) PetscCall(PetscInfo((eps),"The solver '%s'%s ignores the extraction settings\n",((PetscObject)(eps))->type_name,(msg))); \
276 if (((mask) & EPS_FEATURE_CONVERGENCE) && (eps)->converged!=EPSConvergedRelative) PetscCall(PetscInfo((eps),"The solver '%s'%s ignores the convergence test settings\n",((PetscObject)(eps))->type_name,(msg))); \
277 if (((mask) & EPS_FEATURE_STOPPING) && (eps)->stopping!=EPSStoppingBasic) PetscCall(PetscInfo((eps),"The solver '%s'%s ignores the stopping test settings\n",((PetscObject)(eps))->type_name,(msg))); \
278 if (((mask) & EPS_FEATURE_TWOSIDED) && (eps)->twosided) PetscCall(PetscInfo((eps),"The solver '%s'%s ignores the two-sided flag\n",((PetscObject)(eps))->type_name,(msg))); \
279 } \
280 } while (0)
281 #define EPSCheckIgnored(eps,mask) EPSCheckIgnoredCondition(eps,mask,PETSC_TRUE,"")
282
283 /*
284 EPSSetCtxThreshold - Fills EPSStoppingCtx with data needed for the threshold stopping test
285
286 k = number of converged approximations, n = total number of available approximations
287 */
288 #define EPSSetCtxThreshold(eps,eigr,eigi,err_est,k,n) \
289 do { \
290 if ((eps)->stop==EPS_STOP_THRESHOLD && (k)) { \
291 PetscScalar __kr=(eigr)[(k)-1],__ki=(eigi)[(k)-1],__krn=0.0,__kin=0.0,__kr0=(eigr)[0],__ki0=(eigi)[0]; \
292 PetscCall(STBackTransform((eps)->st,1,&__kr,&__ki)); \
293 PetscCall(STBackTransform((eps)->st,1,&__kr0,&__ki0)); \
294 if ((n)>(k)) { \
295 __krn=(eigr)[k];__kin=(eigi)[k]; \
296 PetscCall(STBackTransform((eps)->st,1,&__krn,&__kin)); \
297 } \
298 if ((eps)->which==EPS_LARGEST_MAGNITUDE || (eps)->which==EPS_SMALLEST_MAGNITUDE) { \
299 ((EPSStoppingCtx)(eps)->stoppingctx)->firstev = SlepcAbsEigenvalue(__kr0,__ki0); \
300 ((EPSStoppingCtx)(eps)->stoppingctx)->lastev = SlepcAbsEigenvalue(__kr,__ki); \
301 ((EPSStoppingCtx)(eps)->stoppingctx)->firstnc = SlepcAbsEigenvalue(__krn,__kin); \
302 } else { \
303 ((EPSStoppingCtx)(eps)->stoppingctx)->firstev = PetscRealPart(__kr0); \
304 ((EPSStoppingCtx)(eps)->stoppingctx)->lastev = PetscRealPart(__kr); \
305 ((EPSStoppingCtx)(eps)->stoppingctx)->firstnc = PetscRealPart(__krn); \
306 } \
307 ((EPSStoppingCtx)(eps)->stoppingctx)->errest = (err_est)[k]; \
308 ((EPSStoppingCtx)(eps)->stoppingctx)->napprox = (n); \
309 } \
310 } while (0)
311
312 /*
313 EPS_SetInnerProduct - set B matrix for inner product if appropriate.
314 */
315 9695 static inline PetscErrorCode EPS_SetInnerProduct(EPS eps)
316 {
317 9695 Mat B;
318
319
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
9695 PetscFunctionBegin;
320
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9695 if (!eps->V) PetscCall(EPSGetBV(eps,&eps->V));
321
6/6
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 95 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 30 times.
9695 if (eps->ispositive || (eps->isgeneralized && eps->ishermitian)) {
322
4/6
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
1438 PetscCall(STGetBilinearForm(eps->st,&B));
323
4/6
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
1438 PetscCall(BVSetMatrix(eps->V,B,PetscNot(eps->ispositive)));
324
6/8
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 95 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
1438 if (eps->twosided) PetscCall(BVSetMatrix(eps->W,B,PetscNot(eps->ispositive)));
325
4/6
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 75 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
1438 PetscCall(MatDestroy(&B));
326
4/6
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
8257 } else PetscCall(BVSetMatrix(eps->V,NULL,PETSC_FALSE));
327
7/14
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 20 times.
1868 PetscFunctionReturn(PETSC_SUCCESS);
328 }
329
330 /*
331 EPS_Purify - purify the first m vectors in the V basis
332 */
333 795 static inline PetscErrorCode EPS_Purify(EPS eps,PetscInt m)
334 {
335 795 PetscInt l,k;
336 795 Mat X,Y;
337
338
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
795 PetscFunctionBegin;
339
2/16
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
795 if (!m) PetscFunctionReturn(PETSC_SUCCESS);
340
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(BVGetActiveColumns(eps->V,&l,&k));
341
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(BVSetActiveColumns(eps->V,0,m));
342
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(BVGetMat(eps->V,&Y));
343
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(MatDuplicate(Y,MAT_COPY_VALUES,&X));
344
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(STApplyMat(eps->st,X,Y));
345
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(MatProductClear(Y)); /* release the product's reference to X before restoring the BV */
346
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(MatDestroy(&X));
347
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(BVRestoreMat(eps->V,&Y));
348
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
795 PetscCall(BVSetActiveColumns(eps->V,l,k));
349
7/14
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
165 PetscFunctionReturn(PETSC_SUCCESS);
350 }
351
352 /*
353 EPS_KSPSetOperators - Sets the KSP matrices, see also ST_KSPSetOperators()
354 */
355 3841 static inline PetscErrorCode EPS_KSPSetOperators(KSP ksp,Mat A,Mat B)
356 {
357 3841 const char *prefix;
358
359
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
3841 PetscFunctionBegin;
360
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
3841 PetscCall(KSPSetOperators(ksp,A,B));
361
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
3841 PetscCall(MatGetOptionsPrefix(B,&prefix));
362
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
3841 if (!prefix) {
363 /* set Mat prefix to be the same as KSP to enable setting command-line options (e.g. MUMPS)
364 only applies if the Mat has no user-defined prefix */
365
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
3841 PetscCall(KSPGetOptionsPrefix(ksp,&prefix));
366
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
3841 PetscCall(MatSetOptionsPrefix(B,prefix));
367 }
368
7/14
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 4 times.
817 PetscFunctionReturn(PETSC_SUCCESS);
369 }
370
371 /*
372 EPS_GetActualConverged - Gets the actual value of nconv; in special cases the
373 number of available eigenvalues is larger than the computed ones
374 */
375 285644 static inline PetscErrorCode EPS_GetActualConverged(EPS eps,PetscInt *nconv)
376 {
377
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
285644 PetscFunctionBegin;
378 285644 *nconv = eps->nconv;
379
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 20 times.
285644 if (eps->isstructured) {
380
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
41633 if (eps->problem_type == EPS_BSE && (eps->which == EPS_SMALLEST_MAGNITUDE || eps->which == EPS_LARGEST_MAGNITUDE || eps->which == EPS_TARGET_MAGNITUDE)) *nconv *= 2;
381
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
16411 else if (eps->problem_type == EPS_HAMILT && (eps->which == EPS_SMALLEST_MAGNITUDE || eps->which == EPS_LARGEST_MAGNITUDE || eps->which == EPS_TARGET_MAGNITUDE)) *nconv *= 2;
382
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
15336 else if (eps->problem_type == EPS_LREP && (eps->which == EPS_SMALLEST_MAGNITUDE || eps->which == EPS_LARGEST_MAGNITUDE || eps->which == EPS_TARGET_MAGNITUDE)) *nconv *= 2;
383 }
384
7/14
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 4 times.
285644 PetscFunctionReturn(PETSC_SUCCESS);
385 }
386
387 19182 static inline PetscErrorCode EPS_GetEigenvector_BSE(EPS eps,BV V,PetscInt i,Vec Vr,Vec Vi)
388 {
389 19182 PetscInt k;
390 19182 Vec v0,v1,w,w0,w1;
391 19182 Mat H;
392 19182 IS is[2];
393
394
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
19182 PetscFunctionBegin;
395
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19182 PetscCheck(eps->which == EPS_SMALLEST_MAGNITUDE || eps->which == EPS_LARGEST_MAGNITUDE || eps->which == EPS_TARGET_MAGNITUDE,PetscObjectComm((PetscObject)(eps)),PETSC_ERR_PLIB,"Inconsistent state");
396 /* BSE problem, even index is +lambda, odd index is -lambda */
397 19182 k = eps->perm[i/2];
398
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
19182 if (i%2) {
399 /* eigenvector of -lambda is J*conj(x) where J=[0 I; I 0] and x is eigenvector of lambda */
400
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
9591 PetscCall(VecDuplicate(Vr?Vr:Vi,&w));
401
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(STGetMatrix(eps->st,0,&H));
402
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(MatNestGetISs(H,is,NULL));
403
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
9591 if (Vr) {
404
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(BV_GetEigenvector(V,k,eps->eigi[k],w,NULL));
405
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecConjugate(w));
406
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecGetSubVector(w,is[0],&w0));
407
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecGetSubVector(w,is[1],&w1));
408
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecGetSubVector(Vr,is[0],&v0));
409
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecGetSubVector(Vr,is[1],&v1));
410
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecCopy(w1,v0));
411
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecCopy(w0,v1));
412
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecRestoreSubVector(w,is[0],&w0));
413
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecRestoreSubVector(w,is[1],&w1));
414
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecRestoreSubVector(Vr,is[0],&v0));
415
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecRestoreSubVector(Vr,is[1],&v1));
416 }
417 #if !PetscDefined(USE_COMPLEX)
418
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
5996 if (Vi) {
419
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(BV_GetEigenvector(V,k,eps->eigi[k],NULL,w));
420
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecScale(w,-1.0));
421
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecGetSubVector(w,is[0],&w0));
422
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecGetSubVector(w,is[1],&w1));
423
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecGetSubVector(Vi,is[0],&v0));
424
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecGetSubVector(Vi,is[1],&v1));
425
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecCopy(w1,v0));
426
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecCopy(w0,v1));
427
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecRestoreSubVector(w,is[0],&w0));
428
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecRestoreSubVector(w,is[1],&w1));
429
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecRestoreSubVector(Vi,is[0],&v0));
430
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1132 PetscCall(VecRestoreSubVector(Vi,is[1],&v1));
431 }
432 #endif
433
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(VecDestroy(&w));
434 } else {
435
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
9591 PetscCall(BV_GetEigenvector(V,k,eps->eigi[k],Vr,Vi));
436 }
437
7/14
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
3264 PetscFunctionReturn(PETSC_SUCCESS);
438 }
439
440 260 static inline PetscErrorCode EPS_GetEigenvector_HAMILT(EPS eps,BV V,PetscInt i,Vec Vr,Vec Vi)
441 {
442 #if !PetscDefined(USE_COMPLEX)
443 260 PetscInt k;
444 260 Vec w;
445 260 PetscInt k0,k1,k2,iquad;
446 260 PetscReal nrm,nrmr=0.0,nrmi=0.0,sgn;
447 #endif
448
449
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
260 PetscFunctionBegin;
450 #if !PetscDefined(USE_COMPLEX)
451 260 k = eps->perm[i/2];
452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
260 if (eps->eigi[k]==0.0) { /* real eigenvalue */
453 ✗ if (Vr) {
454 ✗ PetscCall(BVCopyVec(V,k+eps->ncv/2+1,Vr));
455 ✗ PetscCall(BVGetColumn(V,k,&w));
456 ✗ PetscCall(VecAXPY(Vr,(i%2)?-eps->eigr[k]:eps->eigr[k],w));
457 ✗ PetscCall(BVRestoreColumn(V,k,&w));
458 ✗ PetscCall(VecNorm(Vr,NORM_2,&nrmr));
459 }
460 ✗ if (Vi) PetscCall(VecZeroEntries(Vi));
461 ✗ nrm = nrmr;
462
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
260 } else if (eps->eigr[k]==0.0 ) { /* purely imaginary eigenvalue */
463
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
60 if (Vr) {
464
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
60 PetscCall(BVCopyVec(V,k+eps->ncv/2+1,Vr));
465
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
60 PetscCall(VecNorm(Vr,NORM_2,&nrmr));
466 }
467
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
60 if (Vi) {
468
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
60 PetscCall(BVCopyVec(V,k,Vi));
469
7/8
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
60 PetscCall(VecScale(Vi,(i%2)?-eps->eigi[k]:eps->eigi[k]));
470
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
60 PetscCall(VecNorm(Vi,NORM_2,&nrmi));
471 }
472 60 nrm = SlepcAbs(nrmr,nrmi);
473 } else { /* quadruple eigenvalue (-conj(lambda),-lambda,lambda,conj(lambda)) */
474 200 iquad = i%2; /* index within the 4 values */
475
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
200 if (i>=2) {
476 160 k2 = eps->perm[(i-2)/2];
477
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
160 if (eps->eigr[k]==eps->eigr[k2] && eps->eigi[k]==-eps->eigi[k2]) iquad += 2;
478 }
479
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
160 k0 = (iquad<2)? k: k2;
480 200 k1 = k0+1;
481 /* Vr+Vi*i obtained as eig*u+v where u=ur+ui*i is stored in cols k0 (ur) and k1 (ui) and
482 v=vr+vi*i is in cols shifted by ncv/2+1.
483 For lambda=eigr+eigi*i:
484 Vr+Vi*i = (eigr+eigi*i)(ur+ui*i) + vr+vi*i
485 Vr+Vi*i = eigr*(ur+ui*i) - eigi*ui+eigi*ur*i + vr+vi*i
486 Vr+Vi*i = eigr*ur-eigi*ui+vr + (eigi*ur+eigr*ui+vi)*i
487 For -conj(lambda): eigr, ui and vi have the signs changed
488 For -lambda: eigr and eigi have the signs changed
489 For conj(lambda): eigi, ui and vi have the signs changed */
490
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
200 if (Vr) {
491
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
200 sgn = (iquad<2)? -1.0: 1.0;
492
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVCopyVec(V,k0,Vr)); /* ur */
493
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(VecScale(Vr,sgn*eps->eigr[k0]));
494
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVGetColumn(V,k1,&w)); /* ui */
495
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(VecAXPY(Vr,-sgn*eps->eigi[k0],w));
496
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVRestoreColumn(V,k1,&w));
497
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVGetColumn(V,k0+eps->ncv/2+1,&w)); /* vr */
498
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(VecAXPY(Vr,1.0,w));
499
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVRestoreColumn(V,k0+eps->ncv/2+1,&w));
500
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(VecNorm(Vr,NORM_2,&nrmr));
501 }
502
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
200 if (Vi) {
503
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
200 sgn = (iquad%2)? -1.0: 1.0;
504
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVCopyVec(V,k0,Vi)); /* ur */
505
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(VecScale(Vi,sgn*eps->eigi[k0]));
506
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVGetColumn(V,k1,&w)); /* ui */
507
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(VecAXPY(Vi,sgn*eps->eigr[k0],w));
508
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVRestoreColumn(V,k1,&w));
509
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVGetColumn(V,k1+eps->ncv/2+1,&w)); /* vi */
510
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
200 sgn = (iquad%3)? 1.0: -1.0;
511
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(VecAXPY(Vi,sgn,w));
512
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(BVRestoreColumn(V,k1+eps->ncv/2+1,&w));
513
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
200 PetscCall(VecNorm(Vi,NORM_2,&nrmi));
514 }
515 200 nrm = SlepcAbs(nrmr,nrmi);
516 }
517
5/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
260 if (Vr) PetscCall(VecScale(Vr,1.0/nrm));
518
5/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
260 if (Vi) PetscCall(VecScale(Vi,1.0/nrm));
519 #endif
520
7/14
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
52 PetscFunctionReturn(PETSC_SUCCESS);
521 }
522
523 5212 static inline PetscErrorCode EPS_GetEigenvector_LREP(EPS eps,BV V,PetscInt i,Vec Vr,Vec Vi)
524 {
525 5212 PetscInt k;
526 5212 Vec v;
527 5212 Mat H;
528 5212 IS is[2];
529
530
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
5212 PetscFunctionBegin;
531 /* LREP problem, even index is +lambda, odd index is -lambda */
532 5212 k = eps->perm[i/2];
533
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
5212 PetscCall(BV_GetEigenvector(V,k,eps->eigi[k],Vr,Vi));
534
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
5212 if (i%2) {
535 /* eigenvector of -lambda is S*x where S=[I 0; 0 -I] and x is eigenvector of lambda */
536
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
2606 PetscCall(STGetMatrix(eps->st,0,&H));
537
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
2606 PetscCall(MatNestGetISs(H,is,NULL));
538
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
2606 PetscCall(VecGetSubVector(Vr,is[1],&v));
539
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
2606 PetscCall(VecScale(v,-1.0));
540
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
2606 PetscCall(VecRestoreSubVector(Vr,is[1],&v));
541 }
542
7/14
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
884 PetscFunctionReturn(PETSC_SUCCESS);
543 }
544
545 /*
546 EPS_GetEigenvector - Gets the i-th eigenvector taking into account the case
547 where i exceeds the number of computed vectors (structure-preserving solver).
548 The argument V should be eps->V for right eigenvectors, eps->W for left ones.
549 */
550 101322 static inline PetscErrorCode EPS_GetEigenvector(EPS eps,BV V,PetscInt i,Vec Vr,Vec Vi)
551 {
552 101322 PetscInt k;
553 101322 PetscBool reduced;
554 101322 Mat H;
555
556
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
101322 PetscFunctionBegin;
557
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
101322 if (!eps->isstructured) {
558 76668 k = eps->perm[i];
559
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
76668 PetscCall(BV_GetEigenvector(V,k,eps->eigi[k],Vr,Vi));
560 } else {
561
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
24654 switch (eps->problem_type) {
562 13970 case EPS_BSE:
563
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
13970 PetscCall(EPS_GetEigenvector_BSE(eps,V,i,Vr,Vi));
564 break;
565 260 case EPS_HAMILT:
566
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
8223 PetscCall(EPS_GetEigenvector_HAMILT(eps,V,i,Vr,Vi));
567 break;
568 10424 case EPS_LREP:
569
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
10424 PetscCall(STGetMatrix(eps->st,0,&H));
570
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
10424 PetscCall(SlepcCheckMatLREPReduced(H,&reduced));
571
6/8
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
10424 if (reduced) PetscCall(EPS_GetEigenvector_LREP(eps,V,i,Vr,Vi));
572
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
5212 else PetscCall(EPS_GetEigenvector_BSE(eps,V,i,Vr,Vi));
573 break;
574 ✗ default:
575 − SETERRQ(PetscObjectComm((PetscObject)eps),PETSC_ERR_LIB,"Inconsistent state");
576 }
577 }
578
7/14
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 2 times.
18020 PetscFunctionReturn(PETSC_SUCCESS);
579 }
580
581 SLEPC_INTERN PetscErrorCode EPSSetWhichEigenpairs_Default(EPS);
582 SLEPC_INTERN PetscErrorCode EPSSetDimensions_Default(EPS,PetscInt*,PetscInt*,PetscInt*);
583 SLEPC_INTERN PetscErrorCode EPSBackTransform_Default(EPS);
584 SLEPC_INTERN PetscErrorCode EPSComputeVectors(EPS);
585 SLEPC_INTERN PetscErrorCode EPSComputeVectors_Hermitian(EPS);
586 SLEPC_INTERN PetscErrorCode EPSComputeVectors_Schur(EPS);
587 SLEPC_INTERN PetscErrorCode EPSComputeVectors_Indefinite(EPS);
588 SLEPC_INTERN PetscErrorCode EPSComputeVectors_Twosided(EPS);
589 SLEPC_INTERN PetscErrorCode EPSComputeVectors_Slice(EPS);
590 SLEPC_INTERN PetscErrorCode EPSComputeResidualNorm_Private(EPS,PetscBool,PetscScalar,PetscScalar,Vec,Vec,Vec*,PetscReal*);
591 SLEPC_INTERN PetscErrorCode EPSComputeRitzVector(EPS,PetscScalar*,PetscScalar*,BV,Vec,Vec);
592 SLEPC_INTERN PetscErrorCode EPSGetStartVector(EPS,PetscInt,PetscBool*);
593 SLEPC_INTERN PetscErrorCode EPSGetLeftStartVector(EPS,PetscInt,PetscBool*);
594 SLEPC_INTERN PetscErrorCode MatEstimateSpectralRange_EPS(Mat,PetscReal*,PetscReal*);
595
596 /* Private functions of the solver implementations */
597
598 SLEPC_INTERN PetscErrorCode EPSDelayedArnoldi(EPS,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*);
599 SLEPC_INTERN PetscErrorCode EPSDelayedArnoldi1(EPS,PetscScalar*,PetscInt,PetscInt,PetscInt*,PetscReal*,PetscBool*);
600 SLEPC_INTERN PetscErrorCode EPSKrylovConvergence(EPS,PetscBool,PetscInt,PetscInt,PetscReal,PetscReal,PetscReal,PetscInt*);
601 SLEPC_INTERN PetscErrorCode EPSPseudoLanczos(EPS,PetscReal*,PetscReal*,PetscReal*,PetscInt,PetscInt*,PetscBool*,PetscBool*,PetscReal*,Vec);
602 SLEPC_INTERN PetscErrorCode EPSBuildBalance_Krylov(EPS);
603 SLEPC_INTERN PetscErrorCode EPSSetDefaultST(EPS);
604 SLEPC_INTERN PetscErrorCode EPSSetDefaultST_Precond(EPS);
605 SLEPC_INTERN PetscErrorCode EPSSetDefaultST_GMRES(EPS);
606 SLEPC_INTERN PetscErrorCode EPSSetDefaultST_NoFactor(EPS);
607 SLEPC_INTERN PetscErrorCode EPSSetUpSort_Basic(EPS);
608 SLEPC_INTERN PetscErrorCode EPSSetUpSort_Default(EPS);
609