pspline 5.0.2 → 5.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa8139dbd0860ead8217998e30e2e6a47668139d
4
- data.tar.gz: 0da507577b79ca733d4200a9e0a433877d40cf00
3
+ metadata.gz: cb96468c596ae7908fdd735008f4a5a22a68a56b
4
+ data.tar.gz: 7239450009f59fcda3844416ec1a7b575e8aa2ad
5
5
  SHA512:
6
- metadata.gz: 72f9669ca12d4c7b71dbe765a13813403c981668198a2106a40606b138abb6a35fe4b7359be858597abd18b7e99da8ddf22392d0c894407951e38ce651d1d24d
7
- data.tar.gz: d183a49bb333a423ebeac8a98c5dce9436192645aa7de31f5f60a8c77f96958e90310629d92d1fcc290f196b8e55b9de71c44a06257e0e3c67d38872821b244a
6
+ metadata.gz: a4e07bd3ba5932852d9bdcfa5ec22b7b1826a276b5830b3dab7f639f2a6fd51a9dbdf48c6faacd33cc3a7e4c9298777df5159834095b412210988a26510faf14
7
+ data.tar.gz: 78858c5c8f9ca31ee18551cfee1877a165ba909ec60f5dbedb3c338398f912224cb372fdc6bd998333edc05b2ce851780d0711ea5f657922087385c86ff6d32e
data/README.md CHANGED
@@ -22,6 +22,13 @@ Or install it yourself as:
22
22
 
23
23
  See pspline.wiki at https://github.com/vsp2old/pspline .
24
24
 
25
+ ## Revision history
26
+
27
+ 5.0.0 Upload for test.
28
+ 5.0.1 Upload for test.
29
+ 5.0.2 Upload for release.
30
+ 5.0.3 Add class PSPLINE::Rfft, class PSPLINE::Cfft.
31
+
25
32
  ## Development
26
33
 
27
34
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -2,53 +2,31 @@
2
2
  require 'pspline'
3
3
  include PSPLINE
4
4
 
5
- =begin
6
-
7
- 1 varable M dimension parametric interpolation
8
-
9
- 【Module】 PSPLINE
10
- 【Module Function】
11
-
12
- (1)obj = PSPLINE#fft_complex_transform([[x1,y1],...,[xn,yn]], f)
13
- obj => FFT:[[u1,...,un],[v1,...,vn]]
14
- :1 list of complex data
15
- :2 type 1 => forward, 0 => backword, -1 => inverse
16
-
17
- (2)obj = PSPLINE#fft_complex_get([[u1,...,un],[v1,...,vn]], t)
18
- obj => [x,y]
19
- :1 FFT_complex data
20
- :2 data point ( -N/2 <= t <= N/2 + N%2 )
21
-
22
- (3)obj = PSPLINE#fft_complex_bspline([[u1,...,un],[v1,...,vn]], j)
23
- obj => PSPLINE#Bspline
24
- :1 FFT_complex data
25
- :2 dimension
26
-
27
- =end
28
-
29
5
  puts "# complex FFT data points"
30
6
 
31
7
  XY = [ [0, 1],[0, 1],[0, 1],[1, 0,],[1, 0,],[1, 0],[1, 0],[0, 1],[0, 1],[0, 1] ]
32
8
 
33
- fs = fft_complex_transform(XY, 1);
34
- fs[0].each {|x| printf("% .2f ", x) }
9
+ fs = Cfft.new(XY)
10
+ fs.real.each {|x| printf("% .2f ", x) }
35
11
  puts
36
- fs[1].each {|y| printf("% .2f ", y) }
12
+ fs.imag.each {|y| printf("% .2f ", y) }
37
13
  puts
38
14
 
15
+ printf "Real :"
39
16
  -5.upto(5) {|t|
40
- w = fft_complex_get(fs, t)
17
+ w = fs[t]
41
18
  printf "% .2f ", w[0]
42
19
  }
43
20
  puts
21
+ printf "Imag :"
44
22
  -5.upto(5) {|t|
45
- w = fft_complex_get(fs, t)
23
+ w = fs[t]
46
24
  printf "% .2f ", w[1]
47
25
  }
