Actual source code: petscvec.h

petsc-master 2014-11-26
Report Typos and Errors
  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 <petscviewer.h>

 12: /*S
 13:      Vec - Abstract PETSc vector object

 15:    Level: beginner

 17:   Concepts: field variables, unknowns, arrays

 19: .seealso:  VecCreate(), VecType, VecSetType()
 20: S*/
 21: typedef struct _p_Vec*         Vec;

 23: /*S
 24:      VecScatter - Object used to manage communication of data
 25:        between vectors in parallel. Manages both scatters and gathers

 27:    Level: beginner

 29:   Concepts: scatter

 31: .seealso:  VecScatterCreate(), VecScatterBegin(), VecScatterEnd()
 32: S*/
 33: typedef struct _p_VecScatter*  VecScatter;

 35: /*E
 36:   ScatterMode - Determines the direction of a scatter

 38:   Level: beginner

 40: .seealso: VecScatter, VecScatterBegin(), VecScatterEnd()
 41: E*/
 42: typedef enum {SCATTER_FORWARD=0, SCATTER_REVERSE=1, SCATTER_FORWARD_LOCAL=2, SCATTER_REVERSE_LOCAL=3, SCATTER_LOCAL=2} ScatterMode;

 44: /*MC
 45:     SCATTER_FORWARD - Scatters the values as dictated by the VecScatterCreate() call

 47:     Level: beginner

 49: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD_LOCAL,
 50:           SCATTER_REVERSE_LOCAL

 52: M*/

 54: /*MC
 55:     SCATTER_REVERSE - Moves the values in the opposite direction then the directions indicated in
 56:          in the VecScatterCreate()

 58:     Level: beginner

 60: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
 61:           SCATTER_REVERSE_LOCAL

 63: M*/

 65: /*MC
 66:     SCATTER_FORWARD_LOCAL - Scatters the values as dictated by the VecScatterCreate() call except NO parallel communication
 67:        is done. Any variables that have be moved between processes are ignored

 69:     Level: developer

 71: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_REVERSE, SCATTER_FORWARD,
 72:           SCATTER_REVERSE_LOCAL

 74: M*/

 76: /*MC
 77:     SCATTER_REVERSE_LOCAL - Moves the values in the opposite direction then the directions indicated in
 78:          in the VecScatterCreate()  except NO parallel communication
 79:        is done. Any variables that have be moved between processes are ignored

 81:     Level: developer

 83: .seealso: VecScatter, ScatterMode, VecScatterCreate(), VecScatterBegin(), VecScatterEnd(), SCATTER_FORWARD, SCATTER_FORWARD_LOCAL,
 84:           SCATTER_REVERSE

 86: M*/

 88: /*J
 89:     VecType - String with the name of a PETSc vector

 91:    Level: beginner

 93: .seealso: VecSetType(), Vec, VecCreate(), VecDestroy()
 94: J*/
 95: typedef const char* VecType;
 96: #define VECSEQ         "seq"
 97: #define VECMPI         "mpi"
 98: #define VECSTANDARD    "standard"   /* seq on one process and mpi on several */
 99: #define VECSHARED      "shared"
100: #define VECSEQCUSP     "seqcusp"
101: #define VECMPICUSP     "mpicusp"
102: #define VECCUSP        "cusp"       /* seqcusp on one process and mpicusp on several */
103: #define VECSEQVIENNACL "seqviennacl"
104: #define VECMPIVIENNACL "mpiviennacl"
105: #define VECVIENNACL    "viennacl"   /* seqviennacl on one process and mpiviennacl on several */
106: #define VECNEST        "nest"
107: #define VECSEQPTHREAD  "seqpthread"
108: #define VECMPIPTHREAD  "mpipthread"
109: #define VECPTHREAD     "pthread"    /* seqpthread on one process and mpipthread on several */


112: /* Logging support */
113: #define    VEC_FILE_CLASSID 1211214
114: PETSC_EXTERN PetscClassId VEC_CLASSID;
115: PETSC_EXTERN PetscClassId VEC_SCATTER_CLASSID;


118: PETSC_EXTERN PetscErrorCode VecInitializePackage(void);
119: PETSC_EXTERN PetscErrorCode VecFinalizePackage(void);

