spline_n3.cpp 24 KB
Newer Older
Chichi Lalescu's avatar
Chichi Lalescu committed
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
/***********************************************************************
*
*  Copyright 2015 Max Planck Institute for Dynamics and SelfOrganization
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Contact: Cristian.Lalescu@ds.mpg.de
*
************************************************************************/



#include "spline_n3.hpp"
#include <math.h>

void beta_n3_m0(int deriv, double x, double *poly_val)
{
    switch(deriv)
    {
    case 0:
        poly_val[0] = 0;
        poly_val[1] = 0;
        poly_val[2] = 0;
        poly_val[3] = -x + 1;
        poly_val[4] = x;
        poly_val[5] = 0;
        poly_val[6] = 0;
        poly_val[7] = 0;
        break;
    case 1:
        poly_val[0] = 0;
        poly_val[1] = 0;
        poly_val[2] = 0;
        poly_val[3] = -1;
        poly_val[4] = 1;
        poly_val[5] = 0;
        poly_val[6] = 0;
        poly_val[7] = 0;
        break;
    case 2:
        poly_val[0] = 0;
        poly_val[1] = 0;
        poly_val[2] = 0;
        poly_val[3] = 0;
        poly_val[4] = 0;
        poly_val[5] = 0;
        poly_val[6] = 0;
        poly_val[7] = 0;
        break;
    }
}

void beta_n3_m1(int deriv, double x, double *poly_val)
{
    switch(deriv)
    {
    case 0:
        poly_val[0] = x*(x*(-1.0L/60.0L*x + 1.0L/30.0L) - 1.0L/60.0L);
        poly_val[1] = x*(x*((2.0L/15.0L)*x - 17.0L/60.0L) + 3.0L/20.0L);
        poly_val[2] = x*(x*(-3.0L/5.0L*x + 27.0L/20.0L) - 3.0L/4.0L);
        poly_val[3] = pow(x, 2)*((5.0L/4.0L)*x - 9.0L/4.0L) + 1;
        poly_val[4] = x*(x*(-5.0L/4.0L*x + 3.0L/2.0L) + 3.0L/4.0L);
        poly_val[5] = x*(x*((3.0L/5.0L)*x - 9.0L/20.0L) - 3.0L/20.0L);
        poly_val[6] = x*(x*(-2.0L/15.0L*x + 7.0L/60.0L) + 1.0L/60.0L);
        poly_val[7] = pow(x, 2)*((1.0L/60.0L)*x - 1.0L/60.0L);
        break;
    case 1:
        poly_val[0] = x*(-1.0L/20.0L*x + 1.0L/15.0L) - 1.0L/60.0L;
        poly_val[1] = x*((2.0L/5.0L)*x - 17.0L/30.0L) + 3.0L/20.0L;
        poly_val[2] = x*(-9.0L/5.0L*x + 27.0L/10.0L) - 3.0L/4.0L;
        poly_val[3] = x*((15.0L/4.0L)*x - 9.0L/2.0L);
        poly_val[4] = x*(-15.0L/4.0L*x + 3) + 3.0L/4.0L;
        poly_val[5] = x*((9.0L/5.0L)*x - 9.0L/10.0L) - 3.0L/20.0L;
        poly_val[6] = x*(-2.0L/5.0L*x + 7.0L/30.0L) + 1.0L/60.0L;
        poly_val[7] = x*((1.0L/20.0L)*x - 1.0L/30.0L);
        break;
    case 2:
        poly_val[0] = -1.0L/10.0L*x + 1.0L/15.0L;
        poly_val[1] = (4.0L/5.0L)*x - 17.0L/30.0L;
        poly_val[2] = -18.0L/5.0L*x + 27.0L/10.0L;
        poly_val[3] = (15.0L/2.0L)*x - 9.0L/2.0L;
        poly_val[4] = -15.0L/2.0L*x + 3;
        poly_val[5] = (18.0L/5.0L)*x - 9.0L/10.0L;
        poly_val[6] = -4.0L/5.0L*x + 7.0L/30.0L;
        poly_val[7] = (1.0L/10.0L)*x - 1.0L/30.0L;
        break;
    }
}

