MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / fft

Method fft

src/test/java/com/thealgorithms/maths/FFTTest.java:116–137  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

114 // https://scistatcalc.blogspot.com/2013/12/fft-calculator.html used this link to
115 // ensure the result
116 @Test
117 void fft() {
118 ArrayList<FFT.Complex> arr = new ArrayList<FFT.Complex>();
119 FFT.Complex complex1 = new FFT.Complex(2.0, 2.0);
120 FFT.Complex complex2 = new FFT.Complex(1.0, 3.0);
121 FFT.Complex complex3 = new FFT.Complex(3.0, 1.0);
122 FFT.Complex complex4 = new FFT.Complex(2.0, 2.0);
123
124 arr.add(complex1);
125 arr.add(complex2);
126 arr.add(complex3);
127 arr.add(complex4);
128 arr = FFT.fft(arr, false);
129 double realV1 = arr.get(0).getReal();
130 double realV2 = arr.get(2).getReal();
131 double imgV1 = arr.get(0).getImaginary();
132 double imgV2 = arr.get(2).getImaginary();
133 assertEquals(8.0, realV1);
134 assertEquals(2.0, realV2);
135 assertEquals(8.0, imgV1);
136 assertEquals(-2.0, imgV2);
137 }
138}

Callers

nothing calls this directly

Calls 5

fftMethod · 0.95
getRealMethod · 0.80
getImaginaryMethod · 0.80
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected