1: /*
2: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3: SLEPc - Scalable Library for Eigenvalue Problem Computations
4: Copyright (c) , Universitat Politecnica de Valencia, Spain
6: This file is part of SLEPc.
8: SLEPc is free software: you can redistribute it and/or modify it under the
9: terms of version 3 of the GNU Lesser General Public License as published by
10: the Free Software Foundation.
12: SLEPc is distributed in the hope that it will be useful, but WITHOUT ANY
13: WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14: FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15: more details.
17: You should have received a copy of the GNU Lesser General Public License
18: along with SLEPc. If not, see <http://www.gnu.org/licenses/>.
19: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
20: */
22: #if !defined(_STIMPL)
23: #define _STIMPL 25: #include <slepcst.h>
26: #include <slepc/private/slepcimpl.h>
28: PETSC_EXTERN PetscBool STRegisterAllCalled;
29: PETSC_EXTERN PetscErrorCode STRegisterAll(void);
30: PETSC_EXTERN PetscLogEvent ST_SetUp,ST_Apply,ST_ApplyTranspose,ST_MatSetUp,ST_MatMult,ST_MatMultTranspose,ST_MatSolve,ST_MatSolveTranspose;
32: typedef struct _STOps *STOps;
34: struct _STOps {
35: PetscErrorCode (*setup)(ST);
36: PetscErrorCode (*apply)(ST,Vec,Vec);
37: PetscErrorCode (*getbilinearform)(ST,Mat*);
38: PetscErrorCode (*applytrans)(ST,Vec,Vec);
39: PetscErrorCode (*setshift)(ST,PetscScalar);
40: PetscErrorCode (*setfromoptions)(PetscOptions*,ST);
41: PetscErrorCode (*postsolve)(ST);
42: PetscErrorCode (*backtransform)(ST,PetscInt,PetscScalar*,PetscScalar*);
43: PetscErrorCode (*destroy)(ST);
44: PetscErrorCode (*reset)(ST);
45: PetscErrorCode (*view)(ST,PetscViewer);
46: PetscErrorCode (*checknullspace)(ST,BV);
47: };
49: struct _p_ST {
50: PETSCHEADER(struct _STOps);
51: /*------------------------- User parameters --------------------------*/
52: Mat *A; /* Matrices that define the eigensystem */
53: PetscObjectState *Astate; /* State (to identify the original matrices) */
54: Mat *T; /* Matrices resulting from transformation */
55: Mat P; /* Matrix from which preconditioner is built */
56: PetscInt nmat; /* Number of matrices */
57: PetscScalar sigma; /* Value of the shift */
58: PetscBool sigma_set; /* whether the user provided the shift or not */
59: PetscScalar defsigma; /* Default value of the shift */
60: STMatMode shift_matrix;
61: MatStructure str; /* whether matrices have the same pattern or not */
62: PetscBool transform; /* whether transformed matrices are computed */
64: /*------------------------- Misc data --------------------------*/
65: KSP ksp;
66: Vec w;
67: Vec D; /* diagonal matrix for balancing */
68: Vec wb; /* balancing requires an extra work vector */
69: void *data;
70: PetscInt setupcalled;
71: };
73: /*
74: Macros to test valid ST arguments
75: */
76: #if !defined(PETSC_USE_DEBUG)
78: #define STCheckMatrices(h,arg) do {} while (0) 80: #else
82: #define STCheckMatrices(h,arg) \ 83: do { \ 84: if (!h->A) SETERRQ1(PetscObjectComm((PetscObject)h),PETSC_ERR_ARG_WRONGSTATE,"ST matrices have not been set: Parameter #%d",arg); \ 85: } while (0) 87: #endif
89: PETSC_INTERN PetscErrorCode STGetBilinearForm_Default(ST,Mat*);
90: PETSC_INTERN PetscErrorCode STCheckNullSpace_Default(ST,BV);
91: PETSC_INTERN PetscErrorCode STMatShellCreate(ST,PetscScalar,PetscInt,PetscInt*,PetscScalar*,Mat*);
92: PETSC_INTERN PetscErrorCode STMatShellShift(Mat,PetscScalar);
93: PETSC_INTERN PetscErrorCode STMatSetHermitian(ST,Mat);
94: PETSC_INTERN PetscErrorCode STCheckFactorPackage(ST);
95: PETSC_INTERN PetscErrorCode STMatMAXPY_Private(ST,PetscScalar,PetscScalar,PetscInt,PetscScalar*,PetscBool,Mat*);
96: PETSC_INTERN PetscErrorCode STCoeffs_Monomial(ST,PetscScalar*);
98: #endif