void beta_n3_m2(int deriv, double x, double *poly_val)
{
    switch(deriv)
    {
    case 0:
        poly_val[0] = x*(x*(x*(x*((2.0L/45.0L)*x - 7.0L/60.0L) + 1.0L/12.0L) + 1.0L/180.0L) - 1.0L/60.0L);
        poly_val[1] = x*(x*(x*(x*(-23.0L/72.0L*x + 61.0L/72.0L) - 217.0L/360.0L) - 3.0L/40.0L) + 3.0L/20.0L);
        poly_val[2] = x*(x*(x*(x*((39.0L/40.0L)*x - 51.0L/20.0L) + 63.0L/40.0L) + 3.0L/4.0L) - 3.0L/4.0L);
        poly_val[3] = pow(x, 2)*(x*(x*(-59.0L/36.0L*x + 25.0L/6.0L) - 13.0L/6.0L) - 49.0L/36.0L) + 1;
        poly_val[4] = x*(x*(x*(x*((59.0L/36.0L)*x - 145.0L/36.0L) + 17.0L/9.0L) + 3.0L/4.0L) + 3.0L/4.0L);
        poly_val[5] = x*(x*(x*(x*(-39.0L/40.0L*x + 93.0L/40.0L) - 9.0L/8.0L) - 3.0L/40.0L) - 3.0L/20.0L);
        poly_val[6] = x*(x*(x*(x*((23.0L/72.0L)*x - 3.0L/4.0L) + 49.0L/120.0L) + 1.0L/180.0L) + 1.0L/60.0L);
        poly_val[7] = pow(x, 3)*(x*(-2.0L/45.0L*x + 19.0L/180.0L) - 11.0L/180.0L);
        break;
    case 1:
        poly_val[0] = x*(x*(x*((2.0L/9.0L)*x - 7.0L/15.0L) + 1.0L/4.0L) + 1.0L/90.0L) - 1.0L/60.0L;
        poly_val[1] = x*(x*(x*(-115.0L/72.0L*x + 61.0L/18.0L) - 217.0L/120.0L) - 3.0L/20.0L) + 3.0L/20.0L;
        poly_val[2] = x*(x*(x*((39.0L/8.0L)*x - 51.0L/5.0L) + 189.0L/40.0L) + 3.0L/2.0L) - 3.0L/4.0L;
        poly_val[3] = x*(x*(x*(-295.0L/36.0L*x + 50.0L/3.0L) - 13.0L/2.0L) - 49.0L/18.0L);
        poly_val[4] = x*(x*(x*((295.0L/36.0L)*x - 145.0L/9.0L) + 17.0L/3.0L) + 3.0L/2.0L) + 3.0L/4.0L;
        poly_val[5] = x*(x*(x*(-39.0L/8.0L*x + 93.0L/10.0L) - 27.0L/8.0L) - 3.0L/20.0L) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*((115.0L/72.0L)*x - 3) + 49.0L/40.0L) + 1.0L/90.0L) + 1.0L/60.0L;
        poly_val[7] = pow(x, 2)*(x*(-2.0L/9.0L*x + 19.0L/45.0L) - 11.0L/60.0L);
        break;
    case 2:
        poly_val[0] = x*(x*((8.0L/9.0L)*x - 7.0L/5.0L) + 1.0L/2.0L) + 1.0L/90.0L;
        poly_val[1] = x*(x*(-115.0L/18.0L*x + 61.0L/6.0L) - 217.0L/60.0L) - 3.0L/20.0L;
        poly_val[2] = x*(x*((39.0L/2.0L)*x - 153.0L/5.0L) + 189.0L/20.0L) + 3.0L/2.0L;
        poly_val[3] = x*(x*(-295.0L/9.0L*x + 50) - 13) - 49.0L/18.0L;
        poly_val[4] = x*(x*((295.0L/9.0L)*x - 145.0L/3.0L) + 34.0L/3.0L) + 3.0L/2.0L;
        poly_val[5] = x*(x*(-39.0L/2.0L*x + 279.0L/10.0L) - 27.0L/4.0L) - 3.0L/20.0L;
        poly_val[6] = x*(x*((115.0L/18.0L)*x - 9) + 49.0L/20.0L) + 1.0L/90.0L;
        poly_val[7] = x*(x*(-8.0L/9.0L*x + 19.0L/15.0L) - 11.0L/30.0L);
        break;
    }
}

