pspline 5.0.2
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.
- checksums.yaml +7 -0
- data/Gemfile +5 -0
- data/README.md +34 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ext/pspline/basis.cpp +351 -0
- data/ext/pspline/example/exbspline.ps +2194 -0
- data/ext/pspline/example/exbspline.rb +36 -0
- data/ext/pspline/example/excspline.ps +2985 -0
- data/ext/pspline/example/excspline.rb +36 -0
- data/ext/pspline/example/exdspline.ps +2846 -0
- data/ext/pspline/example/exdspline.rb +33 -0
- data/ext/pspline/example/exfspline.rb +66 -0
- data/ext/pspline/example/exfspline1.rb +40 -0
- data/ext/pspline/example/expspline.ps +3299 -0
- data/ext/pspline/example/expspline.rb +29 -0
- data/ext/pspline/example/expspline1.rb +29 -0
- data/ext/pspline/example/expspline2.rb +47 -0
- data/ext/pspline/example/exqspline.ps +2957 -0
- data/ext/pspline/example/exqspline.rb +31 -0
- data/ext/pspline/example/exqspline1.rb +31 -0
- data/ext/pspline/example/exqspline2.rb +50 -0
- data/ext/pspline/example/exqspline3.rb +51 -0
- data/ext/pspline/example/exrspline.ps +2812 -0
- data/ext/pspline/example/exrspline.rb +34 -0
- data/ext/pspline/example/exrspline1.rb +34 -0
- data/ext/pspline/example/exrspline2.rb +44 -0
- data/ext/pspline/example/exsspline.ps +1965 -0
- data/ext/pspline/example/exsspline.rb +35 -0
- data/ext/pspline/example/exsspline1.rb +35 -0
- data/ext/pspline/example/extspline.ps +2767 -0
- data/ext/pspline/example/extspline.rb +32 -0
- data/ext/pspline/extconf.rb +7 -0
- data/ext/pspline/fft.cpp +552 -0
- data/ext/pspline/include/basis/basis.h +137 -0
- data/ext/pspline/include/basis/fft.h +152 -0
- data/ext/pspline/include/basis/poly_array.h +1568 -0
- data/ext/pspline/include/basis/pspline.h +506 -0
- data/ext/pspline/include/basis/uspline.h +210 -0
- data/ext/pspline/include/basis/util.h +656 -0
- data/ext/pspline/include/bspline.h +377 -0
- data/ext/pspline/include/bspline_Config.h +2 -0
- data/ext/pspline/plotsub.cpp +132 -0
- data/ext/pspline/pspline.cpp +897 -0
- data/ext/pspline/util.cpp +483 -0
- data/lib/pspline.rb +6 -0
- data/lib/pspline/version.rb +3 -0
- data/pspline.gemspec +25 -0
- metadata +122 -0
|
@@ -0,0 +1,377 @@
|
|
|
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
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#include <math.h>
|
|
2
|
+
#include <stdarg.h>
|
|
3
|
+
#include <string.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
#include <stddef.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
|
+
|
|
14
|
+
template <typename T, typename S>
|
|
15
|
+
int plot(const pspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp, const int *b)
|
|
16
|
+
{
|
|
17
|
+
const Int& n = x;
|
|
18
|
+
int N = n.grid(), K = B.Unit_size();
|
|
19
|
+
poly_index<S> H(x, Dp);
|
|
20
|
+
|
|
21
|
+
int Npx = H.index_size(), L = Npx;
|
|
22
|
+
for (int i = 0; i < N; i++) Xp[i] = T_ALLOC(S, Npx);
|
|
23
|
+
for (int i = 0; i < K; i++) Yp[i] = T_ALLOC(T, Npx);
|
|
24
|
+
while (L--) {
|
|
25
|
+
int Np = H.index_value();
|
|
26
|
+
poly<S> Sp = H.get_value();
|
|
27
|
+
for (int i = 0; i < N; i++) Xp[i][Np] = Sp[i];
|
|
28
|
+
poly_array<T> Bp = B(Sp, b);
|
|
29
|
+
for (int i = 0; i < K; i++) Yp[i][Np] = Bp[i];
|
|
30
|
+
++H;
|
|
31
|
+
}
|
|
32
|
+
return Npx;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
template <typename T, typename S>
|
|
36
|
+
int plot(const pspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp, int Jbn, S *jb)
|
|
37
|
+
{
|
|
38
|
+
const Int& n = x;
|
|
39
|
+
int N = n.grid(), K = B.Unit_size();
|
|
40
|
+
poly_index<S> H(x, Dp);
|
|
41
|
+
|
|
42
|
+
int Npx = H.index_size(), L = Npx;
|
|
43
|
+
for (int i = 0; i < N; i++) Xp[i] = T_ALLOC(S, Npx);
|
|
44
|
+
for (int i = 0; i < K; i++) Yp[i] = T_ALLOC(T, Npx);
|
|
45
|
+
while (L--) {
|
|
46
|
+
int Np = H.index_value();
|
|
47
|
+
poly<S> Sp = H.get_value();
|
|
48
|
+
for (int i = 0; i < N; i++) Xp[i][Np] = Sp[i];
|
|
49
|
+
poly_array<T> Bp = B(Sp, Jbn, jb);
|
|
50
|
+
for (int i = 0; i < K; i++) Yp[i][Np] = Bp[i];
|
|
51
|
+
++H;
|
|
52
|
+
}
|
|
53
|
+
return Npx;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
template <typename T, typename S>
|
|
57
|
+
int plot(const pspline<T,S>& B, int n, S *x, S **Xp, T **Yp, int Dp, int b)
|
|
58
|
+
{
|
|
59
|
+
int K = B.Unit_size();
|
|
60
|
+
int jb[] = {b};
|
|
61
|
+
|
|
62
|
+
int Npx = (n - 1) * Dp + 1;
|
|
63
|
+
*Xp = T_ALLOC(S, Npx);
|
|
64
|
+
for (int i = 0; i < K; i++) Yp[i] = T_ALLOC(T, Npx);
|
|
65
|
+
for (int L = 1; L < n; L++) {
|
|
66
|
+
S DT = (x[L] - x[L-1]) / Dp;
|
|
67
|
+
int N0 = (L == 1 ? 0 : 1);
|
|
68
|
+
for (int Nd = N0; Nd <= Dp; Nd++) {
|
|
69
|
+
int Np = Nd + (L-1) * Dp;
|
|
70
|
+
S Tp = x[L-1] + Nd * DT;
|
|
71
|
+
poly<S> Sp(1, Tp, (S)0);
|
|
72
|
+
(*Xp)[Np] = Tp;
|
|
73
|
+
poly_array<T> Z = B(Sp, jb);
|
|
74
|
+
for (int i = 0; i < K; ++i) Yp[i][Np] = Z[i];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return Npx;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
template <typename T, typename S>
|
|
81
|
+
int plot(const bspline<T,S>& B, const comb_array<S>& x, S **Xp, T **Yp, int Dp, int Jbn)
|
|
82
|
+
{
|
|
83
|
+
#ifndef NDEBUG
|
|
84
|
+
const Int& n = x;
|
|
85
|
+
int N = n.grid();
|
|
86
|
+
#endif
|
|
87
|
+
assert(N == 1);
|
|
88
|
+
int K = B.Unit_size();
|
|
89
|
+
poly_index<S> H(x, Dp);
|
|
90
|
+
|
|
91
|
+
int Npx = H.index_size(), L = Npx;
|
|
92
|
+
Xp[0] = T_ALLOC(S, Npx);
|
|
93
|
+
for (int i = 0; i < K; i++) Yp[i] = T_ALLOC(T, Npx);
|
|
94
|
+
while (L--) {
|
|
95
|
+
int Np = H.index_value();
|
|
96
|
+
poly<S> Sp = H.get_value();
|
|
97
|
+
(*Xp)[Np] = Sp[0];
|
|
98
|
+
poly_array<T> Bp = B(Sp[0], Jbn);
|
|
99
|
+
for (int i = 0; i < K; i++) Yp[i][Np] = Bp[i];
|
|
100
|
+
++H;
|
|
101
|
+
}
|
|
102
|
+
return Npx;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
template <typename T, typename S>
|
|
106
|
+
int plot(const bspline<T,S>& B, int n, S *x, S **Xp, T **Yp, int Dp, int b)
|
|
107
|
+
{
|
|
108
|
+
int K = B.Unit_size();
|
|
109
|
+
|
|
110
|
+
int Npx = (n - 1) * Dp + 1;
|
|
111
|
+
*Xp = T_ALLOC(S, Npx);
|
|
112
|
+
for (int i = 0; i < K; i++) Yp[i] = T_ALLOC(T, Npx);
|
|
113
|
+
for (int L = 1; L < n; L++) {
|
|
114
|
+
S DT = (x[L] - x[L-1]) / Dp;
|
|
115
|
+
int N0 = (L == 1 ? 0 : 1);
|
|
116
|
+
for (int Nd = N0; Nd <= Dp; Nd++) {
|
|
117
|
+
int Np = Nd + (L-1) * Dp;
|
|
118
|
+
S Tp = x[L-1] + Nd * DT;
|
|
119
|
+
(*Xp)[Np] = Tp;
|
|
120
|
+
poly_array<T> Z = B(Tp, b);
|
|
121
|
+
for (int i = 0; i < K; ++i) Yp[i][Np] = Z[i];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return Npx;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
template int plot(const pspline<double,double>&, const comb_array<double>&, double**, double**, int, const int*);
|
|
128
|
+
template int plot(const pspline<double,double>&, const comb_array<double>&, double**, double**, int, int, double*);
|
|
129
|
+
template int plot(const pspline<double,double>&, int, double *, double **, double **, int, int);
|
|
130
|
+
template int plot(const bspline<double,double>&, const comb_array<double>&, double **, double **, int, int);
|
|
131
|
+
template int plot(const bspline<double,double>&, int, double *, double **, double **, int, int);
|
|
132
|
+
|