Use "final"; reuse already computed value.

This commit is contained in:
Gilles Sadowski 2021-05-26 12:46:06 +02:00
parent 3dd57c9473
commit ed43735e22
1 changed files with 8 additions and 6 deletions

View File

@ -227,8 +227,8 @@ public class FastFourierTransform implements ComplexTransform {
int lastN0 = 4; int lastN0 = 4;
int lastLogN0 = 2; int lastLogN0 = 2;
while (lastN0 < n) { while (lastN0 < n) {
int n0 = lastN0 << 1; final int n0 = lastN0 << 1;
int logN0 = lastLogN0 + 1; final int logN0 = lastLogN0 + 1;
double wSubN0R = W_SUB_N_R[logN0]; double wSubN0R = W_SUB_N_R[logN0];
double wSubN0I = W_SUB_N_I[logN0]; double wSubN0I = W_SUB_N_I[logN0];
if (inverse) { if (inverse) {
@ -253,12 +253,14 @@ public class FastFourierTransform implements ComplexTransform {
final double hrR = dataR[destOddStartIndexPlusR]; final double hrR = dataR[destOddStartIndexPlusR];
final double hrI = dataI[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 // dest[destEvenStartIndex + r] = Gr + WsubN0ToR * Hr
dataR[destEvenStartIndexPlusR] = grR + wSubN0ToRR * hrR - wSubN0ToRI * hrI; dataR[destEvenStartIndexPlusR] = grR + a;
dataI[destEvenStartIndexPlusR] = grI + wSubN0ToRR * hrI + wSubN0ToRI * hrR; dataI[destEvenStartIndexPlusR] = grI + b;
// dest[destOddStartIndex + r] = Gr - WsubN0ToR * Hr // dest[destOddStartIndex + r] = Gr - WsubN0ToR * Hr
dataR[destOddStartIndexPlusR] = grR - (wSubN0ToRR * hrR - wSubN0ToRI * hrI); dataR[destOddStartIndexPlusR] = grR - a;
dataI[destOddStartIndexPlusR] = grI - (wSubN0ToRR * hrI + wSubN0ToRI * hrR); dataI[destOddStartIndexPlusR] = grI - b;
// WsubN0ToR *= WsubN0R // WsubN0ToR *= WsubN0R
final double nextWsubN0ToRR = wSubN0ToRR * wSubN0R - wSubN0ToRI * wSubN0I; final double nextWsubN0ToRR = wSubN0ToRR * wSubN0R - wSubN0ToRI * wSubN0I;