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,57 +1,57 @@
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
- Jbn = ARGV[0].to_i
12
-
13
- Dp = 10
14
-
15
- Bs = Bspline.new(Ad, 20, 5)
16
-
17
- puts "# Interpolation of the sec2(x) function"
18
-
19
- vv = []
20
- Ad.each do |p|
21
- printf "% .2f % 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
- elsif Jbn > 0
28
- printf ", Jbn = %d\n", Jbn
29
- elsif Jbn < 0
30
- printf ", Jsk = %d\n", -Jbn
31
- end
32
-
33
- s = Bs.plot(vv, Dp, Jbn) do |a,b|
34
- printf "% .2f % f\n", a, b[0]
35
- end
36
- # Draw Graph
37
- require "gnuplot"
38
-
39
- Gnuplot.open do |gp|
40
- Gnuplot::Plot.new( gp ) do |plot|
41
- plot.title 'sec2(x)'
42
- plot.ylabel 'Y'
43
- plot.xlabel 'X'
44
- x = vv.map {|v| v[0]}
45
- y = vv.map {|v| v[1]}
46
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
47
- ds.with = "lines"
48
- ds.linewidth = 2
49
- ds.notitle
50
- end
51
- y = x.map {|v| Bs.sekibun(v)}
52
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
53
- ds.with = "lines"
54
- ds.title = "Integral"
55
- end
56
- end
57
- 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
+ Jbn = ARGV[0].to_i
12
+
13
+ Dp = 10
14
+
15
+ Bs = Bspline.new(Ad, 20, 5)
16
+
17
+ puts "# Interpolation of the sec2(x) function"
18
+
19
+ vv = []
20
+ Ad.each do |p|
21
+ printf "% .2f % 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
+ elsif Jbn > 0
28
+ printf ", Jbn = %d\n", Jbn
29
+ elsif Jbn < 0
30
+ printf ", Jsk = %d\n", -Jbn
31
+ end
32
+
33
+ s = Bs.plot(vv, Dp, Jbn) do |a,b|
34
+ printf "% .2f % .15f\n", a, b[0]
35
+ end
36
+ # Draw Graph
37
+ require "gnuplot"
38
+
39
+ Gnuplot.open do |gp|
40
+ Gnuplot::Plot.new( gp ) do |plot|
41
+ plot.title 'sec2(x)'
42
+ plot.ylabel 'Y'
43
+ plot.xlabel 'X'
44
+ x = vv.map {|v| v[0]}
45
+ y = vv.map {|v| v[1]}
46
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
47
+ ds.with = "lines"
48
+ ds.linewidth = 2
49
+ ds.notitle
50
+ end
51
+ y = x.map {|v| Bs.sekibun(v)}
52
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
53
+ ds.with = "lines"
54
+ ds.title = "Integral"
55
+ end
56
+ end
57
+ end
@@ -1,57 +1,57 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- n = 7
6
- j = 5
7
-
8
- #
9
- #puts "# Interpolation of the Bessel function"
10
- #
11
- # Data points
12
- Ad = [ [0.0, 1.0 ],[0.8, 0.84629],[1.6, 0.45540],[2.0, 0.22389],
13
- [2.4, 0.00251],[3.2,-0.32019],[4.0,-0.39715], ]
14
- # Additional data points
15
- C = [ [0.4, 0.96040],[1.2, 0.67113],[2.8,-0.18504],[3.6,-0.39177] ]
16
- Jbn = ARGV[0].to_i
17
- Dp = 10
18
-
19
- Bs = Bspline.new(Ad + C, n, j)
20
-
21
- vv = []
22
- for i in 0..6
23
- (p, q) = Ad[i]
24
- printf "%.2f, % f\n", p, q
25
- vv.push p
26
- end
27
- printf "# value of interpolation points, Dp = %d", Dp
28
- if Jbn == 0
29
- print "\n"
30
- else
31
- printf ", Jbn = %d\n", Jbn
32
- end
33
- s = Bs.plot(vv, Dp, Jbn) do |u, v|
34
- printf "% .2f % f\n", u, v[0]
35
- end
36
- # Draw Graph
37
- require "gnuplot"
38
-
39
- Gnuplot.open do |gp|
40
- Gnuplot::Plot.new( gp ) do |plot|
41
- plot.title 'Bessel'
42
- plot.ylabel 'Y'
43
- plot.xlabel 'X'
44
- x = vv.map {|v| v[0]}
45
- y = vv.map {|v| v[1]}
46
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
47
- ds.with = "lines"
48
- ds.linewidth = 2
49
- ds.notitle
50
- end
51
- y = x.map {|v| Bs.sekibun(v)}
52
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
53
- ds.with = "lines"
54
- ds.title = "Integral"
55
- end
56
- end
57
- end
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ n = 7
6
+ j = 5
7
+
8
+ #
9
+ #puts "# Interpolation of the Bessel function"
10
+ #
11
+ # Data points
12
+ Ad = [ [0.0, "1.0" ],[0.8," 0.84629"],[1.6," 0.45540"],[2.0, "0.22389"],
13
+ [2.4, "0.00251"],[3.2,"-0.32019"],[4.0,"-0.39715"], ]
14
+ # Additional data points
15
+ C = [ [0.4, "0.96040"],[1.2, "0.67113"],[2.8,"-0.18504"],[3.6,"-0.39177"] ]
16
+ Jbn = ARGV[0].to_i
17
+ Dp = 10
18
+
19
+ Bs = Bspline.new(Ad + C, n, j)
20
+
21
+ vv = []
22
+ for i in 0..6
23
+ (p, q) = Ad[i]
24
+ printf "%.2f, % .5f\n", p, q
25
+ vv.push p
26
+ end
27
+ printf "# value of interpolation points, Dp = %d", Dp
28
+ if Jbn == 0
29
+ print "\n"
30
+ else
31
+ printf ", Jbn = %d\n", Jbn
32
+ end
33
+ s = Bs.plot(vv, Dp, Jbn) do |u, v|
34
+ printf "% .2f % .15f\n", u, v[0]
35
+ end
36
+ # Draw Graph
37
+ require "gnuplot"
38
+
39
+ Gnuplot.open do |gp|
40
+ Gnuplot::Plot.new( gp ) do |plot|
41
+ plot.title 'Bessel'
42
+ plot.ylabel 'Y'
43
+ plot.xlabel 'X'
44
+ x = vv.map {|v| v[0]}
45
+ y = vv.map {|v| v[1]}
46
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
47
+ ds.with = "lines"
48
+ ds.linewidth = 2
49
+ ds.notitle
50
+ end
51
+ y = x.map {|v| Bs.sekibun(v)}
52
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
53
+ ds.with = "lines"
54
+ ds.title = "Integral"
55
+ end
56
+ end
57
+ end
@@ -1,55 +1,55 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- puts "# Interpolation of the sin(x) function"
6
-
7
- XY = [ [0.0],[1.0],[2.0],[3.0],[4.0],[5.0],[6.283185] ]
8
-
9
- XY.each do |a|
10
- a.push Math.sin(a[0])
11
- end
12
-
13
- C = [ [0.0, 1.0],[0.0, 0.0],[6.283185, 1.0],[6.283185, 0.0] ]
14
- D = [1, 2, 1, 2]
15
- Jbn = ARGV[0].to_i
16
- Dp = 10
17
-
18
- Bs = Bspline.new(XY + C, 7, 5, D);
19
-
20
- vv = []
21
- XY.each do |p|
22
- printf "% f, % f\n", p[0], p[1]
23
- vv.push p[0]
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
- s = Bs.plot(vv, 10, Jbn) do |a, b|
32
- printf "% f % f\n", a, b[0]
33
- end
34
- # Draw Graph
35
- require "gnuplot"
36
-
37
- Gnuplot.open do |gp|
38
- Gnuplot::Plot.new( gp ) do |plot|
39
- plot.title 'sin(x)'
40
- plot.ylabel 'Y'
41
- plot.xlabel 'X'
42
- x = vv.map {|v| v[0]}
43
- y = vv.map {|v| v[1]}
44
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
45
- ds.with = "lines"
46
- ds.linewidth = 2
47
- ds.notitle
48
- end
49
- y = x.map {|v| Bs.sekibun(v) - 1}
50
- plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
51
- ds.with = "lines"
52
- ds.title = "Integral"
53
- end
54
- end
55
- end
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ puts "# Interpolation of the sin(x) function"
6
+
7
+ XY = [ [0.0],[1.0],[2.0],[3.0],[4.0],[5.0],[6.283185] ]
8
+
9
+ XY.each do |a|
10
+ a.push Math.sin(a[0])
11
+ end
12
+
13
+ C = [ [0.0, 1.0],[0.0, 0.0],[6.283185, 1.0],[6.283185, 0.0] ]
14
+ D = [1, 2, 1, 2]
15
+ Jbn = ARGV[0].to_i
16
+ Dp = 10
17
+
18
+ Bs = Bspline.new(XY + C, 7, 5, D);
19
+
20
+ vv = []
21
+ XY.each do |p|
22
+ printf "% f, % f\n", p[0], p[1]
23
+ vv.push p[0]
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
+ s = Bs.plot(vv, 10, Jbn) do |a, b|
32
+ printf "% f % .15f\n", a, b[0]
33
+ end
34
+ # Draw Graph
35
+ require "gnuplot"
36
+
37
+ Gnuplot.open do |gp|
38
+ Gnuplot::Plot.new( gp ) do |plot|
39
+ plot.title 'sin(x)'
40
+ plot.ylabel 'Y'
41
+ plot.xlabel 'X'
42
+ x = vv.map {|v| v[0]}
43
+ y = vv.map {|v| v[1]}
44
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
45
+ ds.with = "lines"
46
+ ds.linewidth = 2
47
+ ds.notitle
48
+ end
49
+ y = x.map {|v| Bs.sekibun(v) - 1}
50
+ plot.data << Gnuplot::DataSet.new( [x, y] ) do |ds|
51
+ ds.with = "lines"
52
+ ds.title = "Integral"
53
+ end
54
+ end
55
+ end
@@ -1,44 +1,44 @@
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 = Cfft.new(XY)
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:1
29
- vv = fs.axis
30
-
31
- puts "# Interpolation points"
32
-
33
- s = bs.plot(vv, 4) do |a, b|
34
- printf "% .2f %10.7f %10.7f\n", a, b[0], b[1]
35
- end
36
- #STDERR.puts s
37
-
38
- st = fs.inverse
39
- printf "["
40
- st.each {|x| printf "% .1f ", x[0]}
41
- printf "]\n["
42
- st.each {|x| printf "% .1f ", x[1]}
43
- puts "]"
44
-
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 = Cfft.new(XY)
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:1
29
+ vv = fs.axis
30
+
31
+ puts "# Interpolation points"
32
+
33
+ s = bs.plot(vv, 4) do |a, b|
34
+ printf "% .2f %10.7f %10.7f\n", a, b[0], b[1]
35
+ end
36
+ #STDERR.puts s
37
+
38
+ st = fs.inverse
39
+ printf "["
40
+ st.each {|x| printf "% .1f ", x[0]}
41
+ printf "]\n["
42
+ st.each {|x| printf "% .1f ", x[1]}
43
+ puts "]"
44
+
@@ -1,40 +1,40 @@
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 = Rfft.new(X);
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, 4) do |a, b|
32
- printf "% .2f %10.7f %10.7f\n", a, b[0], b[1]
33
- end
34
- #STDERR.puts s
35
-
36
- st = fs.inverse
37
- printf "["
38
- st.each {|x| printf "% .1f ", x}
39
- puts "]"
40
-
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 = Rfft.new(X);
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, 4) do |a, b|
32
+ printf "% .2f %10.7f %10.7f\n", a, b[0], b[1]
33
+ end
34
+ #STDERR.puts s
35
+
36
+ st = fs.inverse
37
+ printf "["
38
+ st.each {|x| printf "% .1f ", x}
39
+ puts "]"
40
+