pspline 5.0.5 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -5
  3. data/README.md +44 -43
  4. data/Rakefile +6 -6
  5. data/bin/console +14 -14
  6. data/bin/setup +8 -8
  7. data/ext/pspline/basis.cpp +394 -351
  8. data/ext/pspline/example/exbspline.rb +57 -57
  9. data/ext/pspline/example/excspline.rb +57 -57
  10. data/ext/pspline/example/exdspline.rb +55 -55
  11. data/ext/pspline/example/exfspline.rb +44 -44
  12. data/ext/pspline/example/exfspline1.rb +40 -40
  13. data/ext/pspline/example/exfspline2.rb +68 -68
  14. data/ext/pspline/example/exfspline3.rb +64 -64
  15. data/ext/pspline/example/exmspline.rb +68 -68
  16. data/ext/pspline/example/expspline.rb +29 -29
  17. data/ext/pspline/example/expspline1.rb +29 -29
  18. data/ext/pspline/example/expspline2.rb +47 -47
  19. data/ext/pspline/example/exqspline.rb +31 -31
  20. data/ext/pspline/example/exqspline1.rb +31 -31
  21. data/ext/pspline/example/exqspline2.rb +50 -50
  22. data/ext/pspline/example/exqspline3.rb +51 -51
  23. data/ext/pspline/example/exqspline4.rb +35 -35
  24. data/ext/pspline/example/exrspline.rb +34 -34
  25. data/ext/pspline/example/exrspline1.rb +34 -34
  26. data/ext/pspline/example/exrspline2.rb +44 -44
  27. data/ext/pspline/example/exsspline.rb +35 -35
  28. data/ext/pspline/example/exsspline1.rb +35 -35
  29. data/ext/pspline/example/extspline.rb +54 -54
  30. data/ext/pspline/extconf.rb +7 -7
  31. data/ext/pspline/fft.cpp +27 -552
  32. data/ext/pspline/include/basis/basis.h +145 -137
  33. data/ext/pspline/include/basis/fft.h +188 -152
  34. data/ext/pspline/include/basis/fft_complex.h +215 -0
  35. data/ext/pspline/include/basis/fft_real.h +625 -0
  36. data/ext/pspline/include/basis/gabs.h +35 -0
  37. data/ext/pspline/include/basis/marray_class_ext.h +568 -0
  38. data/ext/pspline/include/basis/marray_ext.h +100 -0
  39. data/ext/pspline/include/basis/matrix_luc_ext.h +300 -0
  40. data/ext/pspline/include/basis/matrix_lud_ext.h +298 -0
  41. data/ext/pspline/include/basis/poly.h +454 -0
  42. data/ext/pspline/include/basis/poly_array.h +1030 -1568
  43. data/ext/pspline/include/basis/pspline.h +806 -642
  44. data/ext/pspline/include/basis/real.h +526 -0
  45. data/ext/pspline/include/basis/real_inline.h +442 -0
  46. data/ext/pspline/include/basis/spline.h +83 -0
  47. data/ext/pspline/include/basis/uspline.h +251 -210
  48. data/ext/pspline/include/basis/util.h +122 -656
  49. data/ext/pspline/include/bspline.h +71 -377
  50. data/ext/pspline/include/bspline_Config.h +8 -2
  51. data/ext/pspline/include/real_config.h +3 -0
  52. data/ext/pspline/pspline.cpp +1236 -1038
  53. data/ext/pspline/real.cpp +1607 -0
  54. data/ext/pspline/real_const.cpp +585 -0
  55. data/lib/pspline.rb +71 -71
  56. data/lib/pspline/version.rb +1 -1
  57. data/pspline.gemspec +25 -25
  58. metadata +17 -5
  59. data/ext/pspline/plotsub.cpp +0 -139
  60. data/ext/pspline/util.cpp +0 -483
