pspline 5.0.4 → 5.0.5

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -5
  3. data/README.md +1 -0
  4. data/Rakefile +6 -6
  5. data/bin/console +14 -14
  6. data/bin/setup +8 -8
  7. data/ext/pspline/example/exbspline.rb +57 -36
  8. data/ext/pspline/example/excspline.rb +57 -36
  9. data/ext/pspline/example/exdspline.rb +55 -33
  10. data/ext/pspline/example/exfspline.rb +44 -44
  11. data/ext/pspline/example/exfspline1.rb +40 -40
  12. data/ext/pspline/example/exfspline2.rb +68 -0
  13. data/ext/pspline/example/exfspline3.rb +64 -0
  14. data/ext/pspline/example/exmspline.rb +68 -0
  15. data/ext/pspline/example/expspline.rb +29 -29
  16. data/ext/pspline/example/expspline1.rb +29 -29
  17. data/ext/pspline/example/expspline2.rb +47 -47
  18. data/ext/pspline/example/exqspline.rb +31 -31
  19. data/ext/pspline/example/exqspline2.rb +50 -50
  20. data/ext/pspline/example/exqspline3.rb +51 -51
  21. data/ext/pspline/example/exqspline4.rb +35 -0
  22. data/ext/pspline/example/exrspline.rb +34 -34
  23. data/ext/pspline/example/exrspline1.rb +34 -34
  24. data/ext/pspline/example/exrspline2.rb +44 -44
  25. data/ext/pspline/example/exsspline.rb +35 -35
  26. data/ext/pspline/example/exsspline1.rb +35 -35
  27. data/ext/pspline/example/extspline.rb +54 -32
  28. data/ext/pspline/include/basis/pspline.h +156 -20
  29. data/ext/pspline/include/bspline_Config.h +2 -2
  30. data/ext/pspline/plotsub.cpp +15 -8
  31. data/ext/pspline/pspline.cpp +160 -66
  32. data/lib/pspline.rb +71 -63
  33. data/lib/pspline/version.rb +3 -3
  34. data/pspline.gemspec +25 -25
  35. metadata +7 -13
  36. data/ext/pspline/example/example.rb +0 -34
  37. data/ext/pspline/example/exbspline.ps +0 -2194
  38. data/ext/pspline/example/excspline.ps +0 -2985
  39. data/ext/pspline/example/exdspline.ps +0 -2846
  40. data/ext/pspline/example/expspline.ps +0 -3299
  41. data/ext/pspline/example/exqspline.ps +0 -2957
  42. data/ext/pspline/example/exrspline.ps +0 -2812
  43. data/ext/pspline/example/exsspline.ps +0 -1965
  44. data/ext/pspline/example/extspline.ps +0 -2767
