NEURON
nvector_nrnserial_ld.h
Go to the documentation of this file.
1 /*
2 * N_Vector_NrnSerialLD derived from N_Vector_Serial Sundials version
3 * by replaceing every occurrence of Serial with NrnSerialLD and then
4 * modifying relevant method implementations to allow long double
5 * accumulation.
6 */
7 /*
8 Macros changed with
9 sed 's/NV_\([A-Za-z_]*\)_S/NV_\1_S_LD/g' nvector_nrnserial_ld.h >temp
10 mv temp nvector_nrnserial_ld.h
11 sed 's/NV_\([A-Za-z_]*\)_S/NV_\1_S_LD/g' nvector_nrnserial_ld.cpp >temp
12 mv temp nvector_nrnserial_ld.cpp
13 */
14 
15 /*
16  * -----------------------------------------------------------------
17  * $Revision: 855 $
18  * $Date: 2005-02-10 00:15:46 +0100 (Thu, 10 Feb 2005) $
19  * -----------------------------------------------------------------
20  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
21  * and Aaron Collier @ LLNL
22  * -----------------------------------------------------------------
23  * Copyright (c) 2002, The Regents of the University of California.
24  * Produced at the Lawrence Livermore National Laboratory.
25  * All rights reserved.
26  * For details, see sundials/shared/LICENSE.
27  * -----------------------------------------------------------------
28  * This is the header file for the serial implementation of the
29  * NVECTOR module.
30  *
31  * Part I contains declarations specific to the serial
32  * implementation of the supplied NVECTOR module.
33  *
34  * Part II defines accessor macros that allow the user to
35  * efficiently use the type N_Vector without making explicit
36  * references to the underlying data structure.
37  *
38  * Part III contains the prototype for the constructor N_VNew_NrnSerialLD
39  * as well as implementation-specific prototypes for various useful
40  * vector operations.
41  *
42  * Notes:
43  *
44  * - The definition of the generic N_Vector structure can be found
45  * in the header file shared/include/nvector.h.
46  *
47  * - The definition of the type realtype can be found in the
48  * header file shared/include/sundialstypes.h, and it may be
49  * changed (at the configuration stage) according to the user's
50  * needs. The sundialstypes.h file also contains the definition
51  * for the type booleantype.
52  *
53  * - N_Vector arguments to arithmetic vector operations need not
54  * be distinct. For example, the following call:
55  *
56  * N_VLinearSum_NrnSerialLD(a,x,b,y,y);
57  *
58  * (which stores the result of the operation a*x+b*y in y)
59  * is legal.
60  * -----------------------------------------------------------------
61  */
62 
63 #ifndef _NVECTOR_NRNSERIAL_LD_H
64 #define _NVECTOR_NRNSERIAL_LD_H
65 
66 
67 #include "nvector.h"
68 #include "sundialstypes.h"
69 
70 /*
71  * -----------------------------------------------------------------
72  * PART I: SERIAL implementation of N_Vector
73  * -----------------------------------------------------------------
74  */
75 
76 /* serial implementation of the N_Vector 'content' structure
77  contains the length of the vector, a pointer to an array
78  of realtype components, and a flag indicating ownership of
79  the data */
80 
82  long int length;
83  booleantype own_data;
84  realtype *data;
85 };
86 
88 
89 /*
90  * -----------------------------------------------------------------
91  * PART II: macros NV_CONTENT_S_LD, NV_DATA_S_LD, NV_OWN_DATA_S_LD,
92  * NV_LENGTH_S_LD, and NV_Ith_S_LD
93  * -----------------------------------------------------------------
94  * In the descriptions below, the following user declarations
95  * are assumed:
96  *
97  * N_Vector v;
98  * long int i;
99  *
100  * (1) NV_CONTENT_S_LD
101  *
102  * This routines gives access to the contents of the serial
103  * vector N_Vector.
104  *
105  * The assignment v_cont = NV_CONTENT_S_LD(v) sets v_cont to be
106  * a pointer to the serial N_Vector content structure.
107  *
108  * (2) NV_DATA_S_LD NV_OWN_DATA_S_LD and NV_LENGTH_S_LD
109  *
110  * These routines give access to the individual parts of
111  * the content structure of a serial N_Vector.
112  *
113  * The assignment v_data = NV_DATA_S_LD(v) sets v_data to be
114  * a pointer to the first component of v. The assignment
115  * NV_DATA_S_LD(v) = data_V sets the component array of v to
116  * be data_v by storing the pointer data_v.
117  *
118  * The assignment v_len = NV_LENGTH_S_LD(v) sets v_len to be
119  * the length of v. The call NV_LENGTH_S_LD(v) = len_v sets
120  * the length of v to be len_v.
121  *
122  * (3) NV_Ith_S_LD
123  *
124  * In the following description, the components of an
125  * N_Vector are numbered 0..n-1, where n is the length of v.
126  *
127  * The assignment r = NV_Ith_S_LD(v,i) sets r to be the value of
128  * the ith component of v. The assignment NV_Ith_S_LD(v,i) = r
129  * sets the value of the ith component of v to be r.
130  *
131  * Note: When looping over the components of an N_Vector v, it is
132  * more efficient to first obtain the component array via
133  * v_data = NV_DATA_S_LD(v) and then access v_data[i] within the
134  * loop than it is to use NV_Ith_S_LD(v,i) within the loop.
135  * -----------------------------------------------------------------
136  */
137 
138 #define NV_CONTENT_S_LD(v) ( (N_VectorContent_NrnSerialLD)(v->content) )
139 
140 #define NV_LENGTH_S_LD(v) ( NV_CONTENT_S_LD(v)->length )
141 
142 #define NV_OWN_DATA_S_LD(v) ( NV_CONTENT_S_LD(v)->own_data )
143 
144 #define NV_DATA_S_LD(v) ( NV_CONTENT_S_LD(v)->data )
145 
146 #define NV_Ith_S_LD(v,i) ( NV_DATA_S_LD(v)[i] )
147 
148 /*
149  * -----------------------------------------------------------------
150  * PART III: functions exported by nvector_serial
151  *
152  * CONSTRUCTORS:
153  * N_VNew_NrnSerialLD
154  * N_VNewEmpty_NrnSerialLD
155  * N_VClone_NrnSerialLD
156  * N_VCloneEmpty_NrnSerialLD
157  * N_VMake_NrnSerialLD
158  * N_VNewVectorArray_NrnSerialLD
159  * N_VNewVectorArrayEmpty_NrnSerialLD
160  * DESTRUCTORS:
161  * N_VDestroy_NrnSerialLD
162  * N_VDestroyVectorArray_NrnSerialLD
163  * -----------------------------------------------------------------
164  */
165 
166 /*
167  * -----------------------------------------------------------------
168  * Function : N_VNew_NrnSerialLD
169  * -----------------------------------------------------------------
170  * This function creates and allocates memory for a serial vector.
171  * -----------------------------------------------------------------
172  */
173 
174 N_Vector N_VNew_NrnSerialLD(long int vec_length);
175 
176 /*
177  * -----------------------------------------------------------------
178  * Function : N_VNewEmpty_NrnSerialLD
179  * -----------------------------------------------------------------
180  * This function creates a new serial N_Vector with an empty (NULL)
181  * data array.
182  * -----------------------------------------------------------------
183  */
184 
185 N_Vector N_VNewEmpty_NrnSerialLD(long int vec_length);
186 
187 /*
188  * -----------------------------------------------------------------
189  * Function : N_VCloneEmpty_NrnSerialLD
190  * -----------------------------------------------------------------
191  * This function creates a new serial N_Vector with an empty (NULL)
192  * data array.
193  * -----------------------------------------------------------------
194  */
195 
196 N_Vector N_VCloneEmpty_NrnSerialLD(N_Vector w);
197 
198 /*
199  * -----------------------------------------------------------------
200  * Function : N_VMake_NrnSerialLD
201  * -----------------------------------------------------------------
202  * This function creates and allocates memory for a serial vector
203  * with a user-supplied data array.
204  * -----------------------------------------------------------------
205  */
206 
207 N_Vector N_VMake_NrnSerialLD(long int vec_length, realtype *v_data);
208 
209 /*
210  * -----------------------------------------------------------------
211  * Function : N_VNewVectorArray_NrnSerialLD
212  * -----------------------------------------------------------------
213  * This function creates an array of 'count' serial vectors. This
214  * array of N_Vectors can be freed using N_VDestroyVectorArray
215  * (defined by the generic NVECTOR module).
216  * -----------------------------------------------------------------
217  */
218 
219 N_Vector *N_VNewVectorArray_NrnSerialLD(int count, long int vec_length);
220 
221 /*
222  * -----------------------------------------------------------------
223  * Function : N_VNewVectorArrayEmpty_NrnSerialLD
224  * -----------------------------------------------------------------
225  * This function creates an array of 'count' serial vectors each
226  * with an empty (NULL) data array.
227  * -----------------------------------------------------------------
228  */
229 
230 N_Vector *N_VNewVectorArrayEmpty_NrnSerialLD(int count, long int vec_length);
231 
232 /*
233  * -----------------------------------------------------------------
234  * Function : N_VDestroyVectorArray_NrnSerialLD
235  * -----------------------------------------------------------------
236  * This function frees an array of N_Vector created with
237  * N_VNewVectorArray_NrnSerialLD.
238  * -----------------------------------------------------------------
239  */
240 
241 void N_VDestroyVectorArray_NrnSerialLD(N_Vector *vs, int count);
242 
243 /*
244  * -----------------------------------------------------------------
245  * Function : N_VPrint_NrnSerialLD
246  * -----------------------------------------------------------------
247  * This function prints the content of a serial vector to stdout.
248  * -----------------------------------------------------------------
249  */
250 
251 void N_VPrint_NrnSerialLD(N_Vector v);
252 
253 /*
254  * -----------------------------------------------------------------
255  * serial implementations of various useful vector operations
256  * -----------------------------------------------------------------
257  */
258 
259 N_Vector N_VClone_NrnSerialLD(N_Vector w);
260 void N_VDestroy_NrnSerialLD(N_Vector v);
261 void N_VSpace_NrnSerialLD(N_Vector v, long int *lrw, long int *liw);
262 realtype *N_VGetArrayPointer_NrnSerialLD(N_Vector v);
263 void N_VSetArrayPointer_NrnSerialLD(realtype *v_data, N_Vector v);
264 void N_VLinearSum_NrnSerialLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
265 void N_VConst_NrnSerialLD(realtype c, N_Vector z);
266 void N_VProd_NrnSerialLD(N_Vector x, N_Vector y, N_Vector z);
267 void N_VDiv_NrnSerialLD(N_Vector x, N_Vector y, N_Vector z);
268 void N_VScale_NrnSerialLD(realtype c, N_Vector x, N_Vector z);
269 void N_VAbs_NrnSerialLD(N_Vector x, N_Vector z);
270 void N_VInv_NrnSerialLD(N_Vector x, N_Vector z);
271 void N_VAddConst_NrnSerialLD(N_Vector x, realtype b, N_Vector z);
272 realtype N_VDotProd_NrnSerialLD(N_Vector x, N_Vector y);
273 realtype N_VMaxNorm_NrnSerialLD(N_Vector x);
274 realtype N_VWrmsNorm_NrnSerialLD(N_Vector x, N_Vector w);
275 realtype N_VWrmsNormMask_NrnSerialLD(N_Vector x, N_Vector w, N_Vector id);
276 realtype N_VMin_NrnSerialLD(N_Vector x);
277 realtype N_VWL2Norm_NrnSerialLD(N_Vector x, N_Vector w);
278 realtype N_VL1Norm_NrnSerialLD(N_Vector x);
279 void N_VCompare_NrnSerialLD(realtype c, N_Vector x, N_Vector z);
280 booleantype N_VInvTest_NrnSerialLD(N_Vector x, N_Vector z);
281 booleantype N_VConstrMask_NrnSerialLD(N_Vector c, N_Vector x, N_Vector m);
282 realtype N_VMinQuotient_NrnSerialLD(N_Vector num, N_Vector denom);
283 
284 
285 #endif
realtype N_VL1Norm_NrnSerialLD(N_Vector x)
void N_VDiv_NrnSerialLD(N_Vector x, N_Vector y, N_Vector z)
realtype N_VWrmsNorm_NrnSerialLD(N_Vector x, N_Vector w)
void N_VAddConst_NrnSerialLD(N_Vector x, realtype b, N_Vector z)
void N_VProd_NrnSerialLD(N_Vector x, N_Vector y, N_Vector z)
N_Vector N_VCloneEmpty_NrnSerialLD(N_Vector w)
N_Vector N_VNewEmpty_NrnSerialLD(long int vec_length)
realtype N_VWrmsNormMask_NrnSerialLD(N_Vector x, N_Vector w, N_Vector id)
#define v
Definition: md1redef.h:4
realtype N_VMin_NrnSerialLD(N_Vector x)
realtype N_VDotProd_NrnSerialLD(N_Vector x, N_Vector y)
void N_VCompare_NrnSerialLD(realtype c, N_Vector x, N_Vector z)
void N_VDestroy_NrnSerialLD(N_Vector v)
struct _N_VectorContent_NrnSerialLD * N_VectorContent_NrnSerialLD
void N_VLinearSum_NrnSerialLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
void N_VScale_NrnSerialLD(realtype c, N_Vector x, N_Vector z)
realtype N_VMaxNorm_NrnSerialLD(N_Vector x)
void N_VDestroyVectorArray_NrnSerialLD(N_Vector *vs, int count)
realtype N_VMinQuotient_NrnSerialLD(N_Vector num, N_Vector denom)
void N_VSpace_NrnSerialLD(N_Vector v, long int *lrw, long int *liw)
booleantype N_VInvTest_NrnSerialLD(N_Vector x, N_Vector z)
N_Vector N_VMake_NrnSerialLD(long int vec_length, realtype *v_data)
booleantype N_VConstrMask_NrnSerialLD(N_Vector c, N_Vector x, N_Vector m)
N_Vector * N_VNewVectorArray_NrnSerialLD(int count, long int vec_length)
realtype N_VWL2Norm_NrnSerialLD(N_Vector x, N_Vector w)
N_Vector N_VClone_NrnSerialLD(N_Vector w)
void N_VInv_NrnSerialLD(N_Vector x, N_Vector z)
void N_VConst_NrnSerialLD(realtype c, N_Vector z)
#define c
void N_VPrint_NrnSerialLD(N_Vector v)
void N_VAbs_NrnSerialLD(N_Vector x, N_Vector z)
realtype * N_VGetArrayPointer_NrnSerialLD(N_Vector v)
N_Vector N_VNew_NrnSerialLD(long int vec_length)
N_Vector * N_VNewVectorArrayEmpty_NrnSerialLD(int count, long int vec_length)
void N_VSetArrayPointer_NrnSerialLD(realtype *v_data, N_Vector v)