void beta_n3_m3(int deriv, double x, double *poly_val)
{
    switch(deriv)
    {
    case 0:
        poly_val[0] = x*(x*(x*(x*(x*(x*(-89.0L/720.0L*x + 13.0L/30.0L) - 37.0L/72.0L) + 7.0L/36.0L) + 1.0L/48.0L) + 1.0L/180.0L) - 1.0L/60.0L);
        poly_val[1] = x*(x*(x*(x*(x*(x*((623.0L/720.0L)*x - 2183.0L/720.0L) + 2581.0L/720.0L) - 191.0L/144.0L) - 1.0L/6.0L) - 3.0L/40.0L) + 3.0L/20.0L);
        poly_val[2] = x*(x*(x*(x*(x*(x*(-623.0L/240.0L*x + 1091.0L/120.0L) - 429.0L/40.0L) + 95.0L/24.0L) + 13.0L/48.0L) + 3.0L/4.0L) - 3.0L/4.0L);
        poly_val[3] = pow(x, 2)*(pow(x, 2)*(x*(x*((623.0L/144.0L)*x - 727.0L/48.0L) + 2569.0L/144.0L) - 959.0L/144.0L) - 49.0L/36.0L) + 1;
        poly_val[4] = x*(x*(x*(x*(x*(x*(-623.0L/144.0L*x + 545.0L/36.0L) - 1283.0L/72.0L) + 61.0L/9.0L) - 13.0L/48.0L) + 3.0L/4.0L) + 3.0L/4.0L);
        poly_val[5] = x*(x*(x*(x*(x*(x*((623.0L/240.0L)*x - 2179.0L/240.0L) + 171.0L/16.0L) - 199.0L/48.0L) + 1.0L/6.0L) - 3.0L/40.0L) - 3.0L/20.0L);
        poly_val[6] = x*(x*(x*(x*(x*(x*(-623.0L/720.0L*x + 121.0L/40.0L) - 1283.0L/360.0L) + 101.0L/72.0L) - 1.0L/48.0L) + 1.0L/180.0L) + 1.0L/60.0L);
        poly_val[7] = pow(x, 4)*(x*(x*((89.0L/720.0L)*x - 311.0L/720.0L) + 367.0L/720.0L) - 29.0L/144.0L);
        break;
    case 1:
        poly_val[0] = x*(x*(x*(x*(x*(-623.0L/720.0L*x + 13.0L/5.0L) - 185.0L/72.0L) + 7.0L/9.0L) + 1.0L/16.0L) + 1.0L/90.0L) - 1.0L/60.0L;
        poly_val[1] = x*(x*(x*(x*(x*((4361.0L/720.0L)*x - 2183.0L/120.0L) + 2581.0L/144.0L) - 191.0L/36.0L) - 1.0L/2.0L) - 3.0L/20.0L) + 3.0L/20.0L;
        poly_val[2] = x*(x*(x*(x*(x*(-4361.0L/240.0L*x + 1091.0L/20.0L) - 429.0L/8.0L) + 95.0L/6.0L) + 13.0L/16.0L) + 3.0L/2.0L) - 3.0L/4.0L;
        poly_val[3] = x*(pow(x, 2)*(x*(x*((4361.0L/144.0L)*x - 727.0L/8.0L) + 12845.0L/144.0L) - 959.0L/36.0L) - 49.0L/18.0L);
        poly_val[4] = x*(x*(x*(x*(x*(-4361.0L/144.0L*x + 545.0L/6.0L) - 6415.0L/72.0L) + 244.0L/9.0L) - 13.0L/16.0L) + 3.0L/2.0L) + 3.0L/4.0L;
        poly_val[5] = x*(x*(x*(x*(x*((4361.0L/240.0L)*x - 2179.0L/40.0L) + 855.0L/16.0L) - 199.0L/12.0L) + 1.0L/2.0L) - 3.0L/20.0L) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*(x*(x*(-4361.0L/720.0L*x + 363.0L/20.0L) - 1283.0L/72.0L) + 101.0L/18.0L) - 1.0L/16.0L) + 1.0L/90.0L) + 1.0L/60.0L;
        poly_val[7] = pow(x, 3)*(x*(x*((623.0L/720.0L)*x - 311.0L/120.0L) + 367.0L/144.0L) - 29.0L/36.0L);
        break;
    case 2:
        poly_val[0] = x*(x*(x*(x*(-623.0L/120.0L*x + 13) - 185.0L/18.0L) + 7.0L/3.0L) + 1.0L/8.0L) + 1.0L/90.0L;
        poly_val[1] = x*(x*(x*(x*((4361.0L/120.0L)*x - 2183.0L/24.0L) + 2581.0L/36.0L) - 191.0L/12.0L) - 1) - 3.0L/20.0L;
        poly_val[2] = x*(x*(x*(x*(-4361.0L/40.0L*x + 1091.0L/4.0L) - 429.0L/2.0L) + 95.0L/2.0L) + 13.0L/8.0L) + 3.0L/2.0L;
        poly_val[3] = pow(x, 2)*(x*(x*((4361.0L/24.0L)*x - 3635.0L/8.0L) + 12845.0L/36.0L) - 959.0L/12.0L) - 49.0L/18.0L;
        poly_val[4] = x*(x*(x*(x*(-4361.0L/24.0L*x + 2725.0L/6.0L) - 6415.0L/18.0L) + 244.0L/3.0L) - 13.0L/8.0L) + 3.0L/2.0L;
        poly_val[5] = x*(x*(x*(x*((4361.0L/40.0L)*x - 2179.0L/8.0L) + 855.0L/4.0L) - 199.0L/4.0L) + 1) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*(x*(-4361.0L/120.0L*x + 363.0L/4.0L) - 1283.0L/18.0L) + 101.0L/6.0L) - 1.0L/8.0L) + 1.0L/90.0L;
        poly_val[7] = pow(x, 2)*(x*(x*((623.0L/120.0L)*x - 311.0L/24.0L) + 367.0L/36.0L) - 29.0L/12.0L);
        break;
    }
}