121: PETSC_EXTERN PetscErrorCode VecCreate(MPI_Comm,Vec*);
122: PETSC_EXTERN PetscErrorCode VecCreateSeq(MPI_Comm,PetscInt,Vec*);
123: PETSC_EXTERN PetscErrorCode VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
124: PETSC_EXTERN PetscErrorCode VecCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
125: PETSC_EXTERN PetscErrorCode VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscScalar[],Vec*);
126: PETSC_EXTERN PetscErrorCode VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
127: PETSC_EXTERN PetscErrorCode VecSetFromOptions(Vec);
128: PETSC_STATIC_INLINE PetscErrorCode VecViewFromOptions(Vec A,const char prefix[],const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,prefix,name);}

130: PETSC_EXTERN PetscErrorCode VecSetUp(Vec);
131: PETSC_EXTERN PetscErrorCode VecDestroy(Vec*);
132: PETSC_EXTERN PetscErrorCode VecZeroEntries(Vec);
133: PETSC_EXTERN PetscErrorCode VecSetOptionsPrefix(Vec,const char[]);
134: PETSC_EXTERN PetscErrorCode VecAppendOptionsPrefix(Vec,const char[]);
135: PETSC_EXTERN PetscErrorCode VecGetOptionsPrefix(Vec,const char*[]);

137: PETSC_EXTERN PetscErrorCode VecSetSizes(Vec,PetscInt,PetscInt);

139: PETSC_EXTERN PetscErrorCode VecDotNorm2(Vec,Vec,PetscScalar*,PetscReal*);
140: PETSC_EXTERN PetscErrorCode VecDot(Vec,Vec,PetscScalar*);
141: PETSC_EXTERN PetscErrorCode VecDotRealPart(Vec,Vec,PetscReal*);
142: PETSC_EXTERN PetscErrorCode VecTDot(Vec,Vec,PetscScalar*);
143: PETSC_EXTERN PetscErrorCode VecMDot(Vec,PetscInt,const Vec[],PetscScalar[]);
144: PETSC_EXTERN PetscErrorCode VecMTDot(Vec,PetscInt,const Vec[],PetscScalar[]);
145: PETSC_EXTERN PetscErrorCode VecGetSubVector(Vec,IS,Vec*);
146: PETSC_EXTERN PetscErrorCode VecRestoreSubVector(Vec,IS,Vec*);
147: PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec,Vec*);
148: PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec,Vec*);
149: PETSC_EXTERN PetscErrorCode VecGetLocalVectorWrite(Vec,Vec*);
150: PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorWrite(Vec,Vec*);

152: /*E
153:     NormType - determines what type of norm to compute

155:     Level: beginner

157: .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
158: E*/
159: typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType;
160: PETSC_EXTERN const char *const NormTypes[];
161: #define NORM_MAX NORM_INFINITY

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

166:    Level: beginner

168: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
169:            NORM_INFINITY, NORM_1_AND_2

171: M*/

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

176:    Level: beginner

178: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
179:            NORM_INFINITY, NORM_1_AND_2

181: M*/

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

186:    Level: beginner

188: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
189:            NORM_INFINITY, NORM_1_AND_2

191: M*/

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

196:    Level: beginner

198: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
199:            NORM_FROBINIUS, NORM_1_AND_2

201: M*/

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

206:    Level: beginner

208: .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
209:            NORM_FROBINIUS, NORM_INFINITY

211: M*/

213: /*MC
214:      NORM_MAX - see NORM_INFINITY

216:    Level: beginner

218: M*/

