xref: /petsc/include/petscvec.h (revision e5bd52469b00a8f2942d86b46a52285e84b32048)
12eac72dbSBarry Smith /*
237f753daSBarry Smith     Defines the vector component of PETSc. Vectors generally represent
337f753daSBarry Smith   degrees of freedom for finite element/finite difference functions
484cb2905SBarry Smith   on a grid. They have more mathematical structure then simple arrays.
52eac72dbSBarry Smith */
62eac72dbSBarry Smith 
70a835dfdSSatish Balay #ifndef __PETSCVEC_H
80a835dfdSSatish Balay #define __PETSCVEC_H
90a835dfdSSatish Balay #include "petscis.h"
100a835dfdSSatish Balay #include "petscsys.h"
11e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN
122eac72dbSBarry Smith 
1309321671SBarry Smith /*S
1409321671SBarry Smith      Vec - Abstract PETSc vector object
1509321671SBarry Smith 
1609321671SBarry Smith    Level: beginner
1709321671SBarry Smith 
1809321671SBarry Smith   Concepts: field variables, unknowns, arrays
1909321671SBarry Smith 
2009321671SBarry Smith .seealso:  VecCreate(), VecType, VecSetType()
2109321671SBarry Smith S*/
22f09e8eb9SSatish Balay typedef struct _p_Vec*         Vec;
2309321671SBarry Smith 
2409321671SBarry Smith /*S
2509321671SBarry Smith      VecScatter - Object used to manage communication of data
2609321671SBarry Smith        between vectors in parallel. Manages both scatters and gathers
2709321671SBarry Smith 
2809321671SBarry Smith    Level: beginner
2909321671SBarry Smith 
3009321671SBarry Smith   Concepts: scatter
3109321671SBarry Smith 
3209321671SBarry Smith .seealso:  VecScatterCreate(), VecScatterBegin(), VecScatterEnd()
3309321671SBarry Smith S*/
34f09e8eb9SSatish Balay typedef struct _p_VecScatter*  VecScatter;
3509321671SBarry Smith 
3609321671SBarry Smith /*E
3709321671SBarry Smith     VecType - String with the name of a PETSc vector or the creation function
3809321671SBarry Smith        with an optional dynamic library name, for example
3909321671SBarry Smith        http://www.mcs.anl.gov/petsc/lib.a:myveccreate()
4009321671SBarry Smith 
4109321671SBarry Smith    Level: beginner
4209321671SBarry Smith 
4309321671SBarry Smith .seealso: VecSetType(), Vec
4409321671SBarry Smith E*/
45e5a9bf91SBarry Smith #define VecType const char*
460676abe4SMatthew Knepley #define VECSEQ         "seq"
470676abe4SMatthew Knepley #define VECMPI         "mpi"
480676abe4SMatthew Knepley #define VECFETI        "feti"
490676abe4SMatthew Knepley #define VECSHARED      "shared"
50765467adSMatthew Knepley #define VECSIEVE       "sieve"
512eac72dbSBarry Smith 
52fd487807SMatthew Knepley /* Logging support */
53552e946dSBarry Smith #define    VEC_FILE_COOKIE 1211214
540c735eedSKris Buschelman extern PETSCVEC_DLLEXPORT PetscCookie VEC_COOKIE;
550c735eedSKris Buschelman extern PETSCVEC_DLLEXPORT PetscCookie VEC_SCATTER_COOKIE;
568ba1e511SMatthew Knepley 
57*e5bd5246SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecInitializePackage(const char[]);
58fd487807SMatthew Knepley 
590c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreate(MPI_Comm,Vec*);
60045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreate,(Vec *x),(PETSC_COMM_SELF,x))
610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeq(MPI_Comm,PetscInt,Vec*);
62045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeq,(PetscInt n,Vec *x),(PETSC_COMM_SELF,n,x))
630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPI(MPI_Comm,PetscInt,PetscInt,Vec*);
64045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPI,(PetscInt n,PetscInt N,Vec *x),(PETSC_COMM_WORLD,n,N,x))
650c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateSeqWithArray(MPI_Comm,PetscInt,const PetscScalar[],Vec*);
66045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateSeqWithArray,(PetscInt n,PetscScalar s[],Vec *x),(PETSC_COMM_SELF,n,s,x))
670c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateMPIWithArray(MPI_Comm,PetscInt,PetscInt,const PetscScalar[],Vec*);
68045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecCreateMPIWithArray,(PetscInt n,PetscInt N,PetscScalar s[],Vec *x),(PETSC_COMM_WORLD,n,N,s,x))
690c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateShared(MPI_Comm,PetscInt,PetscInt,Vec*);
700c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetFromOptions(Vec);
71f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetUp(Vec);
720c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroy(Vec);
73f1e08e49SBarry Smith EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecZeroEntries(Vec);
74f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOptionsPrefix(Vec,const char[]);
75f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAppendOptionsPrefix(Vec,const char[]);
76f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOptionsPrefix(Vec,const char*[]);
77f69a0ea3SMatthew Knepley 
780c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetSizes(Vec,PetscInt,PetscInt);
79fd487807SMatthew Knepley 
800c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDot(Vec,Vec,PetscScalar*);
81fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
820c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDot(Vec,Vec,PetscScalar*);
83fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDot,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
848dbd3d1dSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDot(Vec,PetscInt,const Vec[],PetscScalar*);
858dbd3d1dSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDot(Vec,PetscInt,const Vec[],PetscScalar*);
86cddf8d76SBarry Smith 
8709321671SBarry Smith /*E
8809321671SBarry Smith     NormType - determines what type of norm to compute
8909321671SBarry Smith 
9009321671SBarry Smith     Level: beginner
9109321671SBarry Smith 
9209321671SBarry Smith .seealso: VecNorm(), VecNormBegin(), VecNormEnd(), MatNorm()
9309321671SBarry Smith E*/
949dcbbd2bSBarry Smith typedef enum {NORM_1=0,NORM_2=1,NORM_FROBENIUS=2,NORM_INFINITY=3,NORM_1_AND_2=4} NormType;
959dcbbd2bSBarry Smith extern const char *NormTypes[];
96cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY
9709321671SBarry Smith 
989b250c83SBarry Smith /*MC
999b250c83SBarry Smith      NORM_1 - the one norm, ||v|| = sum_i | v_i |. ||A|| = max_j || v_*j ||, maximum column sum
1009b250c83SBarry Smith 
1019b250c83SBarry Smith    Level: beginner
1029b250c83SBarry Smith 
1039b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_2, NORM_FROBENIUS,
1049b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
1059b250c83SBarry Smith 
1069b250c83SBarry Smith M*/
1079b250c83SBarry Smith 
1089b250c83SBarry Smith /*MC
1099b250c83SBarry Smith      NORM_2 - the two norm, ||v|| = sqrt(sum_i (v_i)^2) (vectors only)
1109b250c83SBarry Smith 
1119b250c83SBarry Smith    Level: beginner
1129b250c83SBarry Smith 
1139b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_FROBENIUS,
1149b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
1159b250c83SBarry Smith 
1169b250c83SBarry Smith M*/
1179b250c83SBarry Smith 
1189b250c83SBarry Smith /*MC
1199b250c83SBarry Smith      NORM_FROBENIUS - ||A|| = sqrt(sum_ij (A_ij)^2), same as NORM_2 for vectors
1209b250c83SBarry Smith 
1219b250c83SBarry Smith    Level: beginner
1229b250c83SBarry Smith 
1239b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
1249b250c83SBarry Smith            NORM_INFINITY, NORM_1_AND_2
1259b250c83SBarry Smith 
1269b250c83SBarry Smith M*/
1279b250c83SBarry Smith 
1289b250c83SBarry Smith /*MC
1299b250c83SBarry Smith      NORM_INFINITY - ||v|| = max_i |v_i|. ||A|| = max_i || v_i* ||, maximum row sum
1309b250c83SBarry Smith 
1319b250c83SBarry Smith    Level: beginner
1329b250c83SBarry Smith 
1339b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
1349b250c83SBarry Smith            NORM_FROBINIUS, NORM_1_AND_2
1359b250c83SBarry Smith 
1369b250c83SBarry Smith M*/
1379b250c83SBarry Smith 
1389b250c83SBarry Smith /*MC
1399b250c83SBarry Smith      NORM_1_AND_2 - computes both the 1 and 2 norm of a vector
1409b250c83SBarry Smith 
1419b250c83SBarry Smith    Level: beginner
1429b250c83SBarry Smith 
1439b250c83SBarry Smith .seealso:  NormType, MatNorm(), VecNorm(), VecNormBegin(), VecNormEnd(), NORM_1, NORM_2,
1449b250c83SBarry Smith            NORM_FROBINIUS, NORM_INFINITY
1459b250c83SBarry Smith 
1469b250c83SBarry Smith M*/
1479b250c83SBarry Smith 
1489b250c83SBarry Smith /*MC
1499b250c83SBarry Smith      NORM_MAX - see NORM_INFINITY
1509b250c83SBarry Smith 
151d41222bbSBarry Smith    Level: beginner
152d41222bbSBarry Smith 
1539b250c83SBarry Smith M*/
1549b250c83SBarry Smith 
1550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNorm(Vec,NormType,PetscReal *);
156045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecNorm,(Vec x,PetscReal *r),(x,NORM_2,r))
157c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x,NormType t),(x,t,&r),PetscReal,r)
158c714d2d0SBarry Smith PetscPolymorphicFunction(VecNorm,(Vec x),(x,NORM_2,&r),PetscReal,r)
1590c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormalize(Vec,PetscReal *);
1600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSum(Vec,PetscScalar*);
1610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMax(Vec,PetscInt*,PetscReal *);
162045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMax,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
1630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMin(Vec,PetscInt*,PetscReal *);
164045ff3e0SBarry Smith PetscPolymorphicSubroutine(VecMin,(Vec x,PetscReal *r),(x,PETSC_NULL,r))
1652dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScale(Vec v,PetscScalar a);
1660c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCopy(Vec,Vec);
167abb0e124SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetRandom(Vec,PetscRandom);
1682dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSet(Vec,PetscScalar);
1690c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSwap(Vec,Vec);
1702dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPY(Vec,PetscScalar,Vec);
1712dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAXPBY(Vec,PetscScalar,PetscScalar,Vec);
1722dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMAXPY(Vec,PetscInt,const PetscScalar[],Vec*);
1732dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAYPX(Vec,PetscScalar,Vec);
1742dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecWAXPY(Vec,PetscScalar,Vec,Vec);
1750c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMax(Vec,Vec,Vec);
1760190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMax,(Vec x,Vec y),(x,y,y))
1770c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMaxAbs(Vec,Vec,Vec);
1780190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMaxAbs,(Vec x,Vec y),(x,y,y))
1790c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMin(Vec,Vec,Vec);
1800190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMin,(Vec x,Vec y),(x,y,y))
1810c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseMult(Vec,Vec,Vec);
1820190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseMult,(Vec x,Vec y),(x,y,y))
1830c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPointwiseDivide(Vec,Vec,Vec);
1840190745aSSatish Balay PetscPolymorphicSubroutine(VecPointwiseDivide,(Vec x,Vec y),(x,y,y))
1850c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMaxPointwiseDivide(Vec,Vec,PetscReal*);
1862dcb1b2aSMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecShift(Vec,PetscScalar);
1870c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReciprocal(Vec);
1880c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPermute(Vec, IS, PetscTruth);
1890c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSqrt(Vec);
1900c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAbs(Vec);
1910c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicate(Vec,Vec*);
1920c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDuplicateVecs(Vec,PetscInt,Vec*[]);
1930c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDestroyVecs(Vec[],PetscInt);
1940c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNormAll(Vec,NormType,PetscReal*);
1950c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMaxAll(Vec,PetscInt *,PetscReal *);
1960c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMinAll(Vec,PetscInt *,PetscReal *);
1970c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScaleAll(Vec,PetscScalar*);
1984a560884SBarry Smith 
1990c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideNorm(Vec,PetscInt,NormType,PetscReal*);
200fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i),(x,i,NORM_2,&r),PetscReal,r)
201fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideNorm,(Vec x,PetscInt i,NormType t),(x,i,t,&r),PetscReal,r)
2020c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMax(Vec,PetscInt,PetscInt *,PetscReal *);
203fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMax,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r)
2040c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideMin(Vec,PetscInt,PetscInt *,PetscReal *);
205fcd5dd21SSatish Balay PetscPolymorphicFunction(VecStrideMin,(Vec x,PetscInt i),(x,i,PETSC_NULL,&r),PetscReal,r)
206f31393a2Sdalcinl EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScale(Vec,PetscInt,PetscScalar);
207954b3ec6SBarry Smith 
208954b3ec6SBarry Smith 
2090c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGather(Vec,PetscInt,Vec,InsertMode);
2100c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatter(Vec,PetscInt,Vec,InsertMode);
2110c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideGatherAll(Vec,Vec*,InsertMode);
2120c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStrideScatterAll(Vec*,Vec,InsertMode);
213d2655a18SBarry Smith 
2140c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValues(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
2150c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetValues(Vec,PetscInt,const PetscInt[],PetscScalar[]);
2160c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyBegin(Vec);
2170c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecAssemblyEnd(Vec);
2180c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashSetInitialSize(Vec,PetscInt,PetscInt);
2190c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashView(Vec,PetscViewer);
2200c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecStashGetInfo(Vec,PetscInt*,PetscInt*,PetscInt*,PetscInt*);
22162dc5420SSatish Balay 
22230de9b25SBarry Smith /*MC
22330de9b25SBarry Smith    VecSetValue - Set a single entry into a vector.
22430de9b25SBarry Smith 
22530de9b25SBarry Smith    Synopsis:
226d360dc6fSBarry Smith    PetscErrorCode VecSetValue(Vec v,int row,PetscScalar value, InsertMode mode);
22730de9b25SBarry Smith 
22830de9b25SBarry Smith    Not Collective
22930de9b25SBarry Smith 
23030de9b25SBarry Smith    Input Parameters:
23130de9b25SBarry Smith +  v - the vector
23230de9b25SBarry Smith .  row - the row location of the entry
23330de9b25SBarry Smith .  value - the value to insert
23430de9b25SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
23530de9b25SBarry Smith 
23630de9b25SBarry Smith    Notes:
23730de9b25SBarry Smith    For efficiency one should use VecSetValues() and set several or
23830de9b25SBarry Smith    many values simultaneously if possible.
23930de9b25SBarry Smith 
2401d73ed98SBarry Smith    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
2411d73ed98SBarry Smith    MUST be called after all calls to VecSetValues() have been completed.
2421d73ed98SBarry Smith 
2431d73ed98SBarry Smith    VecSetValues() uses 0-based indices in Fortran as well as in C.
2441d73ed98SBarry Smith 
2451d73ed98SBarry Smith    Level: beginner
2461d73ed98SBarry Smith 
2471d73ed98SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValueLocal()
2481d73ed98SBarry Smith M*/
24950755921SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValue(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValues(v,1,&i,&va,mode);}
2501d73ed98SBarry Smith 
25130de9b25SBarry Smith 
2520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetBlockSize(Vec,PetscInt);
2530c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetBlockSize(Vec,PetscInt*);
254fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetBlockSize,(Vec x),(x,&i),PetscInt,i)
2550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlocked(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
2568ed539a5SBarry Smith 
257fd487807SMatthew Knepley /* Dynamic creation and loading functions */
258fd487807SMatthew Knepley extern PetscFList VecList;
259d772e1d7SMatthew Knepley extern PetscTruth VecRegisterAllCalled;
260f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetType(Vec, VecType);
2610c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetType(Vec, VecType *);
2620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegister(const char[],const char[],const char[],PetscErrorCode (*)(Vec));
2630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterAll(const char []);
2640c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRegisterDestroy(void);
26530de9b25SBarry Smith 
26630de9b25SBarry Smith /*MC
26730de9b25SBarry Smith   VecRegisterDynamic - Adds a new vector component implementation
26830de9b25SBarry Smith 
26930de9b25SBarry Smith   Synopsis:
270d360dc6fSBarry Smith   PetscErrorCode VecRegisterDynamic(char *name, char *path, char *func_name, PetscErrorCode (*create_func)(Vec))
27130de9b25SBarry Smith 
27230de9b25SBarry Smith   Not Collective
27330de9b25SBarry Smith 
27430de9b25SBarry Smith   Input Parameters:
27530de9b25SBarry Smith + name        - The name of a new user-defined creation routine
27630de9b25SBarry Smith . path        - The path (either absolute or relative) of the library containing this routine
27730de9b25SBarry Smith . func_name   - The name of routine to create method context
27830de9b25SBarry Smith - create_func - The creation routine itself
27930de9b25SBarry Smith 
28030de9b25SBarry Smith   Notes:
28130de9b25SBarry Smith   VecRegisterDynamic() may be called multiple times to add several user-defined vectors
28230de9b25SBarry Smith 
28330de9b25SBarry Smith   If dynamic libraries are used, then the fourth input argument (routine_create) is ignored.
28430de9b25SBarry Smith 
28530de9b25SBarry Smith   Sample usage:
28630de9b25SBarry Smith .vb
28730de9b25SBarry Smith     VecRegisterDynamic("my_vec","/home/username/my_lib/lib/libO/solaris/libmy.a", "MyVectorCreate", MyVectorCreate);
28830de9b25SBarry Smith .ve
28930de9b25SBarry Smith 
29030de9b25SBarry Smith   Then, your vector type can be chosen with the procedural interface via
29130de9b25SBarry Smith .vb
29230de9b25SBarry Smith     VecCreate(MPI_Comm, Vec *);
29330de9b25SBarry Smith     VecSetType(Vec,"my_vector_name");
29430de9b25SBarry Smith .ve
29530de9b25SBarry Smith    or at runtime via the option
29630de9b25SBarry Smith .vb
29730de9b25SBarry Smith     -vec_type my_vector_name
29830de9b25SBarry Smith .ve
29930de9b25SBarry Smith 
300ab901514SBarry Smith   Notes: $PETSC_ARCH occuring in pathname will be replaced with appropriate values.
30130de9b25SBarry Smith          If your function is not being put into a shared library then use VecRegister() instead
30230de9b25SBarry Smith 
30330de9b25SBarry Smith   Level: advanced
30430de9b25SBarry Smith 
30530de9b25SBarry Smith .keywords: Vec, register
30630de9b25SBarry Smith .seealso: VecRegisterAll(), VecRegisterDestroy(), VecRegister()
30730de9b25SBarry Smith M*/
308aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES)
309f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,0)
31088d459dfSBarry Smith #else
311f1af5d2fSBarry Smith #define VecRegisterDynamic(a,b,c,d) VecRegister(a,b,c,d)
31288d459dfSBarry Smith #endif
31388d459dfSBarry Smith 
31409321671SBarry Smith 
3150c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreate(Vec,IS,Vec,IS,VecScatter *);
316fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is1,Vec y,IS is2),(x,is1,y,is2,&s),VecScatter,s)
3170190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,IS is,Vec y,VecScatter *s),(x,is,y,PETSC_NULL,s))
318fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,IS is,Vec y),(x,is,y,PETSC_NULL,&s),VecScatter,s)
3190190745aSSatish Balay PetscPolymorphicSubroutine(VecScatterCreate,(Vec x,Vec y,IS is,VecScatter *s),(x,PETSC_NULL,y,is,s))
320fcd5dd21SSatish Balay PetscPolymorphicFunction(VecScatterCreate,(Vec x,Vec y,IS is),(x,PETSC_NULL,y,is,&s),VecScatter,s)
321450faa77SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateEmpty(MPI_Comm,VecScatter *);
3221e337482SLisandro Dalcin EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateLocal_PtoS(PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt,const PetscInt[],const PetscInt[],const PetscInt[],PetscInt,VecScatter);
3230c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterBegin(Vec,Vec,InsertMode,ScatterMode,VecScatter);
3240c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterEnd(Vec,Vec,InsertMode,ScatterMode,VecScatter);
3250c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterDestroy(VecScatter);
3260c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCopy(VecScatter,VecScatter *);
3270c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterView(VecScatter,PetscViewer);
3280c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterRemap(VecScatter,PetscInt *,PetscInt*);
3290c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterGetMerged(VecScatter,PetscTruth*);
3302195c698SBarry Smith 
3310c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray_Private(Vec,PetscScalar*[]);
3320c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray_Private(Vec,PetscScalar*[]);
3330c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
3340c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray4d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar****[]);
3350c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
3360c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray3d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar***[]);
3370c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
3380c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray2d(Vec,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar**[]);
3390c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
3400c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArray1d(Vec,PetscInt,PetscInt,PetscScalar *[]);
341ab360428SBarry Smith 
3420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecPlaceArray(Vec,const PetscScalar[]);
3430c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecResetArray(Vec);
3440c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecReplaceArray(Vec,const PetscScalar[]);
3450c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetArrays(const Vec[],PetscInt,PetscScalar**[]);
3460c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecRestoreArrays(const Vec[],PetscInt,PetscScalar**[]);
34784cb2905SBarry Smith 
3480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecValid(Vec,PetscTruth*);
3490c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecView(Vec,PetscViewer);
3500c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecViewFromOptions(Vec, char *);
3510c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecEqual(Vec,Vec,PetscTruth*);
352fcd5dd21SSatish Balay PetscPolymorphicFunction(VecEqual,(Vec x,Vec y),(x,y,&s),PetscTruth,s)
353f69a0ea3SMatthew Knepley EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoad(PetscViewer,VecType,Vec*);
3540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecLoadIntoVector(PetscViewer,Vec);
3558ed539a5SBarry Smith 
3560c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetSize(Vec,PetscInt*);
357fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetSize,(Vec x),(x,&s),PetscInt,s)
3580c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetLocalSize(Vec,PetscInt*);
359fcd5dd21SSatish Balay PetscPolymorphicFunction(VecGetLocalSize,(Vec x),(x,&s),PetscInt,s)
3600c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGetOwnershipRange(Vec,PetscInt*,PetscInt*);
3618ed539a5SBarry Smith 
3620c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMapping(Vec,ISLocalToGlobalMapping);
3630c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
36488b03592SBarry Smith 
36588b03592SBarry Smith /*MC
36688b03592SBarry Smith    VecSetValueLocal - Set a single entry into a vector using the local numbering
36788b03592SBarry Smith 
36888b03592SBarry Smith    Synopsis:
36988b03592SBarry Smith    PetscErrorCode VecSetValueLocal(Vec v,int row,PetscScalar value, InsertMode mode);
37088b03592SBarry Smith 
37188b03592SBarry Smith    Not Collective
37288b03592SBarry Smith 
37388b03592SBarry Smith    Input Parameters:
37488b03592SBarry Smith +  v - the vector
37588b03592SBarry Smith .  row - the row location of the entry
37688b03592SBarry Smith .  value - the value to insert
37788b03592SBarry Smith -  mode - either INSERT_VALUES or ADD_VALUES
37888b03592SBarry Smith 
37988b03592SBarry Smith    Notes:
38088b03592SBarry Smith    For efficiency one should use VecSetValues() and set several or
38188b03592SBarry Smith    many values simultaneously if possible.
38288b03592SBarry Smith 
38388b03592SBarry Smith    These values may be cached, so VecAssemblyBegin() and VecAssemblyEnd()
38488b03592SBarry Smith    MUST be called after all calls to VecSetValues() have been completed.
38588b03592SBarry Smith 
38688b03592SBarry Smith    VecSetValues() uses 0-based indices in Fortran as well as in C.
38788b03592SBarry Smith 
38888b03592SBarry Smith    Level: beginner
38988b03592SBarry Smith 
39088b03592SBarry Smith .seealso: VecSetValues(), VecAssemblyBegin(), VecAssemblyEnd(), VecSetValuesBlockedLocal(), VecSetValue()
39188b03592SBarry Smith M*/
39288b03592SBarry Smith PETSC_STATIC_INLINE PetscErrorCode VecSetValueLocal(Vec v,PetscInt i,PetscScalar va,InsertMode mode) {return VecSetValuesLocal(v,1,&i,&va,mode);}
39388b03592SBarry Smith 
3940c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetLocalToGlobalMappingBlock(Vec,ISLocalToGlobalMapping);
3950c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetValuesBlockedLocal(Vec,PetscInt,const PetscInt[],const PetscScalar[],InsertMode);
39690f02eecSBarry Smith 
3970c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotBegin(Vec,Vec,PetscScalar *);
398ba966639SSatish Balay PetscPolymorphicSubroutine(VecDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL))
3990c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecDotEnd(Vec,Vec,PetscScalar *);
400fcd5dd21SSatish Balay PetscPolymorphicFunction(VecDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
4010c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotBegin(Vec,Vec,PetscScalar *);
402ba966639SSatish Balay PetscPolymorphicSubroutine(VecTDotBegin,(Vec x,Vec y),(x,y,PETSC_NULL))
4030c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecTDotEnd(Vec,Vec,PetscScalar *);
404fcd5dd21SSatish Balay PetscPolymorphicFunction(VecTDotEnd,(Vec x,Vec y),(x,y,&s),PetscScalar,s)
4050c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormBegin(Vec,NormType,PetscReal *);
406ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x,NormType t),(x,t,PETSC_NULL))
407ba966639SSatish Balay PetscPolymorphicSubroutine(VecNormBegin,(Vec x),(x,NORM_2,PETSC_NULL))
4080c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecNormEnd(Vec,NormType,PetscReal *);
409fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x,NormType t),(x,t,&s),PetscReal,s)
410fcd5dd21SSatish Balay PetscPolymorphicFunction(VecNormEnd,(Vec x),(x,NORM_2,&s),PetscReal,s)
411d3c178dbSBarry Smith 
4128dbd3d1dSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotBegin(Vec,PetscInt,const Vec[],PetscScalar *);
4138dbd3d1dSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMDotEnd(Vec,PetscInt,const Vec[],PetscScalar *);
4148dbd3d1dSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotBegin(Vec,PetscInt,const Vec[],PetscScalar *);
4158dbd3d1dSSatish Balay EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecMTDotEnd(Vec,PetscInt,const Vec[],PetscScalar *);
416a751f32aSSatish Balay 
417a751f32aSSatish Balay 
41859b1a713SSatish Balay typedef enum {VEC_IGNORE_OFF_PROC_ENTRIES,VEC_TREAT_OFF_PROC_ENTRIES, \
41959b1a713SSatish Balay               VEC_IGNORE_NEGATIVE_INDICES, VEC_TREAT_NEGATIVE_INDICES} VecOption;
4200c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOption(Vec,VecOption);
42190f02eecSBarry Smith 
422ebe3b25bSBarry Smith /*
423ebe3b25bSBarry Smith    Expose VecGetArray()/VecRestoreArray() to users. Allows this to work without any function
424ebe3b25bSBarry Smith    call overhead on any 'native' Vecs.
425ebe3b25bSBarry Smith */
426e1fa1e0fSSatish Balay 
4271d8d5f9aSSatish Balay #include "private/vecimpl.h"
428ebe3b25bSBarry Smith 
4290c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecContourScale(Vec,PetscReal,PetscReal);
430522c5e43SBarry Smith 
43115091d37SBarry Smith /*
43215091d37SBarry Smith     These numbers need to match the entries in
4333c94ec11SBarry Smith   the function table in vecimpl.h
43415091d37SBarry Smith */
435499d51b4SSatish Balay typedef enum { VECOP_VIEW = 32, VECOP_LOADINTOVECTOR = 40} VecOperation;
4360c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecSetOperation(Vec,VecOperation,void(*)(void));
437b19c1e4cSBarry Smith 
438e182c471SBarry Smith /*
439e182c471SBarry Smith      Routines for dealing with ghosted vectors:
440e182c471SBarry Smith   vectors with ghost elements at the end of the array.
441e182c471SBarry Smith */
4420c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhost(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
4430c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
4440c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlock(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Vec*);
4450c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecCreateGhostBlockWithArray(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscScalar[],Vec*);
4460c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostGetLocalForm(Vec,Vec*);
447ba966639SSatish Balay PetscPolymorphicFunction(VecGhostGetLocalForm,(Vec x),(x,&s),Vec,s)
4480c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostRestoreLocalForm(Vec,Vec*);
4490c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateBegin(Vec,InsertMode,ScatterMode);
4500c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecGhostUpdateEnd(Vec,InsertMode,ScatterMode);
451e182c471SBarry Smith 
4520c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecConjugate(Vec);
45334233285SBarry Smith 
4540c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToAll(Vec,VecScatter*,Vec*);
4550c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT VecScatterCreateToZero(Vec,VecScatter*,Vec*);
456bba1ac68SSatish Balay 
4570c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaGetVector(PetscViewer, Vec);
4580c735eedSKris Buschelman EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscViewerMathematicaPutVector(PetscViewer, Vec);
4597dbadf16SMatthew Knepley 
460d59c15a7SBarry Smith /*S
461d59c15a7SBarry Smith      Vecs - Collection of vectors where the data for the vectors is stored in
462d59c15a7SBarry Smith             one continquous memory
463d59c15a7SBarry Smith 
464d59c15a7SBarry Smith    Level: advanced
465d59c15a7SBarry Smith 
466d59c15a7SBarry Smith    Notes:
467d59c15a7SBarry Smith     Temporary construct for handling multiply right hand side solves
468d59c15a7SBarry Smith 
469d59c15a7SBarry Smith     This is faked by storing a single vector that has enough array space for
470d59c15a7SBarry Smith     n vectors
471d59c15a7SBarry Smith 
472d59c15a7SBarry Smith   Concepts: parallel decomposition
473d59c15a7SBarry Smith 
474d59c15a7SBarry Smith S*/
47595fbd943SSatish Balay         struct _n_Vecs  {PetscInt n; Vec v;};
47695fbd943SSatish Balay typedef struct _n_Vecs* Vecs;
477d59c15a7SBarry Smith #define VecsDestroy(x)            (VecDestroy((x)->v)         || PetscFree(x))
47895fbd943SSatish Balay #define VecsCreateSeq(comm,p,m,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeq(comm,p*m,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
47995fbd943SSatish Balay #define VecsCreateSeqWithArray(comm,p,m,a,x) (PetscNew(struct _n_Vecs,x) || VecCreateSeqWithArray(comm,p*m,a,&(*(x))->v) || (-1 == ((*(x))->n = (m))))
48095fbd943SSatish Balay #define VecsDuplicate(x,y)        (PetscNew(struct _n_Vecs,y) || VecDuplicate(x->v,&(*(y))->v) || (-1 == ((*(y))->n = (x)->n)))
481e9fa29b7SSatish Balay 
482e9fa29b7SSatish Balay 
483e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END
4842eac72dbSBarry Smith #endif
485