void beta_n3_m4(int deriv, double x, double *poly_val)
{
    switch(deriv)
    {
    case 0:
        poly_val[0] = x*(x*(x*(x*(x*(x*(x*(x*((29.0L/72.0L)*x - 29.0L/16.0L) + 2231.0L/720.0L) - 859.0L/360.0L) + 25.0L/36.0L) - 1.0L/144.0L) + 1.0L/48.0L) + 1.0L/180.0L) - 1.0L/60.0L);
        poly_val[1] = x*(x*(x*(x*(x*(x*(x*(x*(-203.0L/72.0L*x + 203.0L/16.0L) - 15617.0L/720.0L) + 4009.0L/240.0L) - 3509.0L/720.0L) + 1.0L/12.0L) - 1.0L/6.0L) - 3.0L/40.0L) + 3.0L/20.0L);
        poly_val[2] = x*(x*(x*(x*(x*(x*(x*(x*((203.0L/24.0L)*x - 609.0L/16.0L) + 15617.0L/240.0L) - 3007.0L/60.0L) + 293.0L/20.0L) - 13.0L/48.0L) + 13.0L/48.0L) + 3.0L/4.0L) - 3.0L/4.0L);
        poly_val[3] = pow(x, 2)*(pow(x, 2)*(x*(x*(x*(x*(-1015.0L/72.0L*x + 1015.0L/16.0L) - 15617.0L/144.0L) + 12029.0L/144.0L) - 3521.0L/144.0L) + 7.0L/18.0L) - 49.0L/36.0L) + 1;
        poly_val[4] = x*(x*(x*(x*(x*(x*(x*(x*((1015.0L/72.0L)*x - 1015.0L/16.0L) + 15617.0L/144.0L) - 2005.0L/24.0L) + 881.0L/36.0L) - 13.0L/48.0L) - 13.0L/48.0L) + 3.0L/4.0L) + 3.0L/4.0L);
        poly_val[5] = x*(x*(x*(x*(x*(x*(x*(x*(-203.0L/24.0L*x + 609.0L/16.0L) - 15617.0L/240.0L) + 12031.0L/240.0L) - 235.0L/16.0L) + 1.0L/12.0L) + 1.0L/6.0L) - 3.0L/40.0L) - 3.0L/20.0L);
        poly_val[6] = x*(x*(x*(x*(x*(x*(x*(x*((203.0L/72.0L)*x - 203.0L/16.0L) + 15617.0L/720.0L) - 752.0L/45.0L) + 881.0L/180.0L) - 1.0L/144.0L) - 1.0L/48.0L) + 1.0L/180.0L) + 1.0L/60.0L);
        poly_val[7] = pow(x, 5)*(x*(x*(x*(-29.0L/72.0L*x + 29.0L/16.0L) - 2231.0L/720.0L) + 191.0L/80.0L) - 503.0L/720.0L);
        break;
    case 1:
        poly_val[0] = x*(x*(x*(x*(x*(x*(x*((29.0L/8.0L)*x - 29.0L/2.0L) + 15617.0L/720.0L) - 859.0L/60.0L) + 125.0L/36.0L) - 1.0L/36.0L) + 1.0L/16.0L) + 1.0L/90.0L) - 1.0L/60.0L;
        poly_val[1] = x*(x*(x*(x*(x*(x*(x*(-203.0L/8.0L*x + 203.0L/2.0L) - 109319.0L/720.0L) + 4009.0L/40.0L) - 3509.0L/144.0L) + 1.0L/3.0L) - 1.0L/2.0L) - 3.0L/20.0L) + 3.0L/20.0L;
        poly_val[2] = x*(x*(x*(x*(x*(x*(x*((609.0L/8.0L)*x - 609.0L/2.0L) + 109319.0L/240.0L) - 3007.0L/10.0L) + 293.0L/4.0L) - 13.0L/12.0L) + 13.0L/16.0L) + 3.0L/2.0L) - 3.0L/4.0L;
        poly_val[3] = x*(pow(x, 2)*(x*(x*(x*(x*(-1015.0L/8.0L*x + 1015.0L/2.0L) - 109319.0L/144.0L) + 12029.0L/24.0L) - 17605.0L/144.0L) + 14.0L/9.0L) - 49.0L/18.0L);
        poly_val[4] = x*(x*(x*(x*(x*(x*(x*((1015.0L/8.0L)*x - 1015.0L/2.0L) + 109319.0L/144.0L) - 2005.0L/4.0L) + 4405.0L/36.0L) - 13.0L/12.0L) - 13.0L/16.0L) + 3.0L/2.0L) + 3.0L/4.0L;
        poly_val[5] = x*(x*(x*(x*(x*(x*(x*(-609.0L/8.0L*x + 609.0L/2.0L) - 109319.0L/240.0L) + 12031.0L/40.0L) - 1175.0L/16.0L) + 1.0L/3.0L) + 1.0L/2.0L) - 3.0L/20.0L) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*(x*(x*(x*(x*((203.0L/8.0L)*x - 203.0L/2.0L) + 109319.0L/720.0L) - 1504.0L/15.0L) + 881.0L/36.0L) - 1.0L/36.0L) - 1.0L/16.0L) + 1.0L/90.0L) + 1.0L/60.0L;
        poly_val[7] = pow(x, 4)*(x*(x*(x*(-29.0L/8.0L*x + 29.0L/2.0L) - 15617.0L/720.0L) + 573.0L/40.0L) - 503.0L/144.0L);
        break;
    case 2:
        poly_val[0] = x*(x*(x*(x*(x*(x*(29*x - 203.0L/2.0L) + 15617.0L/120.0L) - 859.0L/12.0L) + 125.0L/9.0L) - 1.0L/12.0L) + 1.0L/8.0L) + 1.0L/90.0L;
        poly_val[1] = x*(x*(x*(x*(x*(x*(-203*x + 1421.0L/2.0L) - 109319.0L/120.0L) + 4009.0L/8.0L) - 3509.0L/36.0L) + 1) - 1) - 3.0L/20.0L;
        poly_val[2] = x*(x*(x*(x*(x*(x*(609*x - 4263.0L/2.0L) + 109319.0L/40.0L) - 3007.0L/2.0L) + 293) - 13.0L/4.0L) + 13.0L/8.0L) + 3.0L/2.0L;
        poly_val[3] = pow(x, 2)*(x*(x*(x*(x*(-1015*x + 7105.0L/2.0L) - 109319.0L/24.0L) + 60145.0L/24.0L) - 17605.0L/36.0L) + 14.0L/3.0L) - 49.0L/18.0L;
        poly_val[4] = x*(x*(x*(x*(x*(x*(1015*x - 7105.0L/2.0L) + 109319.0L/24.0L) - 10025.0L/4.0L) + 4405.0L/9.0L) - 13.0L/4.0L) - 13.0L/8.0L) + 3.0L/2.0L;
        poly_val[5] = x*(x*(x*(x*(x*(x*(-609*x + 4263.0L/2.0L) - 109319.0L/40.0L) + 12031.0L/8.0L) - 1175.0L/4.0L) + 1) + 1) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*(x*(x*(x*(203*x - 1421.0L/2.0L) + 109319.0L/120.0L) - 1504.0L/3.0L) + 881.0L/9.0L) - 1.0L/12.0L) - 1.0L/8.0L) + 1.0L/90.0L;
        poly_val[7] = pow(x, 3)*(x*(x*(x*(-29*x + 203.0L/2.0L) - 15617.0L/120.0L) + 573.0L/8.0L) - 503.0L/36.0L);
        break;
    }
}

