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 | This provides a simple shell interface for programmers to create | ||
12 | their own spectral transformations without writing much interface code | ||
13 | */ | ||
14 | |||
15 | #include <slepc/private/stimpl.h> /*I "slepcst.h" I*/ | ||
16 | |||
17 | typedef struct { | ||
18 | void *ctx; /* user provided context */ | ||
19 | PetscErrorCode (*apply)(ST,Vec,Vec); | ||
20 | PetscErrorCode (*applytrans)(ST,Vec,Vec); | ||
21 | PetscErrorCode (*applyhermtrans)(ST,Vec,Vec); | ||
22 | PetscErrorCode (*backtransform)(ST,PetscInt n,PetscScalar*,PetscScalar*); | ||
23 | } ST_SHELL; | ||
24 | |||
25 | /*@C | ||
26 | STShellGetContext - Returns the user-provided context associated with a shell ST | ||
27 | |||
28 | Not Collective | ||
29 | |||
30 | Input Parameter: | ||
31 | . st - spectral transformation context | ||
32 | |||
33 | Output Parameter: | ||
34 | . ctx - the user provided context | ||
35 | |||
36 | Level: advanced | ||
37 | |||
38 | Notes: | ||
39 | This routine is intended for use within various shell routines | ||
40 | |||
41 | .seealso: STShellSetContext() | ||
42 | @*/ | ||
43 | 356111 | PetscErrorCode STShellGetContext(ST st,void *ctx) | |
44 | { | ||
45 | 356111 | PetscBool flg; | |
46 | |||
47 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
356111 | PetscFunctionBegin; |
48 |
3/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
356111 | PetscValidHeaderSpecific(st,ST_CLASSID,1); |
49 |
2/8✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
356111 | PetscAssertPointer(ctx,2); |
50 |
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.
|
356111 | PetscCall(PetscObjectTypeCompare((PetscObject)st,STSHELL,&flg)); |
51 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
356111 | if (!flg) *(void**)ctx = NULL; |
52 | 356111 | else *(void**)ctx = ((ST_SHELL*)st->data)->ctx; | |
53 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
70538 | PetscFunctionReturn(PETSC_SUCCESS); |
54 | } | ||
55 | |||
56 | /*@ | ||
57 | STShellSetContext - Sets the context for a shell ST | ||
58 | |||
59 | Logically Collective | ||
60 | |||
61 | Input Parameters: | ||
62 | + st - the shell ST | ||
63 | - ctx - the context | ||
64 | |||
65 | Level: advanced | ||
66 | |||
67 | Fortran Notes: | ||
68 | To use this from Fortran you must write a Fortran interface definition | ||
69 | for this function that tells Fortran the Fortran derived data type that | ||
70 | you are passing in as the ctx argument. | ||
71 | |||
72 | .seealso: STShellGetContext() | ||
73 | @*/ | ||
74 | 319 | PetscErrorCode STShellSetContext(ST st,void *ctx) | |
75 | { | ||
76 | 319 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
77 | 319 | PetscBool flg; | |
78 | |||
79 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
319 | PetscFunctionBegin; |
80 |
3/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
319 | PetscValidHeaderSpecific(st,ST_CLASSID,1); |
81 |
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.
|
319 | PetscCall(PetscObjectTypeCompare((PetscObject)st,STSHELL,&flg)); |
82 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
319 | if (flg) shell->ctx = ctx; |
83 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
63 | PetscFunctionReturn(PETSC_SUCCESS); |
84 | } | ||
85 | |||
86 | 30316 | static PetscErrorCode STApply_Shell(ST st,Vec x,Vec y) | |
87 | { | ||
88 | 30316 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
89 | 30316 | PetscObjectState instate,outstate; | |
90 | |||
91 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
30316 | PetscFunctionBegin; |
92 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
30316 | PetscCheck(shell->apply,PetscObjectComm((PetscObject)st),PETSC_ERR_USER,"No apply() routine provided to Shell ST"); |
93 |
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.
|
30316 | PetscCall(VecGetState(y,&instate)); |
94 |
14/26✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 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 not taken.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 2 times.
|
30316 | PetscCallBack("STSHELL user function apply()",(*shell->apply)(st,x,y)); |
95 |
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.
|
30316 | PetscCall(VecGetState(y,&outstate)); |
96 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
30316 | if (instate == outstate) { |
97 | /* user forgot to increase the state of the output vector */ | ||
98 | ✗ | PetscCall(PetscObjectStateIncrease((PetscObject)y)); | |
99 | } | ||
100 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
5970 | PetscFunctionReturn(PETSC_SUCCESS); |
101 | } | ||
102 | |||
103 | 775 | static PetscErrorCode STApplyTranspose_Shell(ST st,Vec x,Vec y) | |
104 | { | ||
105 | 775 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
106 | 775 | PetscObjectState instate,outstate; | |
107 | |||
108 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
775 | PetscFunctionBegin; |
109 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
775 | PetscCheck(shell->applytrans,PetscObjectComm((PetscObject)st),PETSC_ERR_USER,"No applytrans() routine provided to Shell ST"); |
110 |
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.
|
775 | PetscCall(VecGetState(y,&instate)); |
111 |
14/26✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 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 not taken.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 2 times.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 2 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 2 times.
|
775 | PetscCallBack("STSHELL user function applytrans()",(*shell->applytrans)(st,x,y)); |
112 |
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.
|
775 | PetscCall(VecGetState(y,&outstate)); |
113 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
|
775 | if (instate == outstate) { |
114 | /* user forgot to increase the state of the output vector */ | ||
115 | ✗ | PetscCall(PetscObjectStateIncrease((PetscObject)y)); | |
116 | } | ||
117 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
147 | PetscFunctionReturn(PETSC_SUCCESS); |
118 | } | ||
119 | |||
120 | #if defined(PETSC_USE_COMPLEX) | ||
121 | 460 | static PetscErrorCode STApplyHermitianTranspose_Shell(ST st,Vec x,Vec y) | |
122 | { | ||
123 | 460 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
124 | 460 | PetscObjectState instate,outstate; | |
125 | 460 | Vec w; | |
126 | |||
127 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
460 | PetscFunctionBegin; |
128 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
|
460 | if (shell->applyhermtrans) { |
129 |
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.
|
105 | PetscCall(VecGetState(y,&instate)); |
130 |
14/26✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 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 not taken.
✓ Branch 11 taken 1 times.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1 times.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 1 times.
|
105 | PetscCallBack("STSHELL user function applyhermtrans()",(*shell->applyhermtrans)(st,x,y)); |
131 |
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.
|
105 | PetscCall(VecGetState(y,&outstate)); |
132 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
105 | if (instate == outstate) { |
133 | /* user forgot to increase the state of the output vector */ | ||
134 | ✗ | PetscCall(PetscObjectStateIncrease((PetscObject)y)); | |
135 | } | ||
136 | } else { | ||
137 |
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.
|
355 | PetscCall(VecDuplicate(x,&w)); |
138 |
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.
|
355 | PetscCall(VecCopy(x,w)); |
139 |
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.
|
355 | PetscCall(VecConjugate(w)); |
140 |
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.
|
355 | PetscCall(STApplyTranspose_Shell(st,w,y)); |
141 |
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.
|
355 | PetscCall(VecDestroy(&w)); |
142 |
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.
|
355 | PetscCall(VecConjugate(y)); |
143 | } | ||
144 |
6/12✓ 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 not taken.
✓ Branch 11 taken 1 times.
|
76 | PetscFunctionReturn(PETSC_SUCCESS); |
145 | } | ||
146 | #endif | ||
147 | |||
148 | 345281 | static PetscErrorCode STBackTransform_Shell(ST st,PetscInt n,PetscScalar *eigr,PetscScalar *eigi) | |
149 | { | ||
150 | 345281 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
151 | |||
152 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
345281 | PetscFunctionBegin; |
153 |
16/28✓ Branch 0 taken 10 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 8 times.
✓ 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.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 2 times.
✓ Branch 18 taken 2 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 2 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✓ Branch 23 taken 2 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 2 times.
|
345281 | if (shell->backtransform) PetscCallBack("STSHELL user function backtransform()",(*shell->backtransform)(st,n,eigr,eigi)); |
154 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
67746 | PetscFunctionReturn(PETSC_SUCCESS); |
155 | } | ||
156 | |||
157 | /* | ||
158 | STIsInjective_Shell - Check if the user has provided the backtransform operation. | ||
159 | */ | ||
160 | 331 | PetscErrorCode STIsInjective_Shell(ST st,PetscBool* is) | |
161 | { | ||
162 | 331 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
163 | |||
164 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
331 | PetscFunctionBegin; |
165 | 331 | *is = shell->backtransform? PETSC_TRUE: PETSC_FALSE; | |
166 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
331 | PetscFunctionReturn(PETSC_SUCCESS); |
167 | } | ||
168 | |||
169 | 371 | static PetscErrorCode STDestroy_Shell(ST st) | |
170 | { | ||
171 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
371 | PetscFunctionBegin; |
172 |
5/8✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
|
371 | PetscCall(PetscFree(st->data)); |
173 |
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.
|
371 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApply_C",NULL)); |
174 |
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.
|
371 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyTranspose_C",NULL)); |
175 |
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.
|
371 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyHermitianTranspose_C",NULL)); |
176 |
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.
|
371 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetBackTransform_C",NULL)); |
177 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
71 | PetscFunctionReturn(PETSC_SUCCESS); |
178 | } | ||
179 | |||
180 | 331 | static PetscErrorCode STShellSetApply_Shell(ST st,STShellApplyFn *apply) | |
181 | { | ||
182 | 331 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
183 | |||
184 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
331 | PetscFunctionBegin; |
185 | 331 | shell->apply = apply; | |
186 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
331 | PetscFunctionReturn(PETSC_SUCCESS); |
187 | } | ||
188 | |||
189 | /*@C | ||
190 | STShellSetApply - Sets routine to use as the application of the | ||
191 | operator to a vector in the user-defined spectral transformation. | ||
192 | |||
193 | Logically Collective | ||
194 | |||
195 | Input Parameters: | ||
196 | + st - the spectral transformation context | ||
197 | - apply - the application-provided transformation routine | ||
198 | |||
199 | Level: advanced | ||
200 | |||
201 | .seealso: STShellSetBackTransform(), STShellSetApplyTranspose(), STShellSetApplyHermitianTranspose() | ||
202 | @*/ | ||
203 | 331 | PetscErrorCode STShellSetApply(ST st,STShellApplyFn *apply) | |
204 | { | ||
205 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
331 | PetscFunctionBegin; |
206 |
3/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
331 | PetscValidHeaderSpecific(st,ST_CLASSID,1); |
207 |
8/14✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
✓ 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.
|
331 | PetscTryMethod(st,"STShellSetApply_C",(ST,STShellApplyFn*),(st,apply)); |
208 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
331 | PetscFunctionReturn(PETSC_SUCCESS); |
209 | } | ||
210 | |||
211 | 72 | static PetscErrorCode STShellSetApplyTranspose_Shell(ST st,STShellApplyTransposeFn *applytrans) | |
212 | { | ||
213 | 72 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
214 | |||
215 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
72 | PetscFunctionBegin; |
216 | 72 | shell->applytrans = applytrans; | |
217 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
72 | PetscFunctionReturn(PETSC_SUCCESS); |
218 | } | ||
219 | |||
220 | /*@C | ||
221 | STShellSetApplyTranspose - Sets routine to use as the application of the | ||
222 | transposed operator to a vector in the user-defined spectral transformation. | ||
223 | |||
224 | Logically Collective | ||
225 | |||
226 | Input Parameters: | ||
227 | + st - the spectral transformation context | ||
228 | - applytrans - the application-provided transformation routine | ||
229 | |||
230 | Level: advanced | ||
231 | |||
232 | .seealso: STShellSetApply(), STShellSetBackTransform() | ||
233 | @*/ | ||
234 | 72 | PetscErrorCode STShellSetApplyTranspose(ST st,STShellApplyTransposeFn *applytrans) | |
235 | { | ||
236 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
72 | PetscFunctionBegin; |
237 |
3/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
72 | PetscValidHeaderSpecific(st,ST_CLASSID,1); |
238 |
8/14✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
✓ 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.
|
72 | PetscTryMethod(st,"STShellSetApplyTranspose_C",(ST,STShellApplyTransposeFn*),(st,applytrans)); |
239 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
72 | PetscFunctionReturn(PETSC_SUCCESS); |
240 | } | ||
241 | |||
242 | #if defined(PETSC_USE_COMPLEX) | ||
243 | 13 | static PetscErrorCode STShellSetApplyHermitianTranspose_Shell(ST st,STShellApplyHermitianTransposeFn *applyhermtrans) | |
244 | { | ||
245 | 13 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
246 | |||
247 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
13 | PetscFunctionBegin; |
248 | 13 | shell->applyhermtrans = applyhermtrans; | |
249 |
6/12✓ 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 not taken.
✓ Branch 11 taken 1 times.
|
13 | PetscFunctionReturn(PETSC_SUCCESS); |
250 | } | ||
251 | #endif | ||
252 | |||
253 | /*@C | ||
254 | STShellSetApplyHermitianTranspose - Sets routine to use as the application of the | ||
255 | conjugate-transposed operator to a vector in the user-defined spectral transformation. | ||
256 | |||
257 | Logically Collective | ||
258 | |||
259 | Input Parameters: | ||
260 | + st - the spectral transformation context | ||
261 | - applyhermtrans - the application-provided transformation routine | ||
262 | |||
263 | Note: | ||
264 | If configured with real scalars, this function has the same effect as STShellSetApplyTranspose(), | ||
265 | so no need to call both. | ||
266 | |||
267 | Level: advanced | ||
268 | |||
269 | .seealso: STShellSetApply(), STShellSetApplyTranspose(), STShellSetBackTransform() | ||
270 | @*/ | ||
271 | 13 | PetscErrorCode STShellSetApplyHermitianTranspose(ST st,STShellApplyHermitianTransposeFn *applyhermtrans) | |
272 | { | ||
273 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
13 | PetscFunctionBegin; |
274 |
3/16✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
13 | PetscValidHeaderSpecific(st,ST_CLASSID,1); |
275 |
8/14✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
✓ 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.
|
13 | PetscTryMethod(st,"STShellSetApplyHermitianTranspose_C",(ST,STShellApplyHermitianTransposeFn*),(st,applyhermtrans)); |
276 |
6/12✓ 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 not taken.
✓ Branch 11 taken 1 times.
|
13 | PetscFunctionReturn(PETSC_SUCCESS); |
277 | } | ||
278 | |||
279 | 321 | static PetscErrorCode STShellSetBackTransform_Shell(ST st,STShellBackTransformFn *backtr) | |
280 | { | ||
281 | 321 | ST_SHELL *shell = (ST_SHELL*)st->data; | |
282 | |||
283 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
321 | PetscFunctionBegin; |
284 | 321 | shell->backtransform = backtr; | |
285 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
321 | PetscFunctionReturn(PETSC_SUCCESS); |
286 | } | ||
287 | |||
288 | /*@C | ||
289 | STShellSetBackTransform - Sets the routine to be called after the | ||
290 | eigensolution process has finished in order to transform back the | ||
291 | computed eigenvalues. | ||
292 | |||
293 | Logically Collective | ||
294 | |||
295 | Input Parameters: | ||
296 | + st - the spectral transformation context | ||
297 | - backtr - the application-provided backtransform routine | ||
298 | |||
299 | Level: advanced | ||
300 | |||
301 | .seealso: STShellSetApply(), STShellSetApplyTranspose() | ||
302 | @*/ | ||
303 | 321 | PetscErrorCode STShellSetBackTransform(ST st,STShellBackTransformFn *backtr) | |
304 | { | ||
305 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
321 | PetscFunctionBegin; |
306 |
3/16✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 2 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
321 | PetscValidHeaderSpecific(st,ST_CLASSID,1); |
307 |
8/14✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
✓ 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.
|
321 | PetscTryMethod(st,"STShellSetBackTransform_C",(ST,STShellBackTransformFn*),(st,backtr)); |
308 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
321 | PetscFunctionReturn(PETSC_SUCCESS); |
309 | } | ||
310 | |||
311 | /*MC | ||
312 | STSHELL - User-defined spectral transformation via callback functions | ||
313 | for the application of the operator to a vector and (optionally) the | ||
314 | backtransform operation. | ||
315 | |||
316 | Level: advanced | ||
317 | |||
318 | Usage: | ||
319 | $ extern PetscErrorCode (*apply)(void*,Vec,Vec); | ||
320 | $ extern PetscErrorCode (*applytrans)(void*,Vec,Vec); | ||
321 | $ extern PetscErrorCode (*applyht)(void*,Vec,Vec); | ||
322 | $ extern PetscErrorCode (*backtr)(void*,PetscScalar*,PetscScalar*); | ||
323 | $ | ||
324 | $ STCreate(comm,&st); | ||
325 | $ STSetType(st,STSHELL); | ||
326 | $ STShellSetContext(st,ctx); | ||
327 | $ STShellSetApply(st,apply); | ||
328 | $ STShellSetApplyTranspose(st,applytrans); (optional) | ||
329 | $ STShellSetApplyHermitianTranspose(st,applyht); (optional, only in complex scalars) | ||
330 | $ STShellSetBackTransform(st,backtr); (optional) | ||
331 | |||
332 | M*/ | ||
333 | |||
334 | 371 | SLEPC_EXTERN PetscErrorCode STCreate_Shell(ST st) | |
335 | { | ||
336 | 371 | ST_SHELL *ctx; | |
337 | |||
338 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
371 | PetscFunctionBegin; |
339 |
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.
|
371 | PetscCall(PetscNew(&ctx)); |
340 | 371 | st->data = (void*)ctx; | |
341 | |||
342 | 371 | st->usesksp = PETSC_FALSE; | |
343 | |||
344 | 371 | st->ops->apply = STApply_Shell; | |
345 | 371 | st->ops->applytrans = STApplyTranspose_Shell; | |
346 | #if defined(PETSC_USE_COMPLEX) | ||
347 | 190 | st->ops->applyhermtrans = STApplyHermitianTranspose_Shell; | |
348 | #else | ||
349 | 181 | st->ops->applyhermtrans = STApplyTranspose_Shell; | |
350 | #endif | ||
351 | 371 | st->ops->backtransform = STBackTransform_Shell; | |
352 | 371 | st->ops->destroy = STDestroy_Shell; | |
353 | |||
354 |
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.
|
371 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApply_C",STShellSetApply_Shell)); |
355 |
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.
|
371 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyTranspose_C",STShellSetApplyTranspose_Shell)); |
356 | #if defined(PETSC_USE_COMPLEX) | ||
357 |
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.
|
190 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyHermitianTranspose_C",STShellSetApplyHermitianTranspose_Shell)); |
358 | #else | ||
359 |
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.
|
181 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetApplyHermitianTranspose_C",STShellSetApplyTranspose_Shell)); |
360 | #endif | ||
361 |
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.
|
371 | PetscCall(PetscObjectComposeFunction((PetscObject)st,"STShellSetBackTransform_C",STShellSetBackTransform_Shell)); |
362 |
6/12✓ 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 not taken.
✓ Branch 11 taken 2 times.
|
71 | PetscFunctionReturn(PETSC_SUCCESS); |
363 | } | ||
364 |