xref: /petsc/include/petscvec.h (revision 9d00d63d4b4014b06eeb660baae4e576889960ed)
12eac72dbSBarry Smith /*
22eac72dbSBarry Smith    This defines the abstract vector component. These are patterned
32eac72dbSBarry Smith    after the Level-1 Blas, but with some additions that have proved
42eac72dbSBarry Smith    useful. These include routines to allocate and free vectors.
52eac72dbSBarry Smith 
62eac72dbSBarry Smith    Note that the routines that are normally thought of as returning a
72eac72dbSBarry Smith    value (e.g., dot, norm) return their value through an argument.
82eac72dbSBarry Smith    This allows these routines to be used with other datatype, such
92eac72dbSBarry Smith    as float and dcomplex.
102eac72dbSBarry Smith 
112eac72dbSBarry Smith    All vectors should be declared as a Vec. All vector routines begin
122eac72dbSBarry Smith    with Vec.
132eac72dbSBarry Smith 
142eac72dbSBarry Smith 
152eac72dbSBarry Smith  */
162eac72dbSBarry Smith 
172eac72dbSBarry Smith #ifndef __VEC_PACKAGE
182eac72dbSBarry Smith #define __VEC_PACKAGE
192eac72dbSBarry Smith #include "is.h"
202eac72dbSBarry Smith 
219e25ed09SBarry Smith #define VEC_COOKIE         PETSC_COOKIE+3
229e25ed09SBarry Smith #define VEC_SCATTER_COOKIE PETSC_COOKIE+4
239e25ed09SBarry Smith 
24f0479e8cSBarry Smith 
252eac72dbSBarry Smith typedef struct _Vec*            Vec;
2620563c6bSBarry Smith typedef struct _VecScatterCtx*  VecScatterCtx;
272eac72dbSBarry Smith 
286b5873e3SBarry Smith extern int VecCreateSequential(MPI_Comm,int,Vec *);
298ed539a5SBarry Smith extern int VecCreateMPI(MPI_Comm,int,int,Vec *);
306b5873e3SBarry Smith extern int VecCreateInitialVector(MPI_Comm,int,Vec *);
312eac72dbSBarry Smith 
328ed539a5SBarry Smith extern int VecDot(Vec, Vec, Scalar*);
338ed539a5SBarry Smith extern int VecTDot(Vec, Vec, Scalar*);
348ed539a5SBarry Smith extern int VecMDot(int,      Vec ,Vec*,Scalar*);
358ed539a5SBarry Smith extern int VecMTDot(int,      Vec ,Vec*,Scalar*);
368ed539a5SBarry Smith extern int VecNorm(Vec, double*);
3720563c6bSBarry Smith extern int VecASum(Vec, double*);
38ee50ffe9SBarry Smith extern int VecSum(Vec,Scalar*);
39fddd07d0SBarry Smith extern int VecAMax(Vec, int *,   double*);
407c16e1c9SBarry Smith extern int VecMax(Vec, int *,    double*);
417c16e1c9SBarry Smith extern int VecMin(Vec, int *,    double*);
428ed539a5SBarry Smith extern int VecScale(Scalar*, Vec);
438ed539a5SBarry Smith extern int VecCopy(Vec, Vec);
448ed539a5SBarry Smith extern int VecSet(Scalar*, Vec);
458ed539a5SBarry Smith extern int VecSwap(Vec, Vec);
468ed539a5SBarry Smith extern int VecAXPY(Scalar*, Vec, Vec);
478ed539a5SBarry Smith extern int VecMAXPY(int,      Scalar*, Vec ,Vec*);
488ed539a5SBarry Smith extern int VecAYPX(Scalar*, Vec, Vec);
498ed539a5SBarry Smith extern int VecWAXPY(Scalar*, Vec, Vec, Vec);
508ed539a5SBarry Smith extern int VecPMult(Vec, Vec, Vec);
518ed539a5SBarry Smith extern int VecPDiv(Vec, Vec, Vec);
528ed539a5SBarry Smith extern int VecCreate(Vec,Vec *);
538ed539a5SBarry Smith extern int VecDestroy(Vec);
548ed539a5SBarry Smith extern int VecGetVecs(Vec, int,Vec **);
558ed539a5SBarry Smith extern int VecFreeVecs(Vec*,int);
562eac72dbSBarry Smith 
57*9d00d63dSBarry Smith typedef enum {NOTSETVALUES, INSERTVALUES, ADDVALUES} InsertMode;
5820563c6bSBarry Smith 
5920563c6bSBarry Smith extern int VecSetValues(Vec, int, int *,Scalar*,InsertMode);
60ee50ffe9SBarry Smith extern int VecAssemblyBegin(Vec);
61ee50ffe9SBarry Smith extern int VecAssemblyEnd(Vec);
628ed539a5SBarry Smith 
63*9d00d63dSBarry Smith typedef enum {SCATTERREVERSE=1,SCATTERDOWN=2,SCATTERUP=4,SCATTERALL=8,
64*9d00d63dSBarry Smith               SCATTERALLREVERSE=9} ScatterMode;
65ee50ffe9SBarry Smith 
66ee50ffe9SBarry Smith extern int VecScatterBegin(Vec,IS,Vec,IS,InsertMode,ScatterMode,VecScatterCtx);
67ee50ffe9SBarry Smith extern int VecScatterEnd(Vec,IS,Vec,IS,InsertMode,ScatterMode,VecScatterCtx);
6820563c6bSBarry Smith extern int VecScatterCtxCreate(Vec,IS,Vec,IS,VecScatterCtx *);
6920563c6bSBarry Smith extern int VecScatterCtxDestroy(VecScatterCtx);
70d6dfbf8fSBarry Smith extern int VecScatterCtxCopy(VecScatterCtx,VecScatterCtx *);
71d6dfbf8fSBarry Smith 
72*9d00d63dSBarry Smith typedef enum {PIPELINEDOWN=0,PIPELINEUP=1} PipelineMode;
73ee50ffe9SBarry Smith 
74ca9b4cbeSLois Curfman McInnes extern int VecPipelineBegin(Vec,IS,Vec,IS,InsertMode,PipelineMode,VecScatterCtx);
75ca9b4cbeSLois Curfman McInnes extern int VecPipelineEnd(Vec,IS,Vec,IS,InsertMode,PipelineMode,VecScatterCtx);
768ed539a5SBarry Smith 
778ed539a5SBarry Smith extern int VecGetArray(Vec,Scalar**);
786b5873e3SBarry Smith extern int VecRestoreArray(Vec,Scalar**);
798ed539a5SBarry Smith extern int VecValidVector(Vec);
808ed539a5SBarry Smith extern int VecView(Vec, Viewer);
818ed539a5SBarry Smith 
828ed539a5SBarry Smith extern int VecGetSize(Vec,int *);
838ed539a5SBarry Smith extern int VecGetLocalSize(Vec,int *);
84d6dfbf8fSBarry Smith extern int VecGetOwnershipRange(Vec,int*,int*);
858ed539a5SBarry Smith 
868ed539a5SBarry Smith /* utility routines */
878ed539a5SBarry Smith extern int VecReciprocal(Vec);
882eac72dbSBarry Smith 
892eac72dbSBarry Smith #endif
902eac72dbSBarry Smith 
912eac72dbSBarry Smith 
92