-
Notifications
You must be signed in to change notification settings - Fork 0
/
myNVector.h
270 lines (199 loc) · 7.79 KB
/
myNVector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
/* -----------------------------------------------------------------
* Programmer(s): Daniel R. Reynolds @ SMU
* -----------------------------------------------------------------
* SUNDIALS Copyright Start
* Copyright (c) 2002-2024, Lawrence Livermore National Security
* and Southern Methodist University.
* All rights reserved.
*
* See the top-level LICENSE and NOTICE files for details.
*
* SPDX-License-Identifier: BSD-3-Clause
* SUNDIALS Copyright End
* -----------------------------------------------------------------
* This is the header file for a custom N_Vector implementation
* (note that this template just implements the serial N_Vector).
* -----------------------------------------------------------------*/
#ifndef _MY_NVECTOR_H
#define _MY_NVECTOR_H
#include <stdio.h>
#include <sundials/sundials_nvector.h>
#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
#endif
/*
* -----------------------------------------------------------------
* Custom implementation of N_Vector
* -----------------------------------------------------------------
*/
struct _My_NVectorContent
{
sunindextype length; /* vector length */
sunbooleantype own_data; /* data ownership flag */
sunrealtype* data; /* data array */
};
typedef struct _My_NVectorContent* My_NVectorContent;
/*
* -----------------------------------------------------------------
* Macros MY_NV_CONTENT, MY_NV_DATA, MY_NV_OWN_DATA,
* MY_NV_LENGTH, and MY_NV_Ith
* -----------------------------------------------------------------
*/
#define MYNV_CONTENT(v) ((My_NVectorContent)(v->content))
#define MYNV_LENGTH(v) (MYNV_CONTENT(v)->length)
#define MYNV_OWN_DATA(v) (MYNV_CONTENT(v)->own_data)
#define MYNV_DATA(v) (MYNV_CONTENT(v)->data)
#define MYNV_Ith(v, i) (MYNV_DATA(v)[i])
/*
* -----------------------------------------------------------------
* Functions exported by nvector_serial
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT
N_Vector N_VNewEmpty_Mine(sunindextype vec_length, SUNContext sunctx);
SUNDIALS_EXPORT
N_Vector N_VNew_Mine(sunindextype vec_length, SUNContext sunctx);
SUNDIALS_EXPORT
N_Vector N_VMake_Mine(sunindextype vec_length, sunrealtype* v_data,
SUNContext sunctx);
SUNDIALS_EXPORT
sunindextype N_VGetLength_Mine(N_Vector v);
SUNDIALS_EXPORT
void N_VPrint_Mine(N_Vector v);
SUNDIALS_EXPORT
void N_VPrintFile_Mine(N_Vector v, FILE* outfile);
static inline N_Vector_ID N_VGetVectorID_Mine(N_Vector v)
{
return SUNDIALS_NVEC_CUSTOM;
}
SUNDIALS_EXPORT
N_Vector N_VCloneEmpty_Mine(N_Vector w);
SUNDIALS_EXPORT
N_Vector N_VClone_Mine(N_Vector w);
SUNDIALS_EXPORT
void N_VDestroy_Mine(N_Vector v);
SUNDIALS_EXPORT
void N_VSpace_Mine(N_Vector v, sunindextype* lrw, sunindextype* liw);
SUNDIALS_EXPORT
sunrealtype* N_VGetArrayPointer_Mine(N_Vector v);
SUNDIALS_EXPORT
void N_VSetArrayPointer_Mine(sunrealtype* v_data, N_Vector v);
/* standard vector operations */
SUNDIALS_EXPORT
void N_VLinearSum_Mine(sunrealtype a, N_Vector x, sunrealtype b, N_Vector y,
N_Vector z);
SUNDIALS_EXPORT
void N_VConst_Mine(sunrealtype c, N_Vector z);
SUNDIALS_EXPORT
void N_VProd_Mine(N_Vector x, N_Vector y, N_Vector z);
SUNDIALS_EXPORT
void N_VDiv_Mine(N_Vector x, N_Vector y, N_Vector z);
SUNDIALS_EXPORT
void N_VScale_Mine(sunrealtype c, N_Vector x, N_Vector z);
SUNDIALS_EXPORT
void N_VAbs_Mine(N_Vector x, N_Vector z);
SUNDIALS_EXPORT
void N_VInv_Mine(N_Vector x, N_Vector z);
SUNDIALS_EXPORT
void N_VAddConst_Mine(N_Vector x, sunrealtype b, N_Vector z);
SUNDIALS_EXPORT
sunrealtype N_VDotProd_Mine(N_Vector x, N_Vector y);
SUNDIALS_EXPORT
sunrealtype N_VMaxNorm_Mine(N_Vector x);
SUNDIALS_EXPORT
sunrealtype N_VWrmsNorm_Mine(N_Vector x, N_Vector w);
SUNDIALS_EXPORT
sunrealtype N_VWrmsNormMask_Mine(N_Vector x, N_Vector w, N_Vector id);
SUNDIALS_EXPORT
sunrealtype N_VMin_Mine(N_Vector x);
SUNDIALS_EXPORT
sunrealtype N_VWL2Norm_Mine(N_Vector x, N_Vector w);
SUNDIALS_EXPORT
sunrealtype N_VL1Norm_Mine(N_Vector x);
SUNDIALS_EXPORT
void N_VCompare_Mine(sunrealtype c, N_Vector x, N_Vector z);
SUNDIALS_EXPORT
sunbooleantype N_VInvTest_Mine(N_Vector x, N_Vector z);
SUNDIALS_EXPORT
sunbooleantype N_VConstrMask_Mine(N_Vector c, N_Vector x, N_Vector m);
SUNDIALS_EXPORT
sunrealtype N_VMinQuotient_Mine(N_Vector num, N_Vector denom);
/* fused vector operations */
SUNDIALS_EXPORT
SUNErrCode N_VLinearCombination_Mine(int nvec, sunrealtype* c, N_Vector* V,
N_Vector z);
SUNDIALS_EXPORT
SUNErrCode N_VScaleAddMulti_Mine(int nvec, sunrealtype* a, N_Vector x,
N_Vector* Y, N_Vector* Z);
SUNDIALS_EXPORT
SUNErrCode N_VDotProdMulti_Mine(int nvec, N_Vector x, N_Vector* Y,
sunrealtype* dotprods);
/* vector array operations */
SUNDIALS_EXPORT
SUNErrCode N_VLinearSumVectorArray_Mine(int nvec, sunrealtype a, N_Vector* X,
sunrealtype b, N_Vector* Y,
N_Vector* Z);
SUNDIALS_EXPORT
SUNErrCode N_VScaleVectorArray_Mine(int nvec, sunrealtype* c, N_Vector* X,
N_Vector* Z);
SUNDIALS_EXPORT
SUNErrCode N_VConstVectorArray_Mine(int nvecs, sunrealtype c, N_Vector* Z);
SUNDIALS_EXPORT
SUNErrCode N_VWrmsNormVectorArray_Mine(int nvecs, N_Vector* X, N_Vector* W,
sunrealtype* nrm);
SUNDIALS_EXPORT
SUNErrCode N_VWrmsNormMaskVectorArray_Mine(int nvecs, N_Vector* X, N_Vector* W,
N_Vector id, sunrealtype* nrm);
SUNDIALS_EXPORT
SUNErrCode N_VScaleAddMultiVectorArray_Mine(int nvec, int nsum,
sunrealtype* a, N_Vector* X,
N_Vector** Y, N_Vector** Z);
SUNDIALS_EXPORT
SUNErrCode N_VLinearCombinationVectorArray_Mine(int nvec, int nsum,
sunrealtype* c, N_Vector** X,
N_Vector* Z);
/* OPTIONAL local reduction kernels (no parallel communication) */
SUNDIALS_EXPORT
sunrealtype N_VWSqrSumLocal_Mine(N_Vector x, N_Vector w);
SUNDIALS_EXPORT
sunrealtype N_VWSqrSumMaskLocal_Mine(N_Vector x, N_Vector w, N_Vector id);
/* OPTIONAL XBraid interface operations */
SUNDIALS_EXPORT
SUNErrCode N_VBufSize_Mine(N_Vector x, sunindextype* size);
SUNDIALS_EXPORT
SUNErrCode N_VBufPack_Mine(N_Vector x, void* buf);
SUNDIALS_EXPORT
SUNErrCode N_VBufUnpack_Mine(N_Vector x, void* buf);
/*
* -----------------------------------------------------------------
* Enable / disable fused vector operations
* -----------------------------------------------------------------
*/
SUNDIALS_EXPORT
SUNErrCode N_VEnableFusedOps_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableLinearCombination_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableScaleAddMulti_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableDotProdMulti_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableLinearSumVectorArray_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableScaleVectorArray_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableConstVectorArray_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableWrmsNormVectorArray_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableWrmsNormMaskVectorArray_Mine(N_Vector v, sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableScaleAddMultiVectorArray_Mine(N_Vector v,
sunbooleantype tf);
SUNDIALS_EXPORT
SUNErrCode N_VEnableLinearCombinationVectorArray_Mine(N_Vector v,
sunbooleantype tf);
#ifdef __cplusplus
}
#endif
#endif