void beta_n3_m5(int deriv, double x, double *poly_val)
{
    switch(deriv)
    {
    case 0:
        poly_val[0] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-503.0L/360.0L*x + 5533.0L/720.0L) - 273.0L/16.0L) + 919.0L/48.0L) - 7829.0L/720.0L) + 601.0L/240.0L) - 1.0L/240.0L) - 1.0L/144.0L) + 1.0L/48.0L) + 1.0L/180.0L) - 1.0L/60.0L);
        poly_val[1] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((3521.0L/360.0L)*x - 38731.0L/720.0L) + 1911.0L/16.0L) - 6433.0L/48.0L) + 54803.0L/720.0L) - 631.0L/36.0L) + 1.0L/60.0L) + 1.0L/12.0L) - 1.0L/6.0L) - 3.0L/40.0L) + 3.0L/20.0L);
        poly_val[2] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-3521.0L/120.0L*x + 38731.0L/240.0L) - 5733.0L/16.0L) + 6433.0L/16.0L) - 54803.0L/240.0L) + 12619.0L/240.0L) - 1.0L/48.0L) - 13.0L/48.0L) + 13.0L/48.0L) + 3.0L/4.0L) - 3.0L/4.0L);
        poly_val[3] = pow(x, 2)*(pow(x, 2)*(pow(x, 2)*(x*(x*(x*(x*((3521.0L/72.0L)*x - 38731.0L/144.0L) + 9555.0L/16.0L) - 32165.0L/48.0L) + 54803.0L/144.0L) - 701.0L/8.0L) + 7.0L/18.0L) - 49.0L/36.0L) + 1;
        poly_val[4] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-3521.0L/72.0L*x + 38731.0L/144.0L) - 9555.0L/16.0L) + 32165.0L/48.0L) - 54803.0L/144.0L) + 12617.0L/144.0L) + 1.0L/48.0L) - 13.0L/48.0L) - 13.0L/48.0L) + 3.0L/4.0L) + 3.0L/4.0L);
        poly_val[5] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((3521.0L/120.0L)*x - 38731.0L/240.0L) + 5733.0L/16.0L) - 6433.0L/16.0L) + 54803.0L/240.0L) - 1577.0L/30.0L) - 1.0L/60.0L) + 1.0L/12.0L) + 1.0L/6.0L) - 3.0L/40.0L) - 3.0L/20.0L);
        poly_val[6] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-3521.0L/360.0L*x + 38731.0L/720.0L) - 1911.0L/16.0L) + 6433.0L/48.0L) - 54803.0L/720.0L) + 841.0L/48.0L) + 1.0L/240.0L) - 1.0L/144.0L) - 1.0L/48.0L) + 1.0L/180.0L) + 1.0L/60.0L);
        poly_val[7] = pow(x, 6)*(x*(x*(x*(x*((503.0L/360.0L)*x - 5533.0L/720.0L) + 273.0L/16.0L) - 919.0L/48.0L) + 7829.0L/720.0L) - 901.0L/360.0L);
        break;
    case 1:
        poly_val[0] = x*(x*(x*(x*(x*(x*(x*(x*(x*(-5533.0L/360.0L*x + 5533.0L/72.0L) - 2457.0L/16.0L) + 919.0L/6.0L) - 54803.0L/720.0L) + 601.0L/40.0L) - 1.0L/48.0L) - 1.0L/36.0L) + 1.0L/16.0L) + 1.0L/90.0L) - 1.0L/60.0L;
        poly_val[1] = x*(x*(x*(x*(x*(x*(x*(x*(x*((38731.0L/360.0L)*x - 38731.0L/72.0L) + 17199.0L/16.0L) - 6433.0L/6.0L) + 383621.0L/720.0L) - 631.0L/6.0L) + 1.0L/12.0L) + 1.0L/3.0L) - 1.0L/2.0L) - 3.0L/20.0L) + 3.0L/20.0L;
        poly_val[2] = x*(x*(x*(x*(x*(x*(x*(x*(x*(-38731.0L/120.0L*x + 38731.0L/24.0L) - 51597.0L/16.0L) + 6433.0L/2.0L) - 383621.0L/240.0L) + 12619.0L/40.0L) - 5.0L/48.0L) - 13.0L/12.0L) + 13.0L/16.0L) + 3.0L/2.0L) - 3.0L/4.0L;
        poly_val[3] = x*(pow(x, 2)*(pow(x, 2)*(x*(x*(x*(x*((38731.0L/72.0L)*x - 193655.0L/72.0L) + 85995.0L/16.0L) - 32165.0L/6.0L) + 383621.0L/144.0L) - 2103.0L/4.0L) + 14.0L/9.0L) - 49.0L/18.0L);
        poly_val[4] = x*(x*(x*(x*(x*(x*(x*(x*(x*(-38731.0L/72.0L*x + 193655.0L/72.0L) - 85995.0L/16.0L) + 32165.0L/6.0L) - 383621.0L/144.0L) + 12617.0L/24.0L) + 5.0L/48.0L) - 13.0L/12.0L) - 13.0L/16.0L) + 3.0L/2.0L) + 3.0L/4.0L;
        poly_val[5] = x*(x*(x*(x*(x*(x*(x*(x*(x*((38731.0L/120.0L)*x - 38731.0L/24.0L) + 51597.0L/16.0L) - 6433.0L/2.0L) + 383621.0L/240.0L) - 1577.0L/5.0L) - 1.0L/12.0L) + 1.0L/3.0L) + 1.0L/2.0L) - 3.0L/20.0L) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*(x*(x*(x*(x*(x*(x*(-38731.0L/360.0L*x + 38731.0L/72.0L) - 17199.0L/16.0L) + 6433.0L/6.0L) - 383621.0L/720.0L) + 841.0L/8.0L) + 1.0L/48.0L) - 1.0L/36.0L) - 1.0L/16.0L) + 1.0L/90.0L) + 1.0L/60.0L;
        poly_val[7] = pow(x, 5)*(x*(x*(x*(x*((5533.0L/360.0L)*x - 5533.0L/72.0L) + 2457.0L/16.0L) - 919.0L/6.0L) + 54803.0L/720.0L) - 901.0L/60.0L);
        break;
    case 2:
        poly_val[0] = x*(x*(x*(x*(x*(x*(x*(x*(-5533.0L/36.0L*x + 5533.0L/8.0L) - 2457.0L/2.0L) + 6433.0L/6.0L) - 54803.0L/120.0L) + 601.0L/8.0L) - 1.0L/12.0L) - 1.0L/12.0L) + 1.0L/8.0L) + 1.0L/90.0L;
        poly_val[1] = x*(x*(x*(x*(x*(x*(x*(x*((38731.0L/36.0L)*x - 38731.0L/8.0L) + 17199.0L/2.0L) - 45031.0L/6.0L) + 383621.0L/120.0L) - 3155.0L/6.0L) + 1.0L/3.0L) + 1) - 1) - 3.0L/20.0L;
        poly_val[2] = x*(x*(x*(x*(x*(x*(x*(x*(-38731.0L/12.0L*x + 116193.0L/8.0L) - 51597.0L/2.0L) + 45031.0L/2.0L) - 383621.0L/40.0L) + 12619.0L/8.0L) - 5.0L/12.0L) - 13.0L/4.0L) + 13.0L/8.0L) + 3.0L/2.0L;
        poly_val[3] = pow(x, 2)*(pow(x, 2)*(x*(x*(x*(x*((193655.0L/36.0L)*x - 193655.0L/8.0L) + 85995.0L/2.0L) - 225155.0L/6.0L) + 383621.0L/24.0L) - 10515.0L/4.0L) + 14.0L/3.0L) - 49.0L/18.0L;
        poly_val[4] = x*(x*(x*(x*(x*(x*(x*(x*(-193655.0L/36.0L*x + 193655.0L/8.0L) - 85995.0L/2.0L) + 225155.0L/6.0L) - 383621.0L/24.0L) + 63085.0L/24.0L) + 5.0L/12.0L) - 13.0L/4.0L) - 13.0L/8.0L) + 3.0L/2.0L;
        poly_val[5] = x*(x*(x*(x*(x*(x*(x*(x*((38731.0L/12.0L)*x - 116193.0L/8.0L) + 51597.0L/2.0L) - 45031.0L/2.0L) + 383621.0L/40.0L) - 1577) - 1.0L/3.0L) + 1) + 1) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*(x*(x*(x*(x*(x*(-38731.0L/36.0L*x + 38731.0L/8.0L) - 17199.0L/2.0L) + 45031.0L/6.0L) - 383621.0L/120.0L) + 4205.0L/8.0L) + 1.0L/12.0L) - 1.0L/12.0L) - 1.0L/8.0L) + 1.0L/90.0L;
        poly_val[7] = pow(x, 4)*(x*(x*(x*(x*((5533.0L/36.0L)*x - 5533.0L/8.0L) + 2457.0L/2.0L) - 6433.0L/6.0L) + 54803.0L/120.0L) - 901.0L/12.0L);
        break;
    }
}

