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 #pragma once
64 
65 #include "nvector.h"
66 #include "sundialstypes.h"
67 
68 /*
69  * -----------------------------------------------------------------
70  * PART I: SERIAL implementation of N_Vector
71  * -----------------------------------------------------------------
72  */
73 
74 /* serial implementation of the N_Vector 'content' structure
75  contains the length of the vector, a pointer to an array
76  of realtype components, and a flag indicating ownership of
77  the data */
78 
80  long int length;
81  booleantype own_data;
82  realtype* data;
83 };
84 
86 
87 /*
88  * -----------------------------------------------------------------
89  * PART II: macros NV_CONTENT_S_LD, NV_DATA_S_LD, NV_OWN_DATA_S_LD,
90  * NV_LENGTH_S_LD, and NV_Ith_S_LD
91  * -----------------------------------------------------------------
92  * In the descriptions below, the following user declarations
93  * are assumed:
94  *
95  * N_Vector v;
96  * long int i;
97  *
98  * (1) NV_CONTENT_S_LD
99  *
100  * This routines gives access to the contents of the serial
101  * vector N_Vector.
102  *
103  * The assignment v_cont = NV_CONTENT_S_LD(v) sets v_cont to be
104  * a pointer to the serial N_Vector content structure.
105  *
106  * (2) NV_DATA_S_LD NV_OWN_DATA_S_LD and NV_LENGTH_S_LD
107  *
108  * These routines give access to the individual parts of
109  * the content structure of a serial N_Vector.
110  *
111  * The assignment v_data = NV_DATA_S_LD(v) sets v_data to be
112  * a pointer to the first component of v. The assignment
113  * NV_DATA_S_LD(v) = data_V sets the component array of v to
114  * be data_v by storing the pointer data_v.
115  *
116  * The assignment v_len = NV_LENGTH_S_LD(v) sets v_len to be
117  * the length of v. The call NV_LENGTH_S_LD(v) = len_v sets
118  * the length of v to be len_v.
119  *
120  * (3) NV_Ith_S_LD
121  *
122  * In the following description, the components of an
123  * N_Vector are numbered 0..n-1, where n is the length of v.
124  *
125  * The assignment r = NV_Ith_S_LD(v,i) sets r to be the value of
126  * the ith component of v. The assignment NV_Ith_S_LD(v,i) = r
127  * sets the value of the ith component of v to be r.
128  *
129  * Note: When looping over the components of an N_Vector v, it is
130  * more efficient to first obtain the component array via
131  * v_data = NV_DATA_S_LD(v) and then access v_data[i] within the
132  * loop than it is to use NV_Ith_S_LD(v,i) within the loop.
133  * -----------------------------------------------------------------
134  */
135 
136 #define NV_CONTENT_S_LD(v) ((N_VectorContent_NrnSerialLD) (v->content))
137 
138 #define NV_LENGTH_S_LD(v) (NV_CONTENT_S_LD(v)->length)
139 
140 #define NV_OWN_DATA_S_LD(v) (NV_CONTENT_S_LD(v)->own_data)
141 
142 #define NV_DATA_S_LD(v) (NV_CONTENT_S_LD(v)->data)
143 
144 #define NV_Ith_S_LD(v, i) (NV_DATA_S_LD(v)[i])
145 
146 /*
147  * -----------------------------------------------------------------
148  * PART III: functions exported by nvector_serial
149  *
150  * CONSTRUCTORS:
151  * N_VNew_NrnSerialLD
152  * N_VNewEmpty_NrnSerialLD
153  * N_VClone_NrnSerialLD
154  * N_VCloneEmpty_NrnSerialLD
155  * N_VMake_NrnSerialLD
156  * N_VNewVectorArray_NrnSerialLD
157  * N_VNewVectorArrayEmpty_NrnSerialLD
158  * DESTRUCTORS:
159  * N_VDestroy_NrnSerialLD
160  * N_VDestroyVectorArray_NrnSerialLD
161  * -----------------------------------------------------------------
162  */
163 
164 /*
165  * -----------------------------------------------------------------
166  * Function : N_VNew_NrnSerialLD
167  * -----------------------------------------------------------------
168  * This function creates and allocates memory for a serial vector.
169  * -----------------------------------------------------------------
170  */
171 
172 N_Vector N_VNew_NrnSerialLD(long int vec_length);
173 
174 /*
175  * -----------------------------------------------------------------
176  * Function : N_VNewEmpty_NrnSerialLD
177  * -----------------------------------------------------------------
178  * This function creates a new serial N_Vector with an empty (NULL)
179  * data array.
180  * -----------------------------------------------------------------
181  */
182 
183 N_Vector N_VNewEmpty_NrnSerialLD(long int vec_length);
184 
185 /*
186  * -----------------------------------------------------------------
187  * Function : N_VCloneEmpty_NrnSerialLD
188  * -----------------------------------------------------------------
189  * This function creates a new serial N_Vector with an empty (NULL)
190  * data array.
191  * -----------------------------------------------------------------
192  */
193 
194 N_Vector N_VCloneEmpty_NrnSerialLD(N_Vector w);
195 
196 /*
197  * -----------------------------------------------------------------
198  * Function : N_VMake_NrnSerialLD
199  * -----------------------------------------------------------------
200  * This function creates and allocates memory for a serial vector
201  * with a user-supplied data array.
202  * -----------------------------------------------------------------
203  */
204 
205 N_Vector N_VMake_NrnSerialLD(long int vec_length, realtype* v_data);
206 
207 /*
208  * -----------------------------------------------------------------
209  * Function : N_VNewVectorArray_NrnSerialLD
210  * -----------------------------------------------------------------
211  * This function creates an array of 'count' serial vectors. This
212  * array of N_Vectors can be freed using N_VDestroyVectorArray
213  * (defined by the generic NVECTOR module).
214  * -----------------------------------------------------------------
215  */
216 
217 N_Vector* N_VNewVectorArray_NrnSerialLD(int count, long int vec_length);
218 
219 /*
220  * -----------------------------------------------------------------
221  * Function : N_VNewVectorArrayEmpty_NrnSerialLD
222  * -----------------------------------------------------------------
223  * This function creates an array of 'count' serial vectors each
224  * with an empty (NULL) data array.
225  * -----------------------------------------------------------------
226  */
227 
228 N_Vector* N_VNewVectorArrayEmpty_NrnSerialLD(int count, long int vec_length);
229 
230 /*
231  * -----------------------------------------------------------------
232  * Function : N_VDestroyVectorArray_NrnSerialLD
233  * -----------------------------------------------------------------
234  * This function frees an array of N_Vector created with
235  * N_VNewVectorArray_NrnSerialLD.
236  * -----------------------------------------------------------------
237  */
238 
239 void N_VDestroyVectorArray_NrnSerialLD(N_Vector* vs, int count);
240 
241 /*
242  * -----------------------------------------------------------------
243  * Function : N_VPrint_NrnSerialLD
244  * -----------------------------------------------------------------
245  * This function prints the content of a serial vector to stdout.
246  * -----------------------------------------------------------------
247  */
248 
249 void N_VPrint_NrnSerialLD(N_Vector v);
250 
251 /*
252  * -----------------------------------------------------------------
253  * serial implementations of various useful vector operations
254  * -----------------------------------------------------------------
255  */
256 
257 N_Vector N_VClone_NrnSerialLD(N_Vector w);
258 void N_VDestroy_NrnSerialLD(N_Vector v);
259 void N_VSpace_NrnSerialLD(N_Vector v, long int* lrw, long int* liw);
260 realtype* N_VGetArrayPointer_NrnSerialLD(N_Vector v);
261 void N_VSetArrayPointer_NrnSerialLD(realtype* v_data, N_Vector v);
262 void N_VLinearSum_NrnSerialLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
263 void N_VConst_NrnSerialLD(realtype c, N_Vector z);
264 void N_VProd_NrnSerialLD(N_Vector x, N_Vector y, N_Vector z);
265 void N_VDiv_NrnSerialLD(N_Vector x, N_Vector y, N_Vector z);
266 void N_VScale_NrnSerialLD(realtype c, N_Vector x, N_Vector z);
267 void N_VAbs_NrnSerialLD(N_Vector x, N_Vector z);
268 void N_VInv_NrnSerialLD(N_Vector x, N_Vector z);
269 void N_VAddConst_NrnSerialLD(N_Vector x, realtype b, N_Vector z);
270 realtype N_VDotProd_NrnSerialLD(N_Vector x, N_Vector y);
271 realtype N_VMaxNorm_NrnSerialLD(N_Vector x);
272 realtype N_VWrmsNorm_NrnSerialLD(N_Vector x, N_Vector w);
273 realtype N_VWrmsNormMask_NrnSerialLD(N_Vector x, N_Vector w, N_Vector id);
274 realtype N_VMin_NrnSerialLD(N_Vector x);
275 realtype N_VWL2Norm_NrnSerialLD(N_Vector x, N_Vector w);
276 realtype N_VL1Norm_NrnSerialLD(N_Vector x);
277 void N_VCompare_NrnSerialLD(realtype c, N_Vector x, N_Vector z);
278 booleantype N_VInvTest_NrnSerialLD(N_Vector x, N_Vector z);
279 booleantype N_VConstrMask_NrnSerialLD(N_Vector c, N_Vector x, N_Vector m);
280 realtype N_VMinQuotient_NrnSerialLD(N_Vector num, N_Vector denom);
#define v
Definition: md1redef.h:11
static int c
Definition: hoc.cpp:169
void N_VCompare_NrnSerialLD(realtype c, N_Vector x, N_Vector z)
N_Vector N_VCloneEmpty_NrnSerialLD(N_Vector w)
realtype N_VWL2Norm_NrnSerialLD(N_Vector x, N_Vector w)
void N_VScale_NrnSerialLD(realtype c, N_Vector x, N_Vector z)
void N_VSpace_NrnSerialLD(N_Vector v, long int *lrw, long int *liw)
void N_VLinearSum_NrnSerialLD(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z)
struct _N_VectorContent_NrnSerialLD * N_VectorContent_NrnSerialLD
realtype N_VWrmsNormMask_NrnSerialLD(N_Vector x, N_Vector w, N_Vector id)
booleantype N_VConstrMask_NrnSerialLD(N_Vector c, N_Vector x, N_Vector m)
realtype N_VDotProd_NrnSerialLD(N_Vector x, N_Vector y)
N_Vector N_VNewEmpty_NrnSerialLD(long int vec_length)
N_Vector N_VClone_NrnSerialLD(N_Vector w)
booleantype N_VInvTest_NrnSerialLD(N_Vector x, N_Vector z)
realtype N_VWrmsNorm_NrnSerialLD(N_Vector x, N_Vector w)
void N_VDiv_NrnSerialLD(N_Vector x, N_Vector y, N_Vector z)
void N_VPrint_NrnSerialLD(N_Vector v)
void N_VDestroyVectorArray_NrnSerialLD(N_Vector *vs, int count)
realtype N_VMaxNorm_NrnSerialLD(N_Vector x)
N_Vector N_VMake_NrnSerialLD(long int vec_length, realtype *v_data)
realtype N_VL1Norm_NrnSerialLD(N_Vector x)
realtype N_VMin_NrnSerialLD(N_Vector x)
N_Vector * N_VNewVectorArray_NrnSerialLD(int count, long int vec_length)
realtype * N_VGetArrayPointer_NrnSerialLD(N_Vector v)
void N_VAbs_NrnSerialLD(N_Vector x, N_Vector z)
void N_VSetArrayPointer_NrnSerialLD(realtype *v_data, 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_VDestroy_NrnSerialLD(N_Vector v)
void N_VInv_NrnSerialLD(N_Vector x, N_Vector z)
void N_VAddConst_NrnSerialLD(N_Vector x, realtype b, N_Vector z)
realtype N_VMinQuotient_NrnSerialLD(N_Vector num, N_Vector denom)
void N_VProd_NrnSerialLD(N_Vector x, N_Vector y, N_Vector z)
void N_VConst_NrnSerialLD(realtype c, N_Vector z)