220: PETSC_EXTERN PetscErrorCode VecNorm(Vec,NormType,PetscReal *);
221: PETSC_EXTERN PetscErrorCode VecNormAvailable(Vec,NormType,PetscBool *,PetscReal *);
222: PETSC_EXTERN PetscErrorCode VecNormalize(Vec,PetscReal *);
223: PETSC_EXTERN PetscErrorCode VecSum(Vec,PetscScalar*);
224: PETSC_EXTERN PetscErrorCode VecMax(Vec,PetscInt*,PetscReal *);
225: PETSC_EXTERN PetscErrorCode VecMin(Vec,PetscInt*,PetscReal *);
226: PETSC_EXTERN PetscErrorCode VecScale(Vec,PetscScalar);
227: PETSC_EXTERN PetscErrorCode VecCopy(Vec,Vec);
228: PETSC_EXTERN PetscErrorCode VecSetRandom(Vec,PetscRandom);
229: PETSC_EXTERN PetscErrorCode VecSet(Vec,PetscScalar);
230: PETSC_EXTERN PetscErrorCode VecSwap(Vec,Vec);
231: PETSC_EXTERN PetscErrorCode VecAXPY(Vec,PetscScalar,Vec);
232: PETSC_EXTERN PetscErrorCode VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
233: PETSC_EXTERN PetscErrorCode VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec[]);
234: PETSC_EXTERN PetscErrorCode VecAYPX(Vec,PetscScalar,Vec);
235: PETSC_EXTERN PetscErrorCode VecWAXPY(Vec,PetscScalar,Vec,Vec);
236: PETSC_EXTERN PetscErrorCode VecAXPBYPCZ(Vec,PetscScalar,PetscScalar,PetscScalar,Vec,Vec);
237: PETSC_EXTERN PetscErrorCode VecPointwiseMax(Vec,Vec,Vec);
238: PETSC_EXTERN PetscErrorCode VecPointwiseMaxAbs(Vec,Vec,Vec);
239: PETSC_EXTERN PetscErrorCode VecPointwiseMin(Vec,Vec,Vec);
240: PETSC_EXTERN PetscErrorCode VecPointwiseMult(Vec,Vec,Vec);
241: PETSC_EXTERN PetscErrorCode VecPointwiseDivide(Vec,Vec,Vec);
242: PETSC_EXTERN PetscErrorCode VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
243: PETSC_EXTERN PetscErrorCode VecShift(Vec,PetscScalar);
244: PETSC_EXTERN PetscErrorCode VecReciprocal(Vec);
245: PETSC_EXTERN PetscErrorCode VecPermute(Vec, IS, PetscBool );
246: PETSC_EXTERN PetscErrorCode VecSqrtAbs(Vec);
247: PETSC_EXTERN PetscErrorCode VecLog(Vec);
248: PETSC_EXTERN PetscErrorCode VecExp(Vec);
249: PETSC_EXTERN PetscErrorCode VecAbs(Vec);
250: PETSC_EXTERN PetscErrorCode VecDuplicate(Vec,Vec*);
251: PETSC_EXTERN PetscErrorCode VecDuplicateVecs(Vec,PetscInt,Vec*[]);
252: PETSC_EXTERN PetscErrorCode VecDestroyVecs(PetscInt, Vec*[]);
253: PETSC_EXTERN PetscErrorCode VecStrideNormAll(Vec,NormType,PetscReal[]);
254: PETSC_EXTERN PetscErrorCode VecStrideMaxAll(Vec,PetscInt [],PetscReal []);
255: PETSC_EXTERN PetscErrorCode VecStrideMinAll(Vec,PetscInt [],PetscReal []);
256: PETSC_EXTERN PetscErrorCode VecStrideScaleAll(Vec,const PetscScalar[]);
257: PETSC_EXTERN PetscErrorCode VecUniqueEntries(Vec,PetscInt*,PetscScalar**);

259: PETSC_EXTERN PetscErrorCode VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
260: PETSC_EXTERN PetscErrorCode VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
261: PETSC_EXTERN PetscErrorCode VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
262: PETSC_EXTERN PetscErrorCode VecStrideScale(Vec,PetscInt,PetscScalar);
263: PETSC_EXTERN PetscErrorCode VecStrideSet(Vec,PetscInt,PetscScalar);


266: PETSC_EXTERN PetscErrorCode VecStrideGather(Vec,PetscInt,Vec,InsertMode);
267: PETSC_EXTERN PetscErrorCode VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
268: PETSC_EXTERN PetscErrorCode VecStrideGatherAll(Vec,Vec[],InsertMode);
269: PETSC_EXTERN PetscErrorCode VecStrideScatterAll(Vec[],Vec,InsertMode);

