@@ -4,17 +4,17 @@ import bitLength from '../bits/bitLength';
4
4
/**
5
5
* Returns the number which is the flipped binary representation of input.
6
6
*
7
- * @param {Number } [ input]
8
- * @param {Number } [ bitsCount]
9
- * @return {Number }
7
+ * @param {number } input
8
+ * @param {number } bitsCount
9
+ * @return {number }
10
10
*/
11
11
function reverseBits ( input , bitsCount ) {
12
12
let reversedBits = 0 ;
13
13
14
- for ( let i = 0 ; i < bitsCount ; i += 1 ) {
14
+ for ( let bitIndex = 0 ; bitIndex < bitsCount ; bitIndex += 1 ) {
15
15
reversedBits *= 2 ;
16
16
17
- if ( Math . floor ( input / ( 1 << i ) ) % 2 === 1 ) {
17
+ if ( Math . floor ( input / ( 1 << bitIndex ) ) % 2 === 1 ) {
18
18
reversedBits += 1 ;
19
19
}
20
20
}
@@ -39,8 +39,8 @@ export default function fastFourierTransform(inputData, inverse = false) {
39
39
}
40
40
41
41
const output = [ ] ;
42
- for ( let i = 0 ; i < N ; i += 1 ) {
43
- output [ i ] = inputData [ reverseBits ( i , bitsCount ) ] ;
42
+ for ( let dataSampleIndex = 0 ; dataSampleIndex < N ; dataSampleIndex += 1 ) {
43
+ output [ dataSampleIndex ] = inputData [ reverseBits ( dataSampleIndex , bitsCount ) ] ;
44
44
}
45
45
46
46
for ( let blockLength = 2 ; blockLength <= N ; blockLength *= 2 ) {
@@ -53,23 +53,23 @@ export default function fastFourierTransform(inputData, inverse = false) {
53
53
for ( let blockStart = 0 ; blockStart < N ; blockStart += blockLength ) {
54
54
let phase = new ComplexNumber ( { re : 1 , im : 0 } ) ;
55
55
56
- for ( let idx = blockStart ; idx < blockStart + blockLength / 2 ; idx += 1 ) {
57
- const component = output [ idx + blockLength / 2 ] . multiply ( phase ) ;
56
+ for ( let signalId = blockStart ; signalId < ( blockStart + blockLength / 2 ) ; signalId += 1 ) {
57
+ const component = output [ signalId + blockLength / 2 ] . multiply ( phase ) ;
58
58
59
- const upd1 = output [ idx ] . add ( component ) ;
60
- const upd2 = output [ idx ] . subtract ( component ) ;
59
+ const upd1 = output [ signalId ] . add ( component ) ;
60
+ const upd2 = output [ signalId ] . subtract ( component ) ;
61
61
62
- output [ idx ] = upd1 ;
63
- output [ idx + blockLength / 2 ] = upd2 ;
62
+ output [ signalId ] = upd1 ;
63
+ output [ signalId + blockLength / 2 ] = upd2 ;
64
64
65
65
phase = phase . multiply ( phaseStep ) ;
66
66
}
67
67
}
68
68
}
69
69
70
70
if ( inverse ) {
71
- for ( let idx = 0 ; idx < N ; idx += 1 ) {
72
- output [ idx ] /= N ;
71
+ for ( let signalId = 0 ; signalId < N ; signalId += 1 ) {
72
+ output [ signalId ] /= N ;
73
73
}
74
74
}
75
75
0 commit comments