xref: /petsc/include/petscvec.h (revision 77c4ece699e97450631aa6fc5b0ef04ff52df029)
1*77c4ece6SBarry Smith /* $Id: vec.h,v 1.48 1996/03/14 18:44:41 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 #ifndef __VEC_PACKAGE
172eac72dbSBarry Smith #define __VEC_PACKAGE
182eac72dbSBarry Smith #include "is.h"
19bf5bf444SLois Curfman McInnes #include "sys.h"
202eac72dbSBarry Smith 
219e25ed09SBarry Smith #define VEC_COOKIE         PETSC_COOKIE+3
229e25ed09SBarry Smith #define VEC_SCATTER_COOKIE PETSC_COOKIE+4
239e25ed09SBarry Smith 
24b56ba379SLois Curfman McInnes typedef enum { VECSAME=-1, VECSEQ, VECMPI } VecType;
25f0479e8cSBarry Smith 
262eac72dbSBarry Smith typedef struct _Vec*         Vec;
2708480c60SBarry Smith typedef struct _VecScatter*  VecScatter;
282eac72dbSBarry Smith 
29227d817aSBarry Smith 
30de7da479SBarry Smith extern int VecCreateSeq(MPI_Comm,int,Vec*);
318ed539a5SBarry Smith extern int VecCreateMPI(MPI_Comm,int,int,Vec*);
326469c4f9SBarry Smith extern int VecCreate(MPI_Comm,int,Vec*);
332eac72dbSBarry Smith 
344b0e389bSBarry Smith extern int VecDestroy(Vec);
354b0e389bSBarry Smith 
368ed539a5SBarry Smith extern int VecDot(Vec,Vec,Scalar*);
378ed539a5SBarry Smith extern int VecTDot(Vec,Vec,Scalar*);
388ed539a5SBarry Smith extern int VecMDot(int,Vec,Vec*,Scalar*);
398ed539a5SBarry Smith extern int VecMTDot(int,Vec,Vec*,Scalar*);
40cddf8d76SBarry Smith 
41cddf8d76SBarry Smith typedef enum {NORM_1=1,NORM_2=2,NORM_FROBENIUS=3,NORM_INFINITY=4} NormType;
42cddf8d76SBarry Smith #define NORM_MAX NORM_INFINITY
43cddf8d76SBarry Smith extern int VecNorm(Vec,NormType,double *);
44ee50ffe9SBarry Smith extern int VecSum(Vec,Scalar*);
457c16e1c9SBarry Smith extern int VecMax(Vec,int*,double*);
467c16e1c9SBarry Smith extern int VecMin(Vec,int*,double*);
478ed539a5SBarry Smith extern int VecScale(Scalar*,Vec);
488ed539a5SBarry Smith extern int VecCopy(Vec,Vec);
49*77c4ece6SBarry Smith extern int VecSetRandom(PetscRandom,Vec);
508ed539a5SBarry Smith extern int VecSet(Scalar*,Vec);
518ed539a5SBarry Smith extern int VecSwap(Vec,Vec);
528ed539a5SBarry Smith extern int VecAXPY(Scalar*,Vec,Vec);
53*77c4ece6SBarry Smith extern int VecAXPBY(Scalar*,Scalar *,Vec,Vec);
548ed539a5SBarry Smith extern int VecMAXPY(int,Scalar*,Vec,Vec*);
558ed539a5SBarry Smith extern int VecAYPX(Scalar*,Vec,Vec);
568ed539a5SBarry Smith extern int VecWAXPY(Scalar*,Vec,Vec,Vec);
57*77c4ece6SBarry Smith extern int VecPointwiseMult(Vec,Vec,Vec);
58*77c4ece6SBarry Smith extern int VecPointwiseDivide(Vec,Vec,Vec);
594b0e389bSBarry Smith extern int VecShift(Scalar*,Vec);
604b0e389bSBarry Smith extern int VecReciprocal(Vec);
614b0e389bSBarry Smith extern int VecAbs(Vec);
626469c4f9SBarry Smith extern int VecDuplicate(Vec,Vec*);
63afc8d9b6SBarry Smith extern int VecDuplicateVecs(Vec,int,Vec**);
644b0e389bSBarry Smith extern int VecDestroyVecs(Vec*,int);
652eac72dbSBarry Smith 
6664119d58SLois Curfman McInnes typedef enum {NOT_SET_VALUES, INSERT_VALUES, ADD_VALUES} InsertMode;
6720563c6bSBarry Smith extern int VecSetValues(Vec,int,int*,Scalar*,InsertMode);
68ee50ffe9SBarry Smith extern int VecAssemblyBegin(Vec);
69ee50ffe9SBarry Smith extern int VecAssemblyEnd(Vec);
708ed539a5SBarry Smith 
7164119d58SLois Curfman McInnes typedef enum {SCATTER_REVERSE=1,SCATTER_DOWN=2,SCATTER_UP=4,SCATTER_ALL=8,
7264119d58SLois Curfman McInnes               SCATTER_ALL_REVERSE=9} ScatterMode;
7308480c60SBarry Smith extern int VecScatterBegin(Vec,Vec,InsertMode,ScatterMode,VecScatter);
7408480c60SBarry Smith extern int VecScatterEnd(Vec,Vec,InsertMode,ScatterMode,VecScatter);
7508480c60SBarry Smith extern int VecScatterCreate(Vec,IS,Vec,IS,VecScatter *);
7608480c60SBarry Smith extern int VecScatterDestroy(VecScatter);
7708480c60SBarry Smith extern int VecScatterCopy(VecScatter,VecScatter *);
7808480c60SBarry Smith extern int VecScatterView(VecScatter,Viewer);
79d6dfbf8fSBarry Smith 
802195c698SBarry Smith extern int VecScatterRemap(VecScatter,int *,int*);
812195c698SBarry Smith 
828ed539a5SBarry Smith extern int VecGetArray(Vec,Scalar**);
836b5873e3SBarry Smith extern int VecRestoreArray(Vec,Scalar**);
84afc8d9b6SBarry Smith extern int VecPlaceArray(Vec,Scalar*);
85707f76d8SBarry Smith extern int VecGetArrays(Vec*,int,Scalar***);
86707f76d8SBarry Smith extern int VecRestoreArrays(Vec*,int,Scalar***);
87*77c4ece6SBarry Smith extern int VecValid(Vec,PetscTruth*);
888ed539a5SBarry Smith extern int VecView(Vec,Viewer);
895f52d6abSBarry Smith extern int VecLoad(Viewer,Vec*);
908ed539a5SBarry Smith 
918ed539a5SBarry Smith extern int VecGetSize(Vec,int*);
921dd0cb96SLois Curfman McInnes extern int VecGetType(Vec,VecType*,char**);
938ed539a5SBarry Smith extern int VecGetLocalSize(Vec,int*);
94d6dfbf8fSBarry Smith extern int VecGetOwnershipRange(Vec,int*,int*);
958ed539a5SBarry Smith 
964b0e389bSBarry Smith typedef enum {PIPELINE_DOWN=0,PIPELINE_UP=1} PipelineMode;
974b0e389bSBarry Smith extern int VecPipelineBegin(Vec,Vec,InsertMode,PipelineMode,VecScatter);
984b0e389bSBarry Smith extern int VecPipelineEnd(Vec,Vec,InsertMode,PipelineMode,VecScatter);
992eac72dbSBarry Smith 
10034233285SBarry Smith #if defined(__DRAW_PACKAGE)
101d7e8b826SBarry Smith extern int DrawTensorContour(Draw,int,int,double *,double *,Vec);
10234233285SBarry Smith #endif
10334233285SBarry Smith 
1042eac72dbSBarry Smith #endif
1052eac72dbSBarry Smith 
1062eac72dbSBarry Smith 
107