@@ -1,35 +1,35 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- n = 8
6
- j = 3
7
- s = 3
8
-
9
- puts "# Riesenfeld interpolation (Closed curve)"
10
-
11
- X = [0, 1, 2, 3, 4, 5, 6, 7, 8]
12
-
13
- Y = [ [ 4.0, 0.0],[ 3.0, 3.0],[ 0.0, 4.0],[-3.0, 3.0],
14
- [-4.0, 0.0],[-3.0,-3.0],[ 0.0,-4.0],[ 3.0,-3.0] ]
15
-
16
- Jbn = ARGV[0].to_i
17
-
18
- Dp = 10
19
-
20
- Sp = Pspline.new(Y, [X], [n], [j], [s])
21
-
22
- Y.each do |p|
23
- printf "% f, % f\n", p[0], p[1]
24
- end
25
- printf "# value of interpolation points, Dp = %d", Dp
26
- if Jbn == 0
27
- print "\n"
28
- else
29
- printf ", Jbn = %d\n", Jbn
30
- end
31
- vv = [X]
32
- s = Sp.plot(vv, Dp, [Jbn]) do |a, b|
33
- printf "% .2f, <% .7f, % .7f>\n", a[0], b[0], b[1]
34
- end
35
- #STDERR.puts s
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ n = 8
6
+ j = 3
7
+ s = 3
8
+
9
+ puts "# Riesenfeld interpolation (Closed curve)"
10
+
11
+ X = [0, 1, 2, 3, 4, 5, 6, 7, 8]
12
+
13
+ Y = [ [ 4.0, 0.0],[ 3.0, 3.0],[ 0.0, 4.0],[-3.0, 3.0],
14
+ [-4.0, 0.0],[-3.0,-3.0],[ 0.0,-4.0],[ 3.0,-3.0] ]
15
+
16
+ Jbn = ARGV[0].to_i
17
+
18
+ Dp = 10
19
+
20
+ Sp = Pspline.new(Y, [X], [n], [j], [s])
21
+
22
+ Y.each do |p|
23
+ printf "% f, % f\n", p[0], p[1]
24
+ end
25
+ printf "# value of interpolation points, Dp = %d", Dp
26
+ if Jbn == 0
27
+ print "\n"
28
+ else
29
+ printf ", Jbn = %d\n", Jbn
30
+ end
31
+ vv = [X]
32
+ s = Sp.plot(vv, Dp, [Jbn]) do |a, b|
33
+ printf "% .2f, <% .7f, % .7f>\n", a[0], b[0], b[1]
34
+ end
35
+ #STDERR.puts s
@@ -1,35 +1,35 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- puts "# Riesenfeld interpolation (Closed curve interpolation)"
6
-
7
- n = 8
8
- j = 3
9
- s = 3
10
-
11
- XY = [ [0, 4.0, 0.0],[1, 3.0, 3.0],[2, 0.0, 4.0],[3,-3.0, 3.0],
12
- [4,-4.0, 0.0],[5,-3.0,-3.0],[6, 0.0,-4.0],[7, 3.0,-3.0],
13
- [8, 4.0, 0.0] ]
14
-
15
- Jbn = ARGV[0].to_i
16
-
17
- Dp = 10
18
-
19
- Sp = Bspline.new(XY, n, j, s)
20
-
21
- vv = []
22
- XY.each do |p|
23
- printf "% f, % f\n", p[1], p[2]
24
- vv.push p[0]
25
- end
26
- printf "# value of interpolation points, Dp = %d", Dp
27
- if Jbn == 0
28
- print "\n"
29
- else
30
- printf ", Jbn = %d\n", Jbn
31
- end
32
- s = Sp.plot(vv, Dp, Jbn) do |a, b|
33
- printf "% .2f % .7f % .7f\n", a, b[0], b[1]
34
- end
35
- #STDERR.puts s
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ puts "# Riesenfeld interpolation (Closed curve interpolation)"
6
+
7
+ n = 8
8
+ j = 3
9
+ s = 3
10
+
11
+ XY = [ [0, 4.0, 0.0],[1, 3.0, 3.0],[2, 0.0, 4.0],[3,-3.0, 3.0],
12
+ [4,-4.0, 0.0],[5,-3.0,-3.0],[6, 0.0,-4.0],[7, 3.0,-3.0],
13
+ [8, 4.0, 0.0] ]
14
+
15
+ Jbn = ARGV[0].to_i
16
+
17
+ Dp = 10
18
+
19
+ Sp = Bspline.new(XY, n, j, s)
20
+
21
+ vv = []
22
+ XY.each do |p|
23
+ printf "% f, % f\n", p[1], p[2]
24
+ vv.push p[0]
25
+ end
26
+ printf "# value of interpolation points, Dp = %d", Dp
27
+ if Jbn == 0
28
+ print "\n"
29
+ else
30
+ printf ", Jbn = %d\n", Jbn
31
+ end
32
+ s = Sp.plot(vv, Dp, Jbn) do |a, b|
33
+ printf "% .2f % .7f % .7f\n", a, b[0], b[1]
34
+ end
35
+ #STDERR.puts s
@@ -1,32 +1,54 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- #
6
- #puts "# Interpolation of the Jacobi function"
7
- #
8
- XY = [ [ 0.0, 0.0 ],[ 0.5474, 0.5 ],[ 1.2837, 0.86603],[ 2.7681, 1.0 ],
9
- [ 4.2525, 0.86603],[ 4.9888, 0.5 ],[ 5.5362, 0.0 ],[ 6.0836,-0.5 ],
10
- [ 6.8199,-0.86603],[ 8.3043,-1.0 ],[ 9.7887,-0.86603],[10.5250,-0.5 ],
11
- [11.0724, 0.0 ] ]
12
-
13
- Jbn = ARGV[0].to_i
14
-
15
- Dp = 10
16
-
17
- Bs = Bspline.new(XY, 12, 5, 1)
18
-
19
- vv = []
20
- XY.each do |p|
21
- printf "%7.4f, % f\n", p[0], p[1]
22
- vv.push p[0]
23
- end
24
- printf "# value of interpolation points, Dp = %d", Dp
25
- if Jbn == 0
26
- print "\n"
27
- else
28
- printf ", Jbn = %d\n", Jbn
29
- end
30
- s = Bs.plot(vv, 10, Jbn) do |u, v|
31
- printf "%8.5f % f\n", u, v[0]
32
- end
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ #
6
+ #puts "# Interpolation of the Jacobi function"
7
+ #
8
+ XY = [ [ 0.0, 0.0 ],[ 0.5474, 0.5 ],[ 1.2837, 0.86603],[ 2.7681, 1.0 ],
9
+ [ 4.2525, 0.86603],[ 4.9888, 0.5 ],[ 5.5362, 0.0 ],[ 6.0836,-0.5 ],
10
+ [ 6.8199,-0.86603],[ 8.3043,-1.0 ],[ 9.7887,-0.86603],[10.5250,-0.5 ],
11
+ [11.0724, 0.0 ] ]
12
+
13
+ Jbn = ARGV[0].to_i
14
+
15
+ Dp = 10
16
+
17
+ Bs = Bspline.new(XY, 12, 5, 1)
18
+
19
+ vv = []
20
+ XY.each do |p|
21
+ printf "%7.4f, % f\n", p[0], p[1]
22
+ vv.push p[0]
23
+ end
24
+ printf "# value of interpolation points, Dp = %d", Dp
25
+ if Jbn == 0
26
+ print "\n"
27
+ else
28
+ printf ", Jbn = %d\n", Jbn
29
+ end
30
+ s = Bs.plot(vv, 10, Jbn) do |u, v|
31
+ printf "%8.5f % f\n", u, v[0]
32
+ end
33
+ # Draw Graph
34
+ require "gnuplot"
35
+
36
+ Gnuplot.open do |gp|
37
+ Gnuplot::Plot.new( gp ) do |plot|
38
+ plot.title 'Jacobi'
39
+ plot.ylabel 'Y'
40
+ plot.xlabel 'X'
41
+ x = vv.map {|v| v[0]}
42
+ y = vv.map {|v| v[1]}
43
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
44
+ ds.with = "lines"
45
+ ds.linewidth = 2
46
+ ds.notitle
47
+ end
48
+ y = x.map {|v| Bs.value(v, 1)}
49
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
50
+ ds.with = "lines"
51
+ ds.title = "Differential"
52
+ end
53
+ end
54
+ end
@@ -1,6 +1,18 @@
1
1
  #ifndef _PSPLINE_5_H_INCLUDED_
