mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-06 00:54:32 +08:00
style: enable LocalVariableName
in CheckStyle (#5191)
* style: enable LocalVariableName in checkstyle * Removed minor bug * Resolved Method Name Bug * Changed names according to suggestions
This commit is contained in:
@ -26,8 +26,8 @@ public final class FFTBluestein {
|
||||
* @param inverse True if you want to find the inverse FFT.
|
||||
*/
|
||||
public static void fftBluestein(ArrayList<FFT.Complex> x, boolean inverse) {
|
||||
int N = x.size();
|
||||
int bnSize = 2 * N - 1;
|
||||
int n = x.size();
|
||||
int bnSize = 2 * n - 1;
|
||||
int direction = inverse ? -1 : 1;
|
||||
ArrayList<FFT.Complex> an = new ArrayList<>();
|
||||
ArrayList<FFT.Complex> bn = new ArrayList<>();
|
||||
@ -38,32 +38,32 @@ public final class FFTBluestein {
|
||||
bn.add(new FFT.Complex());
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
double angle = (i - N + 1) * (i - N + 1) * Math.PI / N * direction;
|
||||
for (int i = 0; i < n; i++) {
|
||||
double angle = (i - n + 1) * (i - n + 1) * Math.PI / n * direction;
|
||||
bn.set(i, new FFT.Complex(Math.cos(angle), Math.sin(angle)));
|
||||
bn.set(bnSize - i - 1, new FFT.Complex(Math.cos(angle), Math.sin(angle)));
|
||||
}
|
||||
|
||||
/* Initialization of the a(n) sequence */
|
||||
for (int i = 0; i < N; i++) {
|
||||
double angle = -i * i * Math.PI / N * direction;
|
||||
for (int i = 0; i < n; i++) {
|
||||
double angle = -i * i * Math.PI / n * direction;
|
||||
an.add(x.get(i).multiply(new FFT.Complex(Math.cos(angle), Math.sin(angle))));
|
||||
}
|
||||
|
||||
ArrayList<FFT.Complex> convolution = ConvolutionFFT.convolutionFFT(an, bn);
|
||||
|
||||
/* The final multiplication of the convolution with the b*(k) factor */
|
||||
for (int i = 0; i < N; i++) {
|
||||
double angle = -1 * i * i * Math.PI / N * direction;
|
||||
for (int i = 0; i < n; i++) {
|
||||
double angle = -1 * i * i * Math.PI / n * direction;
|
||||
FFT.Complex bk = new FFT.Complex(Math.cos(angle), Math.sin(angle));
|
||||
x.set(i, bk.multiply(convolution.get(i + N - 1)));
|
||||
x.set(i, bk.multiply(convolution.get(i + n - 1)));
|
||||
}
|
||||
|
||||
/* Divide by N if we want the inverse FFT */
|
||||
/* Divide by n if we want the inverse FFT */
|
||||
if (inverse) {
|
||||
for (int i = 0; i < N; i++) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
FFT.Complex z = x.get(i);
|
||||
x.set(i, z.divide(N));
|
||||
x.set(i, z.divide(n));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user