NEURON
nvector_nrnthread_ld.h
Go to the documentation of this file.
1 /*
2  * N_Vector_NrnThreadLD derived from N_Vector_Serial SunDials version
3  * by replacing every occurrence of nrnthread with nrnthread in the various
4  * cases and then modifying the relevant prototypes.
5  * We only re-implement the ones that are used by cvodes and ida
6  */
7 /*
8 Macros changed with
9 sed 's/NV_\‍([A-Za-z_]*\‍)_NT/NV_\1_NT_LD/g' nvector_nrnthread_ld.cpp > temp
10 mv temp nvector_nrnthread_ld.cpp
11 sed 's/NV_\‍([A-Za-z_]*\‍)_NT/NV_\1_NT_LD/g' nvector_nrnthread_ld.h >temp
12 mv temp nvector_nrnthread_ld.h
13 */
14 /*
15  * -----------------------------------------------------------------
16  * $Revision: 855 $
17  * $Date: 2005-02-09 18:15:46 -0500 (Wed, 09 Feb 2005) $
18  * -----------------------------------------------------------------
19  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
20  * and Aaron Collier @ LLNL
21  * -----------------------------------------------------------------
22  * Copyright (c) 2002, The Regents of the University of California.
23  * Produced at the Lawrence Livermore National Laboratory.
24  * All rights reserved.
25  * For details, see sundials/shared/LICENSE.
26  * -----------------------------------------------------------------
27  * This is the header file for the nrnthread implementation of the
28  * NVECTOR module.
29  *
30  * Part I contains declarations specific to the nrnthread
31  * implementation of the supplied NVECTOR module.
32  *
33  * Part II defines accessor macros that allow the user to
34  * efficiently use the type N_Vector without making explicit
35  * references to the underlying data structure.
36  *
37  * Part III contains the prototype for the constructor N_VNew_NrnThreadLD
38  * as well as implementation-specific prototypes for various useful
39  * vector operations.
40  *
41  * Notes:
42  *
43  * - The definition of the generic N_Vector structure can be found
44  * in the header file shared/include/nvector.h.
45  *
46  * - The definition of the type realtype can be found in the
47  * header file shared/include/sundialstypes.h, and it may be
48  * changed (at the configuration stage) according to the user's
49  * needs. The sundialstypes.h file also contains the definition
50  * for the type booleantype.
51  *
52  * - N_Vector arguments to arithmetic vector operations need not
53  * be distinct. For example, the following call:
54  *
55  * N_VLinearSum_NrnThreadLD(a,x,b,y,y);
56  *
57  * (which stores the result of the operation a*x+b*y in y)
58  * is legal.
59  * -----------------------------------------------------------------
60  */
61 
62 #ifndef _NVECTOR_NRNTHREAD_LD_H
63 #define _NVECTOR_NRNTHREAD_LD_H
64 
65 
66 #include "nvector.h"
67 #include "sundialstypes.h"
68 extern "C" {
69 extern void N_VOneMask_Serial(N_Vector x);
70 }
71 
72 /*
73  * -----------------------------------------------------------------
74  * PART I: NRNTHREAD implementation of N_Vector
75  * -----------------------------------------------------------------
76  */
77 
78 /* nrnthread implementation of the N_Vector 'content' structure
79  contains the length of the vector, nthread, and a pointer to
80  nthread N_Vector (serial)
81 */
82 
84  long int length;
85  int nt; /* number of threads */
86  booleantype own_data;
87  N_Vector* data; /* nt of them (N_Vector_Serial) */
88 };
89 
91 
92 /* Note: documentation below may not be completely transformed from the
93  N_Vector_Serial case
94 */
95 
96 /*
97  * -----------------------------------------------------------------
98  * PART II: macros NV_CONTENT_S, NV_DATA_S, NV_OWN_DATA_S,
99  * NV_LENGTH_S, and NV_Ith_S
100  * -----------------------------------------------------------------
101  * In the descriptions below, the following user declarations
102  * are assumed:
103  *
104  * N_Vector v;
105  * long int i;
106  *
107  * (1) NV_CONTENT_NT_LD
108  *
109  * This routines gives access to the contents of the nrnthread
110  * vector N_Vector.
111  *
112  * The assignment v_cont = NV_CONTENT_NT_LD(v) sets v_cont to be
113  * a pointer to the nrnthread N_Vector content structure.
114  *
115  * (2) NV_SUBVEC_NT_LD and NV_LENGTH_NT_LD
116  *
117  * These routines give access to the individual parts of
118  * the content structure of a nrnthread N_Vector.
119  *
120  * The assignment v_data = NV_SUBVEC_NT_LD(v, i) sets v_data to be
121  * a pointer to the ith N_Vector of v. The assignment
122  * NV_SUBVEC_NT_LD(v, i) = data_V sets the ith component N_Vector of v to
123  * be data_v by storing the pointer data_v.
124  *
125  * The assignment v_llen = NV_SIZE_NT_LD(v,i) sets v_llen to be
126  * the length of the ith component of v. The call NV_LENGTH_NT_LD(v) = len_v sets
127  * the length of v to be len_v.
128  *
129  * (3) NV_Ith_NT_LD
130  *
131  * In the following description, the components of an
132  * N_Vector are numbered 0..n-1, where n is the length of v.
133  *
134  * The assignment r = NV_Ith_S(v,i) sets r to be the value of
135  * the ith component of v. The assignment NV_Ith_S(v,i) = r
136  * sets the value of the ith component of v to be r.
137  *
138  * Note: When looping over the components of an N_Vector v, it is
139  * more efficient to first obtain the component array via
140  * v_data = NV_DATA_S(v) and then access v_data[i] within the
141  * loop than it is to use NV_Ith_S(v,i) within the loop.
142  * -----------------------------------------------------------------
143  */
144 
145 #define NV_CONTENT_NT_LD(v) ((N_VectorContent_NrnThreadLD) (v->content))
146 
147 #define NV_LENGTH_NT_LD(v) (NV_CONTENT_NT_LD(v)->length)
148 
149 #define NV_NT_NT_LD(v) (NV_CONTENT_NT_LD(v)->nt)
150 
151 #define NV_OWN_DATA_NT_LD(v) (NV_CONTENT_NT_LD(v)->own_data)
152 
153 #define NV_DATA_NT_LD(v) (NV_CONTENT_NT_LD(v)->data)
154 
155 #define NV_SUBVEC_NT_LD(v, i) (NV_CONTENT_NT_LD(v)->data[i])
156 
157 #define NV_Ith_NT_LD(v, i) (NV_DATA_NT_LD(v)[i]) /* wrong but not needed */
158 
159 /*
160  * -----------------------------------------------------------------
161  * PART III: functions exported by nvector_nrnthread
162  *
163  * CONSTRUCTORS:
164  * N_VNew_NrnThreadLD
165  * N_VNewEmpty_NrnThreadLD
166  * N_VClone_NrnThreadLD
167  * N_VCloneEmpty_NrnThreadLD
168  * N_VMake_NrnThreadLD
169  * N_VNewVectorArray_NrnThreadLD
170  * N_VNewVectorArrayEmpty_NrnThreadLD
171  * DESTRUCTORS:
172  * N_VDestroy_NrnThreadLD
173  * N_VDestroyVectorArray_NrnThreadLD
174  * -----------------------------------------------------------------
175  */
176 
177 /*
178  * -----------------------------------------------------------------
179  * Function : N_VNew_NrnThreadLD
180  * -----------------------------------------------------------------
181  * This function creates and allocates memory for a nrnthread vector.
182  * -----------------------------------------------------------------
183  */
184 
185 N_Vector N_VNew_NrnThreadLD(long int vec_length, int nthread, long int* sizes);
186 
187 /*
188  * -----------------------------------------------------------------
189  * Function : N_VNewEmpty_NrnThreadLD
190  * -----------------------------------------------------------------
191  * This function creates a new nrnthread N_Vector with an empty (NULL)
192  * data array.
193  * -----------------------------------------------------------------
194  */
195 
196 N_Vector N_VNewEmpty_NrnThreadLD(long int vec_length, int nthread, long int* sizes);
197 
198 /*
199  * -----------------------------------------------------------------
200  * Function : N_VCloneEmpty_NrnThreadLD
201  * -----------------------------------------------------------------
202  * This function creates a new nrnthread N_Vector with an empty (NULL)
203  * data array.
204  * -----------------------------------------------------------------
205  */
206 
207 N_Vector N_VCloneEmpty_NrnThreadLD(N_Vector w);
208 
209 /*
210  * -----------------------------------------------------------------
211  * Function : N_VMake_NrnThreadLD
212  * -----------------------------------------------------------------
213  * This function creates and allocates memory for a nrnthread vector
214  * with a user-supplied data array.
215  * -----------------------------------------------------------------
216  */
217 
218 /*not implemented*/
219 N_Vector N_VMake_NrnThreadLD(long int vec_length, realtype* v_data);
220 
221 /*
222  * -----------------------------------------------------------------
223  * Function : N_VNewVectorArray_NrnThreadLD
224  * -----------------------------------------------------------------
225  * This function creates an array of 'count' nrnthread vectors. This
226  * array of N_Vectors can be freed using N_VDestroyVectorArray
227  * (defined by the generic NVECTOR module).
228  * -----------------------------------------------------------------
229  */
230 
231 N_Vector* N_VNewVectorArray_NrnThreadLD(int count,
232  long int vec_length,
233  int nthread,
234  long int* sizes);
235 
236 /*
237  * -----------------------------------------------------------------
238  * Function : N_VNewVectorArrayEmpty_NrnThreadLD
239  * -----------------------------------------------------------------
240  * This function creates an array of 'count' nrnthread vectors each
241  * with an empty (NULL) data array.
242  * -----------------------------------------------------------------
243  */
244 
245 N_Vector* N_VNewVectorArrayEmpty_NrnThreadLD(int count,
246  long int vec_length,
247  int nthread,
248  long int* sizes);
249 
250 /*
251  * -----------------------------------------------------------------
252  * Function : N_VDestroyVectorArray_NrnThreadLD
253  * -----------------------------------------------------------------
254  * This function frees an array of N_Vector created with
255  * N_VNewVectorArray_NrnThreadLD.
256  * -----------------------------------------------------------------
257  */
258 
259 void N_VDestroyVectorArray_NrnThreadLD(N_Vector* vs, int count);
260 
261 /*
262  * -----------------------------------------------------------------
263  * Function : N_VPrint_NrnThreadLD
264  * -----------------------------------------------------------------
265  * This function prints the content of a nrnthread vector to stdout.
266  * -----------------------------------------------------------------
267  */
268 
269 void N_VPrint_NrnThreadLD(N_Vector v);
270 
271 /*
272  * -----------------------------------------------------------------
273  * nrnthread implementations of various useful vector operations
274  * -----------------------------------------------------------------
275  */
276 
277 N_Vector N_VClone_NrnThreadLD(N_Vector w);
278 void N_VDestroy_NrnThreadLD(N_Vector v);
279 void N_VSpace_NrnThreadLD(N_Vector v, long int* lrw, long int* liw);
280 realtype* N_VGetArrayPointer_NrnThreadLD(N_Vector v);
281 void N_VSetArrayPointer_NrnThreadLD(realtype* v_data, N_Vector v);
282 void N_VLinearSum_NrnThreadLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
283 void N_VConst_NrnThreadLD(realtype c, N_Vector z);
284 void N_VProd_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z);
285 void N_VDiv_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z);
286 void N_VScale_NrnThreadLD(realtype c, N_Vector x, N_Vector z);
287 void N_VAbs_NrnThreadLD(N_Vector x, N_Vector z);
288 void N_VInv_NrnThreadLD(N_Vector x, N_Vector z);
289 void N_VAddConst_NrnThreadLD(N_Vector x, realtype b, N_Vector z);
290 realtype N_VDotProd_NrnThreadLD(N_Vector x, N_Vector y);
291 realtype N_VMaxNorm_NrnThreadLD(N_Vector x);
292 realtype N_VWrmsNorm_NrnThreadLD(N_Vector x, N_Vector w);
293 realtype N_VWrmsNormMask_NrnThreadLD(N_Vector x, N_Vector w, N_Vector id);
294 realtype N_VMin_NrnThreadLD(N_Vector x);
295 realtype N_VWL2Norm_NrnThreadLD(N_Vector x, N_Vector w);
296 realtype N_VL1Norm_NrnThreadLD(N_Vector x);
297 void N_VCompare_NrnThreadLD(realtype c, N_Vector x, N_Vector z);
298 booleantype N_VInvTest_NrnThreadLD(N_Vector x, N_Vector z);
299 booleantype N_VConstrMask_NrnThreadLD(N_Vector c, N_Vector x, N_Vector m);
300 realtype N_VMinQuotient_NrnThreadLD(N_Vector num, N_Vector denom);
301 
302 
303 #endif
#define c
#define v
Definition: md1redef.h:4
realtype N_VDotProd_NrnThreadLD(N_Vector x, N_Vector y)
N_Vector N_VNewEmpty_NrnThreadLD(long int vec_length, int nthread, long int *sizes)
void N_VInv_NrnThreadLD(N_Vector x, N_Vector z)
N_Vector * N_VNewVectorArray_NrnThreadLD(int count, long int vec_length, int nthread, long int *sizes)
booleantype N_VConstrMask_NrnThreadLD(N_Vector c, N_Vector x, N_Vector m)
realtype N_VL1Norm_NrnThreadLD(N_Vector x)
N_Vector N_VCloneEmpty_NrnThreadLD(N_Vector w)
void N_VOneMask_Serial(N_Vector x)
N_Vector N_VMake_NrnThreadLD(long int vec_length, realtype *v_data)
realtype N_VWL2Norm_NrnThreadLD(N_Vector x, N_Vector w)
void N_VAbs_NrnThreadLD(N_Vector x, N_Vector z)
N_Vector N_VClone_NrnThreadLD(N_Vector w)
realtype N_VMin_NrnThreadLD(N_Vector x)
N_Vector * N_VNewVectorArrayEmpty_NrnThreadLD(int count, long int vec_length, int nthread, long int *sizes)
void N_VSetArrayPointer_NrnThreadLD(realtype *v_data, N_Vector v)
void N_VDiv_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z)
void N_VConst_NrnThreadLD(realtype c, N_Vector z)
void N_VCompare_NrnThreadLD(realtype c, N_Vector x, N_Vector z)
void N_VDestroyVectorArray_NrnThreadLD(N_Vector *vs, int count)
realtype N_VWrmsNormMask_NrnThreadLD(N_Vector x, N_Vector w, N_Vector id)
void N_VPrint_NrnThreadLD(N_Vector v)
void N_VLinearSum_NrnThreadLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
booleantype N_VInvTest_NrnThreadLD(N_Vector x, N_Vector z)
realtype N_VMinQuotient_NrnThreadLD(N_Vector num, N_Vector denom)
struct _N_VectorContent_NrnThreadLD * N_VectorContent_NrnThreadLD
void N_VProd_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z)
realtype N_VMaxNorm_NrnThreadLD(N_Vector x)
realtype N_VWrmsNorm_NrnThreadLD(N_Vector x, N_Vector w)
void N_VScale_NrnThreadLD(realtype c, N_Vector x, N_Vector z)
realtype * N_VGetArrayPointer_NrnThreadLD(N_Vector v)
N_Vector N_VNew_NrnThreadLD(long int vec_length, int nthread, long int *sizes)
void N_VAddConst_NrnThreadLD(N_Vector x, realtype b, N_Vector z)
void N_VDestroy_NrnThreadLD(N_Vector v)
void N_VSpace_NrnThreadLD(N_Vector v, long int *lrw, long int *liw)