271: PETSC_EXTERN PetscErrorCode VecStrideSubSetScatter(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);
272: PETSC_EXTERN PetscErrorCode VecStrideSubSetGather(Vec,PetscInt,const PetscInt[],const PetscInt[],Vec,InsertMode);

274: PETSC_EXTERN PetscErrorCode VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
275: PETSC_EXTERN PetscErrorCode VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
276: PETSC_EXTERN PetscErrorCode VecAssemblyBegin(Vec);
277: PETSC_EXTERN PetscErrorCode VecAssemblyEnd(Vec);
278: PETSC_EXTERN PetscErrorCode VecStashSetInitialSize(Vec,PetscInt,PetscInt);
279: PETSC_EXTERN PetscErrorCode VecStashView(Vec,PetscViewer);
280: PETSC_EXTERN PetscErrorCode VecStashViewFromOptions(Vec,const char[],const char[]);
281: PETSC_EXTERN PetscErrorCode VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);

283: /*MC
284:    VecSetValue - Set a single entry into a vector.

286:    Synopsis:
287:    #include <petscvec.h>
288:    PetscErrorCode VecSetValue(Vec v,PetscInt row,PetscScalar value, InsertMode mode);

290:    Not Collective

292:    Input Parameters:
293: +  v - the vector
294: .  row - the row location of the entry
295: .  value - the value to insert
296: -  mode - either INSERT_VALUES or ADD_VALUES

298:    Notes:
299:    For efficiency one should use VecSetValues() and set several or
300:    many values simultaneously if possible.

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

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

307:    Level: beginner

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


314: PETSC_EXTERN PetscErrorCode VecSetBlockSize(Vec,PetscInt);
315: PETSC_EXTERN PetscErrorCode VecGetBlockSize(Vec,PetscInt*);
316: PETSC_EXTERN PetscErrorCode VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

318: /* Dynamic creation and loading functions */
319: PETSC_EXTERN PetscFunctionList VecList;
320: PETSC_EXTERN PetscBool         VecRegisterAllCalled;
321: PETSC_EXTERN PetscErrorCode VecSetType(Vec, VecType);
322: PETSC_EXTERN PetscErrorCode VecGetType(Vec, VecType *);
323: PETSC_EXTERN PetscErrorCode VecRegister(const char[],PetscErrorCode (*)(Vec));
324: PETSC_EXTERN PetscErrorCode VecRegisterAll(void);

326: PETSC_EXTERN PetscErrorCode VecScatterCreate(Vec,IS,Vec,IS,VecScatter *);
327: PETSC_EXTERN PetscErrorCode VecScatterCreateEmpty(MPI_Comm,VecScatter *);
328: PETSC_EXTERN PetscErrorCode VecScatterCreateLocal(VecScatter,PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt);
329: PETSC_EXTERN PetscErrorCode VecScatterBegin(VecScatter,Vec,Vec,InsertMode,ScatterMode);
330: PETSC_EXTERN PetscErrorCode VecScatterEnd(VecScatter,Vec,Vec,InsertMode,ScatterMode);
331: PETSC_EXTERN PetscErrorCode VecScatterDestroy(VecScatter*);
332: PETSC_EXTERN PetscErrorCode VecScatterCopy(VecScatter,VecScatter *);
333: PETSC_EXTERN PetscErrorCode VecScatterView(VecScatter,PetscViewer);
334: PETSC_STATIC_INLINE PetscErrorCode VecScatterViewFromOptions(VecScatter A,const char prefix[],const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,prefix,name);}
335: PETSC_EXTERN PetscErrorCode VecScatterRemap(VecScatter,PetscInt *,PetscInt*);
336: PETSC_EXTERN PetscErrorCode VecScatterGetMerged(VecScatter,PetscBool *);

338: PETSC_EXTERN PetscErrorCode VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
339: PETSC_EXTERN PetscErrorCode VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
340: PETSC_EXTERN PetscErrorCode VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
341: PETSC_EXTERN PetscErrorCode VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
342: PETSC_EXTERN PetscErrorCode VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
343: PETSC_EXTERN PetscErrorCode VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
344: PETSC_EXTERN PetscErrorCode VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
345: PETSC_EXTERN PetscErrorCode VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);