2
2
  #define _PSPLINE_5_H_INCLUDED_
3
3
 
4
+ template <typename T>
5
+ void poly_new_subst(int n, T **w)
6
+ {
7
+ for (int i = 0; i < n; ++i) w[i] = NULL;
8
+ }
9
+
10
+ template <typename T, class... Args>
11
+ void poly_new_subst(int n, T **w, const T *car, const Args... cdr)
12
+ {
13
+ w[0] = new T(*car); if (n > 1) poly_new_subst(n-1, &w[1], cdr...);
14
+ }
15
+
4
16
  /*******************************************************************************
5
17
  define poly_spline[base_spline1*,...base_splineN*]
6
18
  *******************************************************************************/
@@ -26,6 +38,7 @@ struct values_ {
26
38
  } *values;
27
39
 
28
40
  // constructor
41
+ poly_spline() : base(NULL), values(NULL) {}
29
42
  poly_spline(const comb_array<S>& x, const Int& n, const Int& j, const Int& s) : N(x.grid())
30
43
  {
31
44
  base = new base_spline<S>*[N];
@@ -33,8 +46,42 @@ poly_spline(const comb_array<S>& x, const Int& n, const Int& j, const Int& s) :
33
46
  base[i] = new base_spline<S>(n[i], x[i], j[i], -s[i]%2);
34
47
  values = new values_(*this, n.unit_size());
35
48
  }
