nvector_serial.h

Go to the documentation of this file.
00001 /*
00002  * -----------------------------------------------------------------
00003  * $Revision: 1.2 $
00004  * $Date: 2006/11/29 00:05:07 $
00005  * ----------------------------------------------------------------- 
00006  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
00007  *                and Aaron Collier @ LLNL
00008  * -----------------------------------------------------------------
00009  * Copyright (c) 2002, The Regents of the University of California.
00010  * Produced at the Lawrence Livermore National Laboratory.
00011  * All rights reserved.
00012  * For details, see the LICENSE file.
00013  * -----------------------------------------------------------------
00014  * This is the header file for the serial implementation of the
00015  * NVECTOR module.
00016  *
00017  * Part I contains declarations specific to the serial
00018  * implementation of the supplied NVECTOR module.
00019  *
00020  * Part II defines accessor macros that allow the user to
00021  * efficiently use the type N_Vector without making explicit
00022  * references to the underlying data structure.
00023  *
00024  * Part III contains the prototype for the constructor N_VNew_Serial
00025  * as well as implementation-specific prototypes for various useful
00026  * vector operations.
00027  *
00028  * Notes:
00029  *
00030  *   - The definition of the generic N_Vector structure can be found
00031  *     in the header file sundials_nvector.h.
00032  *
00033  *   - The definition of the type 'realtype' can be found in the
00034  *     header file sundials_types.h, and it may be changed (at the 
00035  *     configuration stage) according to the user's needs. 
00036  *     The sundials_types.h file also contains the definition
00037  *     for the type 'booleantype'.
00038  *
00039  *   - N_Vector arguments to arithmetic vector operations need not
00040  *     be distinct. For example, the following call:
00041  *
00042  *       N_VLinearSum_Serial(a,x,b,y,y);
00043  *
00044  *     (which stores the result of the operation a*x+b*y in y)
00045  *     is legal.
00046  * -----------------------------------------------------------------
00047  */
00048 
00049 #ifndef _NVECTOR_SERIAL_H
00050 #define _NVECTOR_SERIAL_H
00051 
00052 #ifdef __cplusplus  /* wrapper to enable C++ usage */
00053 extern "C" {
00054 #endif
00055 
00056 #include <sundials/sundials_nvector.h>
00057 
00058 /*
00059  * -----------------------------------------------------------------
00060  * PART I: SERIAL implementation of N_Vector
00061  * -----------------------------------------------------------------
00062  */
00063 
00064 /* serial implementation of the N_Vector 'content' structure
00065    contains the length of the vector, a pointer to an array
00066    of 'realtype' components, and a flag indicating ownership of
00067    the data */
00068 
00069 struct _N_VectorContent_Serial {
00070   long int length;
00071   booleantype own_data;
00072   realtype *data;
00073 };
00074 
00075 typedef struct _N_VectorContent_Serial *N_VectorContent_Serial;
00076 
00077 /*
00078  * -----------------------------------------------------------------
00079  * PART II: macros NV_CONTENT_S, NV_DATA_S, NV_OWN_DATA_S,
00080  *          NV_LENGTH_S, and NV_Ith_S
00081  * -----------------------------------------------------------------
00082  * In the descriptions below, the following user declarations
00083  * are assumed:
00084  *
00085  * N_Vector v;
00086  * long int i;
00087  *
00088  * (1) NV_CONTENT_S
00089  *
00090  *     This routines gives access to the contents of the serial
00091  *     vector N_Vector.
00092  *
00093  *     The assignment v_cont = NV_CONTENT_S(v) sets v_cont to be
00094  *     a pointer to the serial N_Vector content structure.
00095  *
00096  * (2) NV_DATA_S NV_OWN_DATA_S and NV_LENGTH_S
00097  *
00098  *     These routines give access to the individual parts of
00099  *     the content structure of a serial N_Vector.
00100  *
00101  *     The assignment v_data = NV_DATA_S(v) sets v_data to be
00102  *     a pointer to the first component of v. The assignment
00103  *     NV_DATA_S(v) = data_V sets the component array of v to
00104  *     be data_v by storing the pointer data_v.
00105  *
00106  *     The assignment v_len = NV_LENGTH_S(v) sets v_len to be
00107  *     the length of v. The call NV_LENGTH_S(v) = len_v sets
00108  *     the length of v to be len_v.
00109  *
00110  * (3) NV_Ith_S
00111  *
00112  *     In the following description, the components of an
00113  *     N_Vector are numbered 0..n-1, where n is the length of v.
00114  *
00115  *     The assignment r = NV_Ith_S(v,i) sets r to be the value of
00116  *     the ith component of v. The assignment NV_Ith_S(v,i) = r
00117  *     sets the value of the ith component of v to be r.
00118  *
00119  * Note: When looping over the components of an N_Vector v, it is
00120  * more efficient to first obtain the component array via
00121  * v_data = NV_DATA_S(v) and then access v_data[i] within the
00122  * loop than it is to use NV_Ith_S(v,i) within the loop.
00123  * -----------------------------------------------------------------
00124  */
00125 
00126 #define NV_CONTENT_S(v)  ( (N_VectorContent_Serial)(v->content) )
00127 
00128 #define NV_LENGTH_S(v)   ( NV_CONTENT_S(v)->length )
00129 
00130 #define NV_OWN_DATA_S(v) ( NV_CONTENT_S(v)->own_data )
00131 
00132 #define NV_DATA_S(v)     ( NV_CONTENT_S(v)->data )
00133 
00134 #define NV_Ith_S(v,i)    ( NV_DATA_S(v)[i] )
00135 
00136 /*
00137  * -----------------------------------------------------------------
00138  * PART III: functions exported by nvector_serial
00139  * 
00140  * CONSTRUCTORS:
00141  *    N_VNew_Serial
00142  *    N_VNewEmpty_Serial
00143  *    N_VMake_Serial
00144  *    N_VCloneVectorArray_Serial
00145  *    N_VCloneVectorArrayEmpty_Serial
00146  * DESTRUCTORS:
00147  *    N_VDestroy_Serial
00148  *    N_VDestroyVectorArray_Serial
00149  * OTHER:
00150  *    N_VPrint_Serial
00151  * -----------------------------------------------------------------
00152  */
00153 
00154 /*
00155  * -----------------------------------------------------------------
00156  * Function : N_VNew_Serial
00157  * -----------------------------------------------------------------
00158  * This function creates and allocates memory for a serial vector.
00159  * -----------------------------------------------------------------
00160  */
00161 
00162 SUNDIALS_EXPORT N_Vector N_VNew_Serial(long int vec_length);
00163 
00164 /*
00165  * -----------------------------------------------------------------
00166  * Function : N_VNewEmpty_Serial
00167  * -----------------------------------------------------------------
00168  * This function creates a new serial N_Vector with an empty (NULL)
00169  * data array.
00170  * -----------------------------------------------------------------
00171  */
00172 
00173 SUNDIALS_EXPORT N_Vector N_VNewEmpty_Serial(long int vec_length);
00174 
00175 /*
00176  * -----------------------------------------------------------------
00177  * Function : N_VMake_Serial
00178  * -----------------------------------------------------------------
00179  * This function creates and allocates memory for a serial vector
00180  * with a user-supplied data array.
00181  * -----------------------------------------------------------------
00182  */
00183 
00184 SUNDIALS_EXPORT N_Vector N_VMake_Serial(long int vec_length, realtype *v_data);
00185 
00186 /*
00187  * -----------------------------------------------------------------
00188  * Function : N_VCloneVectorArray_Serial
00189  * -----------------------------------------------------------------
00190  * This function creates an array of 'count' SERIAL vectors by
00191  * cloning a given vector w.
00192  * -----------------------------------------------------------------
00193  */
00194 
00195 SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray_Serial(int count, N_Vector w);
00196 
00197 /*
00198  * -----------------------------------------------------------------
00199  * Function : N_VCloneVectorArrayEmpty_Serial
00200  * -----------------------------------------------------------------
00201  * This function creates an array of 'count' SERIAL vectors each
00202  * with an empty (NULL) data array by cloning w.
00203  * -----------------------------------------------------------------
00204  */
00205 
00206 SUNDIALS_EXPORT N_Vector *N_VCloneVectorArrayEmpty_Serial(int count, N_Vector w);
00207 
00208 /*
00209  * -----------------------------------------------------------------
00210  * Function : N_VDestroyVectorArray_Serial
00211  * -----------------------------------------------------------------
00212  * This function frees an array of SERIAL vectors created with 
00213  * N_VCloneVectorArray_Serial or N_VCloneVectorArrayEmpty_Serial.
00214  * -----------------------------------------------------------------
00215  */
00216 
00217 SUNDIALS_EXPORT void N_VDestroyVectorArray_Serial(N_Vector *vs, int count);
00218 
00219 /*
00220  * -----------------------------------------------------------------
00221  * Function : N_VPrint_Serial
00222  * -----------------------------------------------------------------
00223  * This function prints the content of a serial vector to stdout.
00224  * -----------------------------------------------------------------
00225  */
00226 
00227 SUNDIALS_EXPORT void N_VPrint_Serial(N_Vector v);
00228 
00229 /*
00230  * -----------------------------------------------------------------
00231  * serial implementations of various useful vector operations
00232  * -----------------------------------------------------------------
00233  */
00234 
00235 SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Serial(N_Vector w);
00236 SUNDIALS_EXPORT N_Vector N_VClone_Serial(N_Vector w);
00237 SUNDIALS_EXPORT void N_VDestroy_Serial(N_Vector v);
00238 SUNDIALS_EXPORT void N_VSpace_Serial(N_Vector v, long int *lrw, long int *liw);
00239 SUNDIALS_EXPORT realtype *N_VGetArrayPointer_Serial(N_Vector v);
00240 SUNDIALS_EXPORT void N_VSetArrayPointer_Serial(realtype *v_data, N_Vector v);
00241 SUNDIALS_EXPORT void N_VLinearSum_Serial(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
00242 SUNDIALS_EXPORT void N_VConst_Serial(realtype c, N_Vector z);
00243 SUNDIALS_EXPORT void N_VProd_Serial(N_Vector x, N_Vector y, N_Vector z);
00244 SUNDIALS_EXPORT void N_VDiv_Serial(N_Vector x, N_Vector y, N_Vector z);
00245 SUNDIALS_EXPORT void N_VScale_Serial(realtype c, N_Vector x, N_Vector z);
00246 SUNDIALS_EXPORT void N_VAbs_Serial(N_Vector x, N_Vector z);
00247 SUNDIALS_EXPORT void N_VInv_Serial(N_Vector x, N_Vector z);
00248 SUNDIALS_EXPORT void N_VAddConst_Serial(N_Vector x, realtype b, N_Vector z);
00249 SUNDIALS_EXPORT realtype N_VDotProd_Serial(N_Vector x, N_Vector y);
00250 SUNDIALS_EXPORT realtype N_VMaxNorm_Serial(N_Vector x);
00251 SUNDIALS_EXPORT realtype N_VWrmsNorm_Serial(N_Vector x, N_Vector w);
00252 SUNDIALS_EXPORT realtype N_VWrmsNormMask_Serial(N_Vector x, N_Vector w, N_Vector id);
00253 SUNDIALS_EXPORT realtype N_VMin_Serial(N_Vector x);
00254 SUNDIALS_EXPORT realtype N_VWL2Norm_Serial(N_Vector x, N_Vector w);
00255 SUNDIALS_EXPORT realtype N_VL1Norm_Serial(N_Vector x);
00256 SUNDIALS_EXPORT void N_VCompare_Serial(realtype c, N_Vector x, N_Vector z);
00257 SUNDIALS_EXPORT booleantype N_VInvTest_Serial(N_Vector x, N_Vector z);
00258 SUNDIALS_EXPORT booleantype N_VConstrMask_Serial(N_Vector c, N_Vector x, N_Vector m);
00259 SUNDIALS_EXPORT realtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom);
00260 
00261 #ifdef __cplusplus
00262 }
00263 #endif
00264 
00265 #endif

Generated on Thu Aug 12 16:37:12 2010 for SimTKcore by  doxygen 1.6.1