347: PETSC_EXTERN PetscErrorCode VecPlaceArray(Vec,const PetscScalar[]);
348: PETSC_EXTERN PetscErrorCode VecResetArray(Vec);
349: PETSC_EXTERN PetscErrorCode VecReplaceArray(Vec,const PetscScalar[]);
350: PETSC_EXTERN PetscErrorCode VecGetArrays(const Vec[],PetscInt,PetscScalar**[]);
351: PETSC_EXTERN PetscErrorCode VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]);

353: PETSC_EXTERN PetscErrorCode VecView(Vec,PetscViewer);
354: PETSC_EXTERN PetscErrorCode VecEqual(Vec,Vec,PetscBool *);
355: PETSC_EXTERN PetscErrorCode VecLoad(Vec, PetscViewer);

357: PETSC_EXTERN PetscErrorCode VecGetSize(Vec,PetscInt*);
358: PETSC_EXTERN PetscErrorCode VecGetLocalSize(Vec,PetscInt*);
359: PETSC_EXTERN PetscErrorCode VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
360: PETSC_EXTERN PetscErrorCode VecGetOwnershipRanges(Vec,const PetscInt *[]);

362: PETSC_EXTERN PetscErrorCode VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping);
363: PETSC_EXTERN PetscErrorCode VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);

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

368:    Synopsis:
369:    #include <petscvec.h>
370:    PetscErrorCode VecSetValueLocal(Vec v,PetscInt row,PetscScalar value, InsertMode mode);

372:    Not Collective

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

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

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

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

389:    Level: beginner

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

395: PETSC_EXTERN PetscErrorCode VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
396: PETSC_EXTERN PetscErrorCode VecGetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping*);

398: PETSC_EXTERN PetscErrorCode VecDotBegin(Vec,Vec,PetscScalar *);
399: PETSC_EXTERN PetscErrorCode VecDotEnd(Vec,Vec,PetscScalar *);
400: PETSC_EXTERN PetscErrorCode VecTDotBegin(Vec,Vec,PetscScalar *);
401: PETSC_EXTERN PetscErrorCode VecTDotEnd(Vec,Vec,PetscScalar *);
402: PETSC_EXTERN PetscErrorCode VecNormBegin(Vec,NormType,PetscReal *);
403: PETSC_EXTERN PetscErrorCode VecNormEnd(Vec,NormType,PetscReal *);

405: PETSC_EXTERN PetscErrorCode VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
406: PETSC_EXTERN PetscErrorCode VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
407: PETSC_EXTERN PetscErrorCode VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar[]);
408: PETSC_EXTERN PetscErrorCode VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar[]);
409: PETSC_EXTERN PetscErrorCode PetscCommSplitReductionBegin(MPI_Comm);


412: typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_IGNORE_NEGATIVE_INDICES} VecOption;
413: PETSC_EXTERN PetscErrorCode VecSetOption(Vec,VecOption,PetscBool );

415: PETSC_EXTERN PetscErrorCode VecGetArray(Vec,PetscScalar**);
416: PETSC_EXTERN PetscErrorCode VecGetArrayRead(Vec,const PetscScalar**);
417: PETSC_EXTERN PetscErrorCode VecRestoreArray(Vec,PetscScalar**);
418: PETSC_EXTERN PetscErrorCode VecRestoreArrayRead(Vec,const PetscScalar**);
419: PETSC_EXTERN PetscErrorCode VecGetLocalVector(Vec,Vec*);
420: PETSC_EXTERN PetscErrorCode VecRestoreLocalVector(Vec,Vec*);
421: PETSC_EXTERN PetscErrorCode VecGetLocalVectorRead(Vec,Vec*);
422: PETSC_EXTERN PetscErrorCode VecRestoreLocalVectorRead(Vec,Vec*);

424: PETSC_EXTERN PetscErrorCode VecValidValues(Vec,PetscInt,PetscBool);

426: PETSC_EXTERN PetscErrorCode VecContourScale(Vec,PetscReal,PetscReal);

