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 #pragma once
63 
64 #include "nvector.h"
65 #include "sundialstypes.h"
66 extern "C" {
67 extern void N_VOneMask_Serial(N_Vector x);
68 }
69 
70 /*
71  * -----------------------------------------------------------------
72  * PART I: NRNTHREAD implementation of N_Vector
73  * -----------------------------------------------------------------
74  */
75 
76 /* nrnthread implementation of the N_Vector 'content' structure
77  contains the length of the vector, nthread, and a pointer to
78  nthread N_Vector (serial)
79 */
80 
82  long int length;
83  int nt; /* number of threads */
84  booleantype own_data;
85  N_Vector* data; /* nt of them (N_Vector_Serial) */
86 };
87 
89 
90 /* Note: documentation below may not be completely transformed from the
91  N_Vector_Serial case
92 */
93 
94 /*
95  * -----------------------------------------------------------------
96  * PART II: macros NV_CONTENT_S, NV_DATA_S, NV_OWN_DATA_S,
97  * NV_LENGTH_S, and NV_Ith_S
98  * -----------------------------------------------------------------
99  * In the descriptions below, the following user declarations
100  * are assumed:
101  *
102  * N_Vector v;
103  * long int i;
104  *
105  * (1) NV_CONTENT_NT_LD
106  *
107  * This routines gives access to the contents of the nrnthread
108  * vector N_Vector.
109  *
110  * The assignment v_cont = NV_CONTENT_NT_LD(v) sets v_cont to be
111  * a pointer to the nrnthread N_Vector content structure.
112  *
113  * (2) NV_SUBVEC_NT_LD and NV_LENGTH_NT_LD
114  *
115  * These routines give access to the individual parts of
116  * the content structure of a nrnthread N_Vector.
117  *
118  * The assignment v_data = NV_SUBVEC_NT_LD(v, i) sets v_data to be
119  * a pointer to the ith N_Vector of v. The assignment
120  * NV_SUBVEC_NT_LD(v, i) = data_V sets the ith component N_Vector of v to
121  * be data_v by storing the pointer data_v.
122  *
123  * The assignment v_llen = NV_SIZE_NT_LD(v,i) sets v_llen to be
124  * the length of the ith component of v. The call NV_LENGTH_NT_LD(v) = len_v sets
125  * the length of v to be len_v.
126  *
127  * (3) NV_Ith_NT_LD
128  *
129  * In the following description, the components of an
130  * N_Vector are numbered 0..n-1, where n is the length of v.
131  *
132  * The assignment r = NV_Ith_S(v,i) sets r to be the value of
133  * the ith component of v. The assignment NV_Ith_S(v,i) = r
134  * sets the value of the ith component of v to be r.
135  *
136  * Note: When looping over the components of an N_Vector v, it is
137  * more efficient to first obtain the component array via
138  * v_data = NV_DATA_S(v) and then access v_data[i] within the
139  * loop than it is to use NV_Ith_S(v,i) within the loop.
140  * -----------------------------------------------------------------
141  */
142 
143 #define NV_CONTENT_NT_LD(v) ((N_VectorContent_NrnThreadLD) (v->content))
144 
145 #define NV_LENGTH_NT_LD(v) (NV_CONTENT_NT_LD(v)->length)
146 
147 #define NV_NT_NT_LD(v) (NV_CONTENT_NT_LD(v)->nt)
148 
149 #define NV_OWN_DATA_NT_LD(v) (NV_CONTENT_NT_LD(v)->own_data)
150 
151 #define NV_DATA_NT_LD(v) (NV_CONTENT_NT_LD(v)->data)
152 
153 #define NV_SUBVEC_NT_LD(v, i) (NV_CONTENT_NT_LD(v)->data[i])
154 
155 #define NV_Ith_NT_LD(v, i) (NV_DATA_NT_LD(v)[i]) /* wrong but not needed */
156 
157 /*
158  * -----------------------------------------------------------------
159  * PART III: functions exported by nvector_nrnthread
160  *
161  * CONSTRUCTORS:
162  * N_VNew_NrnThreadLD
163  * N_VNewEmpty_NrnThreadLD
164  * N_VClone_NrnThreadLD
165  * N_VCloneEmpty_NrnThreadLD
166  * N_VMake_NrnThreadLD
167  * N_VNewVectorArray_NrnThreadLD
168  * N_VNewVectorArrayEmpty_NrnThreadLD
169  * DESTRUCTORS:
170  * N_VDestroy_NrnThreadLD
171  * N_VDestroyVectorArray_NrnThreadLD
172  * -----------------------------------------------------------------
173  */
174 
175 /*
176  * -----------------------------------------------------------------
177  * Function : N_VNew_NrnThreadLD
178  * -----------------------------------------------------------------
179  * This function creates and allocates memory for a nrnthread vector.
180  * -----------------------------------------------------------------
181  */
182 
183 N_Vector N_VNew_NrnThreadLD(long int vec_length, int nthread, long int* sizes);
184 
185 /*
186  * -----------------------------------------------------------------
187  * Function : N_VNewEmpty_NrnThreadLD
188  * -----------------------------------------------------------------
189  * This function creates a new nrnthread N_Vector with an empty (NULL)
190  * data array.
191  * -----------------------------------------------------------------
192  */
193 
194 N_Vector N_VNewEmpty_NrnThreadLD(long int vec_length, int nthread, long int* sizes);
195 
196 /*
197  * -----------------------------------------------------------------
198  * Function : N_VCloneEmpty_NrnThreadLD
199  * -----------------------------------------------------------------
200  * This function creates a new nrnthread N_Vector with an empty (NULL)
201  * data array.
202  * -----------------------------------------------------------------
203  */
204 
205 N_Vector N_VCloneEmpty_NrnThreadLD(N_Vector w);
206 
207 /*
208  * -----------------------------------------------------------------
209  * Function : N_VMake_NrnThreadLD
210  * -----------------------------------------------------------------
211  * This function creates and allocates memory for a nrnthread vector
212  * with a user-supplied data array.
213  * -----------------------------------------------------------------
214  */
215 
216 /*not implemented*/
217 N_Vector N_VMake_NrnThreadLD(long int vec_length, realtype* v_data);
218 
219 /*
220  * -----------------------------------------------------------------
221  * Function : N_VNewVectorArray_NrnThreadLD
222  * -----------------------------------------------------------------
223  * This function creates an array of 'count' nrnthread vectors. This
224  * array of N_Vectors can be freed using N_VDestroyVectorArray
225  * (defined by the generic NVECTOR module).
226  * -----------------------------------------------------------------
227  */
228 
229 N_Vector* N_VNewVectorArray_NrnThreadLD(int count,
230  long int vec_length,
231  int nthread,
232  long int* sizes);
233 
234 /*
235  * -----------------------------------------------------------------
236  * Function : N_VNewVectorArrayEmpty_NrnThreadLD
237  * -----------------------------------------------------------------
238  * This function creates an array of 'count' nrnthread vectors each
239  * with an empty (NULL) data array.
240  * -----------------------------------------------------------------
241  */
242 
243 N_Vector* N_VNewVectorArrayEmpty_NrnThreadLD(int count,
244  long int vec_length,
245  int nthread,
246  long int* sizes);
247 
248 /*
249  * -----------------------------------------------------------------
250  * Function : N_VDestroyVectorArray_NrnThreadLD
251  * -----------------------------------------------------------------
252  * This function frees an array of N_Vector created with
253  * N_VNewVectorArray_NrnThreadLD.
254  * -----------------------------------------------------------------
255  */
256 
257 void N_VDestroyVectorArray_NrnThreadLD(N_Vector* vs, int count);
258 
259 /*
260  * -----------------------------------------------------------------
261  * Function : N_VPrint_NrnThreadLD
262  * -----------------------------------------------------------------
263  * This function prints the content of a nrnthread vector to stdout.
264  * -----------------------------------------------------------------
265  */
266 
267 void N_VPrint_NrnThreadLD(N_Vector v);
268 
269 /*
270  * -----------------------------------------------------------------
271  * nrnthread implementations of various useful vector operations
272  * -----------------------------------------------------------------
273  */
274 
275 N_Vector N_VClone_NrnThreadLD(N_Vector w);
276 void N_VDestroy_NrnThreadLD(N_Vector v);
277 void N_VSpace_NrnThreadLD(N_Vector v, long int* lrw, long int* liw);
278 realtype* N_VGetArrayPointer_NrnThreadLD(N_Vector v);
279 void N_VSetArrayPointer_NrnThreadLD(realtype* v_data, N_Vector v);
280 void N_VLinearSum_NrnThreadLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
281 void N_VConst_NrnThreadLD(realtype c, N_Vector z);
282 void N_VProd_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z);
283 void N_VDiv_NrnThreadLD(N_Vector x, N_Vector y, N_Vector z);
284 void N_VScale_NrnThreadLD(realtype c, N_Vector x, N_Vector z);
285 void N_VAbs_NrnThreadLD(N_Vector x, N_Vector z);
286 void N_VInv_NrnThreadLD(N_Vector x, N_Vector z);
287 void N_VAddConst_NrnThreadLD(N_Vector x, realtype b, N_Vector z);
288 realtype N_VDotProd_NrnThreadLD(N_Vector x, N_Vector y);
289 realtype N_VMaxNorm_NrnThreadLD(N_Vector x);
290 realtype N_VWrmsNorm_NrnThreadLD(N_Vector x, N_Vector w);
291 realtype N_VWrmsNormMask_NrnThreadLD(N_Vector x, N_Vector w, N_Vector id);
292 realtype N_VMin_NrnThreadLD(N_Vector x);
293 realtype N_VWL2Norm_NrnThreadLD(N_Vector x, N_Vector w);
294 realtype N_VL1Norm_NrnThreadLD(N_Vector x);
295 void N_VCompare_NrnThreadLD(realtype c, N_Vector x, N_Vector z);
296 booleantype N_VInvTest_NrnThreadLD(N_Vector x, N_Vector z);
297 booleantype N_VConstrMask_NrnThreadLD(N_Vector c, N_Vector x, N_Vector m);
298 realtype N_VMinQuotient_NrnThreadLD(N_Vector num, N_Vector denom);
#define v
Definition: md1redef.h:11
static int c
Definition: hoc.cpp:169
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)