xref: /petsc/include/petscvec.h (revision 0c295ffd55d452b856784eb664abbb23c6d3c576)
1 /*
2     Defines the vector component of PETSc. Vectors generally represent
3   degrees of freedom for finite element/finite difference functions
4   on a grid. They have more mathematical structure then simple arrays.
5 */
6 
7 #ifndef __PETSCVEC_H
8 #define __PETSCVEC_H
9 #include "petscis.h"
10 #include "petscsys.h"
11 PETSC_EXTERN_CXX_BEGIN
12 
13 /*S
14      PetscMap - Abstract PETSc object that defines the layout of vector and
15   matrices across processors
16 
17    Level: advanced
18 
19    Notes:
20     Does not play a role in the PETSc design, can be ignored
21 
22   Concepts: parallel decomposition
23 
24 .seealso:  PetscMapCreateMPI()
25 S*/
26 typedef struct _p_PetscMap*         PetscMap;
27 
28 #define MAP_SEQ "seq"
29 #define MAP_MPI "mpi"
30 #define PetscMapType char*
31 
32 /* Logging support */
33 extern PetscCookie MAP_COOKIE;
34 
35 EXTERN PetscErrorCode PetscMapCreate(MPI_Comm,PetscMap*);
36 PetscPolymorphicSubroutine(PetscMapCreate,(PetscMap*m),(m))
37 PetscPolymorphicFunction(PetscMapCreate,(void),(PETSC_COMM_SELF,&m),PetscMap,m)
38 EXTERN PetscErrorCode PetscMapCreateMPI(MPI_Comm,PetscInt,PetscInt,PetscMap*);
39 PetscPolymorphicFunction(PetscMapCreateMPI,(MPI_Comm comm,PetscInt l,PetscInt g),(comm,l,g,&m),PetscMap,m)
40 EXTERN PetscErrorCode PetscMapSetFromOptions(PetscMap);
41 EXTERN PetscErrorCode PetscMapPrintHelp(PetscMap);
42 EXTERN PetscErrorCode PetscMapDestroy(PetscMap);
43 
44 EXTERN PetscErrorCode PetscMapSetLocalSize(PetscMap,PetscInt);
45 EXTERN PetscErrorCode PetscMapGetLocalSize(PetscMap,PetscInt *);
46 PetscPolymorphicFunction(PetscMapGetLocalSize,(PetscMap m),(m,&s),PetscInt,s);
47 EXTERN PetscErrorCode PetscMapSetSize(PetscMap,PetscInt);
48 EXTERN PetscErrorCode PetscMapGetSize(PetscMap,PetscInt *);
49 PetscPolymorphicFunction(PetscMapGetSize,(PetscMap m),(m,&s),PetscInt,s);
50 EXTERN PetscErrorCode PetscMapGetLocalRange(PetscMap,PetscInt *,PetscInt *);
51 EXTERN PetscErrorCode PetscMapGetGlobalRange(PetscMap,PetscInt *[]);
52 
53 /* Dynamic creation and loading functions */
54 extern PetscFList PetscMapList;
55 extern PetscTruth PetscMapRegisterAllCalled;
56 EXTERN PetscErrorCode PetscMapSetType(PetscMap, const PetscMapType);
57 EXTERN PetscErrorCode PetscMapGetType(PetscMap, PetscMapType *);
58 PetscPolymorphicFunction(PetscMapGetType,(PetscMap m),(m,&t),PetscMapType,t);
59 EXTERN PetscErrorCode PetscMapRegister(const char[],const char[],const char[],PetscErrorCode (*)(PetscMap));
60 EXTERN PetscErrorCode PetscMapRegisterAll(const char []);
61 EXTERN PetscErrorCode PetscMapRegisterDestroy(void);
62 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
63 #define PetscMapRegisterDynamic(a,b,c,d) PetscMapRegister(a,b,c,0)
64 #else
65 #define PetscMapRegisterDynamic(a,b,c,d) PetscMapRegister(a,b,c,d)
66 #endif
67 
68 /*S
69      Vec - Abstract PETSc vector object
70 
71    Level: beginner
72 
73   Concepts: field variables, unknowns, arrays
74 
75 .seealso:  VecCreate(), VecType, VecSetType()
76 S*/
77 typedef struct _p_Vec*         Vec;
78 
79 /*S
80      VecScatter - Object used to manage communication of data
81        between vectors in parallel. Manages both scatters and gathers
82 
83    Level: beginner
84 
85   Concepts: scatter
86 
87 .seealso:  VecScatterCreate(), VecScatterBegin(), VecScatterEnd()
88 S*/
89 typedef struct _p_VecScatter*  VecScatter;
90 
91 /*E
92     VecType - String with the name of a PETSc vector or the creation function
93        with an optional dynamic library name, for example
94        http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
95 
96    Level: beginner
97 
98 .seealso: VecSetType(), Vec
99 E*/
100 #define VECSEQ         "seq"
101 #define VECMPI         "mpi"
102 #define VECFETI        "feti"
103 #define VECSHARED      "shared"
104 #define VecType char*
105 
106 /* Logging support */
107 #define    VEC_FILE_COOKIE 1211214
108 extern PetscCookie VEC_COOKIE, VEC_SCATTER_COOKIE;
109 extern PetscEvent    VEC_View, VEC_Max, VEC_Min, VEC_DotBarrier, VEC_Dot, VEC_MDotBarrier, VEC_MDot, VEC_TDot, VEC_MTDot;
110 extern PetscEvent    VEC_Norm, VEC_Normalize, VEC_Scale, VEC_Copy, VEC_Set, VEC_AXPY, VEC_AYPX, VEC_WAXPY, VEC_MAXPY;
111 extern PetscEvent    VEC_AssemblyEnd, VEC_PointwiseMult, VEC_SetValues, VEC_Load, VEC_ScatterBarrier, VEC_ScatterBegin, VEC_ScatterEnd;
112 extern PetscEvent    VEC_SetRandom, VEC_ReduceArithmetic, VEC_ReduceBarrier, VEC_ReduceCommunication;
113 extern PetscEvent    VEC_Swap, VEC_AssemblyBegin, VEC_NormBarrier;
114 
115 EXTERN PetscErrorCode VecInitializePackage(char *);
116 
117 EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec *);
118 PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x))
119 EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*);
120 PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x))
121 EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
122 PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x))
123 EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*);
124 PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x))
125 EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
126 PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x))
127 EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
128 EXTERN PetscErrorCode VecSetFromOptions(Vec);
129 EXTERN PetscErrorCode VecPrintHelp(Vec);
130 EXTERN PetscErrorCode VecDestroy(Vec);
131 
132 EXTERN PetscErrorCode VecSetSizes(Vec,PetscInt,PetscInt);
133 
134 EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*);
135 EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*);
136 EXTERN PetscErrorCode VecMDot(PetscInt,Vec,const Vec[],PetscScalar*);
137 EXTERN PetscErrorCode VecMTDot(PetscInt,Vec,const Vec[],PetscScalar*);
138 
139 /*E
140     NormType - determines what type of norm to compute
141 
142     Level: beginner
143 
144 .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
145 E*/
146 typedef enum {NORM_1=1,NORM_2=2,NORM_FROBENIUS=3,NORM_INFINITY=4,NORM_1_AND_2=5} NormType;
147 #define NORM_MAX NORM_INFINITY
148 
149 /*MC
150      NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum
151 
152    Level: beginner
153 
154 .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
155            NORM_INFINITY, NORM_1_AND_2
156 
157 M*/
158 
159 /*MC
160      NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only)
161 
162    Level: beginner
163 
164 .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
165            NORM_INFINITY, NORM_1_AND_2
166 
167 M*/
168 
169 /*MC
170      NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors
171 
172    Level: beginner
173 
174 .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
175            NORM_INFINITY, NORM_1_AND_2
176 
177 M*/
178 
179 /*MC
180      NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum
181 
182    Level: beginner
183 
184 .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
185            NORM_FROBINIUS, NORM_1_AND_2
186 
187 M*/
188 
189 /*MC
190      NORM_1_AND_2 - computes both the 1 and 2 norm of a vector
191 
192    Level: beginner
193 
194 .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
195            NORM_FROBINIUS, NORM_INFINITY
196 
197 M*/
198 
199 /*MC
200      NORM_MAX - see NORM_INFINITY
201 
202    Level: beginner
203 
204 M*/
205 
206 EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *);
207 PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r))
208 PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r)
209 PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r)
210 EXTERN PetscErrorCode VecNormComposedDataID(NormType,PetscInt*);
211 EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *);
212 EXTERN PetscErrorCode VecSum(Vec,PetscScalar*);
213 EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *);
214 PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
215 EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *);
216 PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
217 EXTERN PetscErrorCode VecScale(const PetscScalar *a,Vec v);
218 EXTERN PetscErrorCode VecCopy(Vec,Vec);
219 EXTERN PetscErrorCode VecSetRandom(PetscRandom,Vec);
220 EXTERN PetscErrorCode VecSet(const PetscScalar*,Vec);
221 EXTERN PetscErrorCode VecSwap(Vec,Vec);
222 EXTERN PetscErrorCode VecAXPY(const PetscScalar*,Vec,Vec);
223 EXTERN PetscErrorCode VecAXPBY(const PetscScalar*,const PetscScalar *,Vec,Vec);
224 EXTERN PetscErrorCode VecMAXPY(PetscInt,const PetscScalar*,Vec,Vec*);
225 EXTERN PetscErrorCode VecAYPX(const PetscScalar*,Vec,Vec);
226 EXTERN PetscErrorCode VecWAXPY(const PetscScalar*,Vec,Vec,Vec);
227 EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec);
228 EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec);
229 EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec);
230 EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec);
231 EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec);
232 EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
233 EXTERN PetscErrorCode VecShift(const PetscScalar*,Vec);
234 EXTERN PetscErrorCode VecReciprocal(Vec);
235 EXTERN PetscErrorCode VecPermute(Vec, IS, PetscTruth);
236 EXTERN PetscErrorCode VecSqrt(Vec);
237 EXTERN PetscErrorCode VecAbs(Vec);
238 EXTERN PetscErrorCode VecDuplicate(Vec,Vec*);
239 EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]);
240 EXTERN PetscErrorCode VecDestroyVecs(Vec[],PetscInt);
241 EXTERN PetscErrorCode VecGetPetscMap(Vec,PetscMap*);
242 
243 EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal*);
244 EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt *,PetscReal *);
245 EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt *,PetscReal *);
246 EXTERN PetscErrorCode VecStrideScaleAll(Vec,PetscScalar*);
247 
248 EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
249 EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
250 EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
251 EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar*);
252 EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode);
253 EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
254 EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec*,InsertMode);
255 EXTERN PetscErrorCode VecStrideScatterAll(Vec*,Vec,InsertMode);
256 
257 EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
258 EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
259 EXTERN PetscErrorCode VecAssemblyBegin(Vec);
260 EXTERN PetscErrorCode VecAssemblyEnd(Vec);
261 EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt);
262 EXTERN PetscErrorCode VecStashView(Vec,PetscViewer);
263 EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
264 
265 extern PetscInt         VecSetValue_Row;
266 extern PetscScalar VecSetValue_Value;
267 /*MC
268    VecSetValue - Set a single entry into a vector.
269 
270    Synopsis:
271    PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode);
272 
273    Not Collective
274 
275    Input Parameters:
276 +  v - the vector
277 .  row - the row location of the entry
278 .  value - the value to insert
279 -  mode - either INSERT_VALUES or ADD_VALUES
280 
281    Notes:
282    For efficiency one should use VecSetValues() and set several or
283    many values simultaneously if possible.
284 
285    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
286    MUST be called after all calls to VecSetValues() have been completed.
287 
288    VecSetValues() uses 0-based indices in Fortran as well as in C.
289 
290    Level: beginner
291 
292 .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal()
293 M*/
294 #define VecSetValue(v,i,va,mode) ((VecSetValue_Row = i,VecSetValue_Value = va,0) || VecSetValues(v,1,&VecSetValue_Row,&VecSetValue_Value,mode))
295 
296 /*MC
297    VecSetValueLocal - Set a single entry into a vector using the local numbering
298 
299    Synopsis:
300    PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode);
301 
302    Not Collective
303 
304    Input Parameters:
305 +  v - the vector
306 .  row - the row location of the entry
307 .  value - the value to insert
308 -  mode - either INSERT_VALUES or ADD_VALUES
309 
310    Notes:
311    For efficiency one should use VecSetValues() and set several or
312    many values simultaneously if possible.
313 
314    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
315    MUST be called after all calls to VecSetValues() have been completed.
316 
317    VecSetValues() uses 0-based indices in Fortran as well as in C.
318 
319    Level: beginner
320 
321 .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue()
322 M*/
323 #define VecSetValueLocal(v,i,va,mode) ((VecSetValue_Row = i,VecSetValue_Value = va,0) || VecSetValuesLocal(v,1,&VecSetValue_Row,&VecSetValue_Value,mode))
324 
325 EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt);
326 EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*);
327 EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
328 
329 /* Dynamic creation and loading functions */
330 extern PetscFList VecList;
331 extern PetscTruth VecRegisterAllCalled;
332 EXTERN PetscErrorCode VecSetType(Vec, const VecType);
333 EXTERN PetscErrorCode VecGetType(Vec, VecType *);
334 EXTERN PetscErrorCode VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec));
335 EXTERN PetscErrorCode VecRegisterAll(const char []);
336 EXTERN PetscErrorCode VecRegisterDestroy(void);
337 
338 /*MC
339   VecRegisterDynamic - Adds a new vector component implementation
340 
341   Synopsis:
342   PetscErrorCode VecRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(Vec))
343 
344   Not Collective
345 
346   Input Parameters:
347 + name        - The name of a new user-defined creation routine
348 . path        - The path (either absolute or relative) of the library containing this routine
349 . func_name   - The name of routine to create method context
350 - create_func - The creation routine itself
351 
352   Notes:
353   VecRegisterDynamic() may be called multiple times to add several user-defined vectors
354 
355   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
356 
357   Sample usage:
358 .vb
359     VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate);
360 .ve
361 
362   Then, your vector type can be chosen with the procedural interface via
363 .vb
364     VecCreate(MPI_Comm, Vec *);
365     VecSetType(Vec,"my_vector_name");
366 .ve
367    or at runtime via the option
368 .vb
369     -vec_type my_vector_name
370 .ve
371 
372   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
373          If your function is not being put into a shared library then use VecRegister() instead
374 
375   Level: advanced
376 
377 .keywords: Vec, register
378 .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister()
379 M*/
380 #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
381 #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0)
382 #else
383 #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d)
384 #endif
385 
386 
387 EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter *);
388 EXTERN PetscErrorCode VecScatterPostRecvs(Vec,Vec,InsertMode,ScatterMode,VecScatter);
389 EXTERN PetscErrorCode VecScatterBegin(Vec,Vec,InsertMode,ScatterMode,VecScatter);
390 EXTERN PetscErrorCode VecScatterEnd(Vec,Vec,InsertMode,ScatterMode,VecScatter);
391 EXTERN PetscErrorCode VecScatterDestroy(VecScatter);
392 EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *);
393 EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer);
394 EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt *,PetscInt*);
395 EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscTruth*);
396 
397 EXTERN PetscErrorCode VecGetArray_Private(Vec,PetscScalar*[]);
398 EXTERN PetscErrorCode VecRestoreArray_Private(Vec,PetscScalar*[]);
399 EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
400 EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
401 EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
402 EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
403 EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
404 EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
405 EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
406 EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
407 
408 EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]);
409 EXTERN PetscErrorCode VecResetArray(Vec);
410 EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]);
411 EXTERN PetscErrorCode VecGetArrays(const Vec[],PetscInt,PetscScalar**[]);
412 EXTERN PetscErrorCode VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]);
413 
414 EXTERN PetscErrorCode VecValid(Vec,PetscTruth*);
415 EXTERN PetscErrorCode VecView(Vec,PetscViewer);
416 EXTERN PetscErrorCode VecViewFromOptions(Vec, char *);
417 EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscTruth*);
418 EXTERN PetscErrorCode VecLoad(PetscViewer,const VecType,Vec*);
419 EXTERN PetscErrorCode VecLoadIntoVector(PetscViewer,Vec);
420 
421 EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*);
422 EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*);
423 EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
424 
425 EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping);
426 EXTERN PetscErrorCode VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
427 EXTERN PetscErrorCode VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping);
428 EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
429 
430 EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *);
431 EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *);
432 EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *);
433 EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *);
434 EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *);
435 EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *);
436 
437 typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_TREAT_OFF_PROC_ENTRIES} VecOption;
438 EXTERN PetscErrorCode VecSetOption(Vec,VecOption);
439 
440 /*
441    Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function
442    call overhead on any 'native' Vecs.
443 */
444 #include "vecimpl.h"
445 
446 EXTERN PetscErrorCode VecContourScale(Vec,PetscReal,PetscReal);
447 
448 /*
449     These numbers need to match the entries in
450   the function table in vecimpl.h
451 */
452 typedef enum { VECOP_VIEW = 32,
453                VECOP_LOADINTOVECTOR = 38
454              } VecOperation;
455 EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void));
456 
457 /*
458      Routines for dealing with ghosted vectors:
459   vectors with ghost elements at the end of the array.
460 */
461 EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
462 EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
463 EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
464 EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
465 EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*);
466 EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*);
467 EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
468 EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);
469 
470 EXTERN PetscErrorCode VecConjugate(Vec);
471 
472 EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*);
473 EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*);
474 
475 EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec);
476 EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec);
477 
478 /*S
479      Vecs - Collection of vectors where the data for the vectors is stored in
480             one continquous memory
481 
482    Level: advanced
483 
484    Notes:
485     Temporary construct for handling multiply right hand side solves
486 
487     This is faked by storing a single vector that has enough array space for
488     n vectors
489 
490   Concepts: parallel decomposition
491 
492 S*/
493         struct _p_Vecs  {PetscInt n; Vec v;};
494 typedef struct _p_Vecs* Vecs;
495 #define VecsDestroy(x)            (VecDestroy((x)->v)         || PetscFree(x))
496 #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _p_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
497 #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _p_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
498 #define VecsDuplicate(x,y)        (PetscNew(struct _p_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n)))
499 
500 
501 PETSC_EXTERN_CXX_END
502 #endif
503