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