Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d736b2f

Browse files
committed
Style fixes for FFT code.
1 parent ac9920a commit d736b2f

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

‎src/algorithms/math/fourier-transform/__test__/fastFourierTransform.test.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function sequencesApproximatelyEqual(sequence1, sequence2, delta) {
2828
const delta = 1e-6;
2929

3030
describe('fastFourierTransform', () => {
31-
it('should calculate the radix-2 discrete fourier transform after zero padding', () => {
31+
it('should calculate the radix-2 discrete fourier transform #1', () => {
3232
const input = [new ComplexNumber({ re: 0, im: 0 })];
3333
const expectedOutput = [new ComplexNumber({ re: 0, im: 0 })];
3434
const output = fastFourierTransform(input);
@@ -38,7 +38,7 @@ describe('fastFourierTransform', () => {
3838
expect(sequencesApproximatelyEqual(input, invertedOutput, delta)).toBe(true);
3939
});
4040

41-
it('should calculate the radix-2 discrete fourier transform after zero padding', () => {
41+
it('should calculate the radix-2 discrete fourier transform #2', () => {
4242
const input = [
4343
new ComplexNumber({ re: 1, im: 2 }),
4444
new ComplexNumber({ re: 2, im: 3 }),
@@ -59,7 +59,7 @@ describe('fastFourierTransform', () => {
5959
expect(sequencesApproximatelyEqual(input, invertedOut, delta)).toBe(true);
6060
});
6161

62-
it('should calculate the radix-2 discrete fourier transform after zero padding', () => {
62+
it('should calculate the radix-2 discrete fourier transform #3', () => {
6363
const input = [
6464
new ComplexNumber({ re: -83656.9359385182, im: 98724.08038374918 }),
6565
new ComplexNumber({ re: -47537.415125808424, im: 88441.58381765135 }),

‎src/algorithms/math/fourier-transform/fastFourierTransform.js‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ export default function fastFourierTransform(inputData, inverse = false) {
5454
let phase = new ComplexNumber({ re: 1, im: 0 });
5555

5656
for (let idx = blockStart; idx < blockStart + blockLength / 2; idx += 1) {
57-
const upd1 = output[idx].add(output[idx + blockLength / 2].multiply(phase));
58-
const upd2 = output[idx].subtract(output[idx + blockLength / 2].multiply(phase));
57+
const component = output[idx + blockLength / 2].multiply(phase);
58+
59+
const upd1 = output[idx].add(component);
60+
const upd2 = output[idx].subtract(component);
5961

6062
output[idx] = upd1;
6163
output[idx + blockLength / 2] = upd2;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /