Class: Digiproc::Strategies::IFFTConjugateStrategy

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

Overview

Strategy for calculating the Inverse Fast Fourier Transform (IFFT) O(nlgn) runtime, depends on the FFT strategy to calculate thie IFFT Uses “conjugate strategy”

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, fft_strategy = Digiproc::Strategies::Radix2Strategy) ⇒ IFFTConjugateStrategy

Input args:

data

Array (DFT values)

fft_strategy(Optional)

See Digiproc::Strategies::Radix2Strategy for required protocol (This is the default value)



13
14
15
16
# File 'lib/strategies/fft/inverse_fft_conjugate_strategy.rb', line 13

def initialize(data, fft_strategy = Digiproc::Strategies::Radix2Strategy)
    @data = data
    @strategy = fft_strategy.new
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



7
8
9
# File 'lib/strategies/fft/inverse_fft_conjugate_strategy.rb', line 7

def data
  @data
end

#strategyObject

Returns the value of attribute strategy.



7
8
9
# File 'lib/strategies/fft/inverse_fft_conjugate_strategy.rb', line 7

def strategy
  @strategy
end

Instance Method Details

#calculateObject

No input args Calculate the IFFT given Discrete Fourier Transform (DFT) values



21
22
23
24
25
26
# File 'lib/strategies/fft/inverse_fft_conjugate_strategy.rb', line 21

def calculate
    strategy.data = conjugate(data)
    fft_out = strategy.calculate
    n = fft_out.length.to_f
    conjugate(fft_out){ |real, imag| OpenStruct.new(real: (real / n), imaginary: (imag / n) ) }
end