48
26
  puts
49
27
 
50
- vv = []
51
- bs = fft_complex_bspline(fs, 1) {|t, z| vv.push t}
28
+ bs = fs.spline(1)
29
+ vv = fs.axis
52
30
 
53
31
  puts "# Interpolation points"
54
32
 
@@ -57,7 +35,7 @@ s = bs.plot(vv, 4) do |a, b|
57
35
  end
58
36
  #STDERR.puts s
59
37
 
60
- st = fft_complex_transform(fs, -1)
38
+ st = fs.inverse
61
39
  printf "["
62
40
  st.each {|x| printf "% .1f ", x[0]}
63
41
  printf "]\n["
@@ -6,25 +6,25 @@ printf "# real FFT data points\n"
6
6
 
7
7
  X = [ 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 ]
8
8
 
9
- fs = fft_real_transform(X, 1);
10
- fs.each {|x| printf("% .2f ", x) }
9
+ fs = Rfft.new(X);
10
+ fs.real.each {|x| printf("% .2f ", x) }
11
11
  puts
12
12
 
13
13
  printf "Real :"
14
14
  -5.upto(5) {|t|
15
- w = fft_real_get(fs, t)
15
+ w = fs[t]
16
16
  printf "% .2f ", w[0]
17
17
  }
18
18
  puts
19
19
  printf "Imag :"
20
20
  -5.upto(5) {|t|
21
- w = fft_real_get(fs, t)
21
+ w = fs[t]
22
22
  printf "% .2f ", w[1]
23
23
  }
24
24
  puts
25
25
 
26
- vv = []
27
- bs = fft_real_bspline(fs, 3) {|t, z| vv.push t}
26
+ bs = fs.spline(3)
27
+ vv = fs.axis
28
28
 
29
29
  puts "# Interpolation points"
30
30
 
@@ -33,7 +33,7 @@ s = bs.plot(vv, 4) do |a, b|
33
33
  end
34
34
  #STDERR.puts s
35
35
 
36
- st = fft_real_transform(fs, -1)
36
+ st = fs.inverse
37
37
  printf "["
38
38
  st.each {|x| printf "% .1f ", x}
39
39
  puts "]"
data/lib/pspline.rb CHANGED
@@ -2,5 +2,62 @@ require "pspline/version"
2
2
  require "pspline.so"
3
3
 
4
4
  module PSPLINE
5
- # Your code goes here...
5
+
6
+ class Rfft
7
+
8
+ def initialize(data)
9
+ @R = fft_real_transform(data, 1)
10
+ end
11
+ def [] (t)
12
+ fft_real_get(@R, t)
13
+ end
14
+ def spline(j)
15
+ @V = []
16
+ fft_real_bspline(@R, j) {|t, z| @V.push t}
17
+ end
18
+ def axis
19
+ @V.dup
20
+ end
21
+ def inverse
22
+ fft_real_transform(@R, -1)
23
+ end
24
+ def backword
25
+ fft_real_transform(@R, 0)
26
+ end
27
+ def real
28
+ @R.dup
29
+ end
30
+
31
+ end
32
+
33
+ class Cfft
34
+
35
+ def initialize(data)
36
+ @F = fft_complex_transform(data, 1)
37
+ end
38
+ def [] (t)
39
+ fft_complex_get(@F, t)
40
+ end
41
+ def spline(j)
42
+ @V = []
43
+ fft_complex_bspline(@F, j) {|t, z| @V.push t}
44
+ end
45
+ def inverse
46
+ fft_complex_transform(@F, -1)
47
+ end
48
+ def backword
49
+ fft_real_transform(@F, 0)
50
+ end
51
+ def axis
52
+ @V.dup
53
+ end
54
+ def real
55
+ @F[0].dup
56
+ end
57
+ def imag
58
+ @F[1].dup
59
+ end
60
+
61
+ end
62
+
6
63
  end
@@ -1,3 +1,3 @@
1
1
  module PSPLINE
2
- VERSION = "5.0.2"
2
+ VERSION = "5.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pspline
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - vsp2old
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-27 00:00:00.000000000 Z
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler