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
 10:  #include petscsys.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 const 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[]);

 59: EXTERN PetscErrorCode  VecCreate(MPI_Comm,Vec*);
 60: PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x))
 61: EXTERN PetscErrorCode  VecCreateSeq(MPI_Comm,PetscInt,Vec*);
 62: PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x))
 63: EXTERN PetscErrorCode  VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
 64: PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x))
 65: EXTERN PetscErrorCode  VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*);
 66: PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x))
 67: EXTERN PetscErrorCode  VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
 68: PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x))
 69: EXTERN PetscErrorCode  VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
 70: EXTERN PetscErrorCode  VecSetFromOptions(Vec);
 71: EXTERN PetscErrorCode  VecSetUp(Vec);
 72: EXTERN PetscErrorCode  VecDestroy(Vec);
 73: EXTERN PetscErrorCode  VecZeroEntries(Vec);
 74: EXTERN PetscErrorCode  VecSetOptionsPrefix(Vec,const char[]);
 75: EXTERN PetscErrorCode  VecAppendOptionsPrefix(Vec,const char[]);
 76: EXTERN PetscErrorCode  VecGetOptionsPrefix(Vec,const char*[]);

 78: EXTERN PetscErrorCode  VecSetSizes(Vec,PetscInt,PetscInt);

 80: EXTERN PetscErrorCode  VecDotNorm2(Vec,Vec,PetscScalar*,PetscScalar*);
 81: EXTERN PetscErrorCode  VecDot(Vec,Vec,PetscScalar*);
 82: PetscPolymorphicFunction(VecDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
 83: EXTERN PetscErrorCode  VecTDot(Vec,Vec,PetscScalar*);
 84: PetscPolymorphicFunction(VecTDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
 85: EXTERN PetscErrorCode  VecMDot(Vec,PetscInt,const Vec[],PetscScalar*);
 86: EXTERN PetscErrorCode  VecMTDot(Vec,PetscInt,const Vec[],PetscScalar*);

 88: /*E
 89:     NormType - determines what type of norm to compute

 91:     Level: beginner

 93: .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
 94: E*/
 95: typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType;
 97: #define NORM_MAX NORM_INFINITY

 99: /*MC
100:      NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum

102:    Level: beginner

104: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS, 
105:            NORM_INFINITY, NORM_1_AND_2

107: M*/

109: /*MC
110:      NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only)

112:    Level: beginner

114: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS, 
115:            NORM_INFINITY, NORM_1_AND_2

117: M*/

119: /*MC
120:      NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors

122:    Level: beginner

124: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 
125:            NORM_INFINITY, NORM_1_AND_2

127: M*/

129: /*MC
130:      NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum

132:    Level: beginner

134: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 
135:            NORM_FROBINIUS, NORM_1_AND_2

137: M*/

139: /*MC
140:      NORM_1_AND_2 - computes both the 1 and 2 norm of a vector

142:    Level: beginner

144: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2, 
145:            NORM_FROBINIUS, NORM_INFINITY

147: M*/

149: /*MC
150:      NORM_MAX - see NORM_INFINITY

152:    Level: beginner

154: M*/

156: EXTERN PetscErrorCode  VecNorm(Vec,NormType,PetscReal *);
157: PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r))
158: PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r)
159: PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r)
160: EXTERN PetscErrorCode  VecNormalize(Vec,PetscReal *);
161: EXTERN PetscErrorCode  VecSum(Vec,PetscScalar*);
162: EXTERN PetscErrorCode  VecMax(Vec,PetscInt*,PetscReal *);
163: PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
164: EXTERN PetscErrorCode  VecMin(Vec,PetscInt*,PetscReal *);
165: PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
166: EXTERN PetscErrorCode  VecScale(Vec,PetscScalar);
167: EXTERN PetscErrorCode  VecCopy(Vec,Vec);
168: EXTERN PetscErrorCode  VecSetRandom(Vec,PetscRandom);
169: EXTERN PetscErrorCode  VecSet(Vec,PetscScalar);
170: EXTERN PetscErrorCode  VecSwap(Vec,Vec);
171: EXTERN PetscErrorCode  VecAXPY(Vec,PetscScalar,Vec);
172: EXTERN PetscErrorCode  VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
173: EXTERN PetscErrorCode  VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec*);
174: EXTERN PetscErrorCode  VecAYPX(Vec,PetscScalar,Vec);
175: EXTERN PetscErrorCode  VecWAXPY(Vec,PetscScalar,Vec,Vec);
176: EXTERN PetscErrorCode  VecPointwiseMax(Vec,Vec,Vec);
177: PetscPolymorphicSubroutine(VecPointwiseMax,(Vec x,Vec y),(x,y,y))
178: EXTERN PetscErrorCode  VecPointwiseMaxAbs(Vec,Vec,Vec);
179: PetscPolymorphicSubroutine(VecPointwiseMaxAbs,(Vec x,Vec y),(x,y,y))
180: EXTERN PetscErrorCode  VecPointwiseMin(Vec,Vec,Vec);
181: PetscPolymorphicSubroutine(VecPointwiseMin,(Vec x,Vec y),(x,y,y))
182: EXTERN PetscErrorCode  VecPointwiseMult(Vec,Vec,Vec);
183: PetscPolymorphicSubroutine(VecPointwiseMult,(Vec x,Vec y),(x,y,y))
184: EXTERN PetscErrorCode  VecPointwiseDivide(Vec,Vec,Vec);
185: PetscPolymorphicSubroutine(VecPointwiseDivide,(Vec x,Vec y),(x,y,y))
186: EXTERN PetscErrorCode  VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
187: EXTERN PetscErrorCode  VecShift(Vec,PetscScalar);
188: EXTERN PetscErrorCode  VecReciprocal(Vec);
189: EXTERN PetscErrorCode  VecPermute(Vec, IS, PetscTruth);
190: EXTERN PetscErrorCode  VecSqrt(Vec);
191: EXTERN PetscErrorCode  VecAbs(Vec);
192: EXTERN PetscErrorCode  VecDuplicate(Vec,Vec*);
193: EXTERN PetscErrorCode  VecDuplicateVecs(Vec,PetscInt,Vec*[]);
194: EXTERN PetscErrorCode  VecDestroyVecs(Vec[],PetscInt);
195: EXTERN PetscErrorCode  VecStrideNormAll(Vec,NormType,PetscReal*);
196: EXTERN PetscErrorCode  VecStrideMaxAll(Vec,PetscInt *,PetscReal *);
197: EXTERN PetscErrorCode  VecStrideMinAll(Vec,PetscInt *,PetscReal *);
198: EXTERN PetscErrorCode  VecStrideScaleAll(Vec,PetscScalar*);

