@@ -4,17 +4,17 @@ import bitLength from '../bits/bitLength';
44/**
55 * Returns the number which is the flipped binary representation of input.
66 *
7- * @param {Number } [ input]
8- * @param {Number } [ bitsCount]
9- * @return {Number }
7+ * @param {number } input
8+ * @param {number } bitsCount
9+ * @return {number }
1010 */
1111function reverseBits ( input , bitsCount ) {
1212 let reversedBits = 0 ;
1313
14- for ( let i = 0 ; i < bitsCount ; i += 1 ) {
14+ for ( let bitIndex = 0 ; bitIndex < bitsCount ; bitIndex += 1 ) {
1515 reversedBits *= 2 ;
1616
17- if ( Math . floor ( input / ( 1 << i ) ) % 2 === 1 ) {
17+ if ( Math . floor ( input / ( 1 << bitIndex ) ) % 2 === 1 ) {
1818 reversedBits += 1 ;
1919 }
2020 }
@@ -39,8 +39,8 @@ export default function fastFourierTransform(inputData, inverse = false) {
3939 }
4040
4141 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 ) ] ;
4444 }
4545
4646 for ( let blockLength = 2 ; blockLength <= N ; blockLength *= 2 ) {
@@ -53,23 +53,23 @@ export default function fastFourierTransform(inputData, inverse = false) {
5353 for ( let blockStart = 0 ; blockStart < N ; blockStart += blockLength ) {
5454 let phase = new ComplexNumber ( { re : 1 , im : 0 } ) ;
5555
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 ) ;
5858
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 ) ;
6161
62- output [ idx ] = upd1 ;
63- output [ idx + blockLength / 2 ] = upd2 ;
62+ output [ signalId ] = upd1 ;
63+ output [ signalId + blockLength / 2 ] = upd2 ;
6464
6565 phase = phase . multiply ( phaseStep ) ;
6666 }
6767 }
6868 }
6969
7070 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 ;
7373 }
7474 }
7575
0 commit comments