49
+ template <class... Args>
50
+ poly_spline(int k, const base_spline<S> *bsc, Args... bsd)
51
+ : N(sizeof...(bsd)+1), base(new base_spline<S>*[sizeof...(bsd)+1])
52
+ {
53
+ base[0] = new base_spline<S>(*bsc);
54
+ if (N > 1) poly_new_subst(N-1, &base[1], bsd...);
55
+ values = new values_(*this, k);
56
+ }
57
+ poly_spline(int k, const poly_spline<S> *ps, const base_spline<S> *bs)
58
+ : N(ps->Grid()+1), base(new base_spline<S>*[ps->Grid()+1])
59
+ {
60
+ for (int i = 0; i < N-1; i++) {
61
+ const base_spline<S>& b = (*ps)[i];
62
+ base[i] = new base_spline<S>(b);
63
+ }
64
+ base[N-1] = new base_spline<S>(*bs);
65
+ values = new values_(*this, k);
66
+ }
67
+ poly_spline(int k, const base_spline<S> *bs, const poly_spline<S> *ps)
68
+ : N(ps->Grid()+1), base(new base_spline<S>*[ps->Grid()+1])
69
+ {
70
+ base[0] = new base_spline<S>(*bs);
71
+ for (int i = 1; i < N; i++) {
72
+ const base_spline<S>& b = (*ps)[i-1];
73
+ base[i] = new base_spline<S>(b);
74
+ }
75
+ values = new values_(*this, k);
76
+ }
77
+ poly_spline(int k, const base_spline<S>& bsc)
78
+ : N(1), base(new base_spline<S>*[1])
79
+ {
80
+ base[0] = new base_spline<S>(bsc);
81
+ values = new values_(*this, k);
82
+ }
36
83
  // copy constructor
