Actual source code: petscvec.h
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: */
7: #ifndef __PETSCVEC_H
9: #include petscis.h
13: /*S
14: Vec - Abstract PETSc vector object
16: Level: beginner
18: Concepts: field variables, unknowns, arrays
20: .seealso: VecCreate(), VecType, VecSetType()
21: S*/
22: typedef struct _p_Vec* Vec;
24: /*S
25: VecScatter - Object used to manage communication of data
26: between vectors in parallel. Manages both scatters and gathers
28: Level: beginner
30: Concepts: scatter
32: .seealso: VecScatterCreate(), VecScatterBegin(), VecScatterEnd()
33: S*/
34: typedef struct _p_VecScatter* VecScatter;
36: /*E
37: VecType - String with the name of a PETSc vector or the creation function
38: with an optional dynamic library name, for example
39: http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
41: Level: beginner
43: .seealso: VecSetType(), Vec
44: E*/
45: #define VecType char*
46: #define VECSEQ "seq"
47: #define VECMPI "mpi"
48: #define VECFETI "feti"
49: #define VECSHARED "shared"
50: #define VECSIEVE "sieve"
52: /* Logging support */
53: #define VEC_FILE_COOKIE 1211214
57: EXTERN PetscErrorCode VecInitializePackage(const char[]);
58: EXTERN PetscErrorCode VecFinalizePackage(void);
60: EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec*);
61: PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x))
62: EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*);
63: PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x))
64: EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
65: PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x))
66: EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*);
67: PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x))
68: EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
69: PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x))
70: EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
71: EXTERN PetscErrorCode VecSetFromOptions(Vec);
72: EXTERN PetscErrorCode VecSetUp(Vec);
73: EXTERN PetscErrorCode VecDestroy(Vec);
74: EXTERN PetscErrorCode VecZeroEntries(Vec);
75: EXTERN PetscErrorCode VecSetOptionsPrefix(Vec,const char[]);
76: EXTERN PetscErrorCode VecAppendOptionsPrefix(Vec,const char[]);
77: EXTERN PetscErrorCode VecGetOptionsPrefix(Vec,const char*[]);
79: EXTERN PetscErrorCode VecSetSizes(Vec,PetscInt,PetscInt);
81: EXTERN PetscErrorCode VecDotNorm2(Vec,Vec,PetscScalar*,PetscScalar*);
82: EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*);
83: PetscPolymorphicFunction(VecDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
84: EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*);
85: PetscPolymorphicFunction(VecTDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
86: EXTERN PetscErrorCode VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]);
87: EXTERN PetscErrorCode VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]);
89: /*E
90: NormType - determines what type of norm to compute
92: Level: beginner
94: .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
95: E*/
96: typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType;
98: #define NORM_MAX NORM_INFINITY
100: /*MC
101: NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum
103: Level: beginner
105: .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
106: NORM_INFINITY, NORM_1_AND_2
108: M*/
110: /*MC
111: NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only)
113: Level: beginner
115: .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
116: NORM_INFINITY, NORM_1_AND_2
118: M*/
120: /*MC
121: NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors
123: Level: beginner
125: .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
126: NORM_INFINITY, NORM_1_AND_2
128: M*/
130: /*MC
131: NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum
133: Level: beginner
135: .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
136: NORM_FROBINIUS, NORM_1_AND_2
138: M*/
140: /*MC
141: NORM_1_AND_2 - computes both the 1 and 2 norm of a vector
143: Level: beginner
145: .seealso: NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
146: NORM_FROBINIUS, NORM_INFINITY
148: M*/
150: /*MC
151: NORM_MAX - see NORM_INFINITY
153: Level: beginner
155: M*/
157: EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *);
158: EXTERN PetscErrorCode VecNormAvailable(Vec,NormType,PetscTruth*,PetscReal *);
159: PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r))
160: PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r)
161: PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r)
162: EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *);
163: EXTERN PetscErrorCode VecSum(Vec,PetscScalar*);
164: EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *);
165: PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
166: EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *);
167: PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
168: EXTERN PetscErrorCode VecScale(Vec,PetscScalar);
169: EXTERN PetscErrorCode VecCopy(Vec,Vec);
170: EXTERN PetscErrorCode VecSetRandom(Vec,PetscRandom);
171: EXTERN PetscErrorCode VecSet(Vec,PetscScalar);
172: EXTERN PetscErrorCode VecSwap(Vec,Vec);
173: EXTERN PetscErrorCode VecAXPY(Vec,PetscScalar,Vec);
174: EXTERN PetscErrorCode VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
175: EXTERN PetscErrorCode VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]);
176: EXTERN PetscErrorCode VecAYPX(Vec,PetscScalar,Vec);
177: EXTERN PetscErrorCode VecWAXPY(Vec,PetscScalar,Vec,Vec);
178: EXTERN PetscErrorCode VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec);
179: EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec);
180: PetscPolymorphicSubroutine(VecPointwiseMax,(Vec x,Vec y),(x,y,y))
181: EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec);
182: PetscPolymorphicSubroutine(VecPointwiseMaxAbs,(Vec x,Vec y),(x,y,y))
183: EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec);
184: PetscPolymorphicSubroutine(VecPointwiseMin,(Vec x,Vec y),(x,y,y))
185: EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec);
186: PetscPolymorphicSubroutine(VecPointwiseMult,(Vec x,Vec y),(x,x,y))
187: EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec);
188: PetscPolymorphicSubroutine(VecPointwiseDivide,(Vec x,Vec y),(x,x,y))
189: EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
190: EXTERN PetscErrorCode VecShift(Vec,PetscScalar);
191: EXTERN PetscErrorCode VecReciprocal(Vec);
192: EXTERN PetscErrorCode VecPermute(Vec, IS, PetscTruth);
193: EXTERN PetscErrorCode VecSqrt(Vec);
194: EXTERN PetscErrorCode VecLog(Vec);
195: EXTERN PetscErrorCode VecExp(Vec);
196: EXTERN PetscErrorCode VecAbs(Vec);
197: EXTERN PetscErrorCode VecDuplicate(Vec,Vec*);
198: EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]);
199: EXTERN PetscErrorCode VecDestroyVecs(Vec[],PetscInt);
200: EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal[]);
201: EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt [],PetscReal []);
202: EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt [],PetscReal []);
203: EXTERN PetscErrorCode VecStrideScaleAll(Vec,PetscScalar[]);
205: EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
206: PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i),(x,i,NORM_2,&r),PetscReal,r)
207: PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i,NormType t),(x,i,t,&r),PetscReal,r)
208: EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
209: PetscPolymorphicFunction(VecStrideMax,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r)
210: EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
211: PetscPolymorphicFunction(VecStrideMin,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r)
212: EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar);
215: EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode);
216: EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
217: EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec[],InsertMode);
218: EXTERN PetscErrorCode VecStrideScatterAll(Vec[],Vec,InsertMode);
220: EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
221: EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
222: EXTERN PetscErrorCode VecAssemblyBegin(Vec);
223: EXTERN PetscErrorCode VecAssemblyEnd(Vec);
224: EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt);
225: EXTERN PetscErrorCode VecStashView(Vec,PetscViewer);
226: EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
228: /*MC
229: VecSetValue - Set a single entry into a vector.
231: Synopsis:
232: PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode);
234: Not Collective
236: Input Parameters:
237: + v - the vector
238: . row - the row location of the entry
239: . value - the value to insert
240: - mode - either INSERT_VALUES or ADD_VALUES
242: Notes:
243: For efficiency one should use VecSetValues() and set several or
244: many values simultaneously if possible.
246: These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
247: MUST be called after all calls to VecSetValues() have been completed.
249: VecSetValues() uses 0-based indices in Fortran as well as in C.
251: Level: beginner
253: .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal()
254: M*/
255: PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);}
258: EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt);
259: EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*);
260: PetscPolymorphicFunction(VecGetBlockSize,(Vec x),(x,&i),PetscInt,i)
261: EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
263: /* Dynamic creation and loading functions */
266: EXTERN PetscErrorCode VecSetType(Vec, const VecType);
267: EXTERN PetscErrorCode VecGetType(Vec, const VecType *);
268: EXTERN PetscErrorCode VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec));
269: EXTERN PetscErrorCode VecRegisterAll(const char []);
270: EXTERN PetscErrorCode VecRegisterDestroy(void);
272: /*MC
273: VecRegisterDynamic - Adds a new vector component implementation
275: Synopsis:
276: PetscErrorCode VecRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(Vec))
278: Not Collective
280: Input Parameters:
281: + name - The name of a new user-defined creation routine
282: . path - The path (either absolute or relative) of the library containing this routine
283: . func_name - The name of routine to create method context
284: - create_func - The creation routine itself
286: Notes:
287: VecRegisterDynamic() may be called multiple times to add several user-defined vectors
289: If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
291: Sample usage:
292: .vb
293: VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate);
294: .ve
296: Then, your vector type can be chosen with the procedural interface via
297: .vb
298: VecCreate(MPI_Comm, Vec *);
299: VecSetType(Vec,"my_vector_name");
300: .ve
301: or at runtime via the option
302: .vb
303: -vec_type my_vector_name
304: .ve
306: Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
307: If your function is not being put into a shared library then use VecRegister() instead
308:
309: Level: advanced
311: .keywords: Vec, register
312: .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister()
313: M*/
314: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
315: #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0)
316: #else
317: #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d)
318: #endif
321: EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter *);
322: PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is1,Vec y,IS is2),(x,is1,y,is2,&s),VecScatter,s)
323: PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,IS is,Vec y,VecScatter *s),(x,is,y,PETSC_NULL,s))
324: PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is,Vec y),(x,is,y,PETSC_NULL,&s),VecScatter,s)
325: PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,Vec y,IS is,VecScatter *s),(x,PETSC_NULL,y,is,s))
326: PetscPolymorphicFunction(VecScatterCreate,(Vec x,Vec y,IS is),(x,PETSC_NULL,y,is,&s),VecScatter,s)
327: EXTERN PetscErrorCode VecScatterCreateEmpty(MPI_Comm,VecScatter *);
328: EXTERN PetscErrorCode VecScatterCreateLocal(VecScatter,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt);
329: EXTERN PetscErrorCode VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode);
330: EXTERN PetscErrorCode VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode);
331: EXTERN PetscErrorCode VecScatterDestroy(VecScatter);
332: EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *);
333: EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer);
334: EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt *,PetscInt*);
335: EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscTruth*);
337: EXTERN PetscErrorCode VecGetArray_Private(Vec,PetscScalar*[]);
338: EXTERN PetscErrorCode VecRestoreArray_Private(Vec,PetscScalar*[]);
339: EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
340: EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
341: EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
342: EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
343: EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
344: EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
345: EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
346: EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
348: EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]);
349: EXTERN PetscErrorCode VecResetArray(Vec);
350: EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]);
351: EXTERN PetscErrorCode VecGetArrays(const Vec[],PetscInt,PetscScalar**[]);
352: EXTERN PetscErrorCode VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]);
354: EXTERN PetscErrorCode VecValid(Vec,PetscTruth*);
355: EXTERN PetscErrorCode VecView(Vec,PetscViewer);
356: EXTERN PetscErrorCode VecViewFromOptions(Vec, const char *);
357: EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscTruth*);
358: PetscPolymorphicFunction(VecEqual,(Vec x,Vec y),(x,y,&s),PetscTruth,s)
359: EXTERN PetscErrorCode VecLoad(PetscViewer,const VecType,Vec*);
360: EXTERN PetscErrorCode VecLoadIntoVector(PetscViewer,Vec);
362: EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*);
363: PetscPolymorphicFunction(VecGetSize,(Vec x),(x,&s),PetscInt,s)
364: EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*);
365: PetscPolymorphicFunction(VecGetLocalSize,(Vec x),(x,&s),PetscInt,s)
366: EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
367: EXTERN PetscErrorCode VecGetOwnershipRanges(Vec,const PetscInt *[]);
369: EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping);
370: EXTERN PetscErrorCode VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
372: /*MC
373: VecSetValueLocal - Set a single entry into a vector using the local numbering
375: Synopsis:
376: PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode);
378: Not Collective
380: Input Parameters:
381: + v - the vector
382: . row - the row location of the entry
383: . value - the value to insert
384: - mode - either INSERT_VALUES or ADD_VALUES
386: Notes:
387: For efficiency one should use VecSetValues() and set several or
388: many values simultaneously if possible.
390: These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
391: MUST be called after all calls to VecSetValues() have been completed.
393: VecSetValues() uses 0-based indices in Fortran as well as in C.
395: Level: beginner
397: .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue()
398: M*/
399: PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);}
401: EXTERN PetscErrorCode VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping);
402: EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
404: EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *);
405: PetscPolymorphicSubroutine(VecDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL))
406: EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *);
407: PetscPolymorphicFunction(VecDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
408: EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *);
409: PetscPolymorphicSubroutine(VecTDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL))
410: EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *);
411: PetscPolymorphicFunction(VecTDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
412: EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *);
413: PetscPolymorphicSubroutine(VecNormBegin,(Vec x,NormType t),(x,t,PETSC_NULL))
414: PetscPolymorphicSubroutine(VecNormBegin,(Vec x),(x,NORM_2,PETSC_NULL))
415: EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *);
416: PetscPolymorphicFunction(VecNormEnd,(Vec x,NormType t),(x,t,&s),PetscReal,s)
417: PetscPolymorphicFunction(VecNormEnd,(Vec x),(x,NORM_2,&s),PetscReal,s)
419: EXTERN PetscErrorCode VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
420: EXTERN PetscErrorCode VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
421: EXTERN PetscErrorCode VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
422: EXTERN PetscErrorCode VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
425: typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES} VecOption;
426: EXTERN PetscErrorCode VecSetOption(Vec,VecOption,PetscTruth);
428: /*
429: Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function
430: call overhead on any 'native' Vecs.
431: */
433: #include private/vecimpl.h
435: EXTERN PetscErrorCode VecContourScale(Vec,PetscReal,PetscReal);
437: /*
438: These numbers need to match the entries in
439: the function table in vecimpl.h
440: */
441: typedef enum { VECOP_VIEW = 33, VECOP_LOADINTOVECTOR = 41} VecOperation;
442: EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void));
444: /*
445: Routines for dealing with ghosted vectors:
446: vectors with ghost elements at the end of the array.
447: */
448: EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
449: EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
450: EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
451: EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
452: EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*);
453: PetscPolymorphicFunction(VecGhostGetLocalForm,(Vec x),(x,&s),Vec,s)
454: EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*);
455: EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
456: EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);
458: EXTERN PetscErrorCode VecConjugate(Vec);
460: EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*);
461: EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*);
463: EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec);
464: EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec);
466: /*S
467: Vecs - Collection of vectors where the data for the vectors is stored in
468: one contiguous memory
470: Level: advanced
472: Notes:
473: Temporary construct for handling multiply right hand side solves
475: This is faked by storing a single vector that has enough array space for
476: n vectors
478: Concepts: parallel decomposition
480: S*/
481: struct _n_Vecs {PetscInt n; Vec v;};
482: typedef struct _n_Vecs* Vecs;
483: #define VecsDestroy(x) (VecDestroy((x)->v) || PetscFree(x))
484: #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
485: #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
486: #define VecsDuplicate(x,y) (PetscNew(struct _n_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n)))
490: #endif