From ed43735e221467cec99a452474a9df2c56204515 Mon Sep 17 00:00:00 2001 From: Gilles Sadowski Date: Wed, 26 May 2021 12:46:06 +0200 Subject: [PATCH] Use "final"; reuse already computed value. --- .../math4/transform/FastFourierTransform.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastFourierTransform.java b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastFourierTransform.java index 6f4d5a9a2..7877da55d 100644 --- a/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastFourierTransform.java +++ b/commons-math-transform/src/main/java/org/apache/commons/math4/transform/FastFourierTransform.java @@ -227,8 +227,8 @@ public class FastFourierTransform implements ComplexTransform { int lastN0 = 4; int lastLogN0 = 2; while (lastN0 < n) { - int n0 = lastN0 << 1; - int logN0 = lastLogN0 + 1; + final int n0 = lastN0 << 1; + final int logN0 = lastLogN0 + 1; double wSubN0R = W_SUB_N_R[logN0]; double wSubN0I = W_SUB_N_I[logN0]; if (inverse) { @@ -253,12 +253,14 @@ public class FastFourierTransform implements ComplexTransform { final double hrR = dataR[destOddStartIndexPlusR]; final double hrI = dataI[destOddStartIndexPlusR]; + final double a = wSubN0ToRR * hrR - wSubN0ToRI * hrI; + final double b = wSubN0ToRR * hrI + wSubN0ToRI * hrR; // dest[destEvenStartIndex + r] = Gr + WsubN0ToR * Hr - dataR[destEvenStartIndexPlusR] = grR + wSubN0ToRR * hrR - wSubN0ToRI * hrI; - dataI[destEvenStartIndexPlusR] = grI + wSubN0ToRR * hrI + wSubN0ToRI * hrR; + dataR[destEvenStartIndexPlusR] = grR + a; + dataI[destEvenStartIndexPlusR] = grI + b; // dest[destOddStartIndex + r] = Gr - WsubN0ToR * Hr - dataR[destOddStartIndexPlusR] = grR - (wSubN0ToRR * hrR - wSubN0ToRI * hrI); - dataI[destOddStartIndexPlusR] = grI - (wSubN0ToRR * hrI + wSubN0ToRI * hrR); + dataR[destOddStartIndexPlusR] = grR - a; + dataI[destOddStartIndexPlusR] = grI - b; // WsubN0ToR *= WsubN0R final double nextWsubN0ToRR = wSubN0ToRR * wSubN0R - wSubN0ToRI * wSubN0I;