200: EXTERN PetscErrorCode  VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
201: PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i),(x,i,NORM_2,&r),PetscReal,r)
202: PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i,NormType t),(x,i,t,&r),PetscReal,r)
203: EXTERN PetscErrorCode  VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
204: PetscPolymorphicFunction(VecStrideMax,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r)
205: EXTERN PetscErrorCode  VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
206: PetscPolymorphicFunction(VecStrideMin,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r)
207: EXTERN PetscErrorCode  VecStrideScale(Vec,PetscInt,PetscScalar);


210: EXTERN PetscErrorCode  VecStrideGather(Vec,PetscInt,Vec,InsertMode);
211: EXTERN PetscErrorCode  VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
212: EXTERN PetscErrorCode  VecStrideGatherAll(Vec,Vec*,InsertMode);
213: EXTERN PetscErrorCode  VecStrideScatterAll(Vec*,Vec,InsertMode);

215: EXTERN PetscErrorCode  VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
216: EXTERN PetscErrorCode  VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
217: EXTERN PetscErrorCode  VecAssemblyBegin(Vec);
218: EXTERN PetscErrorCode  VecAssemblyEnd(Vec);
219: EXTERN PetscErrorCode  VecStashSetInitialSize(Vec,PetscInt,PetscInt);
220: EXTERN PetscErrorCode  VecStashView(Vec,PetscViewer);
221: EXTERN PetscErrorCode  VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);