void beta_n3_m6(int deriv, double x, double *poly_val)
{
    switch(deriv)
    {
    case 0:
        poly_val[0] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((901.0L/180.0L)*x - 11713.0L/360.0L) + 31933.0L/360.0L) - 93577.0L/720.0L) + 15563.0L/144.0L) - 11623.0L/240.0L) + 6587.0L/720.0L) + 1.0L/720.0L) - 1.0L/240.0L) - 1.0L/144.0L) + 1.0L/48.0L) + 1.0L/180.0L) - 1.0L/60.0L);
        poly_val[1] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-6307.0L/180.0L*x + 81991.0L/360.0L) - 223531.0L/360.0L) + 655039.0L/720.0L) - 108941.0L/144.0L) + 81361.0L/240.0L) - 46109.0L/720.0L) - 1.0L/120.0L) + 1.0L/60.0L) + 1.0L/12.0L) - 1.0L/6.0L) - 3.0L/40.0L) + 3.0L/20.0L);
        poly_val[2] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((6307.0L/60.0L)*x - 81991.0L/120.0L) + 223531.0L/120.0L) - 655039.0L/240.0L) + 108941.0L/48.0L) - 81361.0L/80.0L) + 46109.0L/240.0L) + 1.0L/48.0L) - 1.0L/48.0L) - 13.0L/48.0L) + 13.0L/48.0L) + 3.0L/4.0L) - 3.0L/4.0L);
        poly_val[3] = pow(x, 2)*(pow(x, 2)*(pow(x, 2)*(x*(x*(x*(x*(x*(x*(-6307.0L/36.0L*x + 81991.0L/72.0L) - 223531.0L/72.0L) + 655039.0L/144.0L) - 544705.0L/144.0L) + 81361.0L/48.0L) - 46109.0L/144.0L) - 1.0L/36.0L) + 7.0L/18.0L) - 49.0L/36.0L) + 1;
        poly_val[4] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((6307.0L/36.0L)*x - 81991.0L/72.0L) + 223531.0L/72.0L) - 655039.0L/144.0L) + 544705.0L/144.0L) - 81361.0L/48.0L) + 46109.0L/144.0L) + 1.0L/48.0L) + 1.0L/48.0L) - 13.0L/48.0L) - 13.0L/48.0L) + 3.0L/4.0L) + 3.0L/4.0L);
        poly_val[5] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-6307.0L/60.0L*x + 81991.0L/120.0L) - 223531.0L/120.0L) + 655039.0L/240.0L) - 108941.0L/48.0L) + 81361.0L/80.0L) - 46109.0L/240.0L) - 1.0L/120.0L) - 1.0L/60.0L) + 1.0L/12.0L) + 1.0L/6.0L) - 3.0L/40.0L) - 3.0L/20.0L);
        poly_val[6] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((6307.0L/180.0L)*x - 81991.0L/360.0L) + 223531.0L/360.0L) - 655039.0L/720.0L) + 108941.0L/144.0L) - 81361.0L/240.0L) + 46109.0L/720.0L) + 1.0L/720.0L) + 1.0L/240.0L) - 1.0L/144.0L) - 1.0L/48.0L) + 1.0L/180.0L) + 1.0L/60.0L);
        poly_val[7] = pow(x, 7)*(x*(x*(x*(x*(x*(-901.0L/180.0L*x + 11713.0L/360.0L) - 31933.0L/360.0L) + 93577.0L/720.0L) - 15563.0L/144.0L) + 11623.0L/240.0L) - 6587.0L/720.0L);
        break;
    case 1:
        poly_val[0] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((11713.0L/180.0L)*x - 11713.0L/30.0L) + 351263.0L/360.0L) - 93577.0L/72.0L) + 15563.0L/16.0L) - 11623.0L/30.0L) + 46109.0L/720.0L) + 1.0L/120.0L) - 1.0L/48.0L) - 1.0L/36.0L) + 1.0L/16.0L) + 1.0L/90.0L) - 1.0L/60.0L;
        poly_val[1] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-81991.0L/180.0L*x + 81991.0L/30.0L) - 2458841.0L/360.0L) + 655039.0L/72.0L) - 108941.0L/16.0L) + 81361.0L/30.0L) - 322763.0L/720.0L) - 1.0L/20.0L) + 1.0L/12.0L) + 1.0L/3.0L) - 1.0L/2.0L) - 3.0L/20.0L) + 3.0L/20.0L;
        poly_val[2] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((81991.0L/60.0L)*x - 81991.0L/10.0L) + 2458841.0L/120.0L) - 655039.0L/24.0L) + 326823.0L/16.0L) - 81361.0L/10.0L) + 322763.0L/240.0L) + 1.0L/8.0L) - 5.0L/48.0L) - 13.0L/12.0L) + 13.0L/16.0L) + 3.0L/2.0L) - 3.0L/4.0L;
        poly_val[3] = x*(pow(x, 2)*(pow(x, 2)*(x*(x*(x*(x*(x*(x*(-81991.0L/36.0L*x + 81991.0L/6.0L) - 2458841.0L/72.0L) + 3275195.0L/72.0L) - 544705.0L/16.0L) + 81361.0L/6.0L) - 322763.0L/144.0L) - 1.0L/6.0L) + 14.0L/9.0L) - 49.0L/18.0L);
        poly_val[4] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((81991.0L/36.0L)*x - 81991.0L/6.0L) + 2458841.0L/72.0L) - 3275195.0L/72.0L) + 544705.0L/16.0L) - 81361.0L/6.0L) + 322763.0L/144.0L) + 1.0L/8.0L) + 5.0L/48.0L) - 13.0L/12.0L) - 13.0L/16.0L) + 3.0L/2.0L) + 3.0L/4.0L;
        poly_val[5] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-81991.0L/60.0L*x + 81991.0L/10.0L) - 2458841.0L/120.0L) + 655039.0L/24.0L) - 326823.0L/16.0L) + 81361.0L/10.0L) - 322763.0L/240.0L) - 1.0L/20.0L) - 1.0L/12.0L) + 1.0L/3.0L) + 1.0L/2.0L) - 3.0L/20.0L) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((81991.0L/180.0L)*x - 81991.0L/30.0L) + 2458841.0L/360.0L) - 655039.0L/72.0L) + 108941.0L/16.0L) - 81361.0L/30.0L) + 322763.0L/720.0L) + 1.0L/120.0L) + 1.0L/48.0L) - 1.0L/36.0L) - 1.0L/16.0L) + 1.0L/90.0L) + 1.0L/60.0L;
        poly_val[7] = pow(x, 6)*(x*(x*(x*(x*(x*(-11713.0L/180.0L*x + 11713.0L/30.0L) - 351263.0L/360.0L) + 93577.0L/72.0L) - 15563.0L/16.0L) + 11623.0L/30.0L) - 46109.0L/720.0L);
        break;
    case 2:
        poly_val[0] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((11713.0L/15.0L)*x - 128843.0L/30.0L) + 351263.0L/36.0L) - 93577.0L/8.0L) + 15563.0L/2.0L) - 81361.0L/30.0L) + 46109.0L/120.0L) + 1.0L/24.0L) - 1.0L/12.0L) - 1.0L/12.0L) + 1.0L/8.0L) + 1.0L/90.0L;
        poly_val[1] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-81991.0L/15.0L*x + 901901.0L/30.0L) - 2458841.0L/36.0L) + 655039.0L/8.0L) - 108941.0L/2.0L) + 569527.0L/30.0L) - 322763.0L/120.0L) - 1.0L/4.0L) + 1.0L/3.0L) + 1) - 1) - 3.0L/20.0L;
        poly_val[2] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((81991.0L/5.0L)*x - 901901.0L/10.0L) + 2458841.0L/12.0L) - 1965117.0L/8.0L) + 326823.0L/2.0L) - 569527.0L/10.0L) + 322763.0L/40.0L) + 5.0L/8.0L) - 5.0L/12.0L) - 13.0L/4.0L) + 13.0L/8.0L) + 3.0L/2.0L;
        poly_val[3] = pow(x, 2)*(pow(x, 2)*(x*(x*(x*(x*(x*(x*(-81991.0L/3.0L*x + 901901.0L/6.0L) - 12294205.0L/36.0L) + 3275195.0L/8.0L) - 544705.0L/2.0L) + 569527.0L/6.0L) - 322763.0L/24.0L) - 5.0L/6.0L) + 14.0L/3.0L) - 49.0L/18.0L;
        poly_val[4] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((81991.0L/3.0L)*x - 901901.0L/6.0L) + 12294205.0L/36.0L) - 3275195.0L/8.0L) + 544705.0L/2.0L) - 569527.0L/6.0L) + 322763.0L/24.0L) + 5.0L/8.0L) + 5.0L/12.0L) - 13.0L/4.0L) - 13.0L/8.0L) + 3.0L/2.0L;
        poly_val[5] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*(-81991.0L/5.0L*x + 901901.0L/10.0L) - 2458841.0L/12.0L) + 1965117.0L/8.0L) - 326823.0L/2.0L) + 569527.0L/10.0L) - 322763.0L/40.0L) - 1.0L/4.0L) - 1.0L/3.0L) + 1) + 1) - 3.0L/20.0L;
        poly_val[6] = x*(x*(x*(x*(x*(x*(x*(x*(x*(x*((81991.0L/15.0L)*x - 901901.0L/30.0L) + 2458841.0L/36.0L) - 655039.0L/8.0L) + 108941.0L/2.0L) - 569527.0L/30.0L) + 322763.0L/120.0L) + 1.0L/24.0L) + 1.0L/12.0L) - 1.0L/12.0L) - 1.0L/8.0L) + 1.0L/90.0L;
        poly_val[7] = pow(x, 5)*(x*(x*(x*(x*(x*(-11713.0L/15.0L*x + 128843.0L/30.0L) - 351263.0L/36.0L) + 93577.0L/8.0L) - 15563.0L/2.0L) + 81361.0L/30.0L) - 46109.0L/120.0L);
        break;
    }
}