@@ -1,377 +1,71 @@
1
- #ifndef _BSPLINE_H_INCLUDED_
2
- #define _BSPLINE_H_INCLUDED_
3
-
4
- #include <stddef.h>
5
- #include <stdlib.h>
6
- #include <stdio.h>
7
- #include <assert.h>
8
- #include "bspline_Config.h"
9
- #include "basis/util.h"
10
- #include "basis/poly_array.h"
11
- #include "basis/basis.h"
12
- #include "basis/pspline.h"
13
- #include "basis/uspline.h"
14
-
15
- /*******************************************************************************
16
- make object utility
17
-
18
- 1. poly<T,N> = <{TN,...,T1},T0>
19
-
20
- *******************************************************************************/
21
-
22
- // make_alias<T,N=1>(z) = @<{z0,...,zN-1},zN>
23
-
24
- template<typename T, int N = 1> inline
25
- poly<T> make_alias(T *z)
26
- {
27
- return poly<T>(z, N);
28
- }
29
-
30
- // make_atom<T>(a) = @<a0>
31
-
32
- template <typename T>
33
- poly<T> make_atom(T *a)
34
- {
35
- return poly<T>(a, 0);
36
- }
37
-
38
- // make_poly<T,tN,...,t1>(t0=1) = <{tN,...,t1},t0>
39
-
40
- template<typename T, T... args> inline
41
- poly<T> make_poly(T a = 1)
42
- {
43
- int N = sizeof...(args);
44
- T s[] = {args...};
45
- if (N == 0)
46
- return poly<T>(0, a);
47
- else
48
- return poly<T>(N, s, a);
49
- }
50
-
51
- // make_poly<T,N>(tN,...,t1,t0) = <{tN,...,t1},t0>
52
-
53
- template<typename T, int N, class... Args> inline
54
- poly<T> make_poly(T car, Args... cdr)
55
- {
56
- return poly<T>(N, car, cdr...);
57
- }
58
-
59
- // make_poly<T,N>(s) = <{s0,...,sN-1},sN>
60
-
61
- template<typename T, int N = 1> inline
62
- poly<T> make_poly(const T *s)
63
- {
64
- return poly<T>(N, s);
65
- }
66
-
67
- // make_poly<T,N>(s, a0) = <{s0,...,sN-1},a0>
68
-
69
- template<typename T, int N = 1> inline
70
- poly<T> make_poly(const T *s, T a)
71
- {
72
- return poly<T>(N, s, a);
73
- }
74
-
75
- /*******************************************************************************
76
-
77
- 2. poly_array<T,N> = {<{SN,...,S1},S0>,[T...]}
78
-
79
- *******************************************************************************/
80
-
81
- // make_array<T,SN,...,S1,S0>(t) = [<{SN,...,S1},S0>,[t0,...]]
82
-
83
- template<class T, int... args> inline
84
- poly_array<T> make_array(const T *dat)
85
- {
86
- int N = sizeof...(args) - 1;
87
- int s[] = {args...};
88
- return poly_array<T>(dat, N, s);
89
- }
90
-
91
- // make_array<T,N>(t,SN,...,S1,S0) = [<{SN,...,S1},S0>,[t0,...]]
92
-
93
- template<class T, int N, class... Args> inline
94
- poly_array<T> make_array(const T *dat, int car, Args... cdr)
95
- {
96
- int i = sizeof...(cdr), n = i - N;
97
- int s[] = {car, cdr...}, z[N+1];
98
- for (i = 0; i <= N; ++i, ++n)
99
- if (n < 0) z[i] = 1;
100
- else z[i] = s[n];
101
- return poly_array<T>(dat, N, z);
102
- }
103
-
104
- // make_array<T,N>(t,<{SN,...,S1},S0>) = [<{SN,...,S1},S0>,[t0,...]]
105
-
106
- template<class T, int N> inline
107
- poly_array<T> make_array(const T *dat, const poly<int>& e)
108
- {
109
- return poly_array<T>(dat, e);
110
- }
111
-
112
- // sub_array(int i,[<{SN+1,SN,...,S1},S0>,[[t0,...],...]]) = [<{SN,...,S1},S0>,[ti,...]]
113
-
114
- template<typename T> inline
115
- poly_array<T> sub_array(int p, const poly_array<T>& a)
116
- {
117
- return poly_array<T>(p, a);
118
- }
119
-
120
- // unit_array<T,N>(a) = [<N>,[a0,...,aN-1]] : N > 0
121
- // unit_array<T>(a) = [<1>,[a0]] : N = 0
122
-
123
- template<class T, int N = 0> inline
124
- poly_array<T> unit_array(T *a)
125
- {
126
- if (N > 0) return poly_array<T>(a, N);
127
- else return poly_array<T>(a);
128
- }
129
-
130
- // make_unit<T>(a,N) = [<N>,[a0,...,aN-1]] : N > 0
131
- // make_unit<T>(a) = [<1>,[a0]] : N = 0
132
-
133
- template<class T> inline
134
- poly_array<T> make_unit(T *w, int N = 0)
135
- {
136
- if (N > 0) return poly_array<T>(w, N);
137
- else return poly_array<T>(w);
138
- }
139
-
140
- /*******************************************************************************
141
-
142
- 3. poly_view<T,N> = {<{SN,...,S1},S0>,@[T...]}
143
-
144
- *******************************************************************************/
145
-
146
- // make_view<T,SN,...,S1,S0>(t) = [<{SN,...,S1},S0>,@[t0,...]]
147
-
148
- template<class T, int... args> inline
149
- poly_view<T> make_view(T *dat)
150
- {
151
- int N = sizeof...(args) - 1;
152
- int s[] = {args...};
153
- return poly_view<T>(dat, N, s);
154
- }
155
-
156
- // make_view<T,N>(t,SN,...,S1,S0) = [<{SN,...,S1},S0>,@[t0,...]]
157
-
158
- template<class T, int N, class... Args> inline
159
- poly_view<T> make_view(T *dat, int car, Args... cdr)
160
- {
161
- int i = sizeof...(cdr), n = i - N;
162
- int s[] = {car, cdr...}, z[N+1];
163
- for (i = 0; i <= N; ++i, ++n)
164
- if (n < 0) z[i] = 1;
165
- else z[i] = s[n];
166
- return poly_view<T>(dat, N, z);
167
- }
168
-
169
- // make_view<T,N>(t,<{SN,...,S1},S0>) = [<{SN,...,S1},S0>,@[t0,...]]
170
-
171
- template<class T, int N> inline
172
- poly_view<T> make_view(T *dat, const poly<int>& e)
173
- {
174
- return poly_view<T>(dat, e);
175
- }
176
-
177
- // view([<{SN,...,S1},S0>,[t0,...]]) = [<{SN,...,S1},S0>,@[t0,...]]
178
-
179
- template<typename T> inline
180
- poly_view<T> view(const poly_array<T>& c)
181
- {
182
- return poly_view<T>(c);
183
- }
184
-
185
- // sub_view(int i,[<{SN,...,S1},S0>,[[t0,...],...]]) = [<{SN-1,...,S1},S0>,@[ti,...]]
186
-
187
- template<typename T> inline
188
- poly_view<T> sub_view(int p, const poly_array<T>& a)
189
- {
190
- return poly_view<T>(p, a);
191
- }
192
-
193
- // unit_view<T,N>(a) = [<N>,@[a0,...,aN-1]] : N > 0
194
- // unit_view<T>(a) = [<1>,@[a0]] : N = 0
195
-
196
- template<class T, int N = 0> inline
197
- poly_view<T> unit_view(T *a)
198
- {
199
- if (N > 0)
200
- return poly_view<T>(a, N);
201
- else
202
- return poly_view<T>(a);
203
- }
204
-
205
- // view<T>(a,N) = [<N>,@[a0,...,aN-1]] : N > 0
206
- // view<T>(a) = [<1>,@[a0]] : N = 0
207
-
208
- template<class T> inline
209
- poly_view<T> view(T *w, int N = 0)
210
- {
211
- if (N > 0)
212
- return poly_view<T>(w, N);
213
- else
214
- return poly_view<T>(w);
215
- }
216
-
217
- /*******************************************************************************
218
-
219
- 4. comb_array<T,N> = {<{SN,...,S1},S0>,[TN...],...,[T1,...]}
220
-
221
- *******************************************************************************/
222
-
223
- template<class T, int... args> inline
224
- comb_array<T> make_comb(const T *dat)
225
- {
226
- int n = sizeof...(args);
227
- int s[] = {args...};
228
- return comb_array<T>(dat, n-1, s);
229
- }
230
-
231
- template<class T, int N, class... args> inline
232
- comb_array<T> make_comb(const T *dat, int b, args... arg)
233
- {
234
- int s[] = {b, arg...};
235
- return comb_array<T>(dat, N, s);
236
- }
237
-
238
- template<class T, int N> inline
239
- comb_array<T> make_comb(const T *dat, int *s)
240
- {
241
- return comb_array<T>(dat, N, s);
242
- }
243
-
244
- template<class T, int N> inline
245
- comb_array<T> make_comb(const T *dat, int *s, int k)
246
- {
247
- return comb_array<T>(dat, N, s, k);
248
- }
249
-
250
- template<class T, int N, class E> inline
251
- comb_array<T> make_comb(const T *dat, const E& e)
252
- {
253
- return comb_array<T>(dat, e);
254
- }
255
-
256
- template<class T> inline
257
- comb_array<T> atom_comb(const T *dat)
258
- {
259
- return comb_array<T>(dat);
260
- }
261
-
262
- template<class T> inline
263
- comb_array<T> atom_comb(const T *dat, int s)
264
- {
265
- return comb_array<T>(dat, Atom, s);
266
- }
267
-
268
- /*******************************************************************************
269
-
270
- 5. comb_view<T,N> = {<{SN,...,S1},S0>,@[T...]}
271
-
272
- *******************************************************************************/
273
-
274
- template<class T> inline
275
- comb_view<T> comb(const comb_array<T>& ca)
276
- {
277
- return comb_view<T>(ca);
278
- }
279
-
280
- template<class T, int N, class... args> inline
281
- comb_view<T> comb(T *dat, int b, args... arg)
282
- {
283
- int s[] = {b, arg...};
284
- return comb_view<T>(dat, N, s);
285
- }
286
-
287
- template<class T, int N> inline
288
- comb_view<T> comb(T *dat, int *s)
289
- {
290
- return comb_view<T>(dat, N, s);
291
- }
292
-
293
- template<class T, int N> inline
294
- comb_view<T> comb(T *dat, int *s, int a)
295
- {
296
- return comb_view<T>(dat, N, s, a);
297
- }
298
-
299
- /*******************************************************************************
300
-
301
- 6. comp_array<T,N> = {<{ON,...,O1},{SN,...,S1},K>,[T...]}
302
-
303
- *******************************************************************************/
304
-
305
- template<class T>
306
- comp_array<T> make_mono(T *dat, int o, int s, int k)
307
- {
308
- return comp_array<T>(dat, o, s, k);
309
- }
310
-
311
- template<class T, int N, class... args>
312
- comp_array<T> make_comp(T *dat, int b, args... arg)
313
- {
314
- int s[] = {b, arg...};
315
- return comp_array<T>(dat, N, s);
316
- }
317
-
318
- template<class T, int N>
319
- comp_array<T> make_comp(T *dat, int *s)
320
- {
321
- return comp_array<T>(dat, N, s);
322
- }
323
-
324
- template <typename T> inline
325
- poly_index<T> make_index(const comb_array<T>& x, int dp)
326
- {
327
- return poly_index<T>(x, dp);
328
- }
329
-
330
- template <int M = 1, typename S = double, typename T = double> inline
331
- bspline<T,S> *make_bspline(S *x, int n, T *y, int j, int s = 0, int c = 0, int *d = NULL)
332
- {
333
- auto Y = make_array<T,1>(y, n+c, M);
334
- return new bspline<T,S>(Y, n+(s%2), x, j, s, d);
335
- }
336
-
337
- template <int N, typename T = double> inline
338
- comb_array<T> pack_comb(const T *u, const int *n, const int *s, int a = 1)
339
- {
340
- auto nc = poly<int>(N, n, a);
341
- auto sc = poly<int>(N, s, 0);
342
- auto ns = nc + sc%2;
343
- int nn = ns.comb_size();
344
- T U[nn], *p = U;
345
- for (int i = 0; i < N; ++i) {
346
- int size = ns[i];
347
- for (int j = 0; j < size; ++j)
348
- *p++ = u ? *u++ : (T)j;
349
- }
350
- return comb_array<T>(U, ns);
351
- }
352
-
353
- template <typename T = double> inline
354
- comb_array<T> pack_comb(const T *u, int n, int s = 0, int a = 1)
355
- {
356
- auto ns = poly<int>(1, n+s%2, a);
357
- int nn = ns.comb_size();
358
- T U[nn];
359
- for (int i = 0; i < nn; ++i) U[i] = u ? u[i] : (T)i;
360
- return comb_array<T>(U, ns);
361
- }
362
-
363
- template <int N, int M = 1, typename S = double, typename T = double> inline
364
- pspline<T,S> *make_pspline(const S *x, const int *p, const T *y, const int *n, const int *j, const int *s)
365
- {
366
- auto pc = poly<int>(N, p, 1);
367
- auto nc = poly<int>(N, n, M);
368
- auto jc = poly<int>(N, j, 0);
369
- auto sc = poly<int>(N, s, 0);
370
- auto U = make_comb<S,N>(x, pc);
371
- auto W = make_array<T,N>(y, nc);
372
- return new pspline<T,S>(W, U, jc, sc);
373
- }
374
-
375
- #include "basis/fft.h"
376
-
377
- #endif
1
+ #ifndef _BSPLINE_H_INCLUDED_
2
+ #define _BSPLINE_H_INCLUDED_
3
+
4
+ #include <stddef.h>
5
+ #include <stdlib.h>
6
+ #include <stdio.h>
7
+ #include <string.h>
8
+ #include <math.h>
9
+ #include <assert.h>
10
+ #include "real_config.h"
11
+ #include "bspline_Config.h"
12
+ #include "basis/util.h"
13
+ #include "basis/poly_array.h"
14
+ #include "basis/basis.h"
15
+ #ifdef BSPLINE
16
+ #include "basis/spline.h"
17
+ #endif
18
+ #ifdef PSPLINE
19
+ #include "basis/pspline.h"
20
+ #endif
21
+ /*******************************************************************************
22
+ make object utility
23
+
24
+ 1. poly<T> = <{TN,...,T1},T0>
25
+
26
+ *******************************************************************************/
27
+ template <real_precision T>
28
+ real<double> make(double a)
29
+ {
30
+ real<double> result(static_cast<size_t>(T));
31
+ result[0] = a;
32
+ return result;
33
+ }
34
+ /*******************************************************************************
35
+
36
+ 2. poly_array<T,N> = {<{SN,...,S1},S0>,[T...]}
37
+
38
+ *******************************************************************************/
39
+
40
+
41
+ /*******************************************************************************
42
+
43
+ 3. poly_view<T,N> = {<{SN,...,S1},S0>,@[T...]}
44
+
45
+ *******************************************************************************/
46
+
47
+ /*******************************************************************************
48
+
49
+ 4. comb_array<T,N> = {<{SN,...,S1},S0>,[TN...],...,[T1,...]}
50
+
51
+ *******************************************************************************/
52
+
53
+ template <int N, typename T = double> inline
54
+ comb_array<T> pack_comb(const varray<T>& u, const int *n, const int *s)
55
+ {
56
+ int a = u.atom();
57
+ int ns[N+1];
58
+ for (int i = 0; i < N; ++i) ns[i] = n[i] + (s[i]%2); ns[N] = a;
59
+ Int nsc(N, ns);
60
+ return comb_array<T>((T*)u, nsc);
61
+ }
62
+
63
+ template <typename T = double> inline
64
+ comb_array<T> pack_comb(const varray<T>& x, int n, int s = 0)
65
+ {
66
+ int a = x.atom();
67
+ auto ns = poly<int>{ n + (s%2), a };
68
+ return comb_array<T>((T*)x, ns);
69
+ }
70
+
71
+ #endif
@@ -1,2 +1,8 @@
1
- #define bspline_VERSION 5.0
2
- #define bspline_TYPE 5
1
+ #define bspline_VERSION 6.0
2
+ #define bspline_TYPE 6
3
+ #ifndef SLOPPY
4
+ #define ACCURATE
5
+ #endif
6
+ #ifdef IEEE
7
+ #define IEEE_ADD
8
+ #endif