223: /*MC
224:    VecSetValue - Set a single entry into a vector.

226:    Synopsis:
227:    PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode);

229:    Not Collective

231:    Input Parameters:
232: +  v - the vector
233: .  row - the row location of the entry
234: .  value - the value to insert
235: -  mode - either INSERT_VALUES or ADD_VALUES

237:    Notes:
238:    For efficiency one should use VecSetValues() and set several or 
239:    many values simultaneously if possible.

241:    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 
242:    MUST be called after all calls to VecSetValues() have been completed.

244:    VecSetValues() uses 0-based indices in Fortran as well as in C.

246:    Level: beginner

248: .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal()
249: M*/
250: PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);}


253: EXTERN PetscErrorCode  VecSetBlockSize(Vec,PetscInt);
254: EXTERN PetscErrorCode  VecGetBlockSize(Vec,PetscInt*);
255: PetscPolymorphicFunction(VecGetBlockSize,(Vec x),(x,&i),PetscInt,i)
256: EXTERN PetscErrorCode  VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

258: /* Dynamic creation and loading functions */
261: EXTERN PetscErrorCode  VecSetType(Vec, VecType);
262: EXTERN PetscErrorCode  VecGetType(Vec, VecType *);
263: EXTERN PetscErrorCode  VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec));
264: EXTERN PetscErrorCode  VecRegisterAll(const char []);
265: EXTERN PetscErrorCode  VecRegisterDestroy(void);

267: /*MC
268:   VecRegisterDynamic - Adds a new vector component implementation

270:   Synopsis:
271:   PetscErrorCode VecRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(Vec))

273:   Not Collective

275:   Input Parameters:
276: + name        - The name of a new user-defined creation routine
277: . path        - The path (either absolute or relative) of the library containing this routine
278: . func_name   - The name of routine to create method context
279: - create_func - The creation routine itself

281:   Notes:
282:   VecRegisterDynamic() may be called multiple times to add several user-defined vectors

284:   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.

286:   Sample usage:
287: .vb
288:     VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate);
289: .ve

291:   Then, your vector type can be chosen with the procedural interface via
292: .vb
293:     VecCreate(MPI_Comm, Vec *);
294:     VecSetType(Vec,"my_vector_name");
295: .ve
296:    or at runtime via the option
297: .vb
298:     -vec_type my_vector_name
299: .ve

301:   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
302:          If your function is not being put into a shared library then use VecRegister() instead
303:         
304:   Level: advanced

306: .keywords: Vec, register
307: .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister()
308: M*/
309: #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
310: #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0)
311: #else
312: #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d)
313: #endif


316: EXTERN PetscErrorCode  VecScatterCreate(Vec,IS,Vec,IS,VecScatter *);
317: PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is1,Vec y,IS is2),(x,is1,y,is2,&s),VecScatter,s)
318: PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,IS is,Vec y,VecScatter *s),(x,is,y,PETSC_NULL,s))
319: PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is,Vec y),(x,is,y,PETSC_NULL,&s),VecScatter,s)
320: PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,Vec y,IS is,VecScatter *s),(x,PETSC_NULL,y,is,s))
321: PetscPolymorphicFunction(VecScatterCreate,(Vec x,Vec y,IS is),(x,PETSC_NULL,y,is,&s),VecScatter,s)
322: EXTERN PetscErrorCode  VecScatterCreateEmpty(MPI_Comm,VecScatter *);
323: EXTERN PetscErrorCode  VecScatterCreateLocal(VecScatter,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt);
324: EXTERN PetscErrorCode  VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode);
325: EXTERN PetscErrorCode  VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode);
326: EXTERN PetscErrorCode  VecScatterDestroy(VecScatter);
327: EXTERN PetscErrorCode  VecScatterCopy(VecScatter,VecScatter *);
328: EXTERN PetscErrorCode  VecScatterView(VecScatter,PetscViewer);
329: EXTERN PetscErrorCode  VecScatterRemap(VecScatter,PetscInt *,PetscInt*);
330: EXTERN PetscErrorCode  VecScatterGetMerged(VecScatter,PetscTruth*);

