Class: Digiproc::Strategies::Radix2Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/strategies/fft/radix2_strategy.rb

Overview

O(n*lgn) FFT algorithm Requires that the number of datapoints be a power of 2 if it isn’t the calculation will zero pad to the closest power of 2 above the current data size The size of the outputted DFT will be the size of the zero-padded dataset. Zero-padding causes the “sample locations” of the DFT to be at different locations than if it was not zero padded, but The resolution of the DFT will INCREASE due to zero padding

Constant Summary collapse

E =
Math::E
PI =
Math::PI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil) ⇒ Radix2Strategy

Initialize Arg

data (Optional)

Array (defaults to nil)



20
21
22
23
# File 'lib/strategies/fft/radix2_strategy.rb', line 20

def initialize(data = nil)
    @data = data
    zero_fill if not data.nil?
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



15
16
17
# File 'lib/strategies/fft/radix2_strategy.rb', line 15

def data
  @data
end

Instance Method Details

#calculate(data = @data) ⇒ Object

Input arg

data (Optional)

Array (defaults to @data)



28
29
30
# File 'lib/strategies/fft/radix2_strategy.rb', line 28

def calculate(data = @data)
    recursive_fft(data)
end