37
- poly_spline(const poly_spline& p) : N(p.N)
84
+ poly_spline(const poly_spline& p) : N(p.N), base(new base_spline<S>*[p.N])
38
85
  {
39
86
  for (int i = 0; i < N; i++)
40
87
  base[i] = new base_spline<S>(*p.base[i]);
@@ -47,9 +94,9 @@ poly_spline& operator=(const poly_spline& p)
47
94
  {
48
95
  if (this != &p) {
49
96
  delete[] base;
50
- int N = p.N;
97
+ N = p.N; base = new base_spline<S>*[p.N];
51
98
  for (int i = 0; i < N; i++) {
52
- base[i] = base_spline<S>(*p.base[i]);
99
+ base[i] = new base_spline<S>(*p.base[i]);
53
100
  } delete values;
54
101
  values = new values_(*this, p.values->imax.unit_size());
55
102
  }
@@ -130,9 +177,9 @@ void sekibun(poly_view<T>& r, const poly_view<T>& clp, const poly<int>& h, const
130
177
  FREE(sp);
131
178
  }
132
179
 
133
- base_spline<S>& operator[](int i) {return *base[i];}
180
+ base_spline<S>& operator[](int i) const {return *base[i];}
134
181
 
135
- int Grid() {return N;}
182
+ int Grid() const {return N;}
136
183
 
137
184
  Int Kset(const poly<S>& x) const
138
185
  {
@@ -182,6 +229,7 @@ size_t *Maxq() const
182
229
  // end poly_spline
183
230
  };
184
231
 
232
+ template <class T, class S> class bspline;
185
233
  /*******************************************************************************
186
234
  N変数K次元パラメトリック & リーゼンフェルト スプライン補間
187
235
  int N : number of parameters (Grid)
@@ -204,11 +252,24 @@ class pspline : public poly_spline<S>
204
252
  // constructor
205
253
  pspline():clp(NULL){}
206
254
  pspline(const poly_array<T>&, const comb_array<S>&, const Int&, const Int&);
255
+ template <class... Args>
256
+ pspline(int k, T *v, Args... bset)
257
+ : poly_spline<S>(k, bset...), K(k), clp(v) {}
258
+ pspline(const bspline<T,S>& bs)
259
+ : poly_spline<S>(bs.Unit_size(), base_spline<S>(bs)), K(bs.Unit_size())
260
+ {
261
+ const Int& c = poly_spline<S>::values->icox;
262
+ int s = c.data_size();
263
+ clp = new T[s];
264
+ memcpy(clp, (T*)bs, s * sizeof(T));
265
+ }
207
266
  pspline(const pspline&);
208
267
  // destructor
209
268
  ~pspline() { delete[] clp; }
210
269
  // operator
211
270
  pspline& operator=(const pspline&);
271
+ poly_array<T> operator[](S t) const { return (*this)(t); }
272
+ poly_array<T> operator()(S, int = 0) const;
212
273
  poly_array<T> operator[](const poly<S>& p) const {return (*this)(p);}
213
274
  poly_array<T> operator()(const poly<S>&, const int* = NULL) const;
214
275
  poly_array<T> operator()(const poly<S>&, int, T*) const;
@@ -221,8 +282,8 @@ template <typename T, typename S>
221
282
  pspline<T,S>::pspline(const poly_array<T>& p, const comb_array<S>& x, const Int& j, const Int& s)
222
283
  : poly_spline<S>(x, Int(p), j, s), K(p.unit_size())
223
284
  {
224
- Int a = poly_spline<S>::values->imax;
225
- Int c = poly_spline<S>::values->icox;
285
+ const Int& a = poly_spline<S>::values->imax;
286
+ const Int& c = poly_spline<S>::values->icox;
226
287
  T *alp = clp = new T[c.data_size()];
227
288
  poly_view<T> alv(alp, a), clv(clp, c);
228
289
  if (s < 2) {
@@ -237,7 +298,7 @@ pspline<T,S>::pspline(const poly_array<T>& p, const comb_array<S>& x, const Int&
237
298
  template <typename T, typename S>
238
299
  pspline<T,S>::pspline(const pspline& ps) : poly_spline<S>(ps), K(ps.K)
239
300
  {
240
- Int c = poly_spline<S>::icox;
301
+ const Int& c = poly_spline<S>::values->icox;
241
302
  int len = c.data_size();
242
303
  clp = new T[len];
243
304
  memcpy(clp, (T*)ps, len * sizeof(T));
@@ -249,7 +310,7 @@ pspline<T,S>& pspline<T,S>::operator=(const pspline& ps)
249
310
  if (this != &ps) {
250
311
  delete clp;
251
312
  poly_spline<S>::operator=(ps); K = ps.K;
252
- Int c = poly_spline<S>::icox;
313
+ const Int& c = poly_spline<S>::values->icox;
253
314
  int len = c.data_size();
254
315
  clp = new T[len];
255
316
  memcpy(clp, (T*)ps, len * sizeof(T));
@@ -268,7 +329,7 @@ poly_array<T> pspline<T,S>::operator()(const poly<S>& t, const int *jb) const
268
329
  T result[K]; for (int i = 0; i < K; ++i) result[i] = 0;
269
330
  poly_view<T> res(result, K);
270
331
  comp_array<S> pc = poly_spline<S>::basis(t, jb);
271
- Int& c = poly_spline<S>::values->icox;
332
+ const Int& c = poly_spline<S>::values->icox;
272
333
  poly_view<T> clv(clp, c);
273
334
  Int offset = pc.offset(), size = pc.size();
274
335
  int s = size.grid_size();
@@ -288,7 +349,7 @@ poly_array<T> pspline<T,S>::operator()(const poly<S>& t, int jbn, T *ds) const
288
349
  T result[K]; for (int i = 0; i < K; ++i) result[i] = 0;
289
350
  poly_view<T> res(result, K);
290
351
  comp_array<S> pc = poly_spline<S>::bases(t, jbn);
291
- Int& c = poly_spline<S>::values->icox;
352
+ const Int& c = poly_spline<S>::values->icox;
292
353
  poly_view<T> clv(clp, c);
293
354
  Int offset = pc.offset(), size = pc.size();
294
355
  int s = size.grid_size();
@@ -318,6 +379,29 @@ poly_array<T> pspline<T,S>::sekibun(const poly<S>& t) const
318
379
  return poly_array<T>(result, a);
319
380
  }
320
381
 
382
+ template <typename T, typename S>
383
+ poly_array<T> pspline<T,S>::operator()(S t, int b) const
384
+ {
385
+ int N = this->Grid();
386
+ S w[N+1]; for (int i = 0; i < N; i++) w[i] = t; w[N] = 0;
387
+ poly<S> u(w, N);
388
+ if (!(poly_spline<S>::values->jisu >= b))
389
+ throw "out of range, pspline()";
390
+ T result[K]; for (int i = 0; i < K; ++i) result[i] = 0;
391
+ poly_view<T> res(result, K);
392
+ comp_array<S> pc = poly_spline<S>::bases(u, b);
393
+ const Int& c = poly_spline<S>::values->icox;
394
+ poly_view<T> clv(clp, c);
395
+ Int offset = pc.offset(), size = pc.size();
396
+ int s = size.grid_size();
397
+ for (int i = 0; i < s; ++i)
398
+ {
399
+ Int k = i % size, l = k + offset;
400
+ res += clv[l] * pc[k = b + 1][b];
401
+ }
402
+ return poly_array<T>(result, K);
403
+ }
404
+
321
405
  // 1変数N次元パラメトリックスプライン
322
406
  typedef pspline<double,double> Pspline;
323
407
  // 1変数N次元パラメトリックスプライン
@@ -380,11 +464,11 @@ bspline<T,S>::bspline(
380
464
  }
381
465
 
382
466
  template <class T, class S>
383
- bspline<T,S>::bspline(const bspline& s) : base_spline<S>(s)
467
+ bspline<T,S>::bspline(const bspline& s) : base_spline<S>(s), K(s.K)
384
468
  {
385
469
  int c = base_spline<S>::icox;
386
- clp = new T[c];
387
- memcpy(clp, s, c * sizeof(T));
470
+ clp = new T[c * K];
471
+ memcpy(clp, (T*)s, c * K * sizeof(T));
388
472
  }
389
473
 
390
474
  template <class T, class S>
@@ -392,10 +476,11 @@ bspline<T,S>& bspline<T,S>::operator=(const bspline& s)
392
476
  {
393
477
  if (this != &s) {
394
478
  base_spline<S>::operator=(s);
479
+ K = s.K;
395
480
  delete clp;
396
481
  int c = base_spline<S>::icox;
397
- clp = new T[c];
398
- memcpy(clp, s, c * sizeof(T));
482
+ clp = new T[c * K];
483
+ memcpy(clp, (T*)s, c * K * sizeof(T));
399
484
  }
400
485
  return *this;
401
486
  }
@@ -485,21 +570,72 @@ bspline<T,S> *bspline<T,S>::line_integral(T(*F)(poly_array<S>&), int n, S *u, S
485
570
  poly_array<T> Ya(Y, 1, N, 1);
486
571
  return new bspline<T,S>(Ya, n, X, base_spline<S>::jisu, 0, D);
487
572
  }
573
+
574
+ template <class T, class S>
575
+ pspline<T,S> operator * (const bspline<T,S>& bs1, const bspline<T,S>& bs2)
576
+ {
577
+ int k1 = bs1.Unit_size(), k2 = bs2.Unit_size();
578
+ assert(k1 == k2);
579
+ int c1 = bs1.Icox(), c2 = bs2.Icox();
580
+ T *cp1 = bs1, *cp2 = bs2, *cp3 = new T[c1*c2*k1];
581
+ for (int i = 0; i < k1; i++) {
582
+ varray_view<T> v1(cp1+i, c1, k1), v2(cp2+i, c2, k2), v3(cp3+i, c1*c2, k1);
583
+ kronecker(v1, v2, v3);
584
+ }
585
+ const base_spline<S>& bt1 = bs1;
586
+ const base_spline<S>& bt2 = bs2;
587
+ return pspline<T,S>(k1, cp3, &bt1, &bt2);
588
+ }
589
+
590
+ template <class T, class S>
591
+ pspline<T,S> operator * (const pspline<T,S>& ps, const bspline<T,S>& bs2)
592
+ {
593
+ int k2 = bs2.Unit_size(), c2 = bs2.Icox();
594
+ const poly_spline<S>& ps1 = ps;
595
+ const Int& c = ps1.values->icox;
596
+ int k1 = c.unit_size(), c1 = c.grid_size();
597
+ assert(k1 == k2);
598
+ T *cp1 = ps, *cp2 = bs2, *cp3 = new T[c1*c2*k2];
599
+ for (int i = 0; i < k1; i++) {
600
+ varray_view<T> v1(cp1+i, c1, k1), v2(cp2+i, c2, k2), v3(cp3+i, c1*c2, k1);
601
+ kronecker(v1, v2, v3);
602
+ }
603
+ const base_spline<S>& bt2 = bs2;
604
+ return pspline<T,S>(k2, cp3, &ps1, &bt2);
605
+ }
606
+
607
+ template <class T, class S>
608
+ pspline<T,S> operator * (const bspline<T,S>& bs1, const pspline<T,S>& ps)
609
+ {
610
+ int k1 = bs1.Unit_size(), c1 = bs1.Icox();
611
+ const poly_spline<S>& ps2 = ps;
612
+ const Int& c = ps2.values->icox;
613
+ int k2 = c.unit_size(), c2 = c.grid_size();
614
+ assert(k1 == k2);
615
+ T *cp1 = bs1, *cp2 = ps, *cp3 = new T[c1*c2*k1];
616
+ for (int i = 0; i < k1; i++) {
617
+ varray_view<T> v1(cp1+i, c1, k1), v2(cp2+i, c2, k2), v3(cp3+i, c1*c2, k1);
618
+ kronecker(v1, v2, v3);
619
+ }
620
+ const base_spline<S>& bt1 = bs1;
621
+ return pspline<T,S>(k1, cp3, &bt1, &ps2);
622
+ }
488
623
  //
489
624
  // misc
490
625
  //
626
+ // 偏微分プロット
491
627
  template <class T, class S = double>
492
628
  int plot(const pspline<T,S>&, const comb_array<S>&, S**, T**, int, const int* = NULL);
493
-
629
+ // 全微分プロット
494
630
  template <class T, class S = double>
495
631
  int plot(const pspline<T,S>&, const comb_array<S>&, S**, T**, int, int, S*);
496
-
632
+ // 1変数関数積プロット
497
633
  template <class T, class S = double>
498
634
  int plot(const pspline<T,S>&, int, S*, S**, T**, int, int = 0);
499
-
635
+ // 1変数関数プロット(インデックス)
500
636
  template <class T, class S = double>
501
637
  int plot(const bspline<T,S>&, const comb_array<S>&, S**, T**, int, int = 0);
502
-
638
+ // 1変数関数プロット
503
639
  template <class T, class S = double>
504
640
  int plot(const bspline<T,S>&, int, S*, S**, T**, int, int = 0);
505
641