source: branches/2925_AutoDiffForDynamicalModels/HeuristicLab.Problems.DynamicalSystemsModelling/3.3/sundials/include/nvector/nvector_serial.h @ 16222

Last change on this file since 16222 was 16222, checked in by gkronber, 4 years ago

#2925:

  • added comments about parameter identification for differential equation models
  • added source code of cvodes library (part of sundials) which provides functionality to calculate gradients for the parameters of partial differential equation models efficiently using the 'adjoint state method'.
  • added compiled version of cvodes
File size: 10.8 KB
Line 
1/* -----------------------------------------------------------------
2 * Programmer(s): Scott D. Cohen, Alan C. Hindmarsh, Radu Serban,
3 *                and Aaron Collier @ LLNL
4 * -----------------------------------------------------------------
5 * LLNS Copyright Start
6 * Copyright (c) 2014, Lawrence Livermore National Security
7 * This work was performed under the auspices of the U.S. Department
8 * of Energy by Lawrence Livermore National Laboratory in part under
9 * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
10 * Produced at the Lawrence Livermore National Laboratory.
11 * All rights reserved.
12 * For details, see the LICENSE file.
13 * LLNS Copyright End
14 * -----------------------------------------------------------------
15 * This is the header file for the serial implementation of the
16 * NVECTOR module.
17 *
18 * Part I contains declarations specific to the serial
19 * implementation of the supplied NVECTOR module.
20 *
21 * Part II defines accessor macros that allow the user to
22 * efficiently use the type N_Vector without making explicit
23 * references to the underlying data structure.
24 *
25 * Part III contains the prototype for the constructor N_VNew_Serial
26 * as well as implementation-specific prototypes for various useful
27 * vector operations.
28 *
29 * Notes:
30 *
31 *   - The definition of the generic N_Vector structure can be found
32 *     in the header file sundials_nvector.h.
33 *
34 *   - The definition of the type 'realtype' can be found in the
35 *     header file sundials_types.h, and it may be changed (at the
36 *     configuration stage) according to the user's needs.
37 *     The sundials_types.h file also contains the definition
38 *     for the type 'booleantype'.
39 *
40 *   - N_Vector arguments to arithmetic vector operations need not
41 *     be distinct. For example, the following call:
42 *
43 *       N_VLinearSum_Serial(a,x,b,y,y);
44 *
45 *     (which stores the result of the operation a*x+b*y in y)
46 *     is legal.
47 * -----------------------------------------------------------------*/
48
49#ifndef _NVECTOR_SERIAL_H
50#define _NVECTOR_SERIAL_H
51
52#include <stdio.h>
53#include <sundials/sundials_nvector.h>
54
55#ifdef __cplusplus  /* wrapper to enable C++ usage */
56extern "C" {
57#endif
58
59/*
60 * -----------------------------------------------------------------
61 * PART I: SERIAL implementation of N_Vector
62 * -----------------------------------------------------------------
63 */
64
65/* serial implementation of the N_Vector 'content' structure
66   contains the length of the vector, a pointer to an array
67   of 'realtype' components, and a flag indicating ownership of
68   the data */
69
70struct _N_VectorContent_Serial {
71  sunindextype length;
72  booleantype own_data;
73  realtype *data;
74};
75
76typedef struct _N_VectorContent_Serial *N_VectorContent_Serial;
77
78/*
79 * -----------------------------------------------------------------
80 * PART II: macros NV_CONTENT_S, NV_DATA_S, NV_OWN_DATA_S,
81 *          NV_LENGTH_S, and NV_Ith_S
82 * -----------------------------------------------------------------
83 * In the descriptions below, the following user declarations
84 * are assumed:
85 *
86 * N_Vector v;
87 * sunindextype i;
88 *
89 * (1) NV_CONTENT_S
90 *
91 *     This routines gives access to the contents of the serial
92 *     vector N_Vector.
93 *
94 *     The assignment v_cont = NV_CONTENT_S(v) sets v_cont to be
95 *     a pointer to the serial N_Vector content structure.
96 *
97 * (2) NV_DATA_S NV_OWN_DATA_S and NV_LENGTH_S
98 *
99 *     These routines give access to the individual parts of
100 *     the content structure of a serial N_Vector.
101 *
102 *     The assignment v_data = NV_DATA_S(v) sets v_data to be
103 *     a pointer to the first component of v. The assignment
104 *     NV_DATA_S(v) = data_V sets the component array of v to
105 *     be data_v by storing the pointer data_v.
106 *
107 *     The assignment v_len = NV_LENGTH_S(v) sets v_len to be
108 *     the length of v. The call NV_LENGTH_S(v) = len_v sets
109 *     the length of v to be len_v.
110 *
111 * (3) NV_Ith_S
112 *
113 *     In the following description, the components of an
114 *     N_Vector are numbered 0..n-1, where n is the length of v.
115 *
116 *     The assignment r = NV_Ith_S(v,i) sets r to be the value of
117 *     the ith component of v. The assignment NV_Ith_S(v,i) = r
118 *     sets the value of the ith component of v to be r.
119 *
120 * Note: When looping over the components of an N_Vector v, it is
121 * more efficient to first obtain the component array via
122 * v_data = NV_DATA_S(v) and then access v_data[i] within the
123 * loop than it is to use NV_Ith_S(v,i) within the loop.
124 * -----------------------------------------------------------------
125 */
126
127#define NV_CONTENT_S(v)  ( (N_VectorContent_Serial)(v->content) )
128
129#define NV_LENGTH_S(v)   ( NV_CONTENT_S(v)->length )
130
131#define NV_OWN_DATA_S(v) ( NV_CONTENT_S(v)->own_data )
132
133#define NV_DATA_S(v)     ( NV_CONTENT_S(v)->data )
134
135#define NV_Ith_S(v,i)    ( NV_DATA_S(v)[i] )
136
137/*
138 * -----------------------------------------------------------------
139 * PART III: functions exported by nvector_serial
140 *
141 * CONSTRUCTORS:
142 *    N_VNew_Serial
143 *    N_VNewEmpty_Serial
144 *    N_VMake_Serial
145 *    N_VCloneVectorArray_Serial
146 *    N_VCloneVectorArrayEmpty_Serial
147 * DESTRUCTORS:
148 *    N_VDestroy_Serial
149 *    N_VDestroyVectorArray_Serial
150 * OTHER:
151 *    N_VGetLength_Serial
152 *    N_VPrint_Serial
153 *    N_VPrintFile_Serial
154 * -----------------------------------------------------------------
155 */
156
157/*
158 * -----------------------------------------------------------------
159 * Function : N_VNew_Serial
160 * -----------------------------------------------------------------
161 * This function creates and allocates memory for a serial vector.
162 * -----------------------------------------------------------------
163 */
164
165SUNDIALS_EXPORT N_Vector N_VNew_Serial(sunindextype vec_length);
166
167/*
168 * -----------------------------------------------------------------
169 * Function : N_VNewEmpty_Serial
170 * -----------------------------------------------------------------
171 * This function creates a new serial N_Vector with an empty (NULL)
172 * data array.
173 * -----------------------------------------------------------------
174 */
175
176SUNDIALS_EXPORT N_Vector N_VNewEmpty_Serial(sunindextype vec_length);
177
178/*
179 * -----------------------------------------------------------------
180 * Function : N_VMake_Serial
181 * -----------------------------------------------------------------
182 * This function creates and allocates memory for a serial vector
183 * with a user-supplied data array.
184 * -----------------------------------------------------------------
185 */
186
187SUNDIALS_EXPORT N_Vector N_VMake_Serial(sunindextype vec_length, realtype *v_data);
188
189/*
190 * -----------------------------------------------------------------
191 * Function : N_VCloneVectorArray_Serial
192 * -----------------------------------------------------------------
193 * This function creates an array of 'count' SERIAL vectors by
194 * cloning a given vector w.
195 * -----------------------------------------------------------------
196 */
197
198SUNDIALS_EXPORT N_Vector *N_VCloneVectorArray_Serial(int count, N_Vector w);
199
200/*
201 * -----------------------------------------------------------------
202 * Function : N_VCloneVectorArrayEmpty_Serial
203 * -----------------------------------------------------------------
204 * This function creates an array of 'count' SERIAL vectors each
205 * with an empty (NULL) data array by cloning w.
206 * -----------------------------------------------------------------
207 */
208
209SUNDIALS_EXPORT N_Vector *N_VCloneVectorArrayEmpty_Serial(int count, N_Vector w);
210
211/*
212 * -----------------------------------------------------------------
213 * Function : N_VDestroyVectorArray_Serial
214 * -----------------------------------------------------------------
215 * This function frees an array of SERIAL vectors created with
216 * N_VCloneVectorArray_Serial or N_VCloneVectorArrayEmpty_Serial.
217 * -----------------------------------------------------------------
218 */
219
220SUNDIALS_EXPORT void N_VDestroyVectorArray_Serial(N_Vector *vs, int count);
221
222/*
223 * -----------------------------------------------------------------
224 * Function : N_VGetLength_Serial
225 * -----------------------------------------------------------------
226 * This function returns number of vector elements.
227 * -----------------------------------------------------------------
228 */
229
230SUNDIALS_EXPORT sunindextype N_VGetLength_Serial(N_Vector v);
231
232/*
233 * -----------------------------------------------------------------
234 * Function : N_VPrint_Serial
235 * -----------------------------------------------------------------
236 * This function prints the content of a serial vector to stdout.
237 * -----------------------------------------------------------------
238 */
239
240SUNDIALS_EXPORT void N_VPrint_Serial(N_Vector v);
241
242/*
243 * -----------------------------------------------------------------
244 * Function : N_VPrintFile_Serial
245 * -----------------------------------------------------------------
246 * This function prints the content of a serial vector to outfile.
247 * -----------------------------------------------------------------
248 */
249
250SUNDIALS_EXPORT void N_VPrintFile_Serial(N_Vector v, FILE *outfile);
251
252/*
253 * -----------------------------------------------------------------
254 * serial implementations of various useful vector operations
255 * -----------------------------------------------------------------
256 */
257
258SUNDIALS_EXPORT N_Vector_ID N_VGetVectorID_Serial(N_Vector v);
259SUNDIALS_EXPORT N_Vector N_VCloneEmpty_Serial(N_Vector w);
260SUNDIALS_EXPORT N_Vector N_VClone_Serial(N_Vector w);
261SUNDIALS_EXPORT void N_VDestroy_Serial(N_Vector v);
262SUNDIALS_EXPORT void N_VSpace_Serial(N_Vector v, sunindextype *lrw, sunindextype *liw);
263SUNDIALS_EXPORT realtype *N_VGetArrayPointer_Serial(N_Vector v);
264SUNDIALS_EXPORT void N_VSetArrayPointer_Serial(realtype *v_data, N_Vector v);
265SUNDIALS_EXPORT void N_VLinearSum_Serial(realtype a, N_Vector x, realtype b, N_Vector y, N_Vector z);
266SUNDIALS_EXPORT void N_VConst_Serial(realtype c, N_Vector z);
267SUNDIALS_EXPORT void N_VProd_Serial(N_Vector x, N_Vector y, N_Vector z);
268SUNDIALS_EXPORT void N_VDiv_Serial(N_Vector x, N_Vector y, N_Vector z);
269SUNDIALS_EXPORT void N_VScale_Serial(realtype c, N_Vector x, N_Vector z);
270SUNDIALS_EXPORT void N_VAbs_Serial(N_Vector x, N_Vector z);
271SUNDIALS_EXPORT void N_VInv_Serial(N_Vector x, N_Vector z);
272SUNDIALS_EXPORT void N_VAddConst_Serial(N_Vector x, realtype b, N_Vector z);
273SUNDIALS_EXPORT realtype N_VDotProd_Serial(N_Vector x, N_Vector y);
274SUNDIALS_EXPORT realtype N_VMaxNorm_Serial(N_Vector x);
275SUNDIALS_EXPORT realtype N_VWrmsNorm_Serial(N_Vector x, N_Vector w);
276SUNDIALS_EXPORT realtype N_VWrmsNormMask_Serial(N_Vector x, N_Vector w, N_Vector id);
277SUNDIALS_EXPORT realtype N_VMin_Serial(N_Vector x);
278SUNDIALS_EXPORT realtype N_VWL2Norm_Serial(N_Vector x, N_Vector w);
279SUNDIALS_EXPORT realtype N_VL1Norm_Serial(N_Vector x);
280SUNDIALS_EXPORT void N_VCompare_Serial(realtype c, N_Vector x, N_Vector z);
281SUNDIALS_EXPORT booleantype N_VInvTest_Serial(N_Vector x, N_Vector z);
282SUNDIALS_EXPORT booleantype N_VConstrMask_Serial(N_Vector c, N_Vector x, N_Vector m);
283SUNDIALS_EXPORT realtype N_VMinQuotient_Serial(N_Vector num, N_Vector denom);
284
285#ifdef __cplusplus
286}
287#endif
288
289#endif
Note: See TracBrowser for help on using the repository browser.