xref: /petsc/include/petscvec.h (revision aaa8cc7d2a5c3913edcbb923e20f154fe9c4aa65)
12eac72dbSBarry Smith /*
237f753daSBarry Smith     Defines the vector component of PETSc. Vectors generally represent
337f753daSBarry Smith   degrees of freedom for finite element/finite difference functions
484cb2905SBarry Smith   on a grid. They have more mathematical structure then simple arrays.
52eac72dbSBarry Smith */
66524c165SJacob Faibussowitsch #ifndef PETSCVEC_H
726bd1501SBarry Smith #define PETSCVEC_H
8ac09b921SBarry Smith 
997929ea7SJunchao Zhang #include <petscsys.h>
1097929ea7SJunchao Zhang #include <petscsftypes.h> /* for VecScatter, VecScatterType */
112c8e378dSBarry Smith #include <petscis.h>
12030f984aSJacob Faibussowitsch #include <petscdevicetypes.h>
13665c2dedSJed Brown #include <petscviewer.h>
142eac72dbSBarry Smith 
15ac09b921SBarry Smith /* SUBMANSEC = Vec */
16ac09b921SBarry Smith 
1709321671SBarry Smith /*S
1809321671SBarry Smith      Vec - Abstract PETSc vector object
1909321671SBarry Smith 
2009321671SBarry Smith    Level: beginner
2109321671SBarry Smith 
2220662ed9SBarry Smith .seealso: [](chapter_vectors), `VecCreate()`, `VecType`, `VecSetType()`
2309321671SBarry Smith S*/
24f09e8eb9SSatish Balay typedef struct _p_Vec *Vec;
2509321671SBarry Smith 
2609321671SBarry Smith /*E
27398c84b2SBarry Smith   ScatterMode - Determines the direction of a scatter
28398c84b2SBarry Smith 
29398c84b2SBarry Smith   Level: beginner
30398c84b2SBarry Smith 
3120662ed9SBarry Smith   Values:
3220662ed9SBarry Smith +  `SCATTER_FORWARD` - Scatters the values as dictated by the `VecScatterCreate()` call
3320662ed9SBarry Smith .  `SCATTER_REVERSE` - Moves the values in the opposite direction than the directions indicated in the `VecScatterCreate()` call
3420662ed9SBarry Smith .  `SCATTER_FORWARD_LOCAL` - Scatters the values as dictated by the `VecScatterCreate()` call except NO MPI communication is done
3520662ed9SBarry Smith -  `SCATTER_REVERSE_LOCAL` - Moves the values in the opposite direction than the directions indicated in the `VecScatterCreate()` call
3620662ed9SBarry Smith                              except NO MPI communication is done
3720662ed9SBarry Smith 
3820662ed9SBarry Smith .seealso: [](chapter_vectors), `VecScatter`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_FORWARD`, `SCATTER_REVERSE`, `SCATTER_FORWARD_LOCAL`, `SCATTER_REVERSE_LOCAL`
39398c84b2SBarry Smith E*/
409371c9d4SSatish Balay typedef enum {
419371c9d4SSatish Balay   SCATTER_FORWARD       = 0,
429371c9d4SSatish Balay   SCATTER_REVERSE       = 1,
439371c9d4SSatish Balay   SCATTER_FORWARD_LOCAL = 2,
4420662ed9SBarry Smith   SCATTER_REVERSE_LOCAL = 3
459371c9d4SSatish Balay } ScatterMode;
46398c84b2SBarry Smith 
47398c84b2SBarry Smith /*MC
4887497f52SBarry Smith     SCATTER_FORWARD - Scatters the values as dictated by the `VecScatterCreate()` call
49398c84b2SBarry Smith 
50398c84b2SBarry Smith     Level: beginner
51398c84b2SBarry Smith 
5220662ed9SBarry Smith .seealso: [](chapter_vectors), `VecScatter`, `ScatterMode`, `VecScatterCreate()`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_REVERSE`, `SCATTER_FORWARD_LOCAL`,
53db781477SPatrick Sanan           `SCATTER_REVERSE_LOCAL`
54398c84b2SBarry Smith M*/
55398c84b2SBarry Smith 
56398c84b2SBarry Smith /*MC
57398c84b2SBarry Smith     SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in
5887497f52SBarry Smith          in the `VecScatterCreate()`
59398c84b2SBarry Smith 
60398c84b2SBarry Smith     Level: beginner
61398c84b2SBarry Smith 
6220662ed9SBarry Smith .seealso: [](chapter_vectors), `VecScatter`, `ScatterMode`, `VecScatterCreate()`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_FORWARD`, `SCATTER_FORWARD_LOCAL`,
63db781477SPatrick Sanan           `SCATTER_REVERSE_LOCAL`
64398c84b2SBarry Smith M*/
65398c84b2SBarry Smith 
66398c84b2SBarry Smith /*MC
6787497f52SBarry Smith     SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the `VecScatterCreate()` call except NO parallel communication
68398c84b2SBarry Smith        is done. Any variables that have be moved between processes are ignored
69398c84b2SBarry Smith 
70398c84b2SBarry Smith     Level: developer
71398c84b2SBarry Smith 
7220662ed9SBarry Smith .seealso: [](chapter_vectors), `VecScatter`, `ScatterMode`, `VecScatterCreate()`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_REVERSE`, `SCATTER_FORWARD`,
73db781477SPatrick Sanan           `SCATTER_REVERSE_LOCAL`
74398c84b2SBarry Smith M*/
75398c84b2SBarry Smith 
76398c84b2SBarry Smith /*MC
77398c84b2SBarry Smith     SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in
7887497f52SBarry Smith          in the `VecScatterCreate()`  except NO parallel communication
79398c84b2SBarry Smith        is done. Any variables that have be moved between processes are ignored
80398c84b2SBarry Smith 
81398c84b2SBarry Smith     Level: developer
82398c84b2SBarry Smith 
8320662ed9SBarry Smith .seealso: [](chapter_vectors), `VecScatter`, `ScatterMode`, `VecScatterCreate()`, `VecScatterBegin()`, `VecScatterEnd()`, `SCATTER_FORWARD`, `SCATTER_FORWARD_LOCAL`,
84db781477SPatrick Sanan           `SCATTER_REVERSE`
85398c84b2SBarry Smith M*/
86398c84b2SBarry Smith 
8776bdecfbSBarry Smith /*J
888f6c3df8SBarry Smith     VecType - String with the name of a PETSc vector
8909321671SBarry Smith 
9009321671SBarry Smith    Level: beginner
9109321671SBarry Smith 
9220662ed9SBarry Smith .seealso: [](chapter_vectors), `VecSetType()`, `Vec`, `VecCreate()`, `VecDestroy()`
9376bdecfbSBarry Smith J*/
9419fd82e9SBarry Smith typedef const char *VecType;
950676abe4SMatthew Knepley #define VECSEQ         "seq"
960676abe4SMatthew Knepley #define VECMPI         "mpi"
97f48c50deSBarry Smith #define VECSTANDARD    "standard" /* seq on one process and mpi on several */
980676abe4SMatthew Knepley #define VECSHARED      "shared"
99b17c682bSKarl Rupp #define VECSEQVIENNACL "seqviennacl"
100b17c682bSKarl Rupp #define VECMPIVIENNACL "mpiviennacl"
101b17c682bSKarl Rupp #define VECVIENNACL    "viennacl" /* seqviennacl on one process and mpiviennacl on several */
10282f73ecaSAlejandro Lamas Daviña #define VECSEQCUDA     "seqcuda"
10382f73ecaSAlejandro Lamas Daviña #define VECMPICUDA     "mpicuda"
10482f73ecaSAlejandro Lamas Daviña #define VECCUDA        "cuda" /* seqcuda on one process and mpicuda on several */
10559af0bd3SScott Kruger #define VECSEQHIP      "seqhip"
10659af0bd3SScott Kruger #define VECMPIHIP      "mpihip"
10759af0bd3SScott Kruger #define VECHIP         "hip" /* seqcuda on one process and mpicuda on several */
1081aae2881SJed Brown #define VECNEST        "nest"
10910171e34SJunchao Zhang #define VECSEQKOKKOS   "seqkokkos"
11010171e34SJunchao Zhang #define VECMPIKOKKOS   "mpikokkos"
11110171e34SJunchao Zhang #define VECKOKKOS      "kokkos" /* seqkokkos on one process and mpikokkos on several */
1122eac72dbSBarry Smith 
113803a1b88SHong Zhang /* Dynamic creation and loading functions */
114803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterSetType(VecScatter, VecScatterType);
115803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterGetType(VecScatter, VecScatterType *);
116803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterSetFromOptions(VecScatter);
117803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterRegister(const char[], PetscErrorCode (*)(VecScatter));
118130e142eSJunchao Zhang PETSC_EXTERN PetscErrorCode VecScatterCreate(Vec, IS, Vec, IS, VecScatter *);
1194b71561bSShri Abhyankar 
120fd487807SMatthew Knepley /* Logging support */
121450a797fSBarry Smith #define REAL_FILE_CLASSID 1211213
1220700a824SBarry Smith #define VEC_FILE_CLASSID  1211214
123014dd563SJed Brown PETSC_EXTERN PetscClassId VEC_CLASSID;
12497929ea7SJunchao Zhang PETSC_EXTERN PetscClassId PETSCSF_CLASSID;
12545b63f25SDmitry Karpeev 
126607a6623SBarry Smith PETSC_EXTERN PetscErrorCode VecInitializePackage(void);
127014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecFinalizePackage(void);
128fd487807SMatthew Knepley 
129014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreate(MPI_Comm, Vec *);
130014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateSeq(MPI_Comm, PetscInt, Vec *);
131014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateMPI(MPI_Comm, PetscInt, PetscInt, Vec *);
132014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm, PetscInt, PetscInt, const PetscScalar[], Vec *);
133014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscScalar[], Vec *);
134014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateShared(MPI_Comm, PetscInt, PetscInt, Vec *);
135803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecCreateNode(MPI_Comm, PetscInt, PetscInt, Vec *);
136803a1b88SHong Zhang 
137014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetFromOptions(Vec);
138fe2efc57SMark PETSC_EXTERN PetscErrorCode VecViewFromOptions(Vec, PetscObject, const char[]);
1390d2bece7SBarry Smith 
140014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetUp(Vec);
141014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDestroy(Vec *);
142014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecZeroEntries(Vec);
143014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOptionsPrefix(Vec, const char[]);
144014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAppendOptionsPrefix(Vec, const char[]);
145014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOptionsPrefix(Vec, const char *[]);
146f69a0ea3SMatthew Knepley 
147014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetSizes(Vec, PetscInt, PetscInt);
148fd487807SMatthew Knepley 
14952b6e47cSBarry Smith PETSC_EXTERN PetscErrorCode VecDotNorm2(Vec, Vec, PetscScalar *, PetscReal *);
150014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDot(Vec, Vec, PetscScalar *);
15167392de3SBarry Smith PETSC_EXTERN PetscErrorCode VecDotRealPart(Vec, Vec, PetscReal *);
152014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDot(Vec, Vec, PetscScalar *);
153014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDot(Vec, PetscInt, const Vec[], PetscScalar[]);
154014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDot(Vec, PetscInt, const Vec[], PetscScalar[]);
155014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetSubVector(Vec, IS, Vec *);
156014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreSubVector(Vec, IS, Vec *);
157598f99faSAlp Dener PETSC_EXTERN PetscErrorCode VecConcatenate(PetscInt, const Vec[], Vec *, IS *[]);
158cddf8d76SBarry Smith 
15909321671SBarry Smith /*E
16009321671SBarry Smith     NormType - determines what type of norm to compute
16109321671SBarry Smith 
16209321671SBarry Smith     Level: beginner
16309321671SBarry Smith 
16420662ed9SBarry Smith     Values:
16520662ed9SBarry Smith +    `NORM_1` - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum
16620662ed9SBarry Smith .    `NORM_2` - the two norm, ||v|| = sqrt(sum_i |v_i|^2) (vectors only)
16720662ed9SBarry Smith .    `NORM_FROBENIUS` - ||A|| = sqrt(sum_ij |A_ij|^2), same as `NORM_2` for vectors
16820662ed9SBarry Smith .    `NORM_INFINITY` - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum
16920662ed9SBarry Smith -    `NORM_1_AND_2` - computes both the 1 and 2 norm of a vector
17020662ed9SBarry Smith 
17120662ed9SBarry Smith   Note:
17220662ed9SBarry Smith   The `v` above represents a `Vec` while the `A` represents a `Mat`
17320662ed9SBarry Smith 
17420662ed9SBarry Smith .seealso: [](chapter_vectors), `Vec`, `Mat`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `MatNorm()`, `NORM_1`,
17520662ed9SBarry Smith           `NORM_2`, `NORM_FROBENIUS`, `NORM_INFINITY`, `NORM_1_AND_2`
17609321671SBarry Smith E*/
1779371c9d4SSatish Balay typedef enum {
1789371c9d4SSatish Balay   NORM_1         = 0,
179a873a8cdSSam Reynolds   NORM_2         = 1,
180a873a8cdSSam Reynolds   NORM_FROBENIUS = 2,
181a873a8cdSSam Reynolds   NORM_INFINITY  = 3,
182a873a8cdSSam Reynolds   NORM_1_AND_2   = 4
183a873a8cdSSam Reynolds } NormType;
1846a6fc655SJed Brown PETSC_EXTERN const char *const NormTypes[];
185cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY
18609321671SBarry Smith 
1879b250c83SBarry Smith /*MC
1889b250c83SBarry Smith      NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum
1899b250c83SBarry Smith 
1909b250c83SBarry Smith    Level: beginner
1919b250c83SBarry Smith 
19220662ed9SBarry Smith .seealso: [](chapter_vectors), `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_2`, `NORM_FROBENIUS`,
193db781477SPatrick Sanan           `NORM_INFINITY`, `NORM_1_AND_2`
1949b250c83SBarry Smith M*/
1959b250c83SBarry Smith 
1969b250c83SBarry Smith /*MC
197df54d55cSMatthias Liertzer      NORM_2 - the two norm, ||v|| = sqrt(sum_i |v_i|^2) (vectors only)
1989b250c83SBarry Smith 
1999b250c83SBarry Smith    Level: beginner
2009b250c83SBarry Smith 
20120662ed9SBarry Smith .seealso: [](chapter_vectors), `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_1`, `NORM_FROBENIUS`,
202db781477SPatrick Sanan           `NORM_INFINITY`, `NORM_1_AND_2`
2039b250c83SBarry Smith M*/
2049b250c83SBarry Smith 
2059b250c83SBarry Smith /*MC
20687497f52SBarry Smith      NORM_FROBENIUS - ||A|| = sqrt(sum_ij |A_ij|^2), same as `NORM_2` for vectors
2079b250c83SBarry Smith 
2089b250c83SBarry Smith    Level: beginner
2099b250c83SBarry Smith 
21020662ed9SBarry Smith .seealso: [](chapter_vectors), `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_1`, `NORM_2`,
211db781477SPatrick Sanan           `NORM_INFINITY`, `NORM_1_AND_2`
2129b250c83SBarry Smith M*/
2139b250c83SBarry Smith 
2149b250c83SBarry Smith /*MC
2159b250c83SBarry Smith      NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum
2169b250c83SBarry Smith 
2179b250c83SBarry Smith    Level: beginner
2189b250c83SBarry Smith 
21920662ed9SBarry Smith .seealso: [](chapter_vectors), `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_1`, `NORM_2`,
220db781477SPatrick Sanan           `NORM_FROBENIUS`, `NORM_1_AND_2`
2219b250c83SBarry Smith M*/
2229b250c83SBarry Smith 
2239b250c83SBarry Smith /*MC
22420662ed9SBarry Smith      NORM_1_AND_2 - computes both the 1 and 2 norm of a vector. The values are stored in two adjacent `PetscReal` memory locations
2259b250c83SBarry Smith 
2269b250c83SBarry Smith    Level: beginner
2279b250c83SBarry Smith 
22820662ed9SBarry Smith .seealso: [](chapter_vectors), `NormType`, `MatNorm()`, `VecNorm()`, `VecNormBegin()`, `VecNormEnd()`, `NORM_1`, `NORM_2`,
229db781477SPatrick Sanan           `NORM_FROBENIUS`, `NORM_INFINITY`
2309b250c83SBarry Smith M*/
2319b250c83SBarry Smith 
2329b250c83SBarry Smith /*MC
23387497f52SBarry Smith      NORM_MAX - see `NORM_INFINITY`
2349b250c83SBarry Smith 
235d41222bbSBarry Smith    Level: beginner
2369b250c83SBarry Smith M*/
2379b250c83SBarry Smith 
238a873a8cdSSam Reynolds /*E
23987497f52SBarry Smith     ReductionType - determines what type of column reduction (one that is not a type of norm defined in `NormType`) to compute
240a873a8cdSSam Reynolds 
241a873a8cdSSam Reynolds     Level: beginner
242a873a8cdSSam Reynolds 
24320662ed9SBarry Smith     Values:
24420662ed9SBarry Smith +  `REDUCTION_SUM_REALPART` - sum of real part of each matrix column
245*aaa8cc7dSPierre Jolivet .  `REDUCTION_SUM_IMAGINARYPART` - sum of imaginary part of each matrix column
24620662ed9SBarry Smith .  `REDUCTION_MEAN_REALPART` - arithmetic mean of real part of each matrix column
24720662ed9SBarry Smith -  `REDUCTION_MEAN_IMAGINARYPART` - arithmetic mean of imaginary part of each matrix column
24820662ed9SBarry Smith 
24920662ed9SBarry Smith     Developer Note:
25020662ed9SBarry Smith   The constants defined in `ReductionType` MUST BE DISTINCT from those defined in `NormType`.
25120662ed9SBarry Smith   This is because `MatGetColumnReductions()` is used to compute both norms and other types of reductions,
25220662ed9SBarry Smith   and the constants defined in both `NormType` and `ReductionType` are used to designate the desired operation.
25320662ed9SBarry Smith 
25420662ed9SBarry Smith .seealso: [](chapter_vectors), `MatGetColumnReductions()`, `MatGetColumnNorms()`, `NormType`, `REDUCTION_SUM_REALPART`,
25520662ed9SBarry Smith           `REDUCTION_SUM_IMAGINARYPART`, `REDUCTION_MEAN_REALPART`, `REDUCTION_NORM_1`, `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY`
256a873a8cdSSam Reynolds E*/
2579371c9d4SSatish Balay typedef enum {
2589371c9d4SSatish Balay   REDUCTION_SUM_REALPART       = 10,
259857cbf51SRichard Tran Mills   REDUCTION_MEAN_REALPART      = 11,
260857cbf51SRichard Tran Mills   REDUCTION_SUM_IMAGINARYPART  = 12,
261857cbf51SRichard Tran Mills   REDUCTION_MEAN_IMAGINARYPART = 13
262a873a8cdSSam Reynolds } ReductionType;
263a873a8cdSSam Reynolds 
264a873a8cdSSam Reynolds /*MC
265857cbf51SRichard Tran Mills      REDUCTION_SUM_REALPART - sum of real part of matrix column
266a873a8cdSSam Reynolds 
267a873a8cdSSam Reynolds    Level: beginner
268a873a8cdSSam Reynolds 
26920662ed9SBarry Smith .seealso: [](chapter_vectors), `ReductionType`, `MatGetColumnReductions()`, `REDUCTION_SUM_IMAGINARYPART`, `REDUCTION_MEAN_REALPART`, `REDUCTION_NORM_1`,
270db781477SPatrick Sanan           `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY`
271a873a8cdSSam Reynolds M*/
272a873a8cdSSam Reynolds 
273a873a8cdSSam Reynolds /*MC
274857cbf51SRichard Tran Mills      REDUCTION_SUM_IMAGINARYPART - sum of imaginary part of matrix column
275a873a8cdSSam Reynolds 
276a873a8cdSSam Reynolds    Level: beginner
277a873a8cdSSam Reynolds 
27820662ed9SBarry Smith .seealso: [](chapter_vectors), `ReductionType`, `MatGetColumnReductions()`, `REDUCTION_SUM_REALPART`, `REDUCTION_MEAN_IMAGINARYPART`, `REDUCTION_NORM_1`,
279db781477SPatrick Sanan           `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY`
280857cbf51SRichard Tran Mills M*/
281857cbf51SRichard Tran Mills 
282857cbf51SRichard Tran Mills /*MC
283857cbf51SRichard Tran Mills      REDUCTION_MEAN_REALPART - arithmetic mean of real part of matrix column
284857cbf51SRichard Tran Mills 
285857cbf51SRichard Tran Mills    Level: beginner
286857cbf51SRichard Tran Mills 
28720662ed9SBarry Smith .seealso: [](chapter_vectors), `ReductionType`, `MatGetColumnReductions()`, `REDUCTION_MEAN_IMAGINARYPART`, `REDUCTION_SUM_REALPART`, `REDUCTION_NORM_1`,
288db781477SPatrick Sanan           `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY`
289857cbf51SRichard Tran Mills M*/
290857cbf51SRichard Tran Mills 
291857cbf51SRichard Tran Mills /*MC
292857cbf51SRichard Tran Mills      REDUCTION_MEAN_IMAGINARYPART - arithmetic mean of imaginary part of matrix column
293857cbf51SRichard Tran Mills 
294857cbf51SRichard Tran Mills    Level: beginner
295857cbf51SRichard Tran Mills 
29620662ed9SBarry Smith .seealso: [](chapter_vectors), `ReductionType`, `MatGetColumnReductions()`, `REDUCTION_MEAN_REALPART`, `REDUCTION_SUM_IMAGINARYPART`, `REDUCTION_NORM_1`,
297db781477SPatrick Sanan           `REDUCTION_NORM_2`, `REDUCTION_NORM_FROBENIUS`, `REDUCTION_NORM_INFINITY`
298a873a8cdSSam Reynolds M*/
299a873a8cdSSam Reynolds 
300014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNorm(Vec, NormType, PetscReal *);
301014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormAvailable(Vec, NormType, PetscBool *, PetscReal *);
302014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormalize(Vec, PetscReal *);
303014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSum(Vec, PetscScalar *);
304f7c17b9fSRichard Tran Mills PETSC_EXTERN PetscErrorCode VecMean(Vec, PetscScalar *);
305014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMax(Vec, PetscInt *, PetscReal *);
306014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMin(Vec, PetscInt *, PetscReal *);
307014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScale(Vec, PetscScalar);
308014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCopy(Vec, Vec);
309014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetRandom(Vec, PetscRandom);
310014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSet(Vec, PetscScalar);
311422a814eSBarry Smith PETSC_EXTERN PetscErrorCode VecSetInf(Vec);
312014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSwap(Vec, Vec);
313014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPY(Vec, PetscScalar, Vec);
314014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPBY(Vec, PetscScalar, PetscScalar, Vec);
315014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMAXPY(Vec, PetscInt, const PetscScalar[], Vec[]);
316014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAYPX(Vec, PetscScalar, Vec);
317014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecWAXPY(Vec, PetscScalar, Vec, Vec);
318014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPBYPCZ(Vec, PetscScalar, PetscScalar, PetscScalar, Vec, Vec);
319014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMax(Vec, Vec, Vec);
320014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec, Vec, Vec);
321014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMin(Vec, Vec, Vec);
322014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMult(Vec, Vec, Vec);
323014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseDivide(Vec, Vec, Vec);
324014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec, Vec, PetscReal *);
325014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecShift(Vec, PetscScalar);
326014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecReciprocal(Vec);
327014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPermute(Vec, IS, PetscBool);
328014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSqrtAbs(Vec);
329014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecLog(Vec);
330014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecExp(Vec);
331014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAbs(Vec);
332014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDuplicate(Vec, Vec *);
333014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDuplicateVecs(Vec, PetscInt, Vec *[]);
334014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDestroyVecs(PetscInt, Vec *[]);
335014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideNormAll(Vec, NormType, PetscReal[]);
336014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMaxAll(Vec, PetscInt[], PetscReal[]);
337014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMinAll(Vec, PetscInt[], PetscReal[]);
338014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScaleAll(Vec, const PetscScalar[]);
339408c233dSJeremy L Thompson PETSC_EXTERN PetscErrorCode VecStrideSumAll(Vec, PetscScalar *);
340849b11cfSMatthew G. Knepley PETSC_EXTERN PetscErrorCode VecUniqueEntries(Vec, PetscInt *, PetscScalar **);
3414a560884SBarry Smith 
342014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideNorm(Vec, PetscInt, NormType, PetscReal *);
343014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMax(Vec, PetscInt, PetscInt *, PetscReal *);
344014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMin(Vec, PetscInt, PetscInt *, PetscReal *);
345014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScale(Vec, PetscInt, PetscScalar);
346408c233dSJeremy L Thompson PETSC_EXTERN PetscErrorCode VecStrideSum(Vec, PetscInt, PetscScalar *);
347014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideSet(Vec, PetscInt, PetscScalar);
348954b3ec6SBarry Smith 
349014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideGather(Vec, PetscInt, Vec, InsertMode);
350014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScatter(Vec, PetscInt, Vec, InsertMode);
351014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideGatherAll(Vec, Vec[], InsertMode);
352014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScatterAll(Vec[], Vec, InsertMode);
353d2655a18SBarry Smith 
354bdeb6c88SBarry Smith PETSC_EXTERN PetscErrorCode VecStrideSubSetScatter(Vec, PetscInt, const PetscInt[], const PetscInt[], Vec, InsertMode);
355bdeb6c88SBarry Smith PETSC_EXTERN PetscErrorCode VecStrideSubSetGather(Vec, PetscInt, const PetscInt[], const PetscInt[], Vec, InsertMode);
356bdeb6c88SBarry Smith 
357014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValues(Vec, PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
358014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetValues(Vec, PetscInt, const PetscInt[], PetscScalar[]);
359014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAssemblyBegin(Vec);
360014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAssemblyEnd(Vec);
361014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashSetInitialSize(Vec, PetscInt, PetscInt);
362014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashView(Vec, PetscViewer);
363685405a1SBarry Smith PETSC_EXTERN PetscErrorCode VecStashViewFromOptions(Vec, PetscObject, const char[]);
364014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashGetInfo(Vec, PetscInt *, PetscInt *, PetscInt *, PetscInt *);
36562dc5420SSatish Balay 
366158e8e18SJunchao Zhang PETSC_EXTERN PetscErrorCode VecSetPreallocationCOO(Vec, PetscCount, const PetscInt[]);
367158e8e18SJunchao Zhang PETSC_EXTERN PetscErrorCode VecSetPreallocationCOOLocal(Vec, PetscCount, PetscInt[]);
368158e8e18SJunchao Zhang PETSC_EXTERN PetscErrorCode VecSetValuesCOO(Vec, const PetscScalar[], InsertMode);
369158e8e18SJunchao Zhang 
37030de9b25SBarry Smith /*MC
37130de9b25SBarry Smith    VecSetValue - Set a single entry into a vector.
37230de9b25SBarry Smith 
37330de9b25SBarry Smith    Synopsis:
374aaa7dc30SBarry Smith    #include <petscvec.h>
3758122439eSJed Brown    PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode);
37630de9b25SBarry Smith 
37730de9b25SBarry Smith    Not Collective
37830de9b25SBarry Smith 
37930de9b25SBarry Smith    Input Parameters:
38030de9b25SBarry Smith +  v - the vector
38130de9b25SBarry Smith .  row - the row location of the entry
38230de9b25SBarry Smith .  value - the value to insert
38387497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
38430de9b25SBarry Smith 
38520662ed9SBarry Smith    Level: beginner
38620662ed9SBarry Smith 
38730de9b25SBarry Smith    Notes:
38887497f52SBarry Smith    For efficiency one should use `VecSetValues()` and set several or
38930de9b25SBarry Smith    many values simultaneously if possible.
39030de9b25SBarry Smith 
39187497f52SBarry Smith    These values may be cached, so `VecAssemblyBegin()` and `VecAssemblyEnd()`
39287497f52SBarry Smith    MUST be called after all calls to `VecSetValue()` have been completed.
3931d73ed98SBarry Smith 
39487497f52SBarry Smith    `VecSetValue()` uses 0-based indices in Fortran as well as in C.
3951d73ed98SBarry Smith 
39620662ed9SBarry Smith .seealso: [](chapter_vectors), `VecSetValues()`, `VecAssemblyBegin()`, `VecAssemblyEnd()`, `VecSetValuesBlockedLocal()`, `VecSetValueLocal()`
3971d73ed98SBarry Smith M*/
398d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode VecSetValue(Vec v, PetscInt i, PetscScalar va, InsertMode mode)
399d71ae5a4SJacob Faibussowitsch {
4009371c9d4SSatish Balay   return VecSetValues(v, 1, &i, &va, mode);
4019371c9d4SSatish Balay }
4021d73ed98SBarry Smith 
403014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetBlockSize(Vec, PetscInt);
404014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetBlockSize(Vec, PetscInt *);
405014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesBlocked(Vec, PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
4068ed539a5SBarry Smith 
407fd487807SMatthew Knepley /* Dynamic creation and loading functions */
408140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList VecList;
40919fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode    VecSetType(Vec, VecType);
41019fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode    VecGetType(Vec, VecType *);
411bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode    VecRegister(const char[], PetscErrorCode (*)(Vec));
41230de9b25SBarry Smith 
413014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterBegin(VecScatter, Vec, Vec, InsertMode, ScatterMode);
414014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterEnd(VecScatter, Vec, Vec, InsertMode, ScatterMode);
415014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterDestroy(VecScatter *);
416246626dcSBarry Smith PETSC_EXTERN PetscErrorCode VecScatterSetUp(VecScatter);
417014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCopy(VecScatter, VecScatter *);
418014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterView(VecScatter, PetscViewer);
419fe2efc57SMark PETSC_EXTERN PetscErrorCode VecScatterViewFromOptions(VecScatter, PetscObject, const char[]);
420d27e6124SSatish Balay PETSC_EXTERN PetscErrorCode VecScatterRemap(VecScatter, PetscInt[], PetscInt[]);
421014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterGetMerged(VecScatter, PetscBool *);
4222195c698SBarry Smith 
423014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray4d(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ****[]);
424014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray4d(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ****[]);
425014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray3d(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ***[]);
426014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray3d(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ***[]);
427014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray2d(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar **[]);
428014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray2d(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar **[]);
429014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray1d(Vec, PetscInt, PetscInt, PetscScalar *[]);
430014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray1d(Vec, PetscInt, PetscInt, PetscScalar *[]);
431ab360428SBarry Smith 
432fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ****[]);
433fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ****[]);
434fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray4dWrite(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ****[]);
435fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray3dWrite(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ***[]);
436fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray3dWrite(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ***[]);
437fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray2dWrite(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar **[]);
438fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray2dWrite(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar **[]);
439fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray1dWrite(Vec, PetscInt, PetscInt, PetscScalar *[]);
440fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray1dWrite(Vec, PetscInt, PetscInt, PetscScalar *[]);
441fdc842d1SBarry Smith 
4425edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dRead(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ****[]);
4435edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray4dRead(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ****[]);
4445edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray3dRead(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ***[]);
4455edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray3dRead(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar ***[]);
4465edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray2dRead(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar **[]);
4475edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray2dRead(Vec, PetscInt, PetscInt, PetscInt, PetscInt, PetscScalar **[]);
4485edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray1dRead(Vec, PetscInt, PetscInt, PetscScalar *[]);
4495edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray1dRead(Vec, PetscInt, PetscInt, PetscScalar *[]);
4505edff71fSBarry Smith 
451014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPlaceArray(Vec, const PetscScalar[]);
452014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecResetArray(Vec);
453014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecReplaceArray(Vec, const PetscScalar[]);
454de0d48c1SKarl Rupp 
455014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArrays(const Vec[], PetscInt, PetscScalar **[]);
456014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArrays(const Vec[], PetscInt, PetscScalar **[]);
45784cb2905SBarry Smith 
458014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecView(Vec, PetscViewer);
459f9558f5cSBarry Smith PETSC_EXTERN PetscErrorCode VecViewNative(Vec, PetscViewer);
460014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecEqual(Vec, Vec, PetscBool *);
461014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecLoad(Vec, PetscViewer);
4628ed539a5SBarry Smith 
463014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetSize(Vec, PetscInt *);
464014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetLocalSize(Vec, PetscInt *);
465014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOwnershipRange(Vec, PetscInt *, PetscInt *);
466014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOwnershipRanges(Vec, const PetscInt *[]);
4678ed539a5SBarry Smith 
468014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec, ISLocalToGlobalMapping);
469014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesLocal(Vec, PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
47088b03592SBarry Smith 
47176ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLContext(Vec, PETSC_UINTPTR_T *);
47276ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLQueue(Vec, PETSC_UINTPTR_T *);
47376ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemRead(Vec, PETSC_UINTPTR_T *);
47476ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemWrite(Vec, PETSC_UINTPTR_T *);
47576ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMemWrite(Vec);
47676ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMem(Vec, PETSC_UINTPTR_T *);
47776ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMem(Vec);
47876ec7f3eSKaushik Kulkarni 
47988b03592SBarry Smith /*MC
48020662ed9SBarry Smith    VecSetValueLocal - Set a single entry into a vector using the local numbering, see `VecSetValuesLocal()`
48188b03592SBarry Smith 
48288b03592SBarry Smith    Synopsis:
483aaa7dc30SBarry Smith    #include <petscvec.h>
4848122439eSJed Brown    PetscErrorCode VecSetValueLocal(Vec v,PetscInt row,PetscScalar value, InsertMode mode);
48588b03592SBarry Smith 
48688b03592SBarry Smith    Not Collective
48788b03592SBarry Smith 
48888b03592SBarry Smith    Input Parameters:
48988b03592SBarry Smith +  v - the vector
49088b03592SBarry Smith .  row - the row location of the entry
49188b03592SBarry Smith .  value - the value to insert
49287497f52SBarry Smith -  mode - either `INSERT_VALUES` or `ADD_VALUES`
49388b03592SBarry Smith 
49420662ed9SBarry Smith    Level: beginner
49520662ed9SBarry Smith 
49688b03592SBarry Smith    Notes:
49720662ed9SBarry Smith    For efficiency one should use `VecSetValuesLocal()` and set several or
49888b03592SBarry Smith    many values simultaneously if possible.
49988b03592SBarry Smith 
50087497f52SBarry Smith    These values may be cached, so `VecAssemblyBegin()` and `VecAssemblyEnd()`
50120662ed9SBarry Smith    MUST be called after all calls to `VecSetValueLocal()` have been completed.
50288b03592SBarry Smith 
50387497f52SBarry Smith    `VecSetValues()` uses 0-based indices in Fortran as well as in C.
50488b03592SBarry Smith 
50520662ed9SBarry Smith .seealso: [](chapter_vectors), `VecSetValuesLocal()`, `VecSetValues()`, `VecAssemblyBegin()`, `VecAssemblyEnd()`, `VecSetValuesBlockedLocal()`, `VecSetValue()`
50688b03592SBarry Smith M*/
507d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode VecSetValueLocal(Vec v, PetscInt i, PetscScalar va, InsertMode mode)
508d71ae5a4SJacob Faibussowitsch {
5099371c9d4SSatish Balay   return VecSetValuesLocal(v, 1, &i, &va, mode);
5109371c9d4SSatish Balay }
51188b03592SBarry Smith 
51260211e57SBarry Smith /*MC
51360211e57SBarry Smith    VecCheckAssembled - checks if values have been changed in the vector, by `VecSetValues()` or related routines,  but it has not been assembled
51460211e57SBarry Smith 
51560211e57SBarry Smith    Synopsis:
51660211e57SBarry Smith    #include <petscvec.h>
51760211e57SBarry Smith    VecCheckAssembled(Vec v);
51860211e57SBarry Smith 
51960211e57SBarry Smith    Not Collective
52060211e57SBarry Smith 
52160211e57SBarry Smith    Input Parameter:
52260211e57SBarry Smith .  v - the vector to check
52360211e57SBarry Smith 
52460211e57SBarry Smith    Level: developer
52560211e57SBarry Smith 
52660211e57SBarry Smith    Note:
52760211e57SBarry Smith    After calls to `VecSetValues()` and related routines on must call ``VecAssemblyBegin()` and `VecAssemblyEnd()` before using the vector
52860211e57SBarry Smith 
52960211e57SBarry Smith .seealso: [](chapter_vectors), `Vec`, `VecSetValues()`, `VecAssemblyBegin()`, `VecAssemblyEnd()`, `MatAssemblyBegin()`, `MatAssemblyEnd()`
53060211e57SBarry Smith M*/
53160211e57SBarry Smith #define VecCheckAssembled(v) PetscCheck(v->stash.insertmode == NOT_SET_VALUES, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Not for unassembled vector, did you call VecAssemblyBegin()/VecAssemblyEnd()?");
53260211e57SBarry Smith 
533014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec, PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
534014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetLocalToGlobalMapping(Vec, ISLocalToGlobalMapping *);
53590f02eecSBarry Smith 
536014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDotBegin(Vec, Vec, PetscScalar *);
537014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDotEnd(Vec, Vec, PetscScalar *);
538014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDotBegin(Vec, Vec, PetscScalar *);
539014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDotEnd(Vec, Vec, PetscScalar *);
540014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormBegin(Vec, NormType, PetscReal *);
541014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormEnd(Vec, NormType, PetscReal *);
542d3c178dbSBarry Smith 
543014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDotBegin(Vec, PetscInt, const Vec[], PetscScalar[]);
544014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDotEnd(Vec, PetscInt, const Vec[], PetscScalar[]);
545014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDotBegin(Vec, PetscInt, const Vec[], PetscScalar[]);
546014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDotEnd(Vec, PetscInt, const Vec[], PetscScalar[]);
547014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscCommSplitReductionBegin(MPI_Comm);
548a751f32aSSatish Balay 
549b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecBindToCPU(Vec, PetscBool);
550d71ae5a4SJacob Faibussowitsch PETSC_DEPRECATED_FUNCTION("Use VecBindToCPU (since v3.13)") static inline PetscErrorCode VecPinToCPU(Vec v, PetscBool flg)
551d71ae5a4SJacob Faibussowitsch {
5529371c9d4SSatish Balay   return VecBindToCPU(v, flg);
5539371c9d4SSatish Balay }
5542216c58aSStefano Zampini PETSC_EXTERN PetscErrorCode VecBoundToCPU(Vec, PetscBool *);
55565a9ecf2SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecSetBindingPropagates(Vec, PetscBool);
556e9c74fd6SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecGetBindingPropagates(Vec, PetscBool *);
557387df023SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecSetPinnedMemoryMin(Vec, size_t);
558387df023SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecGetPinnedMemoryMin(Vec, size_t *);
559a751f32aSSatish Balay 
5606fe358cdSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecGetOffloadMask(Vec, PetscOffloadMask *);
56148d97fd2SKaushik Kulkarni 
5629371c9d4SSatish Balay typedef enum {
5639371c9d4SSatish Balay   VEC_IGNORE_OFF_PROC_ENTRIES,
5649371c9d4SSatish Balay   VEC_IGNORE_NEGATIVE_INDICES,
5659371c9d4SSatish Balay   VEC_SUBSET_OFF_PROC_ENTRIES
5669371c9d4SSatish Balay } VecOption;
567014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOption(Vec, VecOption, PetscBool);
56890f02eecSBarry Smith 
5695c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray(Vec, PetscScalar **);
570fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArrayWrite(Vec, PetscScalar **);
5715c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecGetArrayRead(Vec, const PetscScalar **);
5725c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray(Vec, PetscScalar **);
573fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArrayWrite(Vec, PetscScalar **);
5745c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArrayRead(Vec, const PetscScalar **);
575df341386SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateLocalVector(Vec, Vec *);
576046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecGetLocalVector(Vec, Vec);
577046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecRestoreLocalVector(Vec, Vec);
578046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec, Vec);
579046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec, Vec);
580a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayAndMemType(Vec, PetscScalar **, PetscMemType *);
581a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayAndMemType(Vec, PetscScalar **);
582a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayReadAndMemType(Vec, const PetscScalar **, PetscMemType *);
583a256111fSJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayReadAndMemType(Vec, const PetscScalar **);
584b5f78e91SJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayWriteAndMemType(Vec, PetscScalar **, PetscMemType *);
585b5f78e91SJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayWriteAndMemType(Vec, PetscScalar **);
58610171e34SJunchao Zhang 
5879521ec69SBarry Smith /*@C
58820662ed9SBarry Smith    VecGetArrayPair - Accesses a pair of pointers for two vectors that may be common. When not common the first pointer is read only
5899521ec69SBarry Smith 
59020662ed9SBarry Smith    Logically Collective; No Fortran Support
5919521ec69SBarry Smith 
592f5f57ec0SBarry Smith    Input Parameters:
5939521ec69SBarry Smith +  x - the vector
5949521ec69SBarry Smith -  y - the second vector
5959521ec69SBarry Smith 
596f5f57ec0SBarry Smith    Output Parameters:
5979521ec69SBarry Smith +  xv - location to put pointer to the first array
5989521ec69SBarry Smith -  yv - location to put pointer to the second array
5999521ec69SBarry Smith 
6009521ec69SBarry Smith    Level: developer
6019521ec69SBarry Smith 
60220662ed9SBarry Smith .seealso: [](chapter_vectors), `VecGetArray()`, `VecGetArrayRead()`, `VecRestoreArrayPair()`
6039521ec69SBarry Smith @*/
604d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode VecGetArrayPair(Vec x, Vec y, PetscScalar **xv, PetscScalar **yv)
605d71ae5a4SJacob Faibussowitsch {
606d9ca1df4SBarry Smith   PetscFunctionBegin;
6079566063dSJacob Faibussowitsch   PetscCall(VecGetArray(y, yv));
6085f80ce2aSJacob Faibussowitsch   if (x == y) *xv = *yv;
6099566063dSJacob Faibussowitsch   else PetscCall(VecGetArrayRead(x, (const PetscScalar **)xv));
6103ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
611d9ca1df4SBarry Smith }
6129521ec69SBarry Smith 
6139521ec69SBarry Smith /*@C
61420662ed9SBarry Smith    VecRestoreArrayPair - Returns a pair of pointers for two vectors that may be common obtained with `VecGetArrayPair()`
6159521ec69SBarry Smith 
61620662ed9SBarry Smith    Logically Collective; No Fortran Support
6179521ec69SBarry Smith 
618f5f57ec0SBarry Smith    Input Parameters:
6199521ec69SBarry Smith +  x - the vector
62020662ed9SBarry Smith .  y - the second vector
62120662ed9SBarry Smith .  xv - location to put pointer to the first array
6229521ec69SBarry Smith -  yv - location to put pointer to the second array
6239521ec69SBarry Smith 
6249521ec69SBarry Smith    Level: developer
6259521ec69SBarry Smith 
62620662ed9SBarry Smith .seealso: [](chapter_vectors), `VecGetArray()`, `VecGetArrayRead()`, `VecGetArrayPair()`
6279521ec69SBarry Smith @*/
628d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode VecRestoreArrayPair(Vec x, Vec y, PetscScalar **xv, PetscScalar **yv)
629d71ae5a4SJacob Faibussowitsch {
630d9ca1df4SBarry Smith   PetscFunctionBegin;
6319566063dSJacob Faibussowitsch   PetscCall(VecRestoreArray(y, yv));
6329566063dSJacob Faibussowitsch   if (x != y) PetscCall(VecRestoreArrayRead(x, (const PetscScalar **)xv));
6333ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
634d9ca1df4SBarry Smith }
635d9ca1df4SBarry Smith 
636d9ca1df4SBarry Smith #if defined(PETSC_USE_DEBUG)
63738fecf7cSJunchao Zhang PETSC_EXTERN PetscErrorCode  VecLockReadPush(Vec);
63838fecf7cSJunchao Zhang PETSC_EXTERN PetscErrorCode  VecLockReadPop(Vec);
639805b4a0dSBarry Smith PETSC_EXTERN PetscErrorCode  VecLockWriteSet(Vec, PetscBool);
640d9ca1df4SBarry Smith PETSC_EXTERN PetscErrorCode  VecLockGet(Vec, PetscInt *);
6415a96b57dSJacob Faibussowitsch PETSC_EXTERN PetscErrorCode  VecLockGetLocation(Vec, const char *[], const char *[], int *);
642d71ae5a4SJacob Faibussowitsch static inline PetscErrorCode VecSetErrorIfLocked(Vec x, PetscInt arg)
643d71ae5a4SJacob Faibussowitsch {
644da1c2f70SJunchao Zhang   PetscInt state;
64538fecf7cSJunchao Zhang 
646da1c2f70SJunchao Zhang   PetscFunctionBegin;
6479566063dSJacob Faibussowitsch   PetscCall(VecLockGet(x, &state));
6485a96b57dSJacob Faibussowitsch   if (PetscUnlikely(state != 0)) {
6495a96b57dSJacob Faibussowitsch     const char *file, *func, *name;
6505a96b57dSJacob Faibussowitsch     int         line;
6515a96b57dSJacob Faibussowitsch 
6525a96b57dSJacob Faibussowitsch     PetscCall(VecLockGetLocation(x, &file, &func, &line));
6535a96b57dSJacob Faibussowitsch     PetscCall(PetscObjectGetName((PetscObject)x, &name));
654dfb7d7afSStefano Zampini     SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "Vector '%s' (argument #%" PetscInt_FMT ") was locked for %s access in %s() at %s:%d (line numbers only accurate to function begin)", name, arg, state > 0 ? "read-only" : "write-only", func ? func : "unknown_function", file ? file : "unknown file", line);
6555a96b57dSJacob Faibussowitsch   }
6563ba16761SJacob Faibussowitsch   PetscFunctionReturn(PETSC_SUCCESS);
657da1c2f70SJunchao Zhang }
65838fecf7cSJunchao Zhang /* The three are deprecated */
6595f1efc1aSLisandro Dalcin PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPush() (since version 3.11)") PetscErrorCode VecLockPush(Vec);
6605f1efc1aSLisandro Dalcin PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPop() (since version 3.11)") PetscErrorCode VecLockPop(Vec);
661ed274036SLisandro Dalcin   #define VecLocked(x, arg) VecSetErrorIfLocked(x, arg) PETSC_DEPRECATED_MACRO("GCC warning \"Use VecSetErrorIfLocked() (since version 3.11)\"")
662d9ca1df4SBarry Smith #else
6633ba16761SJacob Faibussowitsch   #define VecLockReadPush(x)          PETSC_SUCCESS
6643ba16761SJacob Faibussowitsch   #define VecLockReadPop(x)           PETSC_SUCCESS
6653ba16761SJacob Faibussowitsch   #define VecLockGet(x, s)            (*(s) = 0, PETSC_SUCCESS)
6663ba16761SJacob Faibussowitsch   #define VecSetErrorIfLocked(x, arg) PETSC_SUCCESS
6673ba16761SJacob Faibussowitsch   #define VecLockWriteSet(x, flg)     PETSC_SUCCESS
66838fecf7cSJunchao Zhang   /* The three are deprecated */
6693ba16761SJacob Faibussowitsch   #define VecLockPush(x)              PETSC_SUCCESS
6703ba16761SJacob Faibussowitsch   #define VecLockPop(x)               PETSC_SUCCESS
6713ba16761SJacob Faibussowitsch   #define VecLocked(x, arg)           PETSC_SUCCESS
672d9ca1df4SBarry Smith #endif
673e1fa1e0fSSatish Balay 
67474852143SJacob Faibussowitsch /*E
67574852143SJacob Faibussowitsch   VecOperation - Enumeration of overide-able methods in the `Vec` implementation function-table.
67674852143SJacob Faibussowitsch 
67720662ed9SBarry Smith   Values:
67820662ed9SBarry Smith + `VECOP_DUPLICATE`  - `VecDuplicate()`
67920662ed9SBarry Smith . `VECOP_SET`        - `VecSet()`
68020662ed9SBarry Smith . `VECOP_VIEW`       - `VecView()`
68120662ed9SBarry Smith . `VECOP_LOAD`       - `VecLoad()`
68220662ed9SBarry Smith . `VECOP_VIEWNATIVE` - `VecViewNative()`
68320662ed9SBarry Smith - `VECOP_LOADNATIVE` - `VecLoadNative()`
68420662ed9SBarry Smith 
68520662ed9SBarry Smith   Level: advanced
68674852143SJacob Faibussowitsch 
68774852143SJacob Faibussowitsch   Notes:
68874852143SJacob Faibussowitsch   Some operations may serve as the implementation for other routines not listed above. For
68974852143SJacob Faibussowitsch   example `VECOP_SET` can be used to simultaneously overriding the implementation used in
69074852143SJacob Faibussowitsch   `VecSet()`, `VecSetInf()`, and `VecZeroEntries()`.
69174852143SJacob Faibussowitsch 
69274852143SJacob Faibussowitsch   Entries to `VecOperation` are added as needed so if you do not see the operation listed which
69374852143SJacob Faibussowitsch   you'd like to replace, please send mail to `petsc-maint@mcs.anl.gov`!
69474852143SJacob Faibussowitsch 
69520662ed9SBarry Smith .seealso: [](chapter_vectors), `Vec`, `VecSetOperation()`
69623084d82SJacob Faibussowitsch E*/
6979371c9d4SSatish Balay typedef enum {
6989371c9d4SSatish Balay   VECOP_DUPLICATE  = 0,
69974852143SJacob Faibussowitsch   VECOP_SET        = 10,
7009371c9d4SSatish Balay   VECOP_VIEW       = 33,
7019371c9d4SSatish Balay   VECOP_LOAD       = 41,
7029371c9d4SSatish Balay   VECOP_VIEWNATIVE = 68,
7039371c9d4SSatish Balay   VECOP_LOADNATIVE = 69
7049371c9d4SSatish Balay } VecOperation;
705014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOperation(Vec, VecOperation, void (*)(void));
706b19c1e4cSBarry Smith 
707e182c471SBarry Smith /*
708e182c471SBarry Smith      Routines for dealing with ghosted vectors:
709e182c471SBarry Smith   vectors with ghost elements at the end of the array.
710e182c471SBarry Smith */
711014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMPISetGhost(Vec, PetscInt, const PetscInt[]);
712014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhost(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], Vec *);
713014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscScalar[], Vec *);
714014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], Vec *);
715014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm, PetscInt, PetscInt, PetscInt, PetscInt, const PetscInt[], const PetscScalar[], Vec *);
716014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostGetLocalForm(Vec, Vec *);
717014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec, Vec *);
7183efe6655SBarry Smith PETSC_EXTERN PetscErrorCode VecGhostIsLocalForm(Vec, Vec, PetscBool *);
719014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostUpdateBegin(Vec, InsertMode, ScatterMode);
720014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostUpdateEnd(Vec, InsertMode, ScatterMode);
721e182c471SBarry Smith 
722014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecConjugate(Vec);
723c92e3469SBarry Smith PETSC_EXTERN PetscErrorCode VecImaginaryPart(Vec);
724c92e3469SBarry Smith PETSC_EXTERN PetscErrorCode VecRealPart(Vec);
72534233285SBarry Smith 
726014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCreateToAll(Vec, VecScatter *, Vec *);
727014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCreateToZero(Vec, VecScatter *, Vec *);
728bba1ac68SSatish Balay 
7294473680cSBarry Smith PETSC_EXTERN PetscErrorCode ISComplementVec(IS, Vec, IS *);
7304473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecPow(Vec, PetscScalar);
7314473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecMedian(Vec, Vec, Vec, Vec);
732ce902467SBarry Smith PETSC_EXTERN PetscErrorCode VecWhichInactive(Vec, Vec, Vec, Vec, PetscBool, IS *);
7334473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichBetween(Vec, Vec, Vec, IS *);
7344473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichBetweenOrEqual(Vec, Vec, Vec, IS *);
7354473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichGreaterThan(Vec, Vec, IS *);
7364473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichLessThan(Vec, Vec, IS *);
7374473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichEqual(Vec, Vec, IS *);
7384473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecISAXPY(Vec, IS, PetscScalar, Vec);
7398883cd90SMatthew G. Knepley PETSC_EXTERN PetscErrorCode VecISCopy(Vec, IS, ScatterMode, Vec);
7404473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecISSet(Vec, IS, PetscScalar);
7414473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecBoundGradientProjection(Vec, Vec, Vec, Vec, Vec);
7424473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepBoundInfo(Vec, Vec, Vec, Vec, PetscReal *, PetscReal *, PetscReal *);
7434473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepMax(Vec, Vec, PetscReal *);
7444473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepMaxBounded(Vec, Vec, Vec, Vec, PetscReal *);
7454473680cSBarry Smith 
746014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec);
747014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec);
7487dbadf16SMatthew Knepley 
749d59c15a7SBarry Smith /*S
750d59c15a7SBarry Smith      Vecs - Collection of vectors where the data for the vectors is stored in
751759e7b9cSHong Zhang             one contiguous memory
752d59c15a7SBarry Smith 
753d59c15a7SBarry Smith    Level: advanced
754d59c15a7SBarry Smith 
755d59c15a7SBarry Smith    Notes:
756d59c15a7SBarry Smith     Temporary construct for handling multiply right hand side solves
757d59c15a7SBarry Smith 
758d59c15a7SBarry Smith     This is faked by storing a single vector that has enough array space for
759d59c15a7SBarry Smith     n vectors
760d59c15a7SBarry Smith 
761d59c15a7SBarry Smith S*/
7629371c9d4SSatish Balay struct _n_Vecs {
7639371c9d4SSatish Balay   PetscInt n;
7649371c9d4SSatish Balay   Vec      v;
7659371c9d4SSatish Balay };
76695fbd943SSatish Balay typedef struct _n_Vecs     *Vecs;
767e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsDestroy(Vecs);
768e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsCreateSeq(MPI_Comm, PetscInt, PetscInt, Vecs *);
769e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsCreateSeqWithArray(MPI_Comm, PetscInt, PetscInt, PetscScalar *, Vecs *);
770e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsDuplicate(Vecs, Vecs *);
771e9fa29b7SSatish Balay 
772e9e886b6SKarl Rupp #if defined(PETSC_HAVE_VIENNACL)
773b17c682bSKarl Rupp typedef struct _p_PetscViennaCLIndices *PetscViennaCLIndices;
774b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode             PetscViennaCLIndicesCreate(PetscInt, PetscInt *, PetscInt, PetscInt *, PetscViennaCLIndices *);
775b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode             PetscViennaCLIndicesDestroy(PetscViennaCLIndices *);
776b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode             VecViennaCLCopyToGPUSome_Public(Vec, PetscViennaCLIndices);
777b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode             VecViennaCLCopyFromGPUSome_Public(Vec, PetscViennaCLIndices);
778b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode             VecCreateSeqViennaCL(MPI_Comm, PetscInt, Vec *);
779b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode             VecCreateMPIViennaCL(MPI_Comm, PetscInt, PetscInt, Vec *);
780b8ced49eSKarl Rupp #endif
78159af0bd3SScott Kruger #if defined(PETSC_HAVE_CUDA) || defined(PETSC_HAVE_HIP)
78259af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecScatterInitializeForGPU(VecScatter, Vec);
78359af0bd3SScott Kruger PETSC_EXTERN PetscErrorCode VecScatterFinalizeForGPU(VecScatter);
78459af0bd3SScott Kruger #endif
7851e8b6502SStefano Zampini #if defined(PETSC_HAVE_KOKKOS_KERNELS)
7861e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateSeqKokkos(MPI_Comm, PetscInt, Vec *);
7871e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateSeqKokkosWithArray(MPI_Comm, PetscInt, PetscInt, const PetscScalar *, Vec *);
7881e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateMPIKokkos(MPI_Comm, PetscInt, PetscInt, Vec *);
7891e8b6502SStefano Zampini PETSC_EXTERN PetscErrorCode VecCreateMPIKokkosWithArray(MPI_Comm, PetscInt, PetscInt, PetscInt, const PetscScalar *, Vec *);
7901e8b6502SStefano Zampini #endif
791b17c682bSKarl Rupp 
792014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSubVecs(Vec, PetscInt *, Vec **);
793014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSubVec(Vec, PetscInt, Vec *);
794014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestSetSubVecs(Vec, PetscInt, PetscInt *, Vec *);
795014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestSetSubVec(Vec, PetscInt, Vec);
796014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateNest(MPI_Comm, PetscInt, IS *, Vec *, Vec *);
797014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSize(Vec, PetscInt *);
79845b63f25SDmitry Karpeev 
799c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetVec(PetscOptions, const char[], const char[], Vec, PetscBool *);
8004325cce7SMatthew G Knepley PETSC_EXTERN PetscErrorCode VecChop(Vec, PetscReal);
801ab352700SBarry Smith 
802077aedafSJed Brown PETSC_EXTERN PetscErrorCode VecGetLayout(Vec, PetscLayout *);
803077aedafSJed Brown PETSC_EXTERN PetscErrorCode VecSetLayout(Vec, PetscLayout);
8049a6d0b0bSJed Brown 
8059a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode PetscSectionVecView(PetscSection, Vec, PetscViewer);
8069a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode VecGetValuesSection(Vec, PetscSection, PetscInt, PetscScalar **);
8079a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesSection(Vec, PetscSection, PetscInt, PetscScalar[], InsertMode);
80822d96a0cSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionVecNorm(PetscSection, PetscSection, Vec, NormType, PetscReal[]);
8099a6d0b0bSJed Brown 
8105543aaa0SToby Isaac /*S
8115543aaa0SToby Isaac   VecTagger - Object used to manage the tagging of a subset of indices based on the values of a vector.  The
8125543aaa0SToby Isaac               motivating application is the selection of cells for refinement or coarsening based on vector containing
8135543aaa0SToby Isaac               the values in an error indicator metric.
8145543aaa0SToby Isaac 
8155543aaa0SToby Isaac   Level: advanced
81687497f52SBarry Smith 
81720662ed9SBarry Smith   Values:
81820662ed9SBarry Smith +  `VECTAGGERABSOLUTE` - "absolute" values are in a box of explicitly defined values
81920662ed9SBarry Smith .  `VECTAGGERRELATIVE` - "relative" values are in a box of values relative to the set of all values in the vector
82020662ed9SBarry Smith .  `VECTAGGERCDF` - "cdf" values are in a relative range of the *cumulative distribution* of values in the vector
82120662ed9SBarry Smith .  `VECTAGGEROR` - "or" values are in the union of other tags
82220662ed9SBarry Smith -  `VECTAGGERAND` - "and" values are in the intersection of other tags
82320662ed9SBarry Smith 
82487497f52SBarry Smith   Developer Note:
82587497f52SBarry Smith   Why not use a `DMLabel` or similar object
82687497f52SBarry Smith 
82720662ed9SBarry Smith .seealso: [](chapter_vectors), `Vec`, `VecTaggerType`, `VecTaggerCreate()`
8285543aaa0SToby Isaac S*/
82961bbf837SToby Isaac typedef struct _p_VecTagger *VecTagger;
8305543aaa0SToby Isaac 
8315543aaa0SToby Isaac /*J
83287497f52SBarry Smith   VecTaggerType - String with the name of a `VecTagger` type
8335543aaa0SToby Isaac 
8345543aaa0SToby Isaac   Level: advanced
83520662ed9SBarry Smith 
83620662ed9SBarry Smith .seealso: [](chapter_vectors), `Vec`, `VecTagger`, `VecTaggerCreate()`
8375543aaa0SToby Isaac J*/
8385543aaa0SToby Isaac typedef const char *VecTaggerType;
839cab77d58SToby Isaac #define VECTAGGERABSOLUTE "absolute"
8405543aaa0SToby Isaac #define VECTAGGERRELATIVE "relative"
8411d1d0dd8SToby Isaac #define VECTAGGERCDF      "cdf"
8425543aaa0SToby Isaac #define VECTAGGEROR       "or"
8435543aaa0SToby Isaac #define VECTAGGERAND      "and"
8445543aaa0SToby Isaac 
8455543aaa0SToby Isaac PETSC_EXTERN PetscClassId      VEC_TAGGER_CLASSID;
84661bbf837SToby Isaac PETSC_EXTERN PetscFunctionList VecTaggerList;
84761bbf837SToby Isaac PETSC_EXTERN PetscErrorCode    VecTaggerRegister(const char[], PetscErrorCode (*)(VecTagger));
8485543aaa0SToby Isaac 
8495543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCreate(MPI_Comm, VecTagger *);
850cab77d58SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetBlockSize(VecTagger, PetscInt);
851cab77d58SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetBlockSize(VecTagger, PetscInt *);
8525543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetType(VecTagger, VecTaggerType);
8535543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetType(VecTagger, VecTaggerType *);
8545543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetInvert(VecTagger, PetscBool);
8555543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetInvert(VecTagger, PetscBool *);
8565543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetFromOptions(VecTagger);
8575543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetUp(VecTagger);
8585543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerView(VecTagger, PetscViewer);
8591cee10b1SBarry Smith PETSC_EXTERN PetscErrorCode VecTaggerComputeIS(VecTagger, Vec, IS *, PetscBool *);
8605543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerDestroy(VecTagger *);
8615543aaa0SToby Isaac 
8624178c1b7SToby Isaac /*S
8634178c1b7SToby Isaac    VecTaggerBox - A box range used to tag values.  For real scalars, this is just a closed interval; for complex scalars, the box is the closed region in the complex plane
86420662ed9SBarry Smith    such that real(min) <= real(z) <= real(max) and imag(min) <= imag(z) <= imag(max).  `INF` is an acceptable endpoint.
86561bbf837SToby Isaac 
8664178c1b7SToby Isaac    Level: beginner
86761bbf837SToby Isaac 
86820662ed9SBarry Smith .seealso: [](chapter_vectors), `Vec`, `VecTagger`, `VecTaggerType`, `VecTaggerCreate()`, `VecTaggerComputeIntervals()`
8694178c1b7SToby Isaac S*/
8704178c1b7SToby Isaac typedef struct {
8714178c1b7SToby Isaac   PetscScalar min;
8724178c1b7SToby Isaac   PetscScalar max;
8734178c1b7SToby Isaac } VecTaggerBox;
8741cee10b1SBarry Smith PETSC_EXTERN PetscErrorCode VecTaggerComputeBoxes(VecTagger, Vec, PetscInt *, VecTaggerBox **, PetscBool *);
8754178c1b7SToby Isaac 
8764178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteSetBox(VecTagger, VecTaggerBox *);
8774178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteGetBox(VecTagger, const VecTaggerBox **);
8784178c1b7SToby Isaac 
8794178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRelativeSetBox(VecTagger, VecTaggerBox *);
8804178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRelativeGetBox(VecTagger, const VecTaggerBox **);
8814178c1b7SToby Isaac 
8824178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFSetBox(VecTagger, VecTaggerBox *);
8834178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFGetBox(VecTagger, const VecTaggerBox **);
8841d1d0dd8SToby Isaac 
8851d1d0dd8SToby Isaac /*E
88687497f52SBarry Smith   VecTaggerCDFMethod - Determines what method is used to compute absolute values from cumulative distribution values (e.g., what value is the preimage of .95 in the cdf).
8871d1d0dd8SToby Isaac 
8881d1d0dd8SToby Isaac   Level: advanced
88987497f52SBarry Smith 
89020662ed9SBarry Smith    Values:
89120662ed9SBarry Smith +  `VECTAGGER_CDF_GATHER` - gather results to rank 0, perform the computation and broadcast the result
89220662ed9SBarry Smith -  `VECTAGGER_CDF_ITERATIVE` - compute the results on all ranks iteratively using `MPI_Allreduce()`
89320662ed9SBarry Smith 
89420662ed9SBarry Smith   Note:
89520662ed9SBarry Smith   Relevant only in parallel: in serial it is directly computed.
89620662ed9SBarry Smith 
89720662ed9SBarry Smith .seealso: [](chapter_vectors), `Vec`, `VecTagger`, `VecTaggerType`, `VecTaggerCreate()`, `VecTaggerCDFSetMethod()`, `VecTaggerCDFMethods`
8981d1d0dd8SToby Isaac E*/
8999371c9d4SSatish Balay typedef enum {
9009371c9d4SSatish Balay   VECTAGGER_CDF_GATHER,
9019371c9d4SSatish Balay   VECTAGGER_CDF_ITERATIVE,
9029371c9d4SSatish Balay   VECTAGGER_CDF_NUM_METHODS
9039371c9d4SSatish Balay } VecTaggerCDFMethod;
9041d1d0dd8SToby Isaac PETSC_EXTERN const char *const VecTaggerCDFMethods[];
9051d1d0dd8SToby Isaac 
9061d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFSetMethod(VecTagger, VecTaggerCDFMethod);
9071d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFGetMethod(VecTagger, VecTaggerCDFMethod *);
9081d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeSetTolerances(VecTagger, PetscInt, PetscReal, PetscReal);
9091d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeGetTolerances(VecTagger, PetscInt *, PetscReal *, PetscReal *);
91061bbf837SToby Isaac 
911497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerOrSetSubs(VecTagger, PetscInt, VecTagger *, PetscCopyMode);
912497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerOrGetSubs(VecTagger, PetscInt *, VecTagger **);
91361bbf837SToby Isaac 
914497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAndSetSubs(VecTagger, PetscInt, VecTagger *, PetscCopyMode);
915497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAndGetSubs(VecTagger, PetscInt *, VecTagger **);
91661bbf837SToby Isaac 
91761bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerInitializePackage(void);
91861bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerFinalizePackage(void);
91961bbf837SToby Isaac 
920e0f629ddSJacob Faibussowitsch #if PetscDefined(USE_DEBUG)
921e0f629ddSJacob Faibussowitsch /* This is an internal debug-only routine that should not be used by users */
922e0f629ddSJacob Faibussowitsch PETSC_SINGLE_LIBRARY_INTERN PetscErrorCode VecValidValues_Internal(Vec, PetscInt, PetscBool);
923e0f629ddSJacob Faibussowitsch #else
9243ba16761SJacob Faibussowitsch   #define VecValidValues_Internal(...) PETSC_SUCCESS
925e0f629ddSJacob Faibussowitsch #endif /* PETSC_USE_DEBUG */
926e0f629ddSJacob Faibussowitsch 
9276d54fb17SJacob Faibussowitsch #define VEC_CUPM_NOT_CONFIGURED(impl) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_SUP_SYS, "Must configure PETSc with " PetscStringize(impl) " support to use %s", PETSC_FUNCTION_NAME)
928cdf07013SJacob Faibussowitsch 
9296d54fb17SJacob Faibussowitsch #if PetscDefined(HAVE_CUDA)
930cdf07013SJacob Faibussowitsch   #define VEC_CUDA_DECL_OR_STUB(__decl__, ...) PETSC_EXTERN __decl__;
9316d54fb17SJacob Faibussowitsch #else
932cdf07013SJacob Faibussowitsch   #define VEC_CUDA_DECL_OR_STUB(__decl__, ...) \
933cdf07013SJacob Faibussowitsch     static inline __decl__ \
9346d54fb17SJacob Faibussowitsch     { \
935cdf07013SJacob Faibussowitsch       __VA_ARGS__; \
9366d54fb17SJacob Faibussowitsch       VEC_CUPM_NOT_CONFIGURED(cuda); \
9376d54fb17SJacob Faibussowitsch     }
9386d54fb17SJacob Faibussowitsch #endif /* PETSC_HAVE_CUDA */
9396d54fb17SJacob Faibussowitsch 
9406d54fb17SJacob Faibussowitsch /* extra underscore here to make it line up with the cuda versions */
9416d54fb17SJacob Faibussowitsch #if PetscDefined(HAVE_HIP)
942cdf07013SJacob Faibussowitsch   #define VEC_HIP__DECL_OR_STUB(__decl__, ...) PETSC_EXTERN __decl__;
9436d54fb17SJacob Faibussowitsch #else
944cdf07013SJacob Faibussowitsch   #define VEC_HIP__DECL_OR_STUB(__decl__, ...) \
945cdf07013SJacob Faibussowitsch     static inline __decl__ \
9466d54fb17SJacob Faibussowitsch     { \
947cdf07013SJacob Faibussowitsch       __VA_ARGS__; \
9486d54fb17SJacob Faibussowitsch       VEC_CUPM_NOT_CONFIGURED(hip); \
9496d54fb17SJacob Faibussowitsch     }
9506d54fb17SJacob Faibussowitsch #endif /* PETSC_HAVE_HIP */
9516d54fb17SJacob Faibussowitsch 
952cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCreateSeqCUDA(MPI_Comm a, PetscInt b, Vec *c), (void)a, (void)b, (void)c)
953cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecCreateSeqHIP(MPI_Comm a, PetscInt b, Vec *c), (void)a, (void)b, (void)c)
9546d54fb17SJacob Faibussowitsch 
955cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCreateSeqCUDAWithArray(MPI_Comm a, PetscInt b, PetscInt c, const PetscScalar *d, Vec *e), (void)a, (void)b, (void)c, (void)d, (void)e)
956cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecCreateSeqHIPWithArray(MPI_Comm a, PetscInt b, PetscInt c, const PetscScalar *d, Vec *e), (void)a, (void)b, (void)c, (void)d, (void)e)
9576d54fb17SJacob Faibussowitsch 
958cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCreateSeqCUDAWithArrays(MPI_Comm a, PetscInt b, PetscInt c, const PetscScalar *d, const PetscScalar *e, Vec *f), (void)a, (void)b, (void)c, (void)d, (void)e, (void)f)
959cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecCreateSeqHIPWithArrays(MPI_Comm a, PetscInt b, PetscInt c, const PetscScalar *d, const PetscScalar *e, Vec *f), (void)a, (void)b, (void)c, (void)d, (void)e, (void)f)
9606d54fb17SJacob Faibussowitsch 
961cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCreateMPICUDA(MPI_Comm a, PetscInt b, PetscInt c, Vec *d), (void)a, (void)b, (void)c, (void)d)
962cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecCreateMPIHIP(MPI_Comm a, PetscInt b, PetscInt c, Vec *d), (void)a, (void)b, (void)c, (void)d)
9636d54fb17SJacob Faibussowitsch 
964cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCreateMPICUDAWithArray(MPI_Comm a, PetscInt b, PetscInt c, PetscInt d, const PetscScalar *e, Vec *f), (void)a, (void)b, (void)c, (void)d, (void)e, (void)f)
965cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecCreateMPIHIPWithArray(MPI_Comm a, PetscInt b, PetscInt c, PetscInt d, const PetscScalar *e, Vec *f), (void)a, (void)b, (void)c, (void)d, (void)e, (void)f)
9666d54fb17SJacob Faibussowitsch 
967cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCreateMPICUDAWithArrays(MPI_Comm a, PetscInt b, PetscInt c, PetscInt d, const PetscScalar *e, const PetscScalar *f, Vec *g), (void)a, (void)b, (void)c, (void)d, (void)e, (void)f, (void)g)
968cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecCreateMPIHIPWithArrays(MPI_Comm a, PetscInt b, PetscInt c, PetscInt d, const PetscScalar *e, const PetscScalar *f, Vec *g), (void)a, (void)b, (void)c, (void)d, (void)e, (void)f, (void)g)
9696d54fb17SJacob Faibussowitsch 
970cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDAGetArray(Vec a, PetscScalar **b), (void)a, (void)b)
971cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPGetArray(Vec a, PetscScalar **b), (void)a, (void)b)
9726d54fb17SJacob Faibussowitsch 
973cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDARestoreArray(Vec a, PetscScalar **b), (void)a, (void)b)
974cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPRestoreArray(Vec a, PetscScalar **b), (void)a, (void)b)
9756d54fb17SJacob Faibussowitsch 
976cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDAGetArrayRead(Vec a, const PetscScalar **b), (void)a, (void)b)
977cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPGetArrayRead(Vec a, const PetscScalar **b), (void)a, (void)b)
9786d54fb17SJacob Faibussowitsch 
979cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDARestoreArrayRead(Vec a, const PetscScalar **b), (void)a, (void)b)
980cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPRestoreArrayRead(Vec a, const PetscScalar **b), (void)a, (void)b)
9816d54fb17SJacob Faibussowitsch 
982cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDAGetArrayWrite(Vec a, PetscScalar **b), (void)a, (void)b)
983cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPGetArrayWrite(Vec a, PetscScalar **b), (void)a, (void)b)
9846d54fb17SJacob Faibussowitsch 
985cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDARestoreArrayWrite(Vec a, PetscScalar **b), (void)a, (void)b)
986cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPRestoreArrayWrite(Vec a, PetscScalar **b), (void)a, (void)b)
9876d54fb17SJacob Faibussowitsch 
988cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDAPlaceArray(Vec a, const PetscScalar b[]), (void)a, (void)b)
989cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPPlaceArray(Vec a, const PetscScalar b[]), (void)a, (void)b)
9906d54fb17SJacob Faibussowitsch 
991cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDAReplaceArray(Vec a, const PetscScalar b[]), (void)a, (void)b)
992cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPReplaceArray(Vec a, const PetscScalar b[]), (void)a, (void)b)
9936d54fb17SJacob Faibussowitsch 
994cdf07013SJacob Faibussowitsch VEC_CUDA_DECL_OR_STUB(PetscErrorCode VecCUDAResetArray(Vec a), (void)a)
995cdf07013SJacob Faibussowitsch VEC_HIP__DECL_OR_STUB(PetscErrorCode VecHIPResetArray(Vec a), (void)a)
9966d54fb17SJacob Faibussowitsch 
9976d54fb17SJacob Faibussowitsch #undef VEC_CUPM_NOT_CONFIGURED
9986d54fb17SJacob Faibussowitsch #undef VEC_CUDA_DECL_OR_STUB
9996d54fb17SJacob Faibussowitsch #undef VEC_HIP__DECL_OR_STUB
10006d54fb17SJacob Faibussowitsch 
10012eac72dbSBarry Smith #endif
1002