xref: /petsc/include/petscvec.h (revision f94e795aceab6ef1c1382ce14743fd201c9b87b3)
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 */
62eac72dbSBarry Smith 
726bd1501SBarry Smith #ifndef PETSCVEC_H
826bd1501SBarry Smith #define PETSCVEC_H
92c8e378dSBarry Smith #include <petscis.h>
10665c2dedSJed Brown #include <petscviewer.h>
112eac72dbSBarry Smith 
1209321671SBarry Smith /*S
1309321671SBarry Smith      Vec - Abstract PETSc vector object
1409321671SBarry Smith 
1509321671SBarry Smith    Level: beginner
1609321671SBarry Smith 
1709321671SBarry Smith .seealso:  VecCreate(), VecType, VecSetType()
1809321671SBarry Smith S*/
19f09e8eb9SSatish Balay typedef struct _p_Vec*         Vec;
2009321671SBarry Smith 
2109321671SBarry Smith /*S
2209321671SBarry Smith      VecScatter - Object used to manage communication of data
2309321671SBarry Smith        between vectors in parallel. Manages both scatters and gathers
2409321671SBarry Smith 
2509321671SBarry Smith    Level: beginner
2609321671SBarry Smith 
27130e142eSJunchao Zhang .seealso:  VecScatterCreate(), VecScatterBegin(), VecScatterEnd()
2809321671SBarry Smith S*/
29f09e8eb9SSatish Balay typedef struct _p_VecScatter*  VecScatter;
3009321671SBarry Smith 
3109321671SBarry Smith /*E
32398c84b2SBarry Smith   ScatterMode - Determines the direction of a scatter
33398c84b2SBarry Smith 
34398c84b2SBarry Smith   Level: beginner
35398c84b2SBarry Smith 
36398c84b2SBarry Smith .seealso: VecScatter, VecScatterBegin(), VecScatterEnd()
37398c84b2SBarry Smith E*/
38398c84b2SBarry Smith typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode;
39398c84b2SBarry Smith 
40398c84b2SBarry Smith /*MC
41130e142eSJunchao Zhang     SCATTER_FORWARD - Scatters the values as dictated by the VecScatterCreate() call
42398c84b2SBarry Smith 
43398c84b2SBarry Smith     Level: beginner
44398c84b2SBarry Smith 
45130e142eSJunchao Zhang .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL,
46398c84b2SBarry Smith           SCATTER_REVERSE_LOCAL
47398c84b2SBarry Smith 
48398c84b2SBarry Smith M*/
49398c84b2SBarry Smith 
50398c84b2SBarry Smith /*MC
51398c84b2SBarry Smith     SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in
52130e142eSJunchao Zhang          in the VecScatterCreate()
53398c84b2SBarry Smith 
54398c84b2SBarry Smith     Level: beginner
55398c84b2SBarry Smith 
56130e142eSJunchao Zhang .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
57398c84b2SBarry Smith           SCATTER_REVERSE_LOCAL
58398c84b2SBarry Smith 
59398c84b2SBarry Smith M*/
60398c84b2SBarry Smith 
61398c84b2SBarry Smith /*MC
62130e142eSJunchao Zhang     SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the VecScatterCreate() call except NO parallel communication
63398c84b2SBarry Smith        is done. Any variables that have be moved between processes are ignored
64398c84b2SBarry Smith 
65398c84b2SBarry Smith     Level: developer
66398c84b2SBarry Smith 
67130e142eSJunchao Zhang .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD,
68398c84b2SBarry Smith           SCATTER_REVERSE_LOCAL
69398c84b2SBarry Smith 
70398c84b2SBarry Smith M*/
71398c84b2SBarry Smith 
72398c84b2SBarry Smith /*MC
73398c84b2SBarry Smith     SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in
74130e142eSJunchao Zhang          in the VecScatterCreate()  except NO parallel communication
75398c84b2SBarry Smith        is done. Any variables that have be moved between processes are ignored
76398c84b2SBarry Smith 
77398c84b2SBarry Smith     Level: developer
78398c84b2SBarry Smith 
79130e142eSJunchao Zhang .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
80398c84b2SBarry Smith           SCATTER_REVERSE
81398c84b2SBarry Smith 
82398c84b2SBarry Smith M*/
83398c84b2SBarry Smith 
8476bdecfbSBarry Smith /*J
858f6c3df8SBarry Smith     VecType - String with the name of a PETSc vector
8609321671SBarry Smith 
8709321671SBarry Smith    Level: beginner
8809321671SBarry Smith 
898f6c3df8SBarry Smith .seealso: VecSetType(), Vec, VecCreate(), VecDestroy()
9076bdecfbSBarry Smith J*/
9119fd82e9SBarry Smith typedef const char* VecType;
920676abe4SMatthew Knepley #define VECSEQ         "seq"
930676abe4SMatthew Knepley #define VECMPI         "mpi"
94f48c50deSBarry Smith #define VECSTANDARD    "standard"   /* seq on one process and mpi on several */
950676abe4SMatthew Knepley #define VECSHARED      "shared"
96b17c682bSKarl Rupp #define VECSEQVIENNACL "seqviennacl"
97b17c682bSKarl Rupp #define VECMPIVIENNACL "mpiviennacl"
98b17c682bSKarl Rupp #define VECVIENNACL    "viennacl"   /* seqviennacl on one process and mpiviennacl on several */
9982f73ecaSAlejandro Lamas Daviña #define VECSEQCUDA     "seqcuda"
10082f73ecaSAlejandro Lamas Daviña #define VECMPICUDA     "mpicuda"
10182f73ecaSAlejandro Lamas Daviña #define VECCUDA        "cuda"       /* seqcuda on one process and mpicuda on several */
1021aae2881SJed Brown #define VECNEST        "nest"
103803a1b88SHong Zhang #define VECNODE        "node"       /* use on-node shared memory */
1042eac72dbSBarry Smith 
105803a1b88SHong Zhang /*J
106803a1b88SHong Zhang     VecScatterType - String with the name of a PETSc vector scatter type
107803a1b88SHong Zhang 
108803a1b88SHong Zhang    Level: beginner
109803a1b88SHong Zhang 
110130e142eSJunchao Zhang .seealso: VecScatterSetType(), VecScatter, VecScatterCreate(), VecScatterDestroy()
111803a1b88SHong Zhang J*/
112803a1b88SHong Zhang typedef const char* VecScatterType;
113803a1b88SHong Zhang #define VECSCATTERSEQ       "seq"
114803a1b88SHong Zhang #define VECSCATTERMPI1      "mpi1"
115803a1b88SHong Zhang #define VECSCATTERMPI3      "mpi3"     /* use MPI3 on-node shared memory */
116803a1b88SHong Zhang #define VECSCATTERMPI3NODE  "mpi3node" /* use MPI3 on-node shared memory for vector type VECNODE */
117ef6f2af5SJunchao Zhang #define VECSCATTERSF        "sf"       /* use StarForest */
118803a1b88SHong Zhang 
119803a1b88SHong Zhang /* Dynamic creation and loading functions */
120803a1b88SHong Zhang PETSC_EXTERN PetscFunctionList VecScatterList;
121803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterSetType(VecScatter, VecScatterType);
122803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterGetType(VecScatter, VecScatterType *);
123803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterSetFromOptions(VecScatter);
124803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterRegister(const char[],PetscErrorCode (*)(VecScatter));
125130e142eSJunchao Zhang PETSC_EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter*);
126803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterInitializePackage(void);
127803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecScatterFinalizePackage(void);
1284b71561bSShri Abhyankar 
129fd487807SMatthew Knepley /* Logging support */
130450a797fSBarry Smith #define    REAL_FILE_CLASSID 1211213
1310700a824SBarry Smith #define    VEC_FILE_CLASSID 1211214
132014dd563SJed Brown PETSC_EXTERN PetscClassId VEC_CLASSID;
133014dd563SJed Brown PETSC_EXTERN PetscClassId VEC_SCATTER_CLASSID;
1348ba1e511SMatthew Knepley 
13545b63f25SDmitry Karpeev 
136607a6623SBarry Smith PETSC_EXTERN PetscErrorCode VecInitializePackage(void);
137014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecFinalizePackage(void);
138fd487807SMatthew Knepley 
139014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec*);
140014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*);
141014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
142014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
143014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar[],Vec*);
144014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
145803a1b88SHong Zhang PETSC_EXTERN PetscErrorCode VecCreateNode(MPI_Comm,PetscInt,PetscInt,Vec*);
146803a1b88SHong Zhang 
147014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetFromOptions(Vec);
148fe2efc57SMark PETSC_EXTERN PetscErrorCode VecViewFromOptions(Vec,PetscObject,const char[]);
1490d2bece7SBarry Smith 
150014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetUp(Vec);
151014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDestroy(Vec*);
152014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecZeroEntries(Vec);
153014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOptionsPrefix(Vec,const char[]);
154014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAppendOptionsPrefix(Vec,const char[]);
155014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOptionsPrefix(Vec,const char*[]);
156f69a0ea3SMatthew Knepley 
157014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetSizes(Vec,PetscInt,PetscInt);
158fd487807SMatthew Knepley 
15952b6e47cSBarry Smith PETSC_EXTERN PetscErrorCode VecDotNorm2(Vec,Vec,PetscScalar*,PetscReal*);
160014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*);
16167392de3SBarry Smith PETSC_EXTERN PetscErrorCode VecDotRealPart(Vec,Vec,PetscReal*);
162014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*);
163014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]);
164014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]);
165014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetSubVector(Vec,IS,Vec*);
166014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreSubVector(Vec,IS,Vec*);
167cddf8d76SBarry Smith 
16809321671SBarry Smith /*E
16909321671SBarry Smith     NormType - determines what type of norm to compute
17009321671SBarry Smith 
17109321671SBarry Smith     Level: beginner
17209321671SBarry Smith 
17309321671SBarry Smith .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
17409321671SBarry Smith E*/
1759dcbbd2bSBarry Smith typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType;
1766a6fc655SJed Brown PETSC_EXTERN const char *const NormTypes[];
177cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY
17809321671SBarry Smith 
1799b250c83SBarry Smith /*MC
1809b250c83SBarry Smith      NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum
1819b250c83SBarry Smith 
1829b250c83SBarry Smith    Level: beginner
1839b250c83SBarry Smith 
1849b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
1859b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
1869b250c83SBarry Smith 
1879b250c83SBarry Smith M*/
1889b250c83SBarry Smith 
1899b250c83SBarry Smith /*MC
190df54d55cSMatthias Liertzer      NORM_2 - the two norm, ||v|| = sqrt(sum_i |v_i|^2) (vectors only)
1919b250c83SBarry Smith 
1929b250c83SBarry Smith    Level: beginner
1939b250c83SBarry Smith 
1949b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
1959b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
1969b250c83SBarry Smith 
1979b250c83SBarry Smith M*/
1989b250c83SBarry Smith 
1999b250c83SBarry Smith /*MC
200df54d55cSMatthias Liertzer      NORM_FROBENIUS - ||A|| = sqrt(sum_ij |A_ij|^2), same as NORM_2 for vectors
2019b250c83SBarry Smith 
2029b250c83SBarry Smith    Level: beginner
2039b250c83SBarry Smith 
2049b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
2059b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
2069b250c83SBarry Smith 
2079b250c83SBarry Smith M*/
2089b250c83SBarry Smith 
2099b250c83SBarry Smith /*MC
2109b250c83SBarry Smith      NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum
2119b250c83SBarry Smith 
2129b250c83SBarry Smith    Level: beginner
2139b250c83SBarry Smith 
2149b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
2159b250c83SBarry Smith            NORM_FROBINIUS, NORM_1_AND_2
2169b250c83SBarry Smith 
2179b250c83SBarry Smith M*/
2189b250c83SBarry Smith 
2199b250c83SBarry Smith /*MC
2209b250c83SBarry Smith      NORM_1_AND_2 - computes both the 1 and 2 norm of a vector
2219b250c83SBarry Smith 
2229b250c83SBarry Smith    Level: beginner
2239b250c83SBarry Smith 
2249b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
2259b250c83SBarry Smith            NORM_FROBINIUS, NORM_INFINITY
2269b250c83SBarry Smith 
2279b250c83SBarry Smith M*/
2289b250c83SBarry Smith 
2299b250c83SBarry Smith /*MC
2309b250c83SBarry Smith      NORM_MAX - see NORM_INFINITY
2319b250c83SBarry Smith 
232d41222bbSBarry Smith    Level: beginner
233d41222bbSBarry Smith 
2349b250c83SBarry Smith M*/
2359b250c83SBarry Smith 
236014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *);
237014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormAvailable(Vec,NormType,PetscBool *,PetscReal *);
238014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *);
239014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSum(Vec,PetscScalar*);
240014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *);
241014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *);
242014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScale(Vec,PetscScalar);
243014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCopy(Vec,Vec);
244014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetRandom(Vec,PetscRandom);
245014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSet(Vec,PetscScalar);
246422a814eSBarry Smith PETSC_EXTERN PetscErrorCode VecSetInf(Vec);
247014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSwap(Vec,Vec);
248014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPY(Vec,PetscScalar,Vec);
249014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
250014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]);
251014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAYPX(Vec,PetscScalar,Vec);
252014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecWAXPY(Vec,PetscScalar,Vec,Vec);
253014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec);
254014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec);
255014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec);
256014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec);
257014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec);
258014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec);
259014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
260014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecShift(Vec,PetscScalar);
261014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecReciprocal(Vec);
262014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPermute(Vec, IS, PetscBool);
263014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSqrtAbs(Vec);
264014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecLog(Vec);
265014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecExp(Vec);
266014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAbs(Vec);
267014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDuplicate(Vec,Vec*);
268014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]);
269014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDestroyVecs(PetscInt, Vec*[]);
270014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal[]);
271014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt [],PetscReal []);
272014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt [],PetscReal []);
273014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScaleAll(Vec,const PetscScalar[]);
274849b11cfSMatthew G. Knepley PETSC_EXTERN PetscErrorCode VecUniqueEntries(Vec,PetscInt*,PetscScalar**);
2754a560884SBarry Smith 
276014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
277014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
278014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
279014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar);
280014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideSet(Vec,PetscInt,PetscScalar);
281954b3ec6SBarry Smith 
282954b3ec6SBarry Smith 
283014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode);
284014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
285014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec[],InsertMode);
286014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStrideScatterAll(Vec[],Vec,InsertMode);
287d2655a18SBarry Smith 
288bdeb6c88SBarry Smith PETSC_EXTERN PetscErrorCode VecStrideSubSetScatter(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
289bdeb6c88SBarry Smith PETSC_EXTERN PetscErrorCode VecStrideSubSetGather(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
290bdeb6c88SBarry Smith 
291014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
292014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
293014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAssemblyBegin(Vec);
294014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecAssemblyEnd(Vec);
295014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt);
296014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashView(Vec,PetscViewer);
297685405a1SBarry Smith PETSC_EXTERN PetscErrorCode VecStashViewFromOptions(Vec,PetscObject,const char[]);
298014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
29962dc5420SSatish Balay 
30030de9b25SBarry Smith /*MC
30130de9b25SBarry Smith    VecSetValue - Set a single entry into a vector.
30230de9b25SBarry Smith 
30330de9b25SBarry Smith    Synopsis:
304aaa7dc30SBarry Smith    #include <petscvec.h>
3058122439eSJed Brown    PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode);
30630de9b25SBarry Smith 
30730de9b25SBarry Smith    Not Collective
30830de9b25SBarry Smith 
30930de9b25SBarry Smith    Input Parameters:
31030de9b25SBarry Smith +  v - the vector
31130de9b25SBarry Smith .  row - the row location of the entry
31230de9b25SBarry Smith .  value - the value to insert
31330de9b25SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
31430de9b25SBarry Smith 
31530de9b25SBarry Smith    Notes:
31630de9b25SBarry Smith    For efficiency one should use VecSetValues() and set several or
31730de9b25SBarry Smith    many values simultaneously if possible.
31830de9b25SBarry Smith 
3191d73ed98SBarry Smith    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
320879a43d7SBarry Smith    MUST be called after all calls to VecSetValue() have been completed.
3211d73ed98SBarry Smith 
322879a43d7SBarry Smith    VecSetValue() uses 0-based indices in Fortran as well as in C.
3231d73ed98SBarry Smith 
3241d73ed98SBarry Smith    Level: beginner
3251d73ed98SBarry Smith 
3261d73ed98SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal()
3271d73ed98SBarry Smith M*/
32850755921SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);}
3291d73ed98SBarry Smith 
33030de9b25SBarry Smith 
331014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt);
332014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*);
333014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
3348ed539a5SBarry Smith 
335fd487807SMatthew Knepley /* Dynamic creation and loading functions */
336140e18c1SBarry Smith PETSC_EXTERN PetscFunctionList VecList;
33719fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode VecSetType(Vec,VecType);
33819fd82e9SBarry Smith PETSC_EXTERN PetscErrorCode VecGetType(Vec,VecType*);
339bdf89e91SBarry Smith PETSC_EXTERN PetscErrorCode VecRegister(const char[],PetscErrorCode (*)(Vec));
34030de9b25SBarry Smith 
341014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode);
342014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode);
343014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterDestroy(VecScatter*);
344246626dcSBarry Smith PETSC_EXTERN PetscErrorCode VecScatterSetUp(VecScatter);
345014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *);
346014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer);
347fe2efc57SMark PETSC_EXTERN PetscErrorCode VecScatterViewFromOptions(VecScatter,PetscObject,const char[]);
348d27e6124SSatish Balay PETSC_EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt[],PetscInt[]);
349014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscBool*);
3502195c698SBarry Smith 
351014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
352014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
353014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
354014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
355014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
356014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
357014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]);
358014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar*[]);
359ab360428SBarry Smith 
360fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
361fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
362fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray4dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
363fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
364fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray3dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
365fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
366fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray2dWrite(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
367fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]);
368fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray1dWrite(Vec,PetscInt,PetscInt,PetscScalar*[]);
369fdc842d1SBarry Smith 
3705edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
3715edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray4dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
3725edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
3735edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray3dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
3745edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
3755edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray2dRead(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
3765edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecGetArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]);
3775edff71fSBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArray1dRead(Vec,PetscInt,PetscInt,PetscScalar*[]);
3785edff71fSBarry Smith 
379014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]);
380014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecResetArray(Vec);
381014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]);
382de0d48c1SKarl Rupp 
383014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetArrays(const Vec[],PetscInt,PetscScalar**[]);
384014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]);
38584cb2905SBarry Smith 
386014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecView(Vec,PetscViewer);
387014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscBool*);
388014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecLoad(Vec,PetscViewer);
3898ed539a5SBarry Smith 
390014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*);
391014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*);
392014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
393014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetOwnershipRanges(Vec,const PetscInt*[]);
3948ed539a5SBarry Smith 
395014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping);
396014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
39788b03592SBarry Smith 
3989a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArray(Vec,PetscScalar**);
3999a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArray(Vec,PetscScalar**);
400de0d48c1SKarl Rupp 
4019a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArrayRead(Vec,const PetscScalar**);
4029a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayRead(Vec,const PetscScalar**);
403de0d48c1SKarl Rupp 
4049a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAGetArrayWrite(Vec,PetscScalar**);
4059a971ab9SStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDARestoreArrayWrite(Vec,PetscScalar**);
406de0d48c1SKarl Rupp 
407cbf3516aSStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAPlaceArray(Vec,const PetscScalar[]);
408cbf3516aSStefano Zampini PETSC_EXTERN PetscErrorCode VecCUDAReplaceArray(Vec,const PetscScalar[]);
409de0d48c1SKarl Rupp PETSC_EXTERN PetscErrorCode VecCUDAResetArray(Vec);
410de0d48c1SKarl Rupp 
41176ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLContext(Vec, PETSC_UINTPTR_T*);
41276ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLQueue(Vec, PETSC_UINTPTR_T*);
41376ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemRead(Vec, PETSC_UINTPTR_T*);
41476ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMemWrite(Vec, PETSC_UINTPTR_T*);
41576ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMemWrite(Vec);
41676ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLGetCLMem(Vec, PETSC_UINTPTR_T*);
41776ec7f3eSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecViennaCLRestoreCLMem(Vec);
41876ec7f3eSKaushik Kulkarni 
41988b03592SBarry Smith /*MC
42088b03592SBarry Smith    VecSetValueLocal - Set a single entry into a vector using the local numbering
42188b03592SBarry Smith 
42288b03592SBarry Smith    Synopsis:
423aaa7dc30SBarry Smith    #include <petscvec.h>
4248122439eSJed Brown    PetscErrorCode VecSetValueLocal(Vec v,PetscInt row,PetscScalar value, InsertMode mode);
42588b03592SBarry Smith 
42688b03592SBarry Smith    Not Collective
42788b03592SBarry Smith 
42888b03592SBarry Smith    Input Parameters:
42988b03592SBarry Smith +  v - the vector
43088b03592SBarry Smith .  row - the row location of the entry
43188b03592SBarry Smith .  value - the value to insert
43288b03592SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
43388b03592SBarry Smith 
43488b03592SBarry Smith    Notes:
43588b03592SBarry Smith    For efficiency one should use VecSetValues() and set several or
43688b03592SBarry Smith    many values simultaneously if possible.
43788b03592SBarry Smith 
43888b03592SBarry Smith    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
43988b03592SBarry Smith    MUST be called after all calls to VecSetValues() have been completed.
44088b03592SBarry Smith 
44188b03592SBarry Smith    VecSetValues() uses 0-based indices in Fortran as well as in C.
44288b03592SBarry Smith 
44388b03592SBarry Smith    Level: beginner
44488b03592SBarry Smith 
44588b03592SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue()
44688b03592SBarry Smith M*/
44788b03592SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);}
44888b03592SBarry Smith 
449014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
450014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping*);
45190f02eecSBarry Smith 
452014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *);
453014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *);
454014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *);
455014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *);
456014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *);
457014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *);
458d3c178dbSBarry Smith 
459014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
460014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
461014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
462014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
463014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscCommSplitReductionBegin(MPI_Comm);
464a751f32aSSatish Balay 
465b470e4b4SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecBindToCPU(Vec,PetscBool);
466b470e4b4SRichard Tran Mills PETSC_DEPRECATED_FUNCTION("Use VecBindToCPU (since v3.13)") PETSC_STATIC_INLINE PetscErrorCode VecPinToCPU(Vec v,PetscBool flg) {return VecBindToCPU(v,flg);}
467387df023SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecSetPinnedMemoryMin(Vec,size_t);
468387df023SRichard Tran Mills PETSC_EXTERN PetscErrorCode VecGetPinnedMemoryMin(Vec,size_t *);
469a751f32aSSatish Balay 
470bda0d2a0SJed Brown typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES,VEC_SUBSET_OFF_PROC_ENTRIES} VecOption;
471014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOption(Vec,VecOption,PetscBool);
47290f02eecSBarry Smith 
4735c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecGetArray(Vec,PetscScalar**);
474fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecGetArrayWrite(Vec,PetscScalar**);
4755c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecGetArrayRead(Vec,const PetscScalar**);
4765c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArray(Vec,PetscScalar**);
477fdc842d1SBarry Smith PETSC_EXTERN PetscErrorCode VecRestoreArrayWrite(Vec,PetscScalar**);
4785c0c2446SJed Brown PETSC_EXTERN PetscErrorCode VecRestoreArrayRead(Vec,const PetscScalar**);
479046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecGetLocalVector(Vec,Vec);
480046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecRestoreLocalVector(Vec,Vec);
481046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec,Vec);
482046dc149SDominic Meiser PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec,Vec);
4839521ec69SBarry Smith 
48410ffa2edSJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayInPlace(Vec,PetscScalar**);
48510ffa2edSJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayInPlace(Vec,PetscScalar**);
48610ffa2edSJunchao Zhang PETSC_EXTERN PetscErrorCode VecGetArrayReadInPlace(Vec,const PetscScalar**);
48710ffa2edSJunchao Zhang PETSC_EXTERN PetscErrorCode VecRestoreArrayReadInPlace(Vec,const PetscScalar**);
48810ffa2edSJunchao Zhang 
4899521ec69SBarry Smith /*@C
4909521ec69SBarry Smith    VecGetArrayPair - Accesses a pair of pointers for two vectors that may be common. When not common the first is read only
4919521ec69SBarry Smith 
492d083f849SBarry Smith    Logically Collective on x
4939521ec69SBarry Smith 
494f5f57ec0SBarry Smith    Input Parameters:
4959521ec69SBarry Smith +  x - the vector
4969521ec69SBarry Smith -  y - the second vector
4979521ec69SBarry Smith 
498f5f57ec0SBarry Smith    Output Parameters:
4999521ec69SBarry Smith +  xv - location to put pointer to the first array
5009521ec69SBarry Smith -  yv - location to put pointer to the second array
5019521ec69SBarry Smith 
5029521ec69SBarry Smith    Level: developer
5039521ec69SBarry Smith 
504f5f57ec0SBarry Smith    Not available from Fortran
505f5f57ec0SBarry Smith 
5069521ec69SBarry Smith .seealso: VecGetArray(), VecGetArrayRead(), VecRestoreArrayPair()
5079521ec69SBarry Smith 
5089521ec69SBarry Smith @*/
509d9ca1df4SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecGetArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv)
510d9ca1df4SBarry Smith {
511d9ca1df4SBarry Smith   PetscErrorCode ierr;
512d9ca1df4SBarry Smith 
513d9ca1df4SBarry Smith   PetscFunctionBegin;
514d9ca1df4SBarry Smith   ierr = VecGetArray(y,yv);CHKERRQ(ierr);
515d9ca1df4SBarry Smith   if (x != y) {
516d9ca1df4SBarry Smith     ierr = VecGetArrayRead(x,(const PetscScalar **)xv);CHKERRQ(ierr);
517d9ca1df4SBarry Smith   } else {
518d9ca1df4SBarry Smith     *xv = *yv;
519d9ca1df4SBarry Smith   }
520d9ca1df4SBarry Smith   PetscFunctionReturn(0);
521d9ca1df4SBarry Smith }
5229521ec69SBarry Smith 
5239521ec69SBarry Smith /*@C
5249521ec69SBarry Smith    VecRestoreArrayPair - Returns a pair of pointers for two vectors that may be common. When not common the first is read only
5259521ec69SBarry Smith 
526d083f849SBarry Smith    Logically Collective on x
5279521ec69SBarry Smith 
528f5f57ec0SBarry Smith    Input Parameters:
5299521ec69SBarry Smith +  x - the vector
5309521ec69SBarry Smith -  y - the second vector
5319521ec69SBarry Smith 
532f5f57ec0SBarry Smith    Output Parameters:
5339521ec69SBarry Smith +  xv - location to put pointer to the first array
5349521ec69SBarry Smith -  yv - location to put pointer to the second array
5359521ec69SBarry Smith 
5369521ec69SBarry Smith    Level: developer
5379521ec69SBarry Smith 
538f5f57ec0SBarry Smith    Not available from Fortran
539f5f57ec0SBarry Smith 
5409521ec69SBarry Smith .seealso: VecGetArray(), VecGetArrayRead(), VecGetArrayPair()
5419521ec69SBarry Smith 
5429521ec69SBarry Smith @*/
543d9ca1df4SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecRestoreArrayPair(Vec x,Vec y,PetscScalar **xv,PetscScalar **yv)
544d9ca1df4SBarry Smith {
545d9ca1df4SBarry Smith   PetscErrorCode ierr;
546d9ca1df4SBarry Smith 
547d9ca1df4SBarry Smith   PetscFunctionBegin;
548d9ca1df4SBarry Smith   ierr = VecRestoreArray(y,yv);CHKERRQ(ierr);
549d9ca1df4SBarry Smith   if (x != y) {
550d9ca1df4SBarry Smith     ierr = VecRestoreArrayRead(x,(const PetscScalar **)xv);CHKERRQ(ierr);
551d9ca1df4SBarry Smith   }
552d9ca1df4SBarry Smith   PetscFunctionReturn(0);
553d9ca1df4SBarry Smith }
554d9ca1df4SBarry Smith 
555d9ca1df4SBarry Smith #if defined(PETSC_USE_DEBUG)
55638fecf7cSJunchao Zhang PETSC_EXTERN PetscErrorCode VecLockReadPush(Vec);
55738fecf7cSJunchao Zhang PETSC_EXTERN PetscErrorCode VecLockReadPop(Vec);
55838fecf7cSJunchao Zhang /* We also have a non-public VecLockWriteSet_Private() in vecimpl.h */
559d9ca1df4SBarry Smith PETSC_EXTERN PetscErrorCode VecLockGet(Vec,PetscInt*);
560da1c2f70SJunchao Zhang PETSC_STATIC_INLINE PetscErrorCode VecSetErrorIfLocked(Vec x,PetscInt arg)
561da1c2f70SJunchao Zhang {
562da1c2f70SJunchao Zhang   PetscInt       state;
563da1c2f70SJunchao Zhang   PetscErrorCode ierr;
56438fecf7cSJunchao Zhang 
565da1c2f70SJunchao Zhang   PetscFunctionBegin;
566da1c2f70SJunchao Zhang   ierr = VecLockGet(x,&state);CHKERRQ(ierr);
567da1c2f70SJunchao Zhang   if (state != 0) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONGSTATE," Vec is already locked for read-only or read/write access, argument # %d",arg);
568da1c2f70SJunchao Zhang   PetscFunctionReturn(0);
569da1c2f70SJunchao Zhang }
57038fecf7cSJunchao Zhang /* The three are deprecated */
5715f1efc1aSLisandro Dalcin PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPush() (since version 3.11)") PetscErrorCode VecLockPush(Vec);
5725f1efc1aSLisandro Dalcin PETSC_EXTERN PETSC_DEPRECATED_FUNCTION("Use VecLockReadPop() (since version 3.11)")  PetscErrorCode VecLockPop(Vec);
573ed274036SLisandro Dalcin #define VecLocked(x,arg) VecSetErrorIfLocked(x,arg) PETSC_DEPRECATED_MACRO("GCC warning \"Use VecSetErrorIfLocked() (since version 3.11)\"")
574d9ca1df4SBarry Smith #else
57545fccdb2SJunchao Zhang #define VecLockReadPush(x)           0
57645fccdb2SJunchao Zhang #define VecLockReadPop(x)            0
57738fecf7cSJunchao Zhang #define VecLockGet(x,s)              *(s) = 0
57845fccdb2SJunchao Zhang #define VecSetErrorIfLocked(x,arg)   0
57938fecf7cSJunchao Zhang /* The three are deprecated */
58045fccdb2SJunchao Zhang #define VecLockPush(x)               0
58145fccdb2SJunchao Zhang #define VecLockPop(x)                0
58245fccdb2SJunchao Zhang #define VecLocked(x,arg)             0
583d9ca1df4SBarry Smith #endif
584e1fa1e0fSSatish Balay 
58562796dfbSBarry Smith PETSC_EXTERN PetscErrorCode VecValidValues(Vec,PetscInt,PetscBool);
586f7ecc322SBarry Smith 
58715091d37SBarry Smith /*
58815091d37SBarry Smith     These numbers need to match the entries in
5893c94ec11SBarry Smith   the function table in vecimpl.h
59015091d37SBarry Smith */
59192d03f5aSMatthew G. Knepley typedef enum { VECOP_DUPLICATE = 0, VECOP_VIEW = 33, VECOP_LOAD = 41, VECOP_VIEWNATIVE = 68, VECOP_LOADNATIVE = 69 } VecOperation;
592014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void));
593b19c1e4cSBarry Smith 
594e182c471SBarry Smith /*
595e182c471SBarry Smith      Routines for dealing with ghosted vectors:
596e182c471SBarry Smith   vectors with ghost elements at the end of the array.
597e182c471SBarry Smith */
598014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecMPISetGhost(Vec,PetscInt,const PetscInt[]);
599014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
600014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
601014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
602014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
603014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*);
604014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*);
6053efe6655SBarry Smith PETSC_EXTERN PetscErrorCode VecGhostIsLocalForm(Vec,Vec,PetscBool*);
606014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
607014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);
608e182c471SBarry Smith 
609014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecConjugate(Vec);
610c92e3469SBarry Smith PETSC_EXTERN PetscErrorCode VecImaginaryPart(Vec);
611c92e3469SBarry Smith PETSC_EXTERN PetscErrorCode VecRealPart(Vec);
61234233285SBarry Smith 
613014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*);
614014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*);
615bba1ac68SSatish Balay 
6164473680cSBarry Smith PETSC_EXTERN PetscErrorCode ISComplementVec(IS,Vec,IS*);
6174473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecPow(Vec, PetscScalar);
6184473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecMedian(Vec, Vec, Vec, Vec);
619ce902467SBarry Smith PETSC_EXTERN PetscErrorCode VecWhichInactive(Vec, Vec, Vec, Vec, PetscBool, IS *);
6204473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichBetween(Vec, Vec, Vec, IS *);
6214473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichBetweenOrEqual(Vec, Vec, Vec, IS *);
6224473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichGreaterThan(Vec, Vec, IS *);
6234473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichLessThan(Vec, Vec, IS *);
6244473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecWhichEqual(Vec, Vec, IS *);
6254473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecISAXPY(Vec, IS, PetscScalar,Vec);
6268883cd90SMatthew G. Knepley PETSC_EXTERN PetscErrorCode VecISCopy(Vec, IS, ScatterMode, Vec);
6274473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecISSet(Vec,IS, PetscScalar);
6284473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecBoundGradientProjection(Vec, Vec, Vec, Vec, Vec);
6294473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepBoundInfo(Vec,Vec,Vec,Vec,PetscReal*, PetscReal*,PetscReal*);
6304473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepMax(Vec, Vec, PetscReal *);
6314473680cSBarry Smith PETSC_EXTERN PetscErrorCode VecStepMaxBounded(Vec,Vec,Vec,Vec,PetscReal*);
6324473680cSBarry Smith 
633014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec);
634014dd563SJed Brown PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec);
6357dbadf16SMatthew Knepley 
636d59c15a7SBarry Smith /*S
637d59c15a7SBarry Smith      Vecs - Collection of vectors where the data for the vectors is stored in
638759e7b9cSHong Zhang             one contiguous memory
639d59c15a7SBarry Smith 
640d59c15a7SBarry Smith    Level: advanced
641d59c15a7SBarry Smith 
642d59c15a7SBarry Smith    Notes:
643d59c15a7SBarry Smith     Temporary construct for handling multiply right hand side solves
644d59c15a7SBarry Smith 
645d59c15a7SBarry Smith     This is faked by storing a single vector that has enough array space for
646d59c15a7SBarry Smith     n vectors
647d59c15a7SBarry Smith 
648d59c15a7SBarry Smith S*/
64995fbd943SSatish Balay         struct _n_Vecs  {PetscInt n; Vec v;};
65095fbd943SSatish Balay typedef struct _n_Vecs* Vecs;
651e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsDestroy(Vecs);
652e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsCreateSeq(MPI_Comm,PetscInt,PetscInt,Vecs*);
653e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,PetscScalar*,Vecs*);
654e1317eeeSBarry Smith PETSC_EXTERN PetscErrorCode VecsDuplicate(Vecs,Vecs*);
655e9fa29b7SSatish Balay 
656e9e886b6SKarl Rupp #if defined(PETSC_HAVE_VIENNACL)
657b17c682bSKarl Rupp typedef struct _p_PetscViennaCLIndices* PetscViennaCLIndices;
658b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesCreate(PetscInt, PetscInt*,PetscInt, PetscInt*,PetscViennaCLIndices*);
659b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesDestroy(PetscViennaCLIndices*);
660b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecViennaCLCopyToGPUSome_Public(Vec,PetscViennaCLIndices);
661b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecViennaCLCopyFromGPUSome_Public(Vec,PetscViennaCLIndices);
662b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecCreateSeqViennaCL(MPI_Comm,PetscInt,Vec*);
663b17c682bSKarl Rupp PETSC_EXTERN PetscErrorCode VecCreateMPIViennaCL(MPI_Comm,PetscInt,PetscInt,Vec*);
664b8ced49eSKarl Rupp #endif
665fd314934SBarry Smith #if defined(PETSC_HAVE_CUDA)
66682f73ecaSAlejandro Lamas Daviña typedef struct _p_PetscCUDAIndices* PetscCUDAIndices;
66782f73ecaSAlejandro Lamas Daviña typedef struct _p_VecScatterCUDAIndices_StoS* VecScatterCUDAIndices_StoS;
66882f73ecaSAlejandro Lamas Daviña typedef struct _p_VecScatterCUDAIndices_PtoP* VecScatterCUDAIndices_PtoP;
669959dcdf5SJunchao Zhang PETSC_EXTERN PetscErrorCode VecCUDACopyToGPUSome_Public(Vec,PetscCUDAIndices,ScatterMode);
670959dcdf5SJunchao Zhang PETSC_EXTERN PetscErrorCode VecCUDACopyFromGPUSome_Public(Vec,PetscCUDAIndices,ScatterMode);
671959dcdf5SJunchao Zhang PETSC_EXTERN PetscErrorCode VecScatterInitializeForGPU(VecScatter,Vec);
67282f73ecaSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecScatterFinalizeForGPU(VecScatter);
67382f73ecaSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateSeqCUDA(MPI_Comm,PetscInt,Vec*);
67476d6722aSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,Vec*);
675*f94e795aSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecCreateSeqCUDAWithArrays(MPI_Comm,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
67682f73ecaSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateMPICUDA(MPI_Comm,PetscInt,PetscInt,Vec*);
67776d6722aSAlejandro Lamas Daviña PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,Vec*);
678*f94e795aSKaushik Kulkarni PETSC_EXTERN PetscErrorCode VecCreateMPICUDAWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar*,const PetscScalar*,Vec*);
679b17c682bSKarl Rupp #endif
680b17c682bSKarl Rupp 
681014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSubVecs(Vec,PetscInt*,Vec**);
682014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSubVec(Vec,PetscInt,Vec*);
683014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestSetSubVecs(Vec,PetscInt,PetscInt*,Vec*);
684014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestSetSubVec(Vec,PetscInt,Vec);
685014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecCreateNest(MPI_Comm,PetscInt,IS*,Vec*,Vec*);
686014dd563SJed Brown PETSC_EXTERN PetscErrorCode VecNestGetSize(Vec,PetscInt*);
68745b63f25SDmitry Karpeev 
688c5929fdfSBarry Smith PETSC_EXTERN PetscErrorCode PetscOptionsGetVec(PetscOptions,const char[],const char[],Vec,PetscBool*);
6894325cce7SMatthew G Knepley PETSC_EXTERN PetscErrorCode VecChop(Vec,PetscReal);
690ab352700SBarry Smith 
691077aedafSJed Brown PETSC_EXTERN PetscErrorCode VecGetLayout(Vec,PetscLayout*);
692077aedafSJed Brown PETSC_EXTERN PetscErrorCode VecSetLayout(Vec,PetscLayout);
6939a6d0b0bSJed Brown 
6949a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode PetscSectionVecView(PetscSection, Vec, PetscViewer);
6959a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode VecGetValuesSection(Vec, PetscSection, PetscInt, PetscScalar **);
6969a6d0b0bSJed Brown PETSC_EXTERN PetscErrorCode VecSetValuesSection(Vec, PetscSection, PetscInt, PetscScalar [], InsertMode);
69722d96a0cSMatthew G. Knepley PETSC_EXTERN PetscErrorCode PetscSectionVecNorm(PetscSection, PetscSection, Vec, NormType, PetscReal []);
6989a6d0b0bSJed Brown 
6995543aaa0SToby Isaac /*S
7005543aaa0SToby Isaac   VecTagger - Object used to manage the tagging of a subset of indices based on the values of a vector.  The
7015543aaa0SToby Isaac               motivating application is the selection of cells for refinement or coarsening based on vector containing
7025543aaa0SToby Isaac               the values in an error indicator metric.
7035543aaa0SToby Isaac 
7045543aaa0SToby Isaac   Level: advanced
7055543aaa0SToby Isaac S*/
70661bbf837SToby Isaac typedef struct _p_VecTagger *VecTagger;
7075543aaa0SToby Isaac 
7085543aaa0SToby Isaac /*J
7095543aaa0SToby Isaac   VecTaggerType - String with the name of a VecTagger type
7105543aaa0SToby Isaac 
7115543aaa0SToby Isaac   Level: advanced
7125543aaa0SToby Isaac J*/
7135543aaa0SToby Isaac typedef const char* VecTaggerType;
7144178c1b7SToby Isaac /* tag where the vector values are in a box of explicitly defined values */
715cab77d58SToby Isaac #define VECTAGGERABSOLUTE   "absolute"
7164178c1b7SToby Isaac /* tag where the vector values are in a box of values relative to the set of all values in the vector */
7175543aaa0SToby Isaac #define VECTAGGERRELATIVE   "relative"
7185543aaa0SToby Isaac /* tag where the vector values are in a relative range of the *cumulative distribution* of values in the vector */
7191d1d0dd8SToby Isaac #define VECTAGGERCDF        "cdf"
7205543aaa0SToby Isaac /* tag a vector as the union of other tags */
7215543aaa0SToby Isaac #define VECTAGGEROR         "or"
7225543aaa0SToby Isaac /* tag a vector as the intersection of other tags */
7235543aaa0SToby Isaac #define VECTAGGERAND        "and"
7245543aaa0SToby Isaac 
7255543aaa0SToby Isaac PETSC_EXTERN PetscClassId VEC_TAGGER_CLASSID;
72661bbf837SToby Isaac PETSC_EXTERN PetscFunctionList VecTaggerList;
72761bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRegister(const char[],PetscErrorCode (*) (VecTagger));
7285543aaa0SToby Isaac 
7295543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCreate(MPI_Comm,VecTagger *);
730cab77d58SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetBlockSize(VecTagger,PetscInt);
731cab77d58SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetBlockSize(VecTagger,PetscInt*);
7325543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetType(VecTagger,VecTaggerType);
7335543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetType(VecTagger,VecTaggerType *);
7345543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetInvert(VecTagger,PetscBool);
7355543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerGetInvert(VecTagger,PetscBool*);
7365543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetFromOptions(VecTagger);
7375543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerSetUp(VecTagger);
7385543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerView(VecTagger,PetscViewer);
7395543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerComputeIS(VecTagger,Vec,IS *);
7405543aaa0SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerDestroy(VecTagger *);
7415543aaa0SToby Isaac 
7424178c1b7SToby Isaac /*S
7434178c1b7SToby 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
7444178c1b7SToby Isaac    such that real(min) <= real(z) <= real(max) and imag(min) <= imag(z) <= imag(max).  INF is an acceptable endpoint.
74561bbf837SToby Isaac 
7464178c1b7SToby Isaac    Level: beginner
74761bbf837SToby Isaac 
7484178c1b7SToby Isaac .seealso: VecTaggerComputeIntervals()
7494178c1b7SToby Isaac S*/
7504178c1b7SToby Isaac typedef struct {
7514178c1b7SToby Isaac   PetscScalar min;
7524178c1b7SToby Isaac   PetscScalar max;
7534178c1b7SToby Isaac } VecTaggerBox;
7544178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerComputeBoxes(VecTagger,Vec,PetscInt *,VecTaggerBox **);
7554178c1b7SToby Isaac 
7564178c1b7SToby Isaac 
7574178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteSetBox(VecTagger,VecTaggerBox *);
7584178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAbsoluteGetBox(VecTagger,const VecTaggerBox **);
7594178c1b7SToby Isaac 
7604178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRelativeSetBox(VecTagger,VecTaggerBox *);
7614178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerRelativeGetBox(VecTagger,const VecTaggerBox **);
7624178c1b7SToby Isaac 
7634178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFSetBox(VecTagger,VecTaggerBox *);
7644178c1b7SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFGetBox(VecTagger,const VecTaggerBox **);
7651d1d0dd8SToby Isaac 
7661d1d0dd8SToby Isaac /*E
7671d1d0dd8SToby Isaac   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).  Relevant only in parallel: in serial it is directly computed.
7681d1d0dd8SToby Isaac 
7691d1d0dd8SToby Isaac   Level: advanced
7701d1d0dd8SToby Isaac .seealso: VecTaggerCDFSetMethod(), VecTaggerCDFMethods
7711d1d0dd8SToby Isaac E*/
7721d1d0dd8SToby Isaac typedef enum {VECTAGGER_CDF_GATHER,VECTAGGER_CDF_ITERATIVE,VECTAGGER_CDF_NUM_METHODS} VecTaggerCDFMethod;
7731d1d0dd8SToby Isaac PETSC_EXTERN const char *const VecTaggerCDFMethods[];
7741d1d0dd8SToby Isaac 
7751d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFSetMethod(VecTagger,VecTaggerCDFMethod);
7761d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFGetMethod(VecTagger,VecTaggerCDFMethod*);
7771d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeSetTolerances(VecTagger,PetscInt,PetscReal,PetscReal);
7781d1d0dd8SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerCDFIterativeGetTolerances(VecTagger,PetscInt*,PetscReal*,PetscReal*);
77961bbf837SToby Isaac 
780497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerOrSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode);
781497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerOrGetSubs(VecTagger,PetscInt*,VecTagger**);
78261bbf837SToby Isaac 
783497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAndSetSubs(VecTagger,PetscInt,VecTagger*,PetscCopyMode);
784497ee004SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerAndGetSubs(VecTagger,PetscInt*,VecTagger**);
78561bbf837SToby Isaac 
78661bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerInitializePackage(void);
78761bbf837SToby Isaac PETSC_EXTERN PetscErrorCode VecTaggerFinalizePackage(void);
78861bbf837SToby Isaac 
7892eac72dbSBarry Smith #endif
790