Actual source code: vecimplslepc.h
slepc-3.12.2 2020-01-13
1: /*
2: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3: SLEPc - Scalable Library for Eigenvalue Problem Computations
4: Copyright (c) 2002-2019, Universitat Politecnica de Valencia, Spain
6: This file is part of SLEPc.
7: SLEPc is distributed under a 2-clause BSD license (see LICENSE).
8: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9: */
11: #if !defined(SLEPCVECIMPL_H)
12: #define SLEPCVECIMPL_H
14: #include <slepcvec.h>
15: #include <slepc/private/slepcimpl.h>
17: #if !defined(PETSC_USE_DEBUG)
19: #define SlepcValidVecComp(y,arg) do {} while (0)
21: #else
23: #define SlepcValidVecComp(y,arg) \
24: do { \
25: if (((Vec_Comp*)(y)->data)->nx < ((Vec_Comp*)(y)->data)->n->n) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE,"Invalid number of subvectors required: Parameter #%d",arg); \
26: } while (0)
28: #endif
30: /* Contexts for VecComp */
31: typedef struct {
32: PetscInt n; /* number of active subvectors */
33: PetscInt N; /* virtual global size */
34: PetscInt lN; /* virtual local size */
35: PetscInt friends; /* number of vectors sharing this structure */
36: } Vec_Comp_N;
38: typedef struct {
39: Vec *x; /* the vectors */
40: PetscInt nx; /* number of available subvectors */
41: Vec_Comp_N *n; /* structure shared by friend vectors */
42: } Vec_Comp;
44: /* Operations implemented in VecComp */
45: SLEPC_INTERN PetscErrorCode VecDuplicateVecs_Comp(Vec,PetscInt,Vec*[]);
46: SLEPC_INTERN PetscErrorCode VecDestroyVecs_Comp(PetscInt,Vec[]);
47: SLEPC_INTERN PetscErrorCode VecDuplicate_Comp(Vec,Vec*);
48: SLEPC_INTERN PetscErrorCode VecDestroy_Comp(Vec);
49: SLEPC_INTERN PetscErrorCode VecSet_Comp(Vec,PetscScalar);
50: SLEPC_INTERN PetscErrorCode VecView_Comp(Vec,PetscViewer);
51: SLEPC_INTERN PetscErrorCode VecScale_Comp(Vec,PetscScalar);
52: SLEPC_INTERN PetscErrorCode VecCopy_Comp(Vec,Vec);
53: SLEPC_INTERN PetscErrorCode VecSwap_Comp(Vec,Vec);
54: SLEPC_INTERN PetscErrorCode VecAXPY_Comp(Vec,PetscScalar,Vec);
55: SLEPC_INTERN PetscErrorCode VecAYPX_Comp(Vec,PetscScalar,Vec);
56: SLEPC_INTERN PetscErrorCode VecAXPBY_Comp(Vec,PetscScalar,PetscScalar,Vec);
57: SLEPC_INTERN PetscErrorCode VecMAXPY_Comp(Vec,PetscInt,const PetscScalar*,Vec*);
58: SLEPC_INTERN PetscErrorCode VecWAXPY_Comp(Vec,PetscScalar,Vec,Vec);
59: SLEPC_INTERN PetscErrorCode VecAXPBYPCZ_Comp(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec);
60: SLEPC_INTERN PetscErrorCode VecPointwiseMult_Comp(Vec,Vec,Vec);
61: SLEPC_INTERN PetscErrorCode VecPointwiseDivide_Comp(Vec,Vec,Vec);
62: SLEPC_INTERN PetscErrorCode VecGetSize_Comp(Vec,PetscInt*);
63: SLEPC_INTERN PetscErrorCode VecGetLocalSize_Comp(Vec,PetscInt*);
64: SLEPC_INTERN PetscErrorCode VecMax_Comp(Vec,PetscInt*,PetscReal*);
65: SLEPC_INTERN PetscErrorCode VecMin_Comp(Vec,PetscInt*,PetscReal*);
66: SLEPC_INTERN PetscErrorCode VecSetRandom_Comp(Vec,PetscRandom);
67: SLEPC_INTERN PetscErrorCode VecConjugate_Comp(Vec);
68: SLEPC_INTERN PetscErrorCode VecReciprocal_Comp(Vec);
69: SLEPC_INTERN PetscErrorCode VecMaxPointwiseDivide_Comp(Vec,Vec,PetscReal*);
70: SLEPC_INTERN PetscErrorCode VecPointwiseMax_Comp(Vec,Vec,Vec);
71: SLEPC_INTERN PetscErrorCode VecPointwiseMaxAbs_Comp(Vec,Vec,Vec);
72: SLEPC_INTERN PetscErrorCode VecPointwiseMin_Comp(Vec,Vec,Vec);
73: SLEPC_INTERN PetscErrorCode VecDotNorm2_Comp_Seq(Vec,Vec,PetscScalar*,PetscScalar*);
74: SLEPC_INTERN PetscErrorCode VecDotNorm2_Comp_MPI(Vec,Vec,PetscScalar*,PetscScalar*);
75: SLEPC_INTERN PetscErrorCode VecSqrtAbs_Comp(Vec);
76: SLEPC_INTERN PetscErrorCode VecAbs_Comp(Vec);
77: SLEPC_INTERN PetscErrorCode VecExp_Comp(Vec);
78: SLEPC_INTERN PetscErrorCode VecLog_Comp(Vec);
79: SLEPC_INTERN PetscErrorCode VecShift_Comp(Vec,PetscScalar);
80: SLEPC_EXTERN PetscErrorCode VecCreate_Comp(Vec);
82: /* Definitions and structures for BLAS-type operations in Davidson solvers */
84: typedef PetscInt MatType_t;
85: #define DVD_MAT_HERMITIAN (1<<1)
86: #define DVD_MAT_NEG_DEF (1<<2)
87: #define DVD_MAT_POS_DEF (1<<3)
88: #define DVD_MAT_SINGULAR (1<<4)
89: #define DVD_MAT_COMPLEX (1<<5)
90: #define DVD_MAT_IMPLICIT (1<<6)
91: #define DVD_MAT_IDENTITY (1<<7)
92: #define DVD_MAT_DIAG (1<<8)
93: #define DVD_MAT_TRIANG (1<<9)
94: #define DVD_MAT_UTRIANG (1<<9)
95: #define DVD_MAT_LTRIANG (1<<10)
96: #define DVD_MAT_UNITARY (1<<11)
98: typedef PetscInt EPType_t;
99: #define DVD_EP_STD (1<<1)
100: #define DVD_EP_HERMITIAN (1<<2)
101: #define DVD_EP_INDEFINITE (1<<3)
103: #define DVD_IS(T,P) ((T) & (P))
104: #define DVD_ISNOT(T,P) (((T) & (P)) ^ (P))
106: /* VecPool */
107: typedef struct VecPool_ {
108: Vec v; /* template vector */
109: Vec *vecs; /* pool of vectors */
110: PetscInt n; /* size of vecs */
111: PetscInt used; /* number of already used vectors */
112: PetscInt guess; /* expected maximum number of vectors */
113: struct VecPool_ *next; /* list of pool of vectors */
114: } VecPool_;
115: typedef VecPool_* VecPool;
117: SLEPC_EXTERN PetscErrorCode SlepcVecPoolCreate(Vec,PetscInt,VecPool*);
118: SLEPC_EXTERN PetscErrorCode SlepcVecPoolDestroy(VecPool*);
119: SLEPC_EXTERN PetscErrorCode SlepcVecPoolGetVecs(VecPool,PetscInt,Vec**);
120: SLEPC_EXTERN PetscErrorCode SlepcVecPoolRestoreVecs(VecPool,PetscInt,Vec**);
121: #endif