332: EXTERN PetscErrorCode  VecGetArray_Private(Vec,PetscScalar*[]);
333: EXTERN PetscErrorCode  VecRestoreArray_Private(Vec,PetscScalar*[]);
334: EXTERN PetscErrorCode  VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
335: EXTERN PetscErrorCode  VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
336: EXTERN PetscErrorCode  VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
337: EXTERN PetscErrorCode  VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
338: EXTERN PetscErrorCode  VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
339: EXTERN PetscErrorCode  VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
340: EXTERN PetscErrorCode  VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
341: EXTERN PetscErrorCode  VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);

343: EXTERN PetscErrorCode  VecPlaceArray(Vec,const PetscScalar[]);
344: EXTERN PetscErrorCode  VecResetArray(Vec);
345: EXTERN PetscErrorCode  VecReplaceArray(Vec,const PetscScalar[]);
346: EXTERN PetscErrorCode  VecGetArrays(const Vec[],PetscInt,PetscScalar**[]);
347: EXTERN PetscErrorCode  VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]);

349: EXTERN PetscErrorCode  VecValid(Vec,PetscTruth*);
350: EXTERN PetscErrorCode  VecView(Vec,PetscViewer);
351: EXTERN PetscErrorCode  VecViewFromOptions(Vec, const char *);
352: EXTERN PetscErrorCode  VecEqual(Vec,Vec,PetscTruth*);
353: PetscPolymorphicFunction(VecEqual,(Vec x,Vec y),(x,y,&s),PetscTruth,s)
354: EXTERN PetscErrorCode  VecLoad(PetscViewer,VecType,Vec*);
355: EXTERN PetscErrorCode  VecLoadIntoVector(PetscViewer,Vec);

357: EXTERN PetscErrorCode  VecGetSize(Vec,PetscInt*);
358: PetscPolymorphicFunction(VecGetSize,(Vec x),(x,&s),PetscInt,s)
359: EXTERN PetscErrorCode  VecGetLocalSize(Vec,PetscInt*);
360: PetscPolymorphicFunction(VecGetLocalSize,(Vec x),(x,&s),PetscInt,s)
361: EXTERN PetscErrorCode  VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
362: EXTERN PetscErrorCode  VecGetOwnershipRanges(Vec,const PetscInt *[]);

364: EXTERN PetscErrorCode  VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping);
365: EXTERN PetscErrorCode  VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

367: /*MC
368:    VecSetValueLocal - Set a single entry into a vector using the local numbering

370:    Synopsis:
371:    PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode);

373:    Not Collective

375:    Input Parameters:
376: +  v - the vector
377: .  row - the row location of the entry
378: .  value - the value to insert
379: -  mode - either INSERT_VALUES or ADD_VALUES

381:    Notes:
382:    For efficiency one should use VecSetValues() and set several or 
383:    many values simultaneously if possible.

385:    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd() 
386:    MUST be called after all calls to VecSetValues() have been completed.

388:    VecSetValues() uses 0-based indices in Fortran as well as in C.

390:    Level: beginner

392: .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue()
393: M*/
394: PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);}

396: EXTERN PetscErrorCode  VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping);
397: EXTERN PetscErrorCode  VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

