xref: /petsc/include/petscvec.h (revision 707f76d80e756cb8bf50ce7a4a2dea4223071805)
1*707f76d8SBarry Smith /* $Id: vec.h,v 1.23 1995/06/07 16:29:54 bsmith Exp bsmith $ */
22eac72dbSBarry Smith /*
32eac72dbSBarry Smith    This defines the abstract vector component. These are patterned
42eac72dbSBarry Smith    after the Level-1 Blas, but with some additions that have proved
52eac72dbSBarry Smith    useful. These include routines to allocate and free vectors.
62eac72dbSBarry Smith 
72eac72dbSBarry Smith    Note that the routines that are normally thought of as returning a
82eac72dbSBarry Smith    value (e.g., dot, norm) return their value through an argument.
92eac72dbSBarry Smith    This allows these routines to be used with other datatype, such
102eac72dbSBarry Smith    as float and dcomplex.
112eac72dbSBarry Smith 
122eac72dbSBarry Smith    All vectors should be declared as a Vec. All vector routines begin
132eac72dbSBarry Smith    with Vec.
142eac72dbSBarry Smith 
152eac72dbSBarry Smith 
162eac72dbSBarry Smith  */
172eac72dbSBarry Smith 
182eac72dbSBarry Smith #ifndef __VEC_PACKAGE
192eac72dbSBarry Smith #define __VEC_PACKAGE
202eac72dbSBarry Smith #include "is.h"
212eac72dbSBarry Smith 
229e25ed09SBarry Smith #define VEC_COOKIE         PETSC_COOKIE+3
239e25ed09SBarry Smith #define VEC_SCATTER_COOKIE PETSC_COOKIE+4
249e25ed09SBarry Smith 
25f0479e8cSBarry Smith 
262eac72dbSBarry Smith typedef struct _Vec*            Vec;
2720563c6bSBarry Smith typedef struct _VecScatterCtx*  VecScatterCtx;
282eac72dbSBarry Smith 
296b5873e3SBarry Smith extern int VecCreateSequential(MPI_Comm,int,Vec *);
308ed539a5SBarry Smith extern int VecCreateMPI(MPI_Comm,int,int,Vec *);
316469c4f9SBarry Smith extern int VecCreate(MPI_Comm,int,Vec *);
322eac72dbSBarry Smith 
338ed539a5SBarry Smith extern int VecDot(Vec, Vec, Scalar*);
348ed539a5SBarry Smith extern int VecTDot(Vec, Vec, Scalar*);
358ed539a5SBarry Smith extern int VecMDot(int,      Vec ,Vec*,Scalar*);
368ed539a5SBarry Smith extern int VecMTDot(int,      Vec ,Vec*,Scalar*);
378ed539a5SBarry Smith extern int VecNorm(Vec, double*);
3820563c6bSBarry Smith extern int VecASum(Vec, double*);
39ee50ffe9SBarry Smith extern int VecSum(Vec,Scalar*);
40fddd07d0SBarry Smith extern int VecAMax(Vec, int *,   double*);
417c16e1c9SBarry Smith extern int VecMax(Vec, int *,    double*);
427c16e1c9SBarry Smith extern int VecMin(Vec, int *,    double*);
438ed539a5SBarry Smith extern int VecScale(Scalar*, Vec);
448ed539a5SBarry Smith extern int VecCopy(Vec, Vec);
458ed539a5SBarry Smith extern int VecSet(Scalar*, Vec);
468ed539a5SBarry Smith extern int VecSwap(Vec, Vec);
478ed539a5SBarry Smith extern int VecAXPY(Scalar*, Vec, Vec);
488ed539a5SBarry Smith extern int VecMAXPY(int,      Scalar*, Vec ,Vec*);
498ed539a5SBarry Smith extern int VecAYPX(Scalar*, Vec, Vec);
508ed539a5SBarry Smith extern int VecWAXPY(Scalar*, Vec, Vec, Vec);
518ed539a5SBarry Smith extern int VecPMult(Vec, Vec, Vec);
528ed539a5SBarry Smith extern int VecPDiv(Vec, Vec, Vec);
536469c4f9SBarry Smith extern int VecDuplicate(Vec,Vec *);
548ed539a5SBarry Smith extern int VecDestroy(Vec);
558ed539a5SBarry Smith extern int VecGetVecs(Vec, int,Vec **);
568ed539a5SBarry Smith extern int VecFreeVecs(Vec*,int);
572eac72dbSBarry Smith 
589d00d63dSBarry Smith typedef enum {NOTSETVALUES, INSERTVALUES, ADDVALUES} InsertMode;
5920563c6bSBarry Smith 
6020563c6bSBarry Smith extern int VecSetValues(Vec, int, int *,Scalar*,InsertMode);
61ee50ffe9SBarry Smith extern int VecAssemblyBegin(Vec);
62ee50ffe9SBarry Smith extern int VecAssemblyEnd(Vec);
638ed539a5SBarry Smith 
649d00d63dSBarry Smith typedef enum {SCATTERREVERSE=1,SCATTERDOWN=2,SCATTERUP=4,SCATTERALL=8,
659d00d63dSBarry Smith               SCATTERALLREVERSE=9} ScatterMode;
66ee50ffe9SBarry Smith 
6706be10caSBarry Smith extern int VecScatterBegin(Vec,Vec,InsertMode,ScatterMode,VecScatterCtx);
6806be10caSBarry Smith extern int VecScatterEnd(Vec,Vec,InsertMode,ScatterMode,VecScatterCtx);
6920563c6bSBarry Smith extern int VecScatterCtxCreate(Vec,IS,Vec,IS,VecScatterCtx *);
7020563c6bSBarry Smith extern int VecScatterCtxDestroy(VecScatterCtx);
71d6dfbf8fSBarry Smith extern int VecScatterCtxCopy(VecScatterCtx,VecScatterCtx *);
72d6dfbf8fSBarry Smith 
739d00d63dSBarry Smith typedef enum {PIPELINEDOWN=0,PIPELINEUP=1} PipelineMode;
74ee50ffe9SBarry Smith 
7506be10caSBarry Smith extern int VecPipelineBegin(Vec,Vec,InsertMode,PipelineMode,VecScatterCtx);
7606be10caSBarry Smith extern int VecPipelineEnd(Vec,Vec,InsertMode,PipelineMode,VecScatterCtx);
778ed539a5SBarry Smith 
788ed539a5SBarry Smith extern int VecGetArray(Vec,Scalar**);
796b5873e3SBarry Smith extern int VecRestoreArray(Vec,Scalar**);
80*707f76d8SBarry Smith extern int VecGetArrays(Vec*,int,Scalar***);
81*707f76d8SBarry Smith extern int VecRestoreArrays(Vec*,int,Scalar***);
828ed539a5SBarry Smith extern int VecValidVector(Vec);
838ed539a5SBarry Smith extern int VecView(Vec, Viewer);
848ed539a5SBarry Smith 
858ed539a5SBarry Smith extern int VecGetSize(Vec,int *);
868ed539a5SBarry Smith extern int VecGetLocalSize(Vec,int *);
87d6dfbf8fSBarry Smith extern int VecGetOwnershipRange(Vec,int*,int*);
888ed539a5SBarry Smith 
898ed539a5SBarry Smith /* utility routines */
908ed539a5SBarry Smith extern int VecReciprocal(Vec);
912eac72dbSBarry Smith 
9234233285SBarry Smith #if defined(__DRAW_PACKAGE)
9334233285SBarry Smith extern int DrawTensorContour(DrawCtx,int,int,double *,double *,Vec);
9434233285SBarry Smith #endif
9534233285SBarry Smith 
962eac72dbSBarry Smith #endif
972eac72dbSBarry Smith 
982eac72dbSBarry Smith 
99