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.
- checksums.yaml +4 -4
- data/Gemfile +5 -5
- data/README.md +1 -0
- data/Rakefile +6 -6
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/ext/pspline/example/exbspline.rb +57 -36
- data/ext/pspline/example/excspline.rb +57 -36
- data/ext/pspline/example/exdspline.rb +55 -33
- data/ext/pspline/example/exfspline.rb +44 -44
- data/ext/pspline/example/exfspline1.rb +40 -40
- data/ext/pspline/example/exfspline2.rb +68 -0
- data/ext/pspline/example/exfspline3.rb +64 -0
- data/ext/pspline/example/exmspline.rb +68 -0
- data/ext/pspline/example/expspline.rb +29 -29
- data/ext/pspline/example/expspline1.rb +29 -29
- data/ext/pspline/example/expspline2.rb +47 -47
- data/ext/pspline/example/exqspline.rb +31 -31
- data/ext/pspline/example/exqspline2.rb +50 -50
- data/ext/pspline/example/exqspline3.rb +51 -51
- data/ext/pspline/example/exqspline4.rb +35 -0
- data/ext/pspline/example/exrspline.rb +34 -34
- data/ext/pspline/example/exrspline1.rb +34 -34
- data/ext/pspline/example/exrspline2.rb +44 -44
- data/ext/pspline/example/exsspline.rb +35 -35
- data/ext/pspline/example/exsspline1.rb +35 -35
- data/ext/pspline/example/extspline.rb +54 -32
- data/ext/pspline/include/basis/pspline.h +156 -20
- data/ext/pspline/include/bspline_Config.h +2 -2
- data/ext/pspline/plotsub.cpp +15 -8
- data/ext/pspline/pspline.cpp +160 -66
- data/lib/pspline.rb +71 -63
- data/lib/pspline/version.rb +3 -3
- data/pspline.gemspec +25 -25
- metadata +7 -13
- data/ext/pspline/example/example.rb +0 -34
- data/ext/pspline/example/exbspline.ps +0 -2194
- data/ext/pspline/example/excspline.ps +0 -2985
- data/ext/pspline/example/exdspline.ps +0 -2846
- data/ext/pspline/example/expspline.ps +0 -3299
- data/ext/pspline/example/exqspline.ps +0 -2957
- data/ext/pspline/example/exrspline.ps +0 -2812
- data/ext/pspline/example/exsspline.ps +0 -1965
- data/ext/pspline/example/extspline.ps +0 -2767
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8dacedf68daad7cf3e2b1e3f8aa1e59ccce2408d
|
|
4
|
+
data.tar.gz: 948d586d9d991821a7e0d640ad9ef63fd98fc074
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
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
|
data/bin/console
CHANGED
|
@@ -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
|
-
#
|
|
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
|
-
#
|
|
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.
|
|
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 "
|
|
22
|
-
-5.upto(5) {|t|
|
|
23
|
-
w = fs[t]
|
|
24
|
-
printf "% .2f ", w[1]
|
|
25
|
-
}
|
|
26
|
-
puts
|
|
27
|
-
|
|
28
|
-
bs = fs.spline
|
|
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
|
+
|