428: /*
429:     These numbers need to match the entries in
430:   the function table in vecimpl.h
431: */
432: typedef enum { VECOP_VIEW = 33, VECOP_LOAD = 41, VECOP_DUPLICATE = 0} VecOperation;
433: PETSC_EXTERN PetscErrorCode VecSetOperation(Vec,VecOperation,void(*)(void));

435: /*
436:      Routines for dealing with ghosted vectors:
437:   vectors with ghost elements at the end of the array.
438: */
439: PETSC_EXTERN PetscErrorCode VecMPISetGhost(Vec,PetscInt,const PetscInt[]);
440: PETSC_EXTERN PetscErrorCode VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
441: PETSC_EXTERN PetscErrorCode VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
442: PETSC_EXTERN PetscErrorCode VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
443: PETSC_EXTERN PetscErrorCode VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
444: PETSC_EXTERN PetscErrorCode VecGhostGetLocalForm(Vec,Vec*);
445: PETSC_EXTERN PetscErrorCode VecGhostRestoreLocalForm(Vec,Vec*);
446: PETSC_EXTERN PetscErrorCode VecGhostIsLocalForm(Vec,Vec,PetscBool*);
447: PETSC_EXTERN PetscErrorCode VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
448: PETSC_EXTERN PetscErrorCode VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);

450: PETSC_EXTERN PetscErrorCode VecConjugate(Vec);

452: PETSC_EXTERN PetscErrorCode VecScatterCreateToAll(Vec,VecScatter*,Vec*);
453: PETSC_EXTERN PetscErrorCode VecScatterCreateToZero(Vec,VecScatter*,Vec*);

455: PETSC_EXTERN PetscErrorCode ISComplementVec(IS,Vec,IS*);
456: PETSC_EXTERN PetscErrorCode VecPow(Vec, PetscScalar);
457: PETSC_EXTERN PetscErrorCode VecMedian(Vec, Vec, Vec, Vec);
458: PETSC_EXTERN PetscErrorCode VecWhichBetween(Vec, Vec, Vec, IS *);
459: PETSC_EXTERN PetscErrorCode VecWhichBetweenOrEqual(Vec, Vec, Vec, IS *);
460: PETSC_EXTERN PetscErrorCode VecWhichGreaterThan(Vec, Vec, IS * );
461: PETSC_EXTERN PetscErrorCode VecWhichLessThan(Vec, Vec, IS *);
462: PETSC_EXTERN PetscErrorCode VecWhichEqual(Vec, Vec, IS *);
463: PETSC_EXTERN PetscErrorCode VecISAXPY(Vec, IS, PetscScalar,Vec);
464: PETSC_EXTERN PetscErrorCode VecISSet(Vec,IS, PetscScalar);
465: PETSC_EXTERN PetscErrorCode VecBoundGradientProjection(Vec, Vec, Vec, Vec, Vec);
466: PETSC_EXTERN PetscErrorCode VecStepBoundInfo(Vec,Vec,Vec,Vec,PetscReal*, PetscReal*,PetscReal*);
467: PETSC_EXTERN PetscErrorCode VecStepMax(Vec, Vec, PetscReal *);
468: PETSC_EXTERN PetscErrorCode VecStepMaxBounded(Vec,Vec,Vec,Vec,PetscReal*);

470: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaGetVector(PetscViewer, Vec);
471: PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutVector(PetscViewer, Vec);

473: /*S
474:      Vecs - Collection of vectors where the data for the vectors is stored in
475:             one contiguous memory

477:    Level: advanced

479:    Notes:
480:     Temporary construct for handling multiply right hand side solves

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

485:   Concepts: parallel decomposition

487: S*/
488:         struct _n_Vecs  {PetscInt n; Vec v;};
489: typedef struct _n_Vecs* Vecs;
490: PETSC_EXTERN PetscErrorCode VecsDestroy(Vecs);
491: PETSC_EXTERN PetscErrorCode VecsCreateSeq(MPI_Comm,PetscInt,PetscInt,Vecs*);
492: PETSC_EXTERN PetscErrorCode VecsCreateSeqWithArray(MPI_Comm,PetscInt,PetscInt,PetscScalar*,Vecs*);
493: PETSC_EXTERN PetscErrorCode VecsDuplicate(Vecs,Vecs*);

