Class: SPCore::TukeyWindow
- Inherits:
-
Object
- Object
- SPCore::TukeyWindow
- Defined in:
- lib/spcore/windows/tukey_window.rb
Overview
For more info, see en.wikipedia.org/wiki/Window_function#Tukey_window.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(size, alpha = 0.5) ⇒ TukeyWindow
constructor
A new instance of TukeyWindow.
Constructor Details
#initialize(size, alpha = 0.5) ⇒ TukeyWindow
Returns a new instance of TukeyWindow.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/spcore/windows/tukey_window.rb', line 9 def initialize size, alpha = 0.5 @data = Array.new(size) left = (alpha * (size - 1) / 2.0).to_i right = ((size - 1) * (1.0 - (alpha / 2.0))).to_i size_min_1 = size - 1 for n in 0...left x = Math::PI * (((2.0 * n) / (alpha * size_min_1)) - 1.0) @data[n] = 0.5 * (1.0 + Math::cos(x)) end for n in left..right @data[n] = 1.0 end for n in (right + 1)...size x = Math::PI * (((2 * n) / (alpha * size_min_1)) - (2.0 / alpha) + 1.0) @data[n] = 0.5 * (1.0 + Math::cos(x)) end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/spcore/windows/tukey_window.rb', line 8 def data @data end |