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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd676129ee15c3a24f0aba8101aa3c4e2f0a6ac1
4
- data.tar.gz: 28632b037254bcef8dee32470ee0ab513864e21f
3
+ metadata.gz: 8dacedf68daad7cf3e2b1e3f8aa1e59ccce2408d
4
+ data.tar.gz: 948d586d9d991821a7e0d640ad9ef63fd98fc074
5
5
  SHA512:
6
- metadata.gz: b029fa56366d6557ae1d97fc2f9f4124b393b9c35afe0ccdbca1c8da5e51aacb64da8f00ca3f7446bf857eee0c61a068f9bce55d2d8ea56ba961c56d6ecea19d
7
- data.tar.gz: f5f54d6eabcfb247a31f3d91bf415b84cc4834dccb6c151e1dd90bbd41846639e1adf4279a9e79fd4176d710f407acf1e2e03ef1bff846253dc1b4892d002986
6
+ metadata.gz: c61c3af1bfaed26c57d94e144ad9e6546a5e7a21e2b194d3a703f90640b2beafc87450e4752b1399cc452ecba6cf41e154dee27359912ef5977ba396946dd5d5
7
+ data.tar.gz: 386924860c51388e0ddbd74fc6e95dca67dd771556c13b2d58500e3b833bb476003cd40b539bd496862012f11371e9ecd4e8a1999cb05a4bea2baaba376244bb
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in pspline.gemspec
4
- gemspec
5
- gem "rake-compiler"
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pspline.gemspec
4
+ gemspec
5
+ gem "rake-compiler"
data/README.md CHANGED
@@ -29,6 +29,7 @@ See pspline.wiki at https://github.com/vsp2old/pspline .
29
29
  5.0.2 Upload for release.
30
30
  5.0.3 Add class PSPLINE::Rfft, class PSPLINE::Cfft.
31
31
  5.0.4 Add method line_integral.
32
+ 5.0.5 Add Multiple Bspline.
32
33
 
33
34
  ## Development
34
35
 
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rake/extensiontask"
3
-
4
- Rake::ExtensionTask.new "pspline" do |ext|
5
- ext.lib_dir = "lib/pspline"
6
- end
1
+ require "bundler/gem_tasks"
2
+ require "rake/extensiontask"
3
+
4
+ Rake::ExtensionTask.new "pspline" do |ext|
5
+ ext.lib_dir = "lib/pspline"
6
+ end
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "pspline"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pspline"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,36 +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
- # STDERR.puts s
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,36 +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
- #puts s
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,33 +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
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,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.imag.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 "Imag :"
22
- -5.upto(5) {|t|
23
- w = fs[t]
24
- printf "% .2f ", w[1]
25
- }
26
- puts
27
-
28
- bs = fs.spline(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
+