NEURON
nvector_nrnthread.h
Go to the documentation of this file.
1 /*
2 * N_Vector_NrnThread 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 /*
9  * -----------------------------------------------------------------
10  * $Revision: 855 $
11  * $Date: 2005-02-09 18:15:46 -0500 (Wed, 09 Feb 2005) $
12  * -----------------------------------------------------------------
13  * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
14  * and Aaron Collier @ LLNL
15  * -----------------------------------------------------------------
16  * Copyright (c) 2002, The Regents of the University of California.
17  * Produced at the Lawrence Livermore National Laboratory.
18  * All rights reserved.
19  * For details, see sundials/shared/LICENSE.
20  * -----------------------------------------------------------------
21  * This is the header file for the nrnthread implementation of the
22  * NVECTOR module.
23  *
24  * Part I contains declarations specific to the nrnthread
25  * implementation of the supplied NVECTOR module.
26  *
27  * Part II defines accessor macros that allow the user to
28  * efficiently use the type N_Vector without making explicit
29  * references to the underlying data structure.
30  *
31  * Part III contains the prototype for the constructor N_VNew_NrnThread
32  * as well as implementation-specific prototypes for various useful
33  * vector operations.
34  *
35  * Notes:
36  *
37  * - The definition of the generic N_Vector structure can be found
38  * in the header file shared/include/nvector.h.
39  *
40  * - The definition of the type realtype can be found in the
41  * header file shared/include/sundialstypes.h, and it may be
42  * changed (at the configuration stage) according to the user's
43  * needs. The sundialstypes.h file also contains the definition
44  * for the type booleantype.
45  *
46  * - N_Vector arguments to arithmetic vector operations need not
47  * be distinct. For example, the following call:
48  *
49  * N_VLinearSum_NrnThread(a,x,b,y,y);
50  *
51  * (which stores the result of the operation a*x+b*y in y)
52  * is legal.
53  * -----------------------------------------------------------------
54  */
55 
56 #ifndef _NVECTOR_NRNTHREAD_H
57 #define _NVECTOR_NRNTHREAD_H
58 
59 
60 #include "nvector.h"
61 #include "sundialstypes.h"
62 extern "C" {
63 extern void N_VOneMask_Serial(N_Vector x);
64 }
65 
66 /*
67  * -----------------------------------------------------------------
68  * PART I: NRNTHREAD implementation of N_Vector
69  * -----------------------------------------------------------------
70  */
71 
72 /* nrnthread implementation of the N_Vector 'content' structure
73  contains the length of the vector, nthread, and a pointer to
74  nthread N_Vector (serial)
75 */
76 
78  long int length;
79  int nt; /* number of threads */
80  booleantype own_data;
81  N_Vector *data; /* nt of them (N_Vector_Serial) */
82 };
83 
85 
86 /* Note: documentation below may not be completely transformed from the
87  N_Vector_Serial case
88 */
89 
90 /*
91  * -----------------------------------------------------------------
92  * PART II: macros NV_CONTENT_S, NV_DATA_S, NV_OWN_DATA_S,
93  * NV_LENGTH_S, and NV_Ith_S
94  * -----------------------------------------------------------------
95  * In the descriptions below, the following user declarations
96  * are assumed:
97  *
98  * N_Vector v;
99  * long int i;
100  *
101  * (1) NV_CONTENT_NT
102  *
103  * This routines gives access to the contents of the nrnthread
104  * vector N_Vector.
105  *
106  * The assignment v_cont = NV_CONTENT_NT(v) sets v_cont to be
107  * a pointer to the nrnthread N_Vector content structure.
108  *
109  * (2) NV_SUBVEC_NT and NV_LENGTH_NT
110  *
111  * These routines give access to the individual parts of
112  * the content structure of a nrnthread N_Vector.
113  *
114  * The assignment v_data = NV_SUBVEC_NT(v, i) sets v_data to be
115  * a pointer to the ith N_Vector of v. The assignment
116  * NV_SUBVEC_NT(v, i) = data_V sets the ith component N_Vector of v to
117  * be data_v by storing the pointer data_v.
118  *
119  * The assignment v_llen = NV_SIZE_NT(v,i) sets v_llen to be
120  * the length of the ith component of v. The call NV_LENGTH_NT(v) = len_v sets
121  * the length of v to be len_v.
122  *
123  * (3) NV_Ith_NT
124  *
125  * In the following description, the components of an
126  * N_Vector are numbered 0..n-1, where n is the length of v.
127  *
128  * The assignment r = NV_Ith_S(v,i) sets r to be the value of
129  * the ith component of v. The assignment NV_Ith_S(v,i) = r
130  * sets the value of the ith component of v to be r.
131  *
132  * Note: When looping over the components of an N_Vector v, it is
133  * more efficient to first obtain the component array via
134  * v_data = NV_DATA_S(v) and then access v_data[i] within the
135  * loop than it is to use NV_Ith_S(v,i) within the loop.
136  * -----------------------------------------------------------------
137  */
138 
139 #define NV_CONTENT_NT(v) ( (N_VectorContent_NrnThread)(v->content) )
140 
141 #define NV_LENGTH_NT(v) ( NV_CONTENT_NT(v)->length )
142 
143 #define NV_NT_NT(v) ( NV_CONTENT_NT(v)->nt )
144 
145 #define NV_OWN_DATA_NT(v) ( NV_CONTENT_NT(v)->own_data )
146 
147 #define NV_DATA_NT(v) ( NV_CONTENT_NT(v)->data )
148 
149 #define NV_SUBVEC_NT(v, i) ( NV_CONTENT_NT(v)->data[i] )
150 
151 #define NV_Ith_NT(v,i) ( NV_DATA_NT(v)[i] ) /* wrong but not needed */
152 
153 /*
154  * -----------------------------------------------------------------
155  * PART III: functions exported by nvector_nrnthread
156  *
157  * CONSTRUCTORS:
158  * N_VNew_NrnThread
159  * N_VNewEmpty_NrnThread
160  * N_VClone_NrnThread
161  * N_VCloneEmpty_NrnThread
162  * N_VMake_NrnThread
163  * N_VNewVectorArray_NrnThread
164  * N_VNewVectorArrayEmpty_NrnThread
165  * DESTRUCTORS:
166  * N_VDestroy_NrnThread
167  * N_VDestroyVectorArray_NrnThread
168  * -----------------------------------------------------------------
169  */
170 
171 /*
172  * -----------------------------------------------------------------
173  * Function : N_VNew_NrnThread
174  * -----------------------------------------------------------------
175  * This function creates and allocates memory for a nrnthread vector.
176  * -----------------------------------------------------------------
177  */
178 
179 N_Vector N_VNew_NrnThread(long int vec_length, int nthread, long int* sizes );
180 
181 /*
182  * -----------------------------------------------------------------
183  * Function : N_VNewEmpty_NrnThread
184  * -----------------------------------------------------------------
185  * This function creates a new nrnthread N_Vector with an empty (NULL)
186  * data array.
187  * -----------------------------------------------------------------
188  */
189 
190 N_Vector N_VNewEmpty_NrnThread(long int vec_length, int nthread, long int* sizes);
191 
192 /*
193  * -----------------------------------------------------------------
194  * Function : N_VCloneEmpty_NrnThread
195  * -----------------------------------------------------------------
196  * This function creates a new nrnthread N_Vector with an empty (NULL)
197  * data array.
198  * -----------------------------------------------------------------
199  */
200 
201 N_Vector N_VCloneEmpty_NrnThread(N_Vector w);
202 
203 /*
204  * -----------------------------------------------------------------
205  * Function : N_VMake_NrnThread
206  * -----------------------------------------------------------------
207  * This function creates and allocates memory for a nrnthread vector
208  * with a user-supplied data array.
209  * -----------------------------------------------------------------
210  */
211 
212 /*not implemented*/
213 N_Vector N_VMake_NrnThread(long int vec_length, realtype *v_data);
214 
215 /*
216  * -----------------------------------------------------------------
217  * Function : N_VNewVectorArray_NrnThread
218  * -----------------------------------------------------------------
219  * This function creates an array of 'count' nrnthread vectors. This
220  * array of N_Vectors can be freed using N_VDestroyVectorArray
221  * (defined by the generic NVECTOR module).
222  * -----------------------------------------------------------------
223  */
224 
225 N_Vector *N_VNewVectorArray_NrnThread(int count, long int vec_length,
226  int nthread, long int* sizes);
227 
228 /*
229  * -----------------------------------------------------------------
230  * Function : N_VNewVectorArrayEmpty_NrnThread
231  * -----------------------------------------------------------------
232  * This function creates an array of 'count' nrnthread vectors each
233  * with an empty (NULL) data array.
234  * -----------------------------------------------------------------
235  */
236 
237 N_Vector *N_VNewVectorArrayEmpty_NrnThread(int count, long int vec_length,
238  int nthread, long int* sizes);
239 
240 /*
241  * -----------------------------------------------------------------
242  * Function : N_VDestroyVectorArray_NrnThread
243  * -----------------------------------------------------------------
244  * This function frees an array of N_Vector created with
245  * N_VNewVectorArray_NrnThread.
246  * -----------------------------------------------------------------
247  */
248 
249 void N_VDestroyVectorArray_NrnThread(N_Vector *vs, int count);
250 
251 /*
252  * -----------------------------------------------------------------
253  * Function : N_VPrint_NrnThread
254  * -----------------------------------------------------------------
255  * This function prints the content of a nrnthread vector to stdout.
256  * -----------------------------------------------------------------
257  */
258 
259 void N_VPrint_NrnThread(N_Vector v);
260 
261 /*
262  * -----------------------------------------------------------------
263  * nrnthread implementations of various useful vector operations
264  * -----------------------------------------------------------------
265  */
266 
267 N_Vector N_VClone_NrnThread(N_Vector w);
268 void N_VDestroy_NrnThread(N_Vector v);
269 void N_VSpace_NrnThread(N_Vector v, long int *lrw, long int *liw);
270 realtype *N_VGetArrayPointer_NrnThread(N_Vector v);
271 void N_VSetArrayPointer_NrnThread(realtype *v_data, N_Vector v);
272 void N_VLinearSum_NrnThread(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
273 void N_VConst_NrnThread(realtype c, N_Vector z);
274 void N_VProd_NrnThread(N_Vector x, N_Vector y, N_Vector z);
275 void N_VDiv_NrnThread(N_Vector x, N_Vector y, N_Vector z);
276 void N_VScale_NrnThread(realtype c, N_Vector x, N_Vector z);
277 void N_VAbs_NrnThread(N_Vector x, N_Vector z);
278 void N_VInv_NrnThread(N_Vector x, N_Vector z);
279 void N_VAddConst_NrnThread(N_Vector x, realtype b, N_Vector z);
280 realtype N_VDotProd_NrnThread(N_Vector x, N_Vector y);
281 realtype N_VMaxNorm_NrnThread(N_Vector x);
282 realtype N_VWrmsNorm_NrnThread(N_Vector x, N_Vector w);
283 realtype N_VWrmsNormMask_NrnThread(N_Vector x, N_Vector w, N_Vector id);
284 realtype N_VMin_NrnThread(N_Vector x);
285 realtype N_VWL2Norm_NrnThread(N_Vector x, N_Vector w);
286 realtype N_VL1Norm_NrnThread(N_Vector x);
287 void N_VCompare_NrnThread(realtype c, N_Vector x, N_Vector z);
288 booleantype N_VInvTest_NrnThread(N_Vector x, N_Vector z);
289 booleantype N_VConstrMask_NrnThread(N_Vector c, N_Vector x, N_Vector m);
290 realtype N_VMinQuotient_NrnThread(N_Vector num, N_Vector denom);
291 
292 
293 #endif
realtype N_VMaxNorm_NrnThread(N_Vector x)
N_Vector N_VNewEmpty_NrnThread(long int vec_length, int nthread, long int *sizes)
realtype N_VMinQuotient_NrnThread(N_Vector num, N_Vector denom)
N_Vector N_VCloneEmpty_NrnThread(N_Vector w)
N_Vector N_VNew_NrnThread(long int vec_length, int nthread, long int *sizes)
N_Vector * N_VNewVectorArrayEmpty_NrnThread(int count, long int vec_length, int nthread, long int *sizes)
void N_VDiv_NrnThread(N_Vector x, N_Vector y, N_Vector z)
realtype N_VL1Norm_NrnThread(N_Vector x)
void N_VDestroyVectorArray_NrnThread(N_Vector *vs, int count)
#define v
Definition: md1redef.h:4
void N_VCompare_NrnThread(realtype c, N_Vector x, N_Vector z)
void N_VConst_NrnThread(realtype c, N_Vector z)
N_Vector N_VMake_NrnThread(long int vec_length, realtype *v_data)
void N_VProd_NrnThread(N_Vector x, N_Vector y, N_Vector z)
realtype N_VMin_NrnThread(N_Vector x)
void N_VInv_NrnThread(N_Vector x, N_Vector z)
N_Vector * N_VNewVectorArray_NrnThread(int count, long int vec_length, int nthread, long int *sizes)
booleantype N_VConstrMask_NrnThread(N_Vector c, N_Vector x, N_Vector m)
realtype N_VWL2Norm_NrnThread(N_Vector x, N_Vector w)
void N_VScale_NrnThread(realtype c, N_Vector x, N_Vector z)
void N_VPrint_NrnThread(N_Vector v)
void N_VAbs_NrnThread(N_Vector x, N_Vector z)
realtype N_VWrmsNorm_NrnThread(N_Vector x, N_Vector w)
void N_VOneMask_Serial(N_Vector x)
void N_VDestroy_NrnThread(N_Vector v)
void N_VLinearSum_NrnThread(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
#define c
N_Vector N_VClone_NrnThread(N_Vector w)
realtype N_VWrmsNormMask_NrnThread(N_Vector x, N_Vector w, N_Vector id)
realtype N_VDotProd_NrnThread(N_Vector x, N_Vector y)
booleantype N_VInvTest_NrnThread(N_Vector x, N_Vector z)
struct _N_VectorContent_NrnThread * N_VectorContent_NrnThread
void N_VSpace_NrnThread(N_Vector v, long int *lrw, long int *liw)
void N_VSetArrayPointer_NrnThread(realtype *v_data, N_Vector v)
void N_VAddConst_NrnThread(N_Vector x, realtype b, N_Vector z)
realtype * N_VGetArrayPointer_NrnThread(N_Vector v)