Skip to content

Commit c7aea44

Browse files
committed
chore: add docs and clean-up
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent de91a9f commit c7aea44

File tree

3 files changed

+67
-28
lines changed

3 files changed

+67
-28
lines changed

lib/node_modules/@stdlib/fft/base/fftpack/lib/cc_ref.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
* @param {NonNegativeInteger} ip - number of sub-steps or prime factors in the FFT
7171
* @param {NonNegativeInteger} ido - dimension order
7272
* @returns {NonNegativeInteger} computed index
73+
*
74+
* @example
75+
* var out = ccRef( 3, 2, 1, 2, 2 );
76+
* // returns 11
7377
*/
7478
function ccRef( a1, a2, a3, ip, ido ) {
7579
return ( ( (a3*ip)+a2 ) * ido ) + a1;

lib/node_modules/@stdlib/fft/base/fftpack/lib/cfftb.js

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,64 @@ var cfftb1 = require( './cfftb1.js' );
6666
// MAIN //
6767

6868
/**
69-
* Performs the complex backward Fast Fourier Transform.
69+
* Performs the backward complex Fourier transform (i.e., the Fourier synthesis).
7070
*
71-
* @param {number} n - length of the sequence to transform
72-
* @param {Float64Array} c - input array containing sequence to be transformed
73-
* @param {number} cptr - starting index for c
74-
* @param {Float64Array} wsave - working array containing precomputed values
75-
* @param {number} wptr - starting index for wsave
71+
* ## Notes
72+
*
73+
* - This function computes a complex periodic sequence from its Fourier coefficients.
74+
*
75+
* - Invoking `cfftf` prior to invoking this function will multiply an input sequence by `N`.
76+
*
77+
* - Prior to invoking this function, `wsave` must be initialized by calling `cffti(N, wsave)`.
78+
*
79+
* - This function is more efficient when `N` is the product of small prime numbers.
80+
*
81+
* - A provided workspace array must have at least `4N+15` elements.
82+
*
83+
* - Different workspace arrays must be used for each different value of `N`.
84+
*
85+
* - The workspace array does **not** require re-initialization between subsequent transforms as long as `N` remains the same. Hence, subsequent transforms can be performed faster than the first by avoiding repeated initialization.
86+
*
87+
* - The same workspace array can be used by both `cfftf` and `cfftb`.
88+
*
89+
* - The initialization calculations stored in a workspace must **not** be destroyed between calls of `cfftf` and `cfftb`.
90+
*
91+
* - This function mutates the input array `c`. For `j = 0, ..., N-1`,
92+
*
93+
* ```tex
94+
* c_j = \sum_{k=0}^{N-1} c_k \cdot e^{\frac{2\pi}{N} \cdot ijk}
95+
* ```
96+
*
97+
* where `i = sqrt(-1)`.
98+
*
99+
* @param {NonNegativeInteger} N - length of the sequence to transform
100+
* @param {Float64Array} c - input array containing the sequence to be transformed
101+
* @param {NonNegativeInteger} offsetC - starting index for `c`
102+
* @param {Float64Array} wsave - workspace array containing pre-computed values
103+
* @param {NonNegativeInteger} offsetW - starting index for `wsave`
76104
* @returns {void}
105+
*
106+
* @example
107+
* // TODO
77108
*/
78-
function cfftb( n, c, cptr, wsave, wptr ) {
79-
var iw1;
80-
var iw2;
109+
function cfftb( N, c, offsetC, wsave, offsetW ) {
110+
var offsetT;
111+
var offsetF;
81112

82-
wptr -= 1;
83-
cptr -= 1;
84-
85-
if ( n === 1 ) {
113+
if ( N <= 1 ) {
86114
return;
87115
}
88-
iw1 = ( 2 * n ) + 1;
89-
iw2 = iw1 + ( 2 * n );
90-
cfftb1( n, c, cptr + 1, wsave, wptr + 1, wsave, wptr + iw1, wsave, wptr + iw2 ); // eslint-disable-line max-len
116+
/*
117+
* The workspace array is divided into three sections:
118+
*
119+
* [ intermediate_results | twiddle_factors | factorization_info ]
120+
*
121+
* The first two sections each contain `2*N` elements.
122+
*/
123+
offsetT = N * 2; // index offset for twiddle factors
124+
offsetF = offsetT * 2; // index offset for factorization info
125+
126+
cfftb1( N, c, offsetC, wsave, offsetW, wsave, offsetW+offsetT, wsave, offsetW+offsetF ); // eslint-disable-line max-len
91127
}
92128

93129

lib/node_modules/@stdlib/fft/base/fftpack/lib/cfftb1.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var passfb = require( './passfb.js' );
7272
// MAIN //
7373

7474
/**
75-
* Performs the complex backward Fast Fourier Transform.
75+
* Performs the backward complex Fourier transform (i.e., the Fourier synthesis).
7676
*
7777
* @private
7878
* @param {number} n - length of the sequence to transform
@@ -103,13 +103,12 @@ function cfftb1( n, c, cOffset, ch, chOffset, wa, waOffset, ifac, ifacOffset ) {
103103
var iw;
104104
var i;
105105

106-
// Function Body:
107-
nf = ifac[ ifacOffset + 1 ];
106+
nf = ifac[ ifacOffset+1 ];
108107
na = 0;
109108
l1 = 1;
110109
iw = 0;
111110
for ( k1 = 1; k1 <= nf; k1++ ) {
112-
ip = ifac[ ifacOffset + k1 + 1 ];
111+
ip = ifac[ ifacOffset+k1+1 ];
113112
l2 = ip * l1;
114113
ido = n / l2;
115114
idot = ido + ido;
@@ -118,30 +117,30 @@ function cfftb1( n, c, cOffset, ch, chOffset, wa, waOffset, ifac, ifacOffset ) {
118117
case 4:
119118
ix2 = iw + idot;
120119
ix3 = ix2 + idot;
121-
passb4( idot, l1, ( na ) ? ch : c, ( na ) ? chOffset : cOffset, ( na ) ? c : ch, ( na ) ? cOffset : chOffset, wa, iw + waOffset, wa, ix2 + waOffset, wa, ix3 + waOffset );
120+
passb4( idot, l1, ( na ) ? ch : c, ( na ) ? chOffset : cOffset, ( na ) ? c : ch, ( na ) ? cOffset : chOffset, wa, iw+waOffset, wa, ix2+waOffset, wa, ix3+waOffset );
122121
na = 1 - na;
123122
break;
124123
case 2:
125-
passb2( idot, l1, ( na ) ? ch : c, ( na ) ? chOffset : cOffset, ( na ) ? c : ch, ( na ) ? cOffset : chOffset, wa, iw + waOffset );
124+
passb2( idot, l1, ( na ) ? ch : c, ( na ) ? chOffset : cOffset, ( na ) ? c : ch, ( na ) ? cOffset : chOffset, wa, iw+waOffset );
126125
na = 1 - na;
127126
break;
128127
case 3:
129128
ix2 = iw + idot;
130-
passb3( idot, l1, ( na ) ? ch : c, ( na ) ? chOffset : cOffset, ( na ) ? c : ch, ( na ) ? cOffset : chOffset, wa, iw + waOffset, wa, ix2 + waOffset );
129+
passb3( idot, l1, ( na ) ? ch : c, ( na ) ? chOffset : cOffset, ( na ) ? c : ch, ( na ) ? cOffset : chOffset, wa, iw+waOffset, wa, ix2+waOffset );
131130
na = 1 - na;
132131
break;
133132
case 5:
134133
ix2 = iw + idot;
135134
ix3 = ix2 + idot;
136135
ix4 = ix3 + idot;
137-
passfb5( idot, l1, ( na ) ? ch : c, ( na ) ? chOffset : cOffset, ( na ) ? c : ch, ( na ) ? cOffset : chOffset, wa, iw + waOffset, wa, ix2 + waOffset, wa, ix3 + waOffset, wa, ix4 + waOffset, 1 );
136+
passfb5( idot, l1, ( na ) ? ch : c, ( na ) ? chOffset : cOffset, ( na ) ? c : ch, ( na ) ? cOffset : chOffset, wa, iw+waOffset, wa, ix2+waOffset, wa, ix3+waOffset, wa, ix4+waOffset, 1 );
138137
na = 1 - na;
139138
break;
140139
default:
141140
if ( na === 0 ) {
142-
passfb( nac, idot, ip, l1, idl1, c, cOffset, c, cOffset, c, cOffset, ch, chOffset, ch, chOffset, wa, iw + waOffset, 1 );
141+
passfb( nac, idot, ip, l1, idl1, c, cOffset, c, cOffset, c, cOffset, ch, chOffset, ch, chOffset, wa, iw+waOffset, 1 );
143142
} else {
144-
passfb( nac, idot, ip, l1, idl1, ch, chOffset, ch, chOffset, ch, chOffset, c, cOffset, c, cOffset, wa, iw + waOffset, 1 );
143+
passfb( nac, idot, ip, l1, idl1, ch, chOffset, ch, chOffset, ch, chOffset, c, cOffset, c, cOffset, wa, iw+waOffset, 1 );
145144
}
146145
if ( nac !== 0 ) {
147146
na = 1 - na;
@@ -154,8 +153,8 @@ function cfftb1( n, c, cOffset, ch, chOffset, wa, waOffset, ifac, ifacOffset ) {
154153
if ( na === 0 ) {
155154
return;
156155
}
157-
for ( i = 0; i < ( 2 * n ); i++ ) {
158-
c[ i + cOffset ] = ch[ i + chOffset ];
156+
for ( i = 0; i < n*2; i++ ) {
157+
c[ i+cOffset ] = ch[ i+chOffset ];
159158
}
160159
}
161160

0 commit comments

Comments
 (0)