399: EXTERN PetscErrorCode  VecDotBegin(Vec,Vec,PetscScalar *);
400: PetscPolymorphicSubroutine(VecDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL))
401: EXTERN PetscErrorCode  VecDotEnd(Vec,Vec,PetscScalar *);
402: PetscPolymorphicFunction(VecDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
403: EXTERN PetscErrorCode  VecTDotBegin(Vec,Vec,PetscScalar *);
404: PetscPolymorphicSubroutine(VecTDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL))
405: EXTERN PetscErrorCode  VecTDotEnd(Vec,Vec,PetscScalar *);
406: PetscPolymorphicFunction(VecTDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
407: EXTERN PetscErrorCode  VecNormBegin(Vec,NormType,PetscReal *);
408: PetscPolymorphicSubroutine(VecNormBegin,(Vec x,NormType t),(x,t,PETSC_NULL))
409: PetscPolymorphicSubroutine(VecNormBegin,(Vec x),(x,NORM_2,PETSC_NULL))
410: EXTERN PetscErrorCode  VecNormEnd(Vec,NormType,PetscReal *);
411: PetscPolymorphicFunction(VecNormEnd,(Vec x,NormType t),(x,t,&s),PetscReal,s)
412: PetscPolymorphicFunction(VecNormEnd,(Vec x),(x,NORM_2,&s),PetscReal,s)

414: EXTERN PetscErrorCode  VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar *);
415: EXTERN PetscErrorCode  VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar *);
416: EXTERN PetscErrorCode  VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar *);
417: EXTERN PetscErrorCode  VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar *);


420: typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES} VecOption;
421: EXTERN PetscErrorCode  VecSetOption(Vec,VecOption,PetscTruth);

423: /*
424:    Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function
425:    call overhead on any 'native' Vecs.
426: */

428:  #include private/vecimpl.h

430: EXTERN PetscErrorCode  VecContourScale(Vec,PetscReal,PetscReal);

432: /*
433:     These numbers need to match the entries in 
434:   the function table in vecimpl.h
435: */
436: typedef enum { VECOP_VIEW = 32, VECOP_LOADINTOVECTOR = 40} VecOperation;
437: EXTERN PetscErrorCode  VecSetOperation(Vec,VecOperation,void(*)(void));

439: /*
440:      Routines for dealing with ghosted vectors:
441:   vectors with ghost elements at the end of the array.
442: */
443: EXTERN PetscErrorCode  VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
444: EXTERN PetscErrorCode  VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
445: EXTERN PetscErrorCode  VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
446: EXTERN PetscErrorCode  VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
447: EXTERN PetscErrorCode  VecGhostGetLocalForm(Vec,Vec*);
448: PetscPolymorphicFunction(VecGhostGetLocalForm,(Vec x),(x,&s),Vec,s)
449: EXTERN PetscErrorCode  VecGhostRestoreLocalForm(Vec,Vec*);
450: EXTERN PetscErrorCode  VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
451: EXTERN PetscErrorCode  VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);

453: EXTERN PetscErrorCode  VecConjugate(Vec);

455: EXTERN PetscErrorCode  VecScatterCreateToAll(Vec,VecScatter*,Vec*);
456: EXTERN PetscErrorCode  VecScatterCreateToZero(Vec,VecScatter*,Vec*);

458: EXTERN PetscErrorCode  PetscViewerMathematicaGetVector(PetscViewer, Vec);
459: EXTERN PetscErrorCode  PetscViewerMathematicaPutVector(PetscViewer, Vec);

461: /*S
462:      Vecs - Collection of vectors where the data for the vectors is stored in 
463:             one contiguous memory

465:    Level: advanced

467:    Notes:
468:     Temporary construct for handling multiply right hand side solves

470:     This is faked by storing a single vector that has enough array space for 
471:     n vectors

473:   Concepts: parallel decomposition

475: S*/
476:         struct _n_Vecs  {PetscInt n; Vec v;};
477: typedef struct _n_Vecs* Vecs;
478: #define VecsDestroy(x)            (VecDestroy((x)->v)         || PetscFree(x))
479: #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
480: #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
481: #define VecsDuplicate(x,y)        (PetscNew(struct _n_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n)))


485: #endif