495: #if defined(PETSC_HAVE_CUSP)
496: typedef struct _p_PetscCUSPIndices* PetscCUSPIndices;
497: typedef struct _p_VecScatterCUSPIndices_StoS* VecScatterCUSPIndices_StoS;
498: typedef struct _p_VecScatterCUSPIndices_PtoP* VecScatterCUSPIndices_PtoP;
499: PETSC_EXTERN PetscErrorCode VecCUSPCopyToGPUSome_Public(Vec,PetscCUSPIndices);
500: PETSC_EXTERN PetscErrorCode VecCUSPCopyFromGPUSome_Public(Vec,PetscCUSPIndices);
501: PETSC_EXTERN PetscErrorCode VecScatterInitializeForGPU(VecScatter,Vec,ScatterMode);
502: PETSC_EXTERN PetscErrorCode VecScatterFinalizeForGPU(VecScatter);
503: PETSC_EXTERN PetscErrorCode VecCreateSeqCUSP(MPI_Comm,PetscInt,Vec*);
504: PETSC_EXTERN PetscErrorCode VecCreateMPICUSP(MPI_Comm,PetscInt,PetscInt,Vec*);
505: PETSC_EXTERN PetscErrorCode VecCUSPGetCUDAArray(Vec,PetscScalar**);
506: PETSC_EXTERN PetscErrorCode VecCUSPRestoreCUDAArray(Vec,PetscScalar**);
507: #endif

509: #if defined(PETSC_HAVE_VIENNACL)
510: typedef struct _p_PetscViennaCLIndices* PetscViennaCLIndices;
511: PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesCreate(PetscInt, PetscInt*,PetscInt, PetscInt*,PetscViennaCLIndices*);
512: PETSC_EXTERN PetscErrorCode PetscViennaCLIndicesDestroy(PetscViennaCLIndices*);
513: PETSC_EXTERN PetscErrorCode VecViennaCLCopyToGPUSome_Public(Vec,PetscViennaCLIndices);
514: PETSC_EXTERN PetscErrorCode VecViennaCLCopyFromGPUSome_Public(Vec,PetscViennaCLIndices);
515: PETSC_EXTERN PetscErrorCode VecCreateSeqViennaCL(MPI_Comm,PetscInt,Vec*);
516: PETSC_EXTERN PetscErrorCode VecCreateMPIViennaCL(MPI_Comm,PetscInt,PetscInt,Vec*);
517: #endif

519: PETSC_EXTERN PetscErrorCode VecNestGetSubVecs(Vec,PetscInt*,Vec**);
520: PETSC_EXTERN PetscErrorCode VecNestGetSubVec(Vec,PetscInt,Vec*);
521: PETSC_EXTERN PetscErrorCode VecNestSetSubVecs(Vec,PetscInt,PetscInt*,Vec*);
522: PETSC_EXTERN PetscErrorCode VecNestSetSubVec(Vec,PetscInt,Vec);
523: PETSC_EXTERN PetscErrorCode VecCreateNest(MPI_Comm,PetscInt,IS*,Vec*,Vec*);
524: PETSC_EXTERN PetscErrorCode VecNestGetSize(Vec,PetscInt*);

526: PETSC_EXTERN PetscErrorCode PetscOptionsVec(const char[],const char[],const char[],Vec,PetscBool*);
527: PETSC_EXTERN PetscErrorCode VecChop(Vec,PetscReal);

529: PETSC_EXTERN PetscErrorCode VecGetLayout(Vec,PetscLayout*);
530: PETSC_EXTERN PetscErrorCode VecSetLayout(Vec,PetscLayout);

532: PETSC_EXTERN PetscErrorCode PetscSectionVecView(PetscSection, Vec, PetscViewer);
533: PETSC_EXTERN PetscErrorCode VecGetValuesSection(Vec, PetscSection, PetscInt, PetscScalar **);
534: PETSC_EXTERN PetscErrorCode VecSetValuesSection(Vec, PetscSection, PetscInt, PetscScalar [], InsertMode);

536: #endif