Last active
March 6, 2017 19:57
-
-
Save diegocasmo/4a9d1f91e07d0344e06e4ecf0f90cd86 to your computer and use it in GitHub Desktop.
Tests for the implementation of the 'The Fast Fourier Transform Algorithm'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'minitest/autorun' | |
require './fft' | |
describe FFT do | |
before do | |
@fft = FFT.new | |
end | |
describe "#fft" do | |
it "should return a point-wise representation of a polynomial of degree 1" do | |
assert_equal(@fft.fft([1, 1]), [ | |
Complex(2, +0), | |
Complex(0.0, -1.2246467991473532e-16) | |
]) | |
end | |
it "should return a point-wise representation of a polynomial of degree 3" do | |
assert_equal(@fft.fft([1, 1, 0, 0]), [ | |
Complex(2, +0), | |
Complex(1.0, -1.0), | |
Complex(0.0, -1.2246467991473532e-16), | |
Complex(0.9999999999999998, +1.0) | |
]) | |
end | |
it "should return a point-wise representation of a polynomial of degree 7" do | |
assert_equal(@fft.fft([1, 1, 1, 1, 0, 0, 0, 0]), [ | |
Complex(4, +0), | |
Complex(1.0, -2.414213562373095), | |
Complex(-1.2246467991473532e-16, -1.2246467991473532e-16), | |
Complex(1.0, -0.4142135623730949), | |
Complex(0.0, -2.4492935982947064e-16), | |
Complex(0.9999999999999998, +0.41421356237309515), | |
Complex(1.2246467991473532e-16, -1.224646799147353e-16), | |
Complex(0.9999999999999994, +2.414213562373095) | |
]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full blog post can be found here: https://medium.com/@diegocasmo/the-fast-fourier-transform-algorithm-6f06900c565b#.lqtcu69lk