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,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.real.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 "Imag :"
20
- -5.upto(5) {|t|
21
- w = fs[t]
22
- printf "% .2f ", w[1]
23
- }
24
- puts
25
-
26
- bs = fs.spline(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
+
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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,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
@@ -1,29 +1,29 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- puts "# Parametric spline interpolation"
6
-
7
- XY = [ [0, 1.0, 0.0], [1, 0.0, 1.0], [2,-1.0, 0.0], [3, 0.0,-1.0],
8
- [4, 2.0, 0.0], [5, 0.0, 2.0], [6,-2.0, 0.0], [7, 0.0,-2.0] ]
9
- Jbn = ARGV[0].to_i
10
- Dp = 20
11
-
12
- Qs = Bspline.new(XY, 8, 2)
13
-
14
- vv = []
15
- XY.each do |p|
16
- printf "<% .1f % .1f>\n", p[1], p[2]
17
- vv.push p[0]
18
- end
19
- printf "# value of interpolation points, Dp = %d", Dp
20
- if Jbn == 0
21
- print "\n"
22
- else
23
- printf ", Jbn = %d\n", Jbn
24
- end
25
- s = Qs.plot(vv, Dp, Jbn) do |a, b|
26
- c = Qs.sekibun(a);
27
- printf "% .2f % .7f % .7f % .7f % .7f\n", a, 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
+ XY = [ [0, 1.0, 0.0], [1, 0.0, 1.0], [2,-1.0, 0.0], [3, 0.0,-1.0],
8
+ [4, 2.0, 0.0], [5, 0.0, 2.0], [6,-2.0, 0.0], [7, 0.0,-2.0] ]
9
+ Jbn = ARGV[0].to_i
10
+ Dp = 20
11
+
12
+ Qs = Bspline.new(XY, 8, 2)
13
+
14
+ vv = []
15
+ XY.each do |p|
16
+ printf "<% .1f % .1f>\n", p[1], p[2]
17
+ vv.push p[0]
18
+ end
19
+ printf "# value of interpolation points, Dp = %d", Dp
20
+ if Jbn == 0
21
+ print "\n"
22
+ else
23
+ printf ", Jbn = %d\n", Jbn
24
+ end
25
+ s = Qs.plot(vv, Dp, Jbn) do |a, b|
26
+ c = Qs.sekibun(a);
27
+ printf "% .2f % .7f % .7f % .7f % .7f\n", a, b[0], b[1], c[0], c[1]
28
+ end
29
+ #STDERR.puts s
@@ -1,47 +1,47 @@
1
- #! /usr/local/bin/ruby
2
- require 'pspline'
3
- include PSPLINE
4
-
5
- # Parametric interpolation
6
-
7
- nn = [5, 3]
8
- jj = [3, 2]
9
- ss = [0, 0]
10
-
11
- puts "# 2 variable 3 dimension parametric spline interpolation"
12
-
13
- S = [0, 1, 2, 3, 4]
14
- T = [0, 1, 2]
15
-
16
- XYZ = [ [[ 2.0,-1.0,-2.0], [ 2.0,-2.0,-1.0], [ 2.0,-2.0,-3.0]],
17
- [[ 1.0, 0.0,-1.0], [ 1.0,-1.0, 0.0], [ 1.0,-1.0,-2.0]],
18
- [[ 0.0, 2.0, 0.0], [ 0.0, 0.0, 2.0], [ 0.0, 0.0,-2.0]],
19
- [[-1.0, 2.0, 1.0], [-1.0, 1.0, 2.0], [-1.0, 1.0, 0.0]],
20
- [[-2.0, 3.0, 2.0], [-2.0, 2.0, 3.0], [-2.0, 2.0, 1.0]] ]
21
-
22
- Jbn = ARGV[0].to_i
23
-
24
- Dp = 10
25
-
26
- Ps = Pspline.new(XYZ, [S, T], nn, jj, ss)
27
-
28
- for i in 0..4
29
- for j in 0..2
30
- printf "%d,%d", S[i], T[j]
31
- u = XYZ[i][j]
32
- printf " <% .1f % .1f % .1f>\n", u[0], u[1], u[2]
33
- end
34
- end
35
- printf "# value of interpolation points, Dp = %d", Dp
36
- if Jbn == 0
37
- print "\n"
38
- else
39
- printf ", Jbn = %d\n", Jbn
40
- end
41
- vv = [S, T]
42
- N = Ps.plot(vv, Dp, [Jbn,0]) do |a, b|
43
- if (a[0] == 0.1)
44
- printf "% .2f % .2f % f % f % f\n", a[0], a[1], b[0], b[1], b[2]
45
- end
46
- end
47
- #STDERR.puts N
1
+ #! /usr/local/bin/ruby
2
+ require 'pspline'
3
+ include PSPLINE
4
+
5
+ # Parametric interpolation
6
+
7
+ nn = [5, 3]
8
+ jj = [3, 2]
9
+ ss = [0, 0]
10
+
11
+ puts "# 2 variable 3 dimension parametric spline interpolation"
12
+
13
+ S = [0, 1, 2, 3, 4]
14
+ T = [0, 1, 2]
15
+
16
+ XYZ = [ [[ 2.0,-1.0,-2.0], [ 2.0,-2.0,-1.0], [ 2.0,-2.0,-3.0]],
17
+ [[ 1.0, 0.0,-1.0], [ 1.0,-1.0, 0.0], [ 1.0,-1.0,-2.0]],
18
+ [[ 0.0, 2.0, 0.0], [ 0.0, 0.0, 2.0], [ 0.0, 0.0,-2.0]],
19
+ [[-1.0, 2.0, 1.0], [-1.0, 1.0, 2.0], [-1.0, 1.0, 0.0]],
20
+ [[-2.0, 3.0, 2.0], [-2.0, 2.0, 3.0], [-2.0, 2.0, 1.0]] ]
21
+
22
+ Jbn = ARGV[0].to_i
23
+
24
+ Dp = 10
25
+
26
+ Ps = Pspline.new(XYZ, [S, T], nn, jj, ss)
27
+
28
+ for i in 0..4
29
+ for j in 0..2
30
+ printf "%d,%d", S[i], T[j]
31
+ u = XYZ[i][j]
32
+ printf " <% .1f % .1f % .1f>\n", u[0], u[1], u[2]
33
+ end
34
+ end
35
+ printf "# value of interpolation points, Dp = %d", Dp
36
+ if Jbn == 0
37
+ print "\n"
38
+ else
39
+ printf ", Jbn = %d\n", Jbn
40
+ end
41
+ vv = [S, T]
42
+ N = Ps.plot(vv, Dp, [Jbn,0]) do |a, b|
43
+ if (a[0] == 0.1)
44
+ printf "% .2f % .2f % f % f % f\n", a[0], a[1], b[0], b[1], b[2]
45
+ end
46
+ end
47
+ #STDERR.puts N