NAMD
MsmMacros.h
Go to the documentation of this file.
1 #ifndef MSM_MACROS_H
2 #define MSM_MACROS_H
3
4 #define ROUNDUP_QUOTIENT(n, k) (((n)/(k)) + (((n)%(k)) != 0))
5
6 enum {
8  PERIODIC_VEC1 = 0x01,
9  PERIODIC_VEC2 = 0x02,
10  PERIODIC_VEC3 = 0x04,
12 };
13
14 enum {
24 };
25
26 enum {
61 };
62
73 #undef SPOLY
74 #define SPOLY(pg, pdg, ra, split) \
75  do { \
76  double _r = ra; /* _r=(r/a) */ \
77  double _s = _r*_r; /* _s=(r/a)^2 */ \
78  double _g = 0, _dg = 0; \
79  /* ASSERT(0 <= _s && _s <= 1); */ \
80  switch (split) { \
81  /* from section 5.1 of thesis */ \
82  case SPLIT_TAYLOR2: \
83  _g = 1 + (_s-1)*(-1./2 + (_s-1)*(3./8)); \
84  _dg = (2*_r)*(-1./2 + (_s-1)*(3./4)); \
85  break; \
86  case SPLIT_TAYLOR3: \
87  _g = 1 + (_s-1)*(-1./2 + (_s-1)*(3./8 + (_s-1)*(-5./16))); \
88  _dg = (2*_r)*(-1./2 + (_s-1)*(3./4 + (_s-1)*(-15./16))); \
89  break; \
90  case SPLIT_TAYLOR4: \
91  _g = 1 + (_s-1)*(-1./2 + (_s-1)*(3./8 + (_s-1)*(-5./16 \
92  + (_s-1)*(35./128)))); \
93  _dg = (2*_r)*(-1./2 + (_s-1)*(3./4 + (_s-1)*(-15./16 \
94  + (_s-1)*(35./32)))); \
95  break; \
96  case SPLIT_TAYLOR5: \
97  _g = 1 + (_s-1)*(-1./2 + (_s-1)*(3./8 + (_s-1)*(-5./16 \
98  + (_s-1)*(35./128 + (_s-1)*(-63./256))))); \
99  _dg = (2*_r)*(-1./2 + (_s-1)*(3./4 + (_s-1)*(-15./16 + (_s-1)*(35./32 \
100  + (_s-1)*(-315./256))))); \
101  break; \
102  case SPLIT_TAYLOR6: \
103  _g = 1 + (_s-1)*(-1./2 + (_s-1)*(3./8 + (_s-1)*(-5./16 \
104  + (_s-1)*(35./128 + (_s-1)*(-63./256 \
105  + (_s-1)*(231./1024)))))); \
106  _dg = (2*_r)*(-1./2 + (_s-1)*(3./4 + (_s-1)*(-15./16 + (_s-1)*(35./32 \
107  + (_s-1)*(-315./256 + (_s-1)*(693./512)))))); \
108  break; \
109  case SPLIT_TAYLOR7: \
110  _g = 1 + (_s-1)*(-1./2 + (_s-1)*(3./8 + (_s-1)*(-5./16 \
111  + (_s-1)*(35./128 + (_s-1)*(-63./256 \
112  + (_s-1)*(231./1024 + (_s-1)*(-429./2048))))))); \
113  _dg = (2*_r)*(-1./2 + (_s-1)*(3./4 + (_s-1)*(-15./16 + (_s-1)*(35./32 \
114  + (_s-1)*(-315./256 + (_s-1)*(693./512 \
115  + (_s-1)*(-3003./2048))))))); \
116  break; \
117  case SPLIT_TAYLOR8: \
118  _g = 1 + (_s-1)*(-1./2 + (_s-1)*(3./8 + (_s-1)*(-5./16 \
119  + (_s-1)*(35./128 + (_s-1)*(-63./256 \
120  + (_s-1)*(231./1024 + (_s-1)*(-429./2048 \
121  + (_s-1)*(6435./32768)))))))); \
122  _dg = (2*_r)*(-1./2 + (_s-1)*(3./4 + (_s-1)*(-15./16 + (_s-1)*(35./32 \
123  + (_s-1)*(-315./256 + (_s-1)*(693./512 \
124  + (_s-1)*(-3003./2048 + (_s-1)*(6435./4096)))))))); \
125  break; \
126  case SPLIT_TAYLOR1: \
127  _g = 1 + (_s-1)*(-1./2); \
128  _dg = (2*_r)*(-1./2); \
129  break; \
130  /* from section 5.2 of thesis */ \
131  case SPLIT_SIGMA2_3: /* the "perfect" smoothing */ \
132  _g = 2 + _s*(-2 + _r); \
133  _dg = _r*(-4 + _r*3); \
134  break; \
135  case SPLIT_SIGMA3_5: \
136  _g = 9./4 + _s*(-5./2 + _s*(9./4 - _r)); \
137  _dg = _r*(-5 + _s*(9 + _r*(-5))); \
138  break; \
139  case SPLIT_SIGMA4_6: \
140  _g = 21./8 + _s*(-35./8 + _s*(63./8 + _r*(-7 + _r*(15./8)))); \
141  _dg = _r*(-35./4 + _s*(63./2 + _r*(-35 + _r*(45./4)))); \
142  break; \
143  case SPLIT_SIGMA4_7: \
144  _g = 5./2 + _s*(-7./2 + _s*(7./2 + _s*(-5./2 + _r))); \
145  _dg = _r*(-7 + _s*(14 + _s*(-15 + _r*(7)))); \
146  break; \
147  case SPLIT_SIGMA5_8: \
148  _g = 45./16 + _s*(-21./4 + _s*(63./8 + _s*(-45./4 \
149  + _r*(9 + _r*(-35./16))))); \
150  _dg = _r*(-21./2 + _s*(63./2 + _s*(-135./2 \
151  + _r*(63 + _r*(-35./2))))); \
152  break; \
153  case SPLIT_SIGMA5_9: \
154  _g = 175./64 + _s*(-75./16 + _s*(189./32 + _s*(-75./16 \
155  + _s*(175./64 - _r)))); \
156  _dg = _r*(-75./8 + _s*(189./8 + _s*(-225./8 + _s*(175./8 \
157  + _r*(-9))))); \
158  break; \
159  case SPLIT_SIGMA6_9: \
160  _g = 25./8 + _s*(-15./2 + _s*(63./4 + _s*(-75./2 \
161  + _r*(45 + _r*(-175./8 + _r*4))))); \
162  _dg = _r*(-15 + _s*(63 + _s*(-225 \
163  + _r*(315 + _r*(-175 + _r*36))))); \
164  break; \
165  case SPLIT_SIGMA6_10: \
166  _g = 385./128 + _s*(-825./128 + _s*(693./64 + _s*(-825./64 \
167  + _s*(1925./128 + _r*(-11 + _r*(315./128)))))); \
168  _dg = _r*(-825./64 + _s*(693./16 + _s*(-2475./32 \
169  + _s*(1925./16 + _r*(-99 + _r*(1575./64)))))); \
170  break; \
171  case SPLIT_SIGMA6_11: \
172  _g = 189./64 + _s*(-385./64 + _s*(297./32 + _s*(-297./32 \
173  + _s*(385./64 + _s*(-189./64 + _r))))); \
174  _dg = _r*(-385./32 + _s*(297./8 + _s*(-891./16 + _s*(385./8 \
175  + _s*(-945./32 + _r*(11)))))); \
176  break; \
177  case SPLIT_SIGMA7_11: \
178  _g = 105./32 + _s*(-275./32 + _s*(297./16 + _s*(-495./16 \
179  + _s*(1925./32 + _r*(-66 + _r*(945./32 + _r*(-5))))))); \
180  _dg = _r*(-275./16 + _s*(297./4 + _s*(-1485./8 \
181  + _s*(1925./4 + _r*(-594 + _r*(4725./16 + _r*(-55))))))); \
182  break; \
183  case SPLIT_SIGMA7_12: \
184  _g = 819./256 + _s*(-1001./128 + _s*(3861./256 \
185  + _s*(-1287./64 + _s*(5005./256 + _s*(-2457./128 \
186  + _r*(13 + _r*(-693./256))))))); \
187  _dg = _r*(-1001./64 + _s*(3861./64 + _s*(-3861./32 \
188  + _s*(5005./32 + _s*(-12285./64 + _r*(143 \
189  + _r*(-2079./64))))))); \
190  break; \
191  case SPLIT_SIGMA7_13: \
192  _g = 1617./512 + _s*(-1911./256 + _s*(7007./512 + _s*(-2145./128 \
193  + _s*(7007./512 + _s*(-1911./256 + _s*(1617./512 - _r))))));\
194  _dg = _r*(-1911./128 + _s*(7007./128 + _s*(-6435./64 + _s*(7007./64 \
195  + _s*(-9555./128 + _s*(4851./128 + _r*(-13))))))); \
196  break; \
197  case SPLIT_SIGMA8_12: \
198  _g = 455./128 + _s*(-715./64 + _s*(3861./128 + _s*(-2145./32 \
199  + _s*(25025./128 + _r*(-286 + _r*(12285./64 + _r*(-65 \
200  + _r*(1155./128)))))))); \
201  _dg = _r*(-715./32 + _s*(3861./32 + _s*(-6435./16 \
202  + _s*(25025./16 + _r*(-2574 + _r*(61425./32 + _r*(-715 \
203  + _r*(3465./32)))))))); \
204  break; \
205  case SPLIT_SIGMA8_13: \
206  _g = 441./128 + _s*(-637./64 + _s*(3003./128 \
207  + _s*(-1287./32 + _s*(7007./128 + _s*(-5733./64 \
208  + _r*(91 + _r*(-4851./128 + _r*(6)))))))); \
209  _dg = _r*(-637./32 + _s*(3003./32 + _s*(-3861./16 \
210  + _s*(7007./16 + _s*(-28665./32 + _r*(1001 \
211  + _r*(-14553./32 + _r*(78)))))))); \
212  break; \
213  case SPLIT_SIGMA8_14: \
214  _g = 3465./1024 + _s*(-9555./1024 + _s*(21021./1024 \
215  + _s*(-32175./1024 + _s*(35035./1024 + _s*(-28665./1024 \
216  + _s*(24255./1024 + _r*(-15 + _r*(3003./1024)))))))); \
217  _dg = _r*(-9555./512 + _s*(21021./256 + _s*(-96525./512 \
218  + _s*(35035./128 + _s*(-143325./512 + _s*(72765./256 \
219  + _r*(-195 + _r*(21021./512)))))))); \
220  break; \
221  case SPLIT_SIGMA8_15: \
222  _g = 429./128 + _s*(-1155./128 + _s*(2457./128 + _s*(-3575./128 \
223  + _s*(3575./128 + _s*(-2457./128 + _s*(1155./128 \
224  + _s*(-429./128 + _r))))))); \
225  _dg = _r*(-1155./64 + _s*(2457./32 + _s*(-10725./64 \
226  + _s*(3575./16 + _s*(-12285./64 + _s*(3465./32 \
227  + _s*(-3003./64 + _r*(15)))))))); \
228  break; \
229  /* from section 5.3 of thesis */ \
230  case SPLIT_SIGMA2_6: \
231  _g = (31./16) + _s*(-23./16 + _s*(9./16 + _s*(-1./16))); \
232  _dg = (2*_r)*(-23./16 + _s*(9./8 + _s*(-3./16))); \
233  break; \
234  /* from section 5.4 of thesis */ \
235  case SPLIT_SWITCH1_2: \
236  if (_r > 1./2) { \
237  _g = 5./3 + _r + _s*(-3 + _r*(4./3)); \
238  _dg = 1 + _r*(-6 + _r*(4)); \
239  } \
240  else { \
241  _g = 11./6 - _s; \
242  _dg = _r*(-2); \
243  } \
244  break; \
245  case SPLIT_SWITCH3_4: \
246  if (_r > 3./4) { \
247  _g = 5./7 + _r*(27./7 + _r*(-41./7 + _r*(16./7))); \
248  _dg = 27./7 + _r*(-82./7 + _r*(48./7)); \
249  } \
250  else { \
251  _g = 47./28 + _s*(-5./7); \
252  _dg = _r*(-10./7); \
253  } \
254  break; \
255  case SPLIT_SWITCH7_8: \
256  if (_r > 7./8) { \
257  _g = -19./15 + _r*(49./5 + _r*(-59./5 + _r*(64./15))); \
258  _dg = 49./5 + _r*(-118./5 + _r*(64./5)); \
259  } \
260  else { \
261  _g = 191./120 + _s*(-3./5); \
262  _dg = _r*(-6./5); \
263  } \
264  break; \
265  default: \
266  return /* NL_MSM_ERROR_SUPPORT */; \
267  } \
268  *(pg) = _g; \
269  *(pdg) = _dg; \
270  } while (0)
271  /* closing ';' from use as function call */
272
273
279 #define STENCIL_1D(_phi, _delta, _approx) \
280  do { \
281  float *phi = _phi; \
282  float t = _delta; \
283  switch (_approx) { \
284  case APPROX_CUBIC: \
285  phi[0] = 0.5f * (1 - t) * (2 - t) * (2 - t); \
286  t--; \
287  phi[1] = (1 - t) * (1 + t - 1.5f * t * t); \
288  t--; \
289  phi[2] = (1 + t) * (1 - t - 1.5f * t * t); \
290  t--; \
291  phi[3] = 0.5f * (1 + t) * (2 + t) * (2 + t); \
292  break; \
293  case APPROX_QUINTIC: \
294  phi[0] = (1.f/24) * (1-t) * (2-t) * (3-t) * (3-t) * (4-t); \
295  t--; \
296  phi[1] = (1-t) * (2-t) * (3-t) * ((1.f/6) + t * (0.375f - (5.f/24)*t));\
297  t--; \
298  phi[2] = (1-t*t) * (2-t) * (0.5f + t * (0.25f - (5.f/12)*t)); \
299  t--; \
300  phi[3] = (1-t*t) * (2+t) * (0.5f - t * (0.25f + (5.f/12)*t)); \
301  t--; \
302  phi[4] = (1+t) * (2+t) * (3+t) * ((1.f/6) - t * (0.375f + (5.f/24)*t));\
303  t--; \
304  phi[5] = (1.f/24) * (1+t) * (2+t) * (3+t) * (3+t) * (4+t); \
305  break; \
306  case APPROX_QUINTIC2: \
307  phi[0] = (1.f/24) * (3-t) * (3-t) * (3-t) * (t-2) * (5*t-8); \
308  t--; \
309  phi[1] = (-1.f/24) * (2-t) * (t-1) * (-48+t*(153+t*(-114+t*25))); \
310  t--; \
311  phi[2] = (1.f/12) * (1-t) * (12+t*(12+t*(-3+t*(-38+t*25)))); \
312  t--; \
313  phi[3] = (1.f/12) * (1+t) * (12+t*(-12+t*(-3+t*(38+t*25)))); \
314  t--; \
315  phi[4] = (-1.f/24) * (2+t) * (t+1) * (48+t*(153+t*(114+t*25))); \
316  t--; \
317  phi[5] = (1.f/24) * (3+t) * (3+t) * (3+t) * (t+2) * (5*t+8); \
318  break; \
319  case APPROX_SEPTIC: \
320  phi[0] = (-1.f/720)*(t-1)*(t-2)*(t-3)*(t-4)*(t-4)*(t-5)*(t-6); \
321  t--; \
322  phi[1] = (1.f/720)*(t-1)*(t-2)*(t-3)*(t-4)*(t-5)*(-6+t*(-20+7*t)); \
323  t--; \
324  phi[2] = (-1.f/240)*(t*t-1)*(t-2)*(t-3)*(t-4)*(-10+t*(-12+7*t)); \
325  t--; \
326  phi[3] = (1.f/144)*(t*t-1)*(t*t-4)*(t-3)*(-12+t*(-4+7*t)); \
327  t--; \
328  phi[4] = (-1.f/144)*(t*t-1)*(t*t-4)*(t+3)*(-12+t*(4+7*t)); \
329  t--; \
330  phi[5] = (1.f/240)*(t*t-1)*(t+2)*(t+3)*(t+4)*(-10+t*(12+7*t)); \
331  t--; \
332  phi[6] = (-1.f/720)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(-6+t*(20+7*t)); \
333  t--; \
334  phi[7] = (1.f/720)*(t+1)*(t+2)*(t+3)*(t+4)*(t+4)*(t+5)*(t+6); \
335  break; \
336  case APPROX_SEPTIC3: \
337  phi[0] = (3632.f/5) + t*((-7456.f/5) + t*((58786.f/45) + t*(-633 \
338  + t*((26383.f/144) + t*((-22807.f/720) + t*((727.f/240) \
339  + t*(-89.f/720))))))); \
340  t--; \
341  phi[1] = -440 + t*((25949.f/20) + t*((-117131.f/72) + t*((2247.f/2) \
342  + t*((-66437.f/144) + t*((81109.f/720) + t*((-727.f/48) \
343  + t*(623.f/720))))))); \
344  t--; \
345  phi[2] = (138.f/5) + t*((-8617.f/60) + t*((12873.f/40) + t*((-791.f/2) \
346  + t*((4557.f/16) + t*((-9583.f/80) + t*((2181.f/80) \
347  + t*(-623.f/240))))))); \
348  t--; \
349  phi[3] = 1 + t*t*((-49.f/36) + t*t*((-959.f/144) + t*((2569.f/144) \
350  + t*((-727.f/48) + t*(623.f/144))))); \
351  t--; \
352  phi[4] = 1 + t*t*((-49.f/36) + t*t*((-959.f/144) + t*((-2569.f/144) \
353  + t*((-727.f/48) + t*(-623.f/144))))); \
354  t--; \
355  phi[5] = (138.f/5) + t*((8617.f/60) + t*((12873.f/40) + t*((791.f/2) \
356  + t*((4557.f/16) + t*((9583.f/80) + t*((2181.f/80) \
357  + t*(623.f/240))))))); \
358  t--; \
359  phi[6] = -440 + t*((-25949.f/20) + t*((-117131.f/72) + t*((-2247.f/2) \
360  + t*((-66437.f/144) + t*((-81109.f/720) + t*((-727.f/48) \
361  + t*(-623.f/720))))))); \
362  t--; \
363  phi[7] = (3632.f/5) + t*((7456.f/5) + t*((58786.f/45) + t*(633 \
364  + t*((26383.f/144) + t*((22807.f/720) + t*((727.f/240) \
365  + t*(89.f/720))))))); \
366  break; \
367  case APPROX_NONIC: \
368  phi[0] = (-1.f/40320)*(t-8)*(t-7)*(t-6)*(t-5)*(t-5)*(t-4)*(t-3)* \
369  (t-2)*(t-1); \
370  t--; \
371  phi[1] = (1.f/40320)*(t-7)*(t-6)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)* \
372  (-8+t*(-35+9*t)); \
373  t--; \
374  phi[2] = (-1.f/10080)*(t-6)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)* \
375  (-14+t*(-25+9*t)); \
376  t--; \
377  phi[3] = (1.f/1440)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)* \
378  (-6+t*(-5+3*t)); \
379  t--; \
380  phi[4] = (-1.f/2880)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)* \
381  (-20+t*(-5+9*t)); \
382  t--; \
383  phi[5] = (1.f/2880)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)* \
384  (-20+t*(5+9*t)); \
385  t--; \
386  phi[6] = (-1.f/1440)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)* \
387  (-6+t*(5+3*t)); \
388  t--; \
389  phi[7] = (1.f/10080)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+6)* \
390  (-14+t*(25+9*t)); \
391  t--; \
392  phi[8] = (-1.f/40320)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+6)*(t+7)* \
393  (-8+t*(35+9*t)); \
394  t--; \
395  phi[9] = (1.f/40320)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+5)*(t+6)* \
396  (t+7)*(t+8); \
397  break; \
398  case APPROX_NONIC4: \
399  phi[0] = 439375.f/7+t*(-64188125.f/504+t*(231125375.f/2016 \
400  +t*(-17306975.f/288+t*(7761805.f/384+t*(-2895587.f/640 \
401  +t*(129391.f/192+t*(-259715.f/4032+t*(28909.f/8064 \
402  +t*(-3569.f/40320))))))))); \
403  t--; \
404  phi[1] = -56375+t*(8314091.f/56+t*(-49901303.f/288+t*(3763529.f/32 \
405  +t*(-19648027.f/384+t*(9469163.f/640+t*(-545977.f/192 \
406  +t*(156927.f/448+t*(-28909.f/1152 \
407  +t*(3569.f/4480))))))))); \
408  t--; \
409  phi[2] = 68776.f/7+t*(-1038011.f/28+t*(31157515.f/504+t*(-956669.f/16 \
410  +t*(3548009.f/96+t*(-2422263.f/160+t*(197255.f/48 \
411  +t*(-19959.f/28+t*(144545.f/2016 \
412  +t*(-3569.f/1120))))))))); \
413  t--; \
414  phi[3] = -154+t*(12757.f/12+t*(-230123.f/72+t*(264481.f/48 \
415  +t*(-576499.f/96+t*(686147.f/160+t*(-96277.f/48 \
416  +t*(14221.f/24+t*(-28909.f/288+t*(3569.f/480))))))))); \
417  t--; \
418  phi[4] = 1+t*t*(-205.f/144+t*t*(91.f/192+t*(-6181.f/320 \
419  +t*(6337.f/96+t*(-2745.f/32+t*(28909.f/576 \
420  +t*(-3569.f/320))))))); \
421  t--; \
422  phi[5] = 1+t*t*(-205.f/144+t*t*(91.f/192+t*(6181.f/320 \
423  +t*(6337.f/96+t*(2745.f/32+t*(28909.f/576 \
424  +t*(3569.f/320))))))); \
425  t--; \
426  phi[6] = -154+t*(-12757.f/12+t*(-230123.f/72+t*(-264481.f/48 \
427  +t*(-576499.f/96+t*(-686147.f/160+t*(-96277.f/48 \
428  +t*(-14221.f/24+t*(-28909.f/288+t*(-3569.f/480))))))))); \
429  t--; \
430  phi[7] = 68776.f/7+t*(1038011.f/28+t*(31157515.f/504+t*(956669.f/16 \
431  +t*(3548009.f/96+t*(2422263.f/160+t*(197255.f/48 \
432  +t*(19959.f/28+t*(144545.f/2016+t*(3569.f/1120))))))))); \
433  t--; \
434  phi[8] = -56375+t*(-8314091.f/56+t*(-49901303.f/288+t*(-3763529.f/32 \
435  +t*(-19648027.f/384+t*(-9469163.f/640+t*(-545977.f/192 \
436  +t*(-156927.f/448+t*(-28909.f/1152 \
437  +t*(-3569.f/4480))))))))); \
438  t--; \
439  phi[9] = 439375.f/7+t*(64188125.f/504+t*(231125375.f/2016 \
440  +t*(17306975.f/288+t*(7761805.f/384+t*(2895587.f/640 \
441  +t*(129391.f/192+t*(259715.f/4032+t*(28909.f/8064 \
442  +t*(3569.f/40320))))))))); \
443  break; \
444  case APPROX_BSPLINE: \
445  phi[0] = (1.f/6) * (2-t) * (2-t) * (2-t); \
446  t--; \
447  phi[1] = (2.f/3) + t*t*(-1 + 0.5f*t); \
448  t--; \
449  phi[2] = (2.f/3) + t*t*(-1 - 0.5f*t); \
450  t--; \
451  phi[3] = (1.f/6) * (2+t) * (2+t) * (2+t); \
452  break; \
453  default: \
454  return /* XXX NL_MSM_ERROR_SUPPORT */; \
455  } \
456  } while (0)
457  /* closing ';' from use as function call */
458
459
467 #define D_STENCIL_1D(_dphi, _phi, _h_1, _delta, _approx) \
468  do { \
469  float *dphi = _dphi; \
470  float *phi = _phi; \
471  float h_1 = _h_1; \
472  float t = _delta; \
473  switch (_approx) { \
474  case APPROX_CUBIC: \
475  phi[0] = 0.5f * (1 - t) * (2 - t) * (2 - t); \
476  dphi[0] = (1.5f * t - 2) * (2 - t) * h_1; \
477  t--; \
478  phi[1] = (1 - t) * (1 + t - 1.5f * t * t); \
479  dphi[1] = (-5 + 4.5f * t) * t * h_1; \
480  t--; \
481  phi[2] = (1 + t) * (1 - t - 1.5f * t * t); \
482  dphi[2] = (-5 - 4.5f * t) * t * h_1; \
483  t--; \
484  phi[3] = 0.5f * (1 + t) * (2 + t) * (2 + t); \
485  dphi[3] = (1.5f * t + 2) * (2 + t) * h_1; \
486  break; \
487  case APPROX_QUINTIC: \
488  phi[0] = (1.f/24) * (1-t) * (2-t) * (3-t) * (3-t) * (4-t); \
489  dphi[0] = ((-1.f/24) * ((3-t) * (3-t) * (14 + t * (-14 + 3*t)) \
490  + 2 * (1-t) * (2-t) * (3-t) * (4-t))) * h_1; \
491  t--; \
492  phi[1] = (1-t) * (2-t) * (3-t) * ((1.f/6) + t * (0.375f - (5.f/24)*t));\
493  dphi[1] = (-((1.f/6) + t * (0.375f - (5.f/24)*t)) * (11 + t * (-12 + 3*t))\
494  + (1-t) * (2-t) * (3-t) * (0.375f - (5.f/12)*t)) * h_1; \
495  t--; \
496  phi[2] = (1-t*t) * (2-t) * (0.5f + t * (0.25f - (5.f/12)*t)); \
497  dphi[2] = (-(0.5f + t * (0.25f - (5.f/12)*t)) * (1 + t * (4 - 3*t)) \
498  + (1-t*t) * (2-t) * (0.25f - (5.f/6)*t)) * h_1; \
499  t--; \
500  phi[3] = (1-t*t) * (2+t) * (0.5f - t * (0.25f + (5.f/12)*t)); \
501  dphi[3] = ((0.5f + t * (-0.25f - (5.f/12)*t)) * (1 + t * (-4 - 3*t)) \
502  - (1-t*t) * (2+t) * (0.25f + (5.f/6)*t)) * h_1; \
503  t--; \
504  phi[4] = (1+t) * (2+t) * (3+t) * ((1.f/6) - t * (0.375f + (5.f/24)*t));\
505  dphi[4] = (((1.f/6) + t * (-0.375f - (5.f/24)*t)) * (11 + t * (12 + 3*t)) \
506  - (1+t) * (2+t) * (3+t) * (0.375f + (5.f/12)*t)) * h_1; \
507  t--; \
508  phi[5] = (1.f/24) * (1+t) * (2+t) * (3+t) * (3+t) * (4+t); \
509  dphi[5] = ((1.f/24) * ((3+t) * (3+t) * (14 + t * (14 + 3*t)) \
510  + 2 * (1+t) * (2+t) * (3+t) * (4+t))) * h_1; \
511  break; \
512  case APPROX_QUINTIC2: \
513  phi[0] = (1.f/24) * (3-t) * (3-t) * (3-t) * (t-2) * (5*t-8); \
514  dphi[0] = ((1.f/24) * (3-t) * (3-t) * ((3-t)*(5*t-8) - 3*(t-2)*(5*t-8) \
515  + 5*(t-2)*(3-t))) * h_1; \
516  t--; \
517  phi[1] = (-1.f/24) * (2-t) * (t-1) * (-48+t*(153+t*(-114+t*25))); \
518  dphi[1] = ((-1.f/24) * ((2-t)*(-48+t*(153+t*(-114+t*25))) - (t-1)* \
519  (-48+t*(153+t*(-114+t*25))) \
520  + (2-t)*(t-1)*(153+t*(-228+t*75)))) * h_1; \
521  t--; \
522  phi[2] = (1.f/12) * (1-t) * (12+t*(12+t*(-3+t*(-38+t*25)))); \
523  dphi[2] = ((1.f/12) * (-(12+t*(12+t*(-3+t*(-38+t*25)))) \
524  + (1-t)*(12+t*(-6+t*(-114+t*100))))) * h_1; \
525  t--; \
526  phi[3] = (1.f/12) * (1+t) * (12+t*(-12+t*(-3+t*(38+t*25)))); \
527  dphi[3] = ((1.f/12) * ((12+t*(-12+t*(-3+t*(38+t*25)))) \
528  + (1+t)*(-12+t*(-6+t*(114+t*100))))) * h_1; \
529  t--; \
530  phi[4] = (-1.f/24) * (2+t) * (t+1) * (48+t*(153+t*(114+t*25))); \
531  dphi[4] = ((-1.f/24) * ((2+t)*(48+t*(153+t*(114+t*25))) + (t+1)* \
532  (48+t*(153+t*(114+t*25))) \
533  + (2+t)*(t+1)*(153+t*(228+t*75)))) * h_1; \
534  t--; \
535  phi[5] = (1.f/24) * (3+t) * (3+t) * (3+t) * (t+2) * (5*t+8); \
536  dphi[5] = ((1.f/24) * (3+t) * (3+t) * ((3+t)*(5*t+8) + 3*(t+2)*(5*t+8) \
537  + 5*(t+2)*(3+t))) * h_1; \
538  break; \
539  case APPROX_SEPTIC: \
540  phi[0] = (-1.f/720)*(t-1)*(t-2)*(t-3)*(t-4)*(t-4)*(t-5)*(t-6); \
541  dphi[0] = (-1.f/720)*(t-4)*(-1944+t*(3644+t*(-2512+t*(807 \
542  +t*(-122+t*7))))) * h_1; \
543  t--; \
544  phi[1] = (1.f/720)*(t-1)*(t-2)*(t-3)*(t-4)*(t-5)*(-6+t*(-20+7*t)); \
545  dphi[1] = (1.f/720)*(756+t*(-9940+t*(17724+t*(-12740+t*(4445 \
546  +t*(-750+t*49)))))) * h_1; \
547  t--; \
548  phi[2] = (-1.f/240)*(t*t-1)*(t-2)*(t-3)*(t-4)*(-10+t*(-12+7*t)); \
549  dphi[2] = (-1.f/240)*(-28+t*(1260+t*(-756+t*(-1260+t*(1365 \
550  +t*(-450+t*49)))))) * h_1; \
551  t--; \
552  phi[3] = (1.f/144)*(t*t-1)*(t*t-4)*(t-3)*(-12+t*(-4+7*t)); \
553  dphi[3] = (1.f/144)*t*(-560+t*(84+t*(644+t*(-175+t*(-150+t*49))))) * \
554  h_1; \
555  t--; \
556  phi[4] = (-1.f/144)*(t*t-1)*(t*t-4)*(t+3)*(-12+t*(4+7*t)); \
557  dphi[4] = (-1.f/144)*t*(560+t*(84+t*(-644+t*(-175+t*(150+t*49))))) * \
558  h_1; \
559  t--; \
560  phi[5] = (1.f/240)*(t*t-1)*(t+2)*(t+3)*(t+4)*(-10+t*(12+7*t)); \
561  dphi[5] = (1.f/240)*(-28+t*(-1260+t*(-756+t*(1260+t*(1365 \
562  +t*(450+t*49)))))) * h_1; \
563  t--; \
564  phi[6] = (-1.f/720)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(-6+t*(20+7*t)); \
565  dphi[6] = (-1.f/720)*(756+t*(9940+t*(17724+t*(12740+t*(4445 \
566  +t*(750+t*49)))))) * h_1; \
567  t--; \
568  phi[7] = (1.f/720)*(t+1)*(t+2)*(t+3)*(t+4)*(t+4)*(t+5)*(t+6); \
569  dphi[7] = (1.f/720)*(t+4)*(1944+t*(3644+t*(2512+t*(807 \
570  +t*(122+t*7))))) * h_1; \
571  break; \
572  case APPROX_SEPTIC3: \
573  phi[0] = (3632.f/5) + t*((-7456.f/5) + t*((58786.f/45) + t*(-633 \
574  + t*((26383.f/144) + t*((-22807.f/720) + t*((727.f/240) \
575  + t*(-89.f/720))))))); \
576  dphi[0] = ((-7456.f/5) + t*((117572.f/45) + t*(-1899 + t*((26383.f/36) \
577  + t*((-22807.f/144) + t*((727.f/40) + t*(-623.f/720)))))))*h_1; \
578  t--; \
579  phi[1] = -440 + t*((25949.f/20) + t*((-117131.f/72) + t*((2247.f/2) \
580  + t*((-66437.f/144) + t*((81109.f/720) + t*((-727.f/48) \
581  + t*(623.f/720))))))); \
582  dphi[1] = ((25949.f/20) + t*((-117131.f/36) + t*((6741.f/2) \
583  + t*((-66437.f/36) + t*((81109.f/144) + t*((-727.f/8) \
584  + t*(4361.f/720))))))) * h_1; \
585  t--; \
586  phi[2] = (138.f/5) + t*((-8617.f/60) + t*((12873.f/40) + t*((-791.f/2) \
587  + t*((4557.f/16) + t*((-9583.f/80) + t*((2181.f/80) \
588  + t*(-623.f/240))))))); \
589  dphi[2] = ((-8617.f/60) + t*((12873.f/20) + t*((-2373.f/2) + t*((4557.f/4) \
590  + t*((-9583.f/16) + t*((6543.f/40) + t*(-4361.f/240)))))))*h_1; \
591  t--; \
592  phi[3] = 1 + t*t*((-49.f/36) + t*t*((-959.f/144) + t*((2569.f/144) \
593  + t*((-727.f/48) + t*(623.f/144))))); \
594  dphi[3] = (t*((-49.f/18) + t*t*((-959.f/36) + t*((12845.f/144) \
595  + t*((-727.f/8) + t*(4361.f/144)))))) * h_1; \
596  t--; \
597  phi[4] = 1 + t*t*((-49.f/36) + t*t*((-959.f/144) + t*((-2569.f/144) \
598  + t*((-727.f/48) + t*(-623.f/144))))); \
599  dphi[4] = (t*((-49.f/18) + t*t*((-959.f/36) + t*((-12845.f/144) \
600  + t*((-727.f/8) + t*(-4361.f/144)))))) * h_1; \
601  t--; \
602  phi[5] = (138.f/5) + t*((8617.f/60) + t*((12873.f/40) + t*((791.f/2) \
603  + t*((4557.f/16) + t*((9583.f/80) + t*((2181.f/80) \
604  + t*(623.f/240))))))); \
605  dphi[5] = ((8617.f/60) + t*((12873.f/20) + t*((2373.f/2) + t*((4557.f/4) \
606  + t*((9583.f/16) + t*((6543.f/40) + t*(4361.f/240)))))))*h_1; \
607  t--; \
608  phi[6] = -440 + t*((-25949.f/20) + t*((-117131.f/72) + t*((-2247.f/2) \
609  + t*((-66437.f/144) + t*((-81109.f/720) + t*((-727.f/48) \
610  + t*(-623.f/720))))))); \
611  dphi[6] = ((-25949.f/20) + t*((-117131.f/36) + t*((-6741.f/2) \
612  + t*((-66437.f/36) + t*((-81109.f/144) + t*((-727.f/8) \
613  + t*(-4361.f/720))))))) * h_1; \
614  t--; \
615  phi[7] = (3632.f/5) + t*((7456.f/5) + t*((58786.f/45) + t*(633 \
616  + t*((26383.f/144) + t*((22807.f/720) + t*((727.f/240) \
617  + t*(89.f/720))))))); \
618  dphi[7] = ((7456.f/5) + t*((117572.f/45) + t*(1899 + t*((26383.f/36) \
619  + t*((22807.f/144) + t*((727.f/40) + t*(623.f/720)))))))*h_1; \
620  break; \
621  case APPROX_NONIC: \
622  phi[0] = (-1.f/40320)*(t-8)*(t-7)*(t-6)*(t-5)*(t-5)*(t-4)*(t-3)* \
623  (t-2)*(t-1); \
624  dphi[0] = (-1.f/40320)*(t-5)*(-117648+t*(256552+t*(-221416 \
625  +t*(99340+t*(-25261+t*(3667+t*(-283+t*9)))))))*h_1; \
626  t--; \
627  phi[1] = (1.f/40320)*(t-7)*(t-6)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)* \
628  (-8+t*(-35+9*t)); \
629  dphi[1] = (1.f/40320)*(71856+t*(-795368+t*(1569240+t*(-1357692 \
630  +t*(634725+t*(-172116+t*(27090+t*(-2296+t*81))))))))*h_1; \
631  t--; \
632  phi[2] = (-1.f/10080)*(t-6)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)* \
633  (-14+t*(-25+9*t)); \
634  dphi[2] = (1.f/10080)*(3384+t*(-69080+t*(55026 \
635  +t*(62580+t*(-99225+t*(51660+t*(-13104+t*(1640 \
636  +t*(-81)))))))))*h_1; \
637  t--; \
638  phi[3] = (1.f/1440)*(t-5)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)* \
639  (-6+t*(-5+3*t)); \
640  dphi[3] = (1.f/1440)*(72+t*(-6344+t*(2070 \
641  +t*(7644+t*(-4725+t*(-828+t*(1260+t*(-328+t*27))))))))*h_1; \
642  t--; \
643  phi[4] = (-1.f/2880)*(t-4)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)* \
644  (-20+t*(-5+9*t)); \
645  dphi[4] = (-1.f/2880)*t*(10792+t*(-972+t*(-12516 \
646  +t*(2205+t*(3924+t*(-882+t*(-328+t*81)))))))*h_1; \
647  t--; \
648  phi[5] = (1.f/2880)*(t-3)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)* \
649  (-20+t*(5+9*t)); \
650  dphi[5] = (1.f/2880)*t*(-10792+t*(-972+t*(12516 \
651  +t*(2205+t*(-3924+t*(-882+t*(328+t*81)))))))*h_1; \
652  t--; \
653  phi[6] = (-1.f/1440)*(t-2)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)* \
654  (-6+t*(5+3*t)); \
655  dphi[6] = (1.f/1440)*(-72+t*(-6344+t*(-2070 \
656  +t*(7644+t*(4725+t*(-828+t*(-1260+t*(-328+t*(-27)))))))))*h_1; \
657  t--; \
658  phi[7] = (1.f/10080)*(t-1)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+6)* \
659  (-14+t*(25+9*t)); \
660  dphi[7] = (1.f/10080)*(-3384+t*(-69080+t*(-55026 \
661  +t*(62580+t*(99225+t*(51660+t*(13104+t*(1640+t*81))))))))*h_1; \
662  t--; \
663  phi[8] = (-1.f/40320)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+6)*(t+7)* \
664  (-8+t*(35+9*t)); \
665  dphi[8] = (-1.f/40320)*(71856+t*(795368+t*(1569240 \
666  +t*(1357692+t*(634725+t*(172116+t*(27090+t*(2296 \
667  +t*81))))))))*h_1; \
668  t--; \
669  phi[9] = (1.f/40320)*(t+1)*(t+2)*(t+3)*(t+4)*(t+5)*(t+5)*(t+6)* \
670  (t+7)*(t+8); \
671  dphi[9] = (1.f/40320)*(t+5)*(117648+t*(256552+t*(221416 \
672  +t*(99340+t*(25261+t*(3667+t*(283+t*9)))))))*h_1; \
673  break; \
674  case APPROX_NONIC4: \
675  phi[0] = 439375.f/7+t*(-64188125.f/504+t*(231125375.f/2016 \
676  +t*(-17306975.f/288+t*(7761805.f/384+t*(-2895587.f/640 \
677  +t*(129391.f/192+t*(-259715.f/4032+t*(28909.f/8064 \
678  +t*(-3569.f/40320))))))))); \
679  dphi[0] = (-64188125.f/504+t*(231125375.f/1008 \
680  +t*(-17306975.f/96+t*(7761805.f/96+t*(-2895587.f/128 \
681  +t*(129391.f/32+t*(-259715.f/576+t*(28909.f/1008 \
682  +t*(-3569.f/4480)))))))))*h_1; \
683  t--; \
684  phi[1] = -56375+t*(8314091.f/56+t*(-49901303.f/288+t*(3763529.f/32 \
685  +t*(-19648027.f/384+t*(9469163.f/640+t*(-545977.f/192 \
686  +t*(156927.f/448+t*(-28909.f/1152 \
687  +t*(3569.f/4480))))))))); \
688  dphi[1] = (8314091.f/56+t*(-49901303.f/144+t*(11290587.f/32 \
689  +t*(-19648027.f/96+t*(9469163.f/128+t*(-545977.f/32 \
690  +t*(156927.f/64+t*(-28909.f/144 \
691  +t*(32121.f/4480)))))))))*h_1; \
692  t--; \
693  phi[2] = 68776.f/7+t*(-1038011.f/28+t*(31157515.f/504+t*(-956669.f/16 \
694  +t*(3548009.f/96+t*(-2422263.f/160+t*(197255.f/48 \
695  +t*(-19959.f/28+t*(144545.f/2016 \
696  +t*(-3569.f/1120))))))))); \
697  dphi[2] = (-1038011.f/28+t*(31157515.f/252+t*(-2870007.f/16 \
698  +t*(3548009.f/24+t*(-2422263.f/32+t*(197255.f/8 \
699  +t*(-19959.f/4+t*(144545.f/252 \
700  +t*(-32121.f/1120)))))))))*h_1; \
701  t--; \
702  phi[3] = -154+t*(12757.f/12+t*(-230123.f/72+t*(264481.f/48 \
703  +t*(-576499.f/96+t*(686147.f/160+t*(-96277.f/48 \
704  +t*(14221.f/24+t*(-28909.f/288+t*(3569.f/480))))))))); \
705  dphi[3] = (12757.f/12+t*(-230123.f/36+t*(264481.f/16 \
706  +t*(-576499.f/24+t*(686147.f/32+t*(-96277.f/8 \
707  +t*(99547.f/24+t*(-28909.f/36 \
708  +t*(10707.f/160)))))))))*h_1; \
709  t--; \
710  phi[4] = 1+t*t*(-205.f/144+t*t*(91.f/192+t*(-6181.f/320 \
711  +t*(6337.f/96+t*(-2745.f/32+t*(28909.f/576 \
712  +t*(-3569.f/320))))))); \
713  dphi[4] = t*(-205.f/72+t*t*(91.f/48+t*(-6181.f/64 \
714  +t*(6337.f/16+t*(-19215.f/32+t*(28909.f/72 \
715  +t*(-32121.f/320)))))))*h_1; \
716  t--; \
717  phi[5] = 1+t*t*(-205.f/144+t*t*(91.f/192+t*(6181.f/320 \
718  +t*(6337.f/96+t*(2745.f/32+t*(28909.f/576 \
719  +t*(3569.f/320))))))); \
720  dphi[5] = t*(-205.f/72+t*t*(91.f/48+t*(6181.f/64 \
721  +t*(6337.f/16+t*(19215.f/32+t*(28909.f/72 \
722  +t*(32121.f/320)))))))*h_1; \
723  t--; \
724  phi[6] = -154+t*(-12757.f/12+t*(-230123.f/72+t*(-264481.f/48 \
725  +t*(-576499.f/96+t*(-686147.f/160+t*(-96277.f/48 \
726  +t*(-14221.f/24+t*(-28909.f/288+t*(-3569.f/480))))))))); \
727  dphi[6] = (-12757.f/12+t*(-230123.f/36+t*(-264481.f/16 \
728  +t*(-576499.f/24+t*(-686147.f/32+t*(-96277.f/8 \
729  +t*(-99547.f/24+t*(-28909.f/36 \
730  +t*(-10707.f/160)))))))))*h_1; \
731  t--; \
732  phi[7] = 68776.f/7+t*(1038011.f/28+t*(31157515.f/504+t*(956669.f/16 \
733  +t*(3548009.f/96+t*(2422263.f/160+t*(197255.f/48 \
734  +t*(19959.f/28+t*(144545.f/2016+t*(3569.f/1120))))))))); \
735  dphi[7] = (1038011.f/28+t*(31157515.f/252+t*(2870007.f/16 \
736  +t*(3548009.f/24+t*(2422263.f/32+t*(197255.f/8 \
737  +t*(19959.f/4+t*(144545.f/252 \
738  +t*(32121.f/1120)))))))))*h_1; \
739  t--; \
740  phi[8] = -56375+t*(-8314091.f/56+t*(-49901303.f/288+t*(-3763529.f/32 \
741  +t*(-19648027.f/384+t*(-9469163.f/640+t*(-545977.f/192 \
742  +t*(-156927.f/448+t*(-28909.f/1152 \
743  +t*(-3569.f/4480))))))))); \
744  dphi[8] = (-8314091.f/56+t*(-49901303.f/144+t*(-11290587.f/32 \
745  +t*(-19648027.f/96+t*(-9469163.f/128+t*(-545977.f/32 \
746  +t*(-156927.f/64+t*(-28909.f/144 \
747  +t*(-32121.f/4480)))))))))*h_1; \
748  t--; \
749  phi[9] = 439375.f/7+t*(64188125.f/504+t*(231125375.f/2016 \
750  +t*(17306975.f/288+t*(7761805.f/384+t*(2895587.f/640 \
751  +t*(129391.f/192+t*(259715.f/4032+t*(28909.f/8064 \
752  +t*(3569.f/40320))))))))); \
753  dphi[9] = (64188125.f/504+t*(231125375.f/1008 \
754  +t*(17306975.f/96+t*(7761805.f/96+t*(2895587.f/128 \
755  +t*(129391.f/32+t*(259715.f/576+t*(28909.f/1008 \
756  +t*(3569.f/4480)))))))))*h_1; \
757  break; \
758  case APPROX_BSPLINE: \
759  phi[0] = (1.f/6) * (2-t) * (2-t) * (2-t); \
760  dphi[0] = -0.5f * (2-t) * (2-t) * h_1; \
761  t--; \
762  phi[1] = (2.f/3) + t*t*(-1 + 0.5f*t); \
763  dphi[1] = t*(-2 + 1.5f*t) * h_1; \
764  t--; \
765  phi[2] = (2.f/3) + t*t*(-1 - 0.5f*t); \
766  dphi[2] = t*(-2 - 1.5f*t) * h_1; \
767  t--; \
768  phi[3] = (1.f/6) * (2+t) * (2+t) * (2+t); \
769  dphi[3] = 0.5f * (2+t) * (2+t) * h_1; \
770  break; \
771  default: \
772  return /* XXX NL_MSM_ERROR_SUPPORT */; \
773  } \
774  } while (0)
775  /* closing ';' from use as function call */
776
777
778 #endif // MSM_MACROS_H