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,68 +1,68 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- puts "# complex FFT data points"
6
-
7
- XY = [ [0, 1],[0, 1],[0, 1],[1, 0,],[1, 0,],[1, 0],[1, 0],[0, 1],[0, 1],[0, 1] ]
8
-
9
- fs = XY.fft_complex_forward
10
- fs.real.each {|x| printf("% .2f ", x) }
11
- puts
12
- fs.image.each {|y| printf("% .2f ", y) }
13
- puts
14
-
15
- printf "Real :"
16
- -5.upto(5) {|t|
17
- w = fs[t]
18
- printf "% .2f ", w[0]
19
- }
20
- puts
21
- printf "Image:"
22
- -5.upto(5) {|t|
23
- w = fs[t]
24
- printf "% .2f ", w[1]
25
- }
26
- puts
27
-
28
- bs = fs.spline order:3
29
- vv = fs.axis
30
-
31
- s = bs.plot(vv, 10)
32
-
33
- puts "# Inverse data"
34
-
35
- st = fs.inverse
36
- printf "["
37
- st.each {|x| printf "% .1f ", x[0]}
38
- printf "]\n["
39
- st.each {|x| printf "% .1f ", x[1]}
40
- puts "]"
41
-
42
- # Draw Graph
43
- require "gnuplot"
44
-
45
- Gnuplot.open do |gp|
46
- Gnuplot::Plot.new( gp ) do |plot|
47
- plot.title 'sec2(x)'
48
- plot.ylabel 'Y'
49
- plot.xlabel 'X'
50
- x = vv.map {|v| v[0]}
51
- y = vv.map {|v| v[1][0]}
52
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
53
- ds.with = "lines"
54
- ds.title = "Real"
55
- end
56
- z = vv.map {|v| v[1][1]}
57
- plot.data << Gnuplot::DataSet.new( [x, z] ) do |ds|
58
- ds.with = "lines"
59
- ds.title = "Image"
60
- end
61
- p = vv.map {|v| a = v[1][0]; b = v[1][1]; Math.sqrt(a*a+b*b)}
62
- plot.data << Gnuplot::DataSet.new( [x, p] ) do |ds|
63
- ds.with = "lines"
64
- ds.linewidth = 2
65
- ds.title = "Power"
66
- end
67
- end
68
- end
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ puts "# complex FFT data points"
6
+
7
+ XY = [ [0, 1],[0, 1],[0, 1],[1, 0,],[1, 0,],[1, 0],[1, 0],[0, 1],[0, 1],[0, 1] ]
8
+
9
+ fs = XY.fft_complex_forward
10
+ fs.real.each {|x| printf("% .2f ", x) }
11
+ puts
12
+ fs.image.each {|y| printf("% .2f ", y) }
13
+ puts
14
+
15
+ printf "Real :"
16
+ -5.upto(5) {|t|
17
+ w = fs[t]
18
+ printf "% .2f ", w[0]
19
+ }
20
+ puts
21
+ printf "Image:"
22
+ -5.upto(5) {|t|
23
+ w = fs[t]
24
+ printf "% .2f ", w[1]
25
+ }
26
+ puts
27
+
28
+ bs = fs.spline order:3
29
+ vv = fs.axis
30
+
31
+ s = bs.plot(vv, 10)
32
+
33
+ puts "# Inverse data"
34
+
35
+ st = fs.inverse
36
+ printf "["
37
+ st.each {|x| printf "% .1f ", x[0]}
38
+ printf "]\n["
39
+ st.each {|x| printf "% .1f ", x[1]}
40
+ puts "]"
41
+
42
+ # Draw Graph
43
+ require "gnuplot"
44
+
45
+ Gnuplot.open do |gp|
46
+ Gnuplot::Plot.new( gp ) do |plot|
47
+ plot.title 'sec2(x)'
48
+ plot.ylabel 'Y'
49
+ plot.xlabel 'X'
50
+ x = vv.map {|v| v[0]}
51
+ y = vv.map {|v| v[1][0]}
52
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
53
+ ds.with = "lines"
54
+ ds.title = "Real"
55
+ end
56
+ z = vv.map {|v| v[1][1]}
57
+ plot.data << Gnuplot::DataSet.new( [x, z] ) do |ds|
58
+ ds.with = "lines"
59
+ ds.title = "Image"
60
+ end
61
+ p = vv.map {|v| a = v[1][0]; b = v[1][1]; Math.sqrt(a*a+b*b)}
62
+ plot.data << Gnuplot::DataSet.new( [x, p] ) do |ds|
63
+ ds.with = "lines"
64
+ ds.linewidth = 2
65
+ ds.title = "Power"
66
+ end
67
+ end
68
+ end
@@ -1,64 +1,64 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- printf "# real FFT data points\n"
6
-
7
- X = [ 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 ]
8
-
9
- fs = X.fft_real_forward
10
- fs.each {|x| printf("% .2f ", x) }
11
- puts
12
-
13
- printf "Real :"
14
- -5.upto(5) {|t|
15
- w = fs[t]
16
- printf "% .2f ", w[0]
17
- }
18
- puts
19
- printf "Image:"
20
- -5.upto(5) {|t|
21
- w = fs[t]
22
- printf "% .2f ", w[1]
23
- }
24
- puts
25
-
26
- bs = fs.spline order:3
27
- vv = fs.axis
28
-
29
- puts "# Interpolation points"
30
-
31
- s = bs.plot(vv, 10)
32
-
33
- st = fs.inverse
34
- printf "["
35
- st.each {|x| printf "% .1f ", x}
36
- puts "]"
37
-
38
- # Draw Graph
39
- require "gnuplot"
40
-
41
- Gnuplot.open do |gp|
42
- Gnuplot::Plot.new( gp ) do |plot|
43
- plot.title 'sec2(x)'
44
- plot.ylabel 'Y'
45
- plot.xlabel 'X'
46
- x = vv.map {|v| v[0]}
47
- y = vv.map {|v| v[1][0]}
48
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
49
- ds.with = "lines"
50
- ds.title = "Real"
51
- end
52
- z = vv.map {|v| v[1][1]}
53
- plot.data << Gnuplot::DataSet.new( [x, z] ) do |ds|
54
- ds.with = "lines"
55
- ds.title = "Image"
56
- end
57
- p = vv.map {|v| a = v[1][0]; b = v[1][1]; Math.sqrt(a*a+b*b)}
58
- plot.data << Gnuplot::DataSet.new( [x, p] ) do |ds|
59
- ds.with = "lines"
60
- ds.linewidth = 2
61
- ds.title = "Power"
62
- end
63
- end
64
- end
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ printf "# real FFT data points\n"
6
+
7
+ X = [ 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 ]
8
+
9
+ fs = X.fft_real_forward
10
+ fs.each {|x| printf("% .2f ", x) }
11
+ puts
12
+
13
+ printf "Real :"
14
+ -5.upto(5) {|t|
15
+ w = fs[t]
16
+ printf "% .2f ", w[0]
17
+ }
18
+ puts
19
+ printf "Image:"
20
+ -5.upto(5) {|t|
21
+ w = fs[t]
22
+ printf "% .2f ", w[1]
23
+ }
24
+ puts
25
+
26
+ bs = fs.spline order:3
27
+ vv = fs.axis
28
+
29
+ puts "# Interpolation points"
30
+
31
+ s = bs.plot(vv, 10)
32
+
33
+ st = fs.inverse
34
+ printf "["
35
+ st.each {|x| printf "% .1f ", x}
36
+ puts "]"
37
+
38
+ # Draw Graph
39
+ require "gnuplot"
40
+
41
+ Gnuplot.open do |gp|
42
+ Gnuplot::Plot.new( gp ) do |plot|
43
+ plot.title 'sec2(x)'
44
+ plot.ylabel 'Y'
45
+ plot.xlabel 'X'
46
+ x = vv.map {|v| v[0]}
47
+ y = vv.map {|v| v[1][0]}
48
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
49
+ ds.with = "lines"
50
+ ds.title = "Real"
51
+ end
52
+ z = vv.map {|v| v[1][1]}
53
+ plot.data << Gnuplot::DataSet.new( [x, z] ) do |ds|
54
+ ds.with = "lines"
55
+ ds.title = "Image"
56
+ end
57
+ p = vv.map {|v| a = v[1][0]; b = v[1][1]; Math.sqrt(a*a+b*b)}
58
+ plot.data << Gnuplot::DataSet.new( [x, p] ) do |ds|
59
+ ds.with = "lines"
60
+ ds.linewidth = 2
61
+ ds.title = "Power"
62
+ end
63
+ end
64
+ end
@@ -1,68 +1,68 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- Ad = [[-4.0, 1.34095e-3],[-3.6, 2.98189e-3],[-3.2, 6.62420e-3],[-2.8, 1.46827e-2],
6
- [-2.4, 3.23838e-2],[-2.0, 7.06508e-2],[-1.6, 1.50527e-1],[-1.2, 3.05020e-1],
7
- [-0.8, 5.59055e-1],[-0.4, 8.55639e-1],[ 0.4, 8.55639e-1],[ 0.8, 5.59055e-1],
8
- [ 1.2, 3.05020e-1],[ 1.6, 1.50527e-1],[ 2.0, 7.06508e-2],[ 2.4, 3.23838e-2],
9
- [ 2.8, 1.46827e-2],[ 3.2, 6.62420e-3],[ 3.6, 2.98189e-3],[ 4.0, 1.34095e-3]]
10
-
11
- Bd = [[-4.0, -4.0],[-3.6, -3.6],[-3.2, -3.2],[-2.8, -2.8],
12
- [-2.4, -2.4],[-2.0, -2.0],[-1.6, -1.6],[-1.2, -1.2],
13
- [-0.8, -0.8],[-0.4, -0.4],[ 0.4, 0.4],[ 0.8, 0.8],
14
- [ 1.2, 1.2],[ 1.6, 1.6],[ 2.0, 2.0],[ 2.4, 2.4],
15
- [ 2.8, 2.8],[ 3.2, 3.2],[ 3.6, 3.6],[ 4.0, 4.0]]
16
-
17
- Jbn = ARGV[0].to_i
18
-
19
- Dp = 10
20
-
21
- As = Bspline.new(Ad, 20, 5)
22
- Bs = Bspline.new(Bd, 20, 2)
23
- Ps = As * Bs
24
-
25
- puts "# Interpolation of multiple Bspline function"
26
-
27
- vv = []
28
- Ad.each do |p|
29
- printf "% .2f % f\n", p[0], p[1]
30
- vv.push p[0];
31
- end
32
- printf "# value of interpolation points, Dp = %d", Dp
33
- if Jbn == 0
34
- print "\n"
35
- elsif Jbn > 0
36
- printf ", Jbn = %d\n", Jbn
37
- elsif Jbn < 0
38
- printf ", Jsk = %d\n", -Jbn
39
- end
40
-
41
- s = Ps.plot(vv, Dp, Jbn) do |a,b|
42
- c = As.sekibun(a[0])
43
- d = Ps.sekibun(a[0])
44
- printf "% .2f % f % f % f\n", a[0], b[0], c, d
45
- end
46
- # STDERR.puts s
47
- require "gnuplot"
48
-
49
- Gnuplot.open do |gp|
50
- Gnuplot::Plot.new( gp ) do |plot|
51
- plot.title 'Multiple Bspline'
52
- plot.ylabel 'Y'
53
- plot.xlabel 'X'
54
- x = vv.map {|u,v| u[0]}
55
- y = vv.map {|u,v| v[0]}
56
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
57
- ds.with = "lines"
58
- ds.linewidth = 2
59
- ds.notitle
60
- end
61
- y = vv.map {|u,v| Ps[[u[0], 0.5*u[0]]]}
62
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
63
- ds.with = "lines"
64
- ds.linewidth = 2
65
- ds.notitle
66
- end
67
- end
68
- end
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ Ad = [[-4.0, 1.34095e-3],[-3.6, 2.98189e-3],[-3.2, 6.62420e-3],[-2.8, 1.46827e-2],
6
+ [-2.4, 3.23838e-2],[-2.0, 7.06508e-2],[-1.6, 1.50527e-1],[-1.2, 3.05020e-1],
7
+ [-0.8, 5.59055e-1],[-0.4, 8.55639e-1],[ 0.4, 8.55639e-1],[ 0.8, 5.59055e-1],
8
+ [ 1.2, 3.05020e-1],[ 1.6, 1.50527e-1],[ 2.0, 7.06508e-2],[ 2.4, 3.23838e-2],
9
+ [ 2.8, 1.46827e-2],[ 3.2, 6.62420e-3],[ 3.6, 2.98189e-3],[ 4.0, 1.34095e-3]]
10
+
11
+ Bd = [[-4.0, -4.0],[-3.6, -3.6],[-3.2, -3.2],[-2.8, -2.8],
12
+ [-2.4, -2.4],[-2.0, -2.0],[-1.6, -1.6],[-1.2, -1.2],
13
+ [-0.8, -0.8],[-0.4, -0.4],[ 0.4, 0.4],[ 0.8, 0.8],
14
+ [ 1.2, 1.2],[ 1.6, 1.6],[ 2.0, 2.0],[ 2.4, 2.4],
15
+ [ 2.8, 2.8],[ 3.2, 3.2],[ 3.6, 3.6],[ 4.0, 4.0]]
16
+
17
+ Jbn = ARGV[0].to_i
18
+
19
+ Dp = 10
20
+
21
+ As = Bspline.new(Ad, 20, 5)
22
+ Bs = Bspline.new(Bd, 20, 2)
23
+ Ps = As * Bs
24
+
25
+ puts "# Interpolation of multiple Bspline function"
26
+
27
+ vv = []
28
+ Ad.each do |p|
29
+ printf "% .2f % f\n", p[0], p[1]
30
+ vv.push p[0];
31
+ end
32
+ printf "# value of interpolation points, Dp = %d", Dp
33
+ if Jbn == 0
34
+ print "\n"
35
+ elsif Jbn > 0
36
+ printf ", Jbn = %d\n", Jbn
37
+ elsif Jbn < 0
38
+ printf ", Jsk = %d\n", -Jbn
39
+ end
40
+
41
+ s = Ps.plot(vv, Dp, Jbn) do |a,b|
42
+ c = As.sekibun(a[0])
43
+ d = Ps.sekibun(a[0])
44
+ printf "% .2f % f % f % f\n", a[0], b[0], c, d
45
+ end
46
+ # STDERR.puts s
47
+ require "gnuplot"
48
+
49
+ Gnuplot.open do |gp|
50
+ Gnuplot::Plot.new( gp ) do |plot|
51
+ plot.title 'Multiple Bspline'
52
+ plot.ylabel 'Y'
53
+ plot.xlabel 'X'
54
+ x = vv.map {|u,v| u[0]}
55
+ y = vv.map {|u,v| v[0]}
56
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
57
+ ds.with = "lines"
58
+ ds.linewidth = 2
59
+ ds.notitle
60
+ end
61
+ y = vv.map {|u,v| Ps[[u[0], 0.5*u[0]]]}
62
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
63
+ ds.with = "lines"
64
+ ds.linewidth = 2
65
+ ds.notitle
66
+ end
67
+ end
68
+ end
@@ -1,29 +1,29 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- puts "# Parametric spline interpolation"
6
-
7
- X = [0,1,2,3,4,5,6,7]
8
- Y = [ [ 1.0, 0.0], [ 0.0, 1.0], [-1.0, 0.0], [ 0.0,-1.0],
9
- [ 2.0, 0.0], [ 0.0, 2.0], [-2.0, 0.0], [ 0.0,-2.0] ]
10
- Jbn = ARGV[0].to_i
11
- Dp = 20
12
-
13
- Ps = Pspline.new(Y, [X], [8], [2], [0])
14
-
15
- Y.each do |p|
16
- printf "% .2f % .2f\n", p[0], p[1]
17
- end
18
- printf "# value of interpolation points, Dp = %d", Dp
19
- if Jbn == 0
20
- print "\n"
21
- else
22
- printf ", Jbn = %d\n", Jbn
23
- end
24
- vv = [X]
25
- s = Ps.plot(vv, Dp, [Jbn]) do |a, b|
26
- c = Ps.sekibun(a[0])
27
- printf "% .2f % .7f % .7f % .7f % .7f\n", a[0], b[0], b[1], c[0], c[1]
28
- end
29
- #STDERR.puts s
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ puts "# Parametric spline interpolation"
6
+
7
+ X = [0,1,2,3,4,5,6,7]
8
+ Y = [ [ 1.0, 0.0], [ 0.0, 1.0], [-1.0, 0.0], [ 0.0,-1.0],
9
+ [ 2.0, 0.0], [ 0.0, 2.0], [-2.0, 0.0], [ 0.0,-2.0] ]
10
+ Jbn = ARGV[0].to_i
11
+ Dp = 20
12
+
13
+ Ps = Pspline.new(Y, [X], [8], [2], [0])
14
+
15
+ Y.each do |p|
16
+ printf "% .2f % .2f\n", p[0], p[1]
17
+ end
18
+ printf "# value of interpolation points, Dp = %d", Dp
19
+ if Jbn == 0
20
+ print "\n"
21
+ else
22
+ printf ", Jbn = %d\n", Jbn
23
+ end
24
+ vv = [X]
25
+ s = Ps.plot(vv, Dp, [Jbn]) do |a, b|
26
+ c = Ps.sekibun(a[0])
27
+ printf "% .2f % .7f % .7f % .7f % .7f\n", a[0], b[0], b[1], c[0], c[1]
28
+ end
29
+ #STDERR.puts s