Skip to content

Commit b6ced12

Browse files
committed
feat: add passf4
1 parent d978c43 commit b6ced12

File tree

4 files changed

+163
-3
lines changed

4 files changed

+163
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
* @private
6767
* @param {number} a1 - index of first dimension
6868
* @param {number} a2 - index of second dimension
69-
* @param {Float64Array} c2 - secondary intermediate array for FFT computations
7069
* @param {number} idl1 - stride related to the `l1` parameter
7170
* @returns {number} - calculated index
7271
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function passf2( ido, l1, cc, ch, wa1 ) {
9292
cc_offset = 1 + ( ido * 3 );
9393

9494
// Function body:
95-
if ( ido == 2 ) {
95+
if ( ido === 2 ) {
9696
for ( k = 1; k <= l1; ++k ) {
9797
ch[ chRef( 1, k, 1, l1, ido ) - ch_offset ] = cc[ ccRef( 1, 1, k, 2, ido ) - cc_offset ] + cc[ ccRef( 1, 2, k, 2, ido ) - cc_offset ];
9898
ch[ chRef( 1, k, 2, l1, ido ) - ch_offset ] = cc[ ccRef( 1, 1, k, 2, ido ) - cc_offset ] - cc[ ccRef( 1, 2, k, 2, ido ) - cc_offset ];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function passf3( ido, l1, cc, ch, wa1, wa2 ) {
107107
cc_offset = 1 + ( ido << 2 );
108108

109109
// Function body:
110-
if ( ido == 2 ) {
110+
if ( ido === 2 ) {
111111
for ( k = 1; k <= l1; ++k ) {
112112
tr2 = cc[ ccRef( 1, 2, k, 3, ido ) - cc_offset ] + cc[ ccRef( 1, 3, k, 3, ido ) - cc_offset ];
113113
cr2 = cc[ ccRef( 1, 1, k, 3, ido ) - cc_offset ] + ( taur * tr2 );
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*
19+
* ## Notice
20+
*
21+
* The original C code and copyright notice are from the [PFFFT library]{@link https://github.com/marton78/pffft/blob/master/fftpack.c}. The implementation follows the original, but has been modified for JavaScript.
22+
*
23+
* ```text
24+
* Copyright (c) 2004 the University Corporation for Atmospheric
25+
* Research ("UCAR"). All rights reserved. Developed by NCAR's
26+
* Computational and Information Systems Laboratory, UCAR,
27+
* www.cisl.ucar.edu.
28+
*
29+
* Redistribution and use of the Software in source and binary forms,
30+
* with or without modification, is permitted provided that the
31+
* following conditions are met:
32+
*
33+
* - Neither the names of NCAR's Computational and Information Systems
34+
* Laboratory, the University Corporation for Atmospheric Research,
35+
* nor the names of its sponsors or contributors may be used to
36+
* endorse or promote products derived from this Software without
37+
* specific prior written permission.
38+
*
39+
* - Redistributions of source code must retain the above copyright
40+
* notices, this list of conditions, and the disclaimer below.
41+
*
42+
* - Redistributions in binary form must reproduce the above copyright
43+
* notice, this list of conditions, and the disclaimer below in the
44+
* documentation and/or other materials provided with the
45+
* distribution.
46+
*
47+
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
48+
* EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF
49+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
50+
* NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT
51+
* HOLDERS BE LIABLE FOR ANY CLAIM, INDIRECT, INCIDENTAL, SPECIAL,
52+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY, WHETHER IN AN
53+
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
54+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
55+
* SOFTWARE.
56+
* ```
57+
*/
58+
59+
/* eslint-disable max-len */
60+
61+
'use strict';
62+
63+
// MODULES //
64+
65+
var chRef = require( '@stdlib/fft/base/fftpack/lib/ch_ref.js' );
66+
var ccRef = require( '@stdlib/fft/base/fftpack/lib/cc_ref.js' );
67+
68+
69+
// MAIN //
70+
71+
/**
72+
* Performs a pass of length 4 of the FFT algorithm.
73+
*
74+
* @private
75+
* @param {integer} ido - number of real values for each transform
76+
* @param {integer} l1 - length of the input sequences
77+
* @param {Float64Array} cc - input array containing sequences to be transformed
78+
* @param {Float64Array} ch - output array containing transformed sequences
79+
* @param {Float64Array} wa1 - first array of twiddle factors
80+
* @param {Float64Array} wa2 - second array of twiddle factors
81+
* @param {Float64Array} wa3 - third array of twiddle factors
82+
* @returns {void}
83+
*/
84+
function passf4( ido, l1, cc, ch, wa1, wa2, wa3 ) {
85+
var ch_offset;
86+
var cc_offset;
87+
var ci2;
88+
var ci3;
89+
var ci4;
90+
var cr2;
91+
var cr3;
92+
var cr4;
93+
var ti1;
94+
var ti2;
95+
var ti3;
96+
var ti4;
97+
var tr1;
98+
var tr2;
99+
var tr3;
100+
var tr4;
101+
var i;
102+
var k;
103+
104+
// Parameter adjustments...
105+
ch_offset = 1 + ( ido * ( 1 + l1 ) );
106+
cc_offset = 1 + ( ido * 5 );
107+
108+
// Function body:
109+
if ( ido === 2 ) {
110+
for ( k = 1; k <= l1; ++k ) {
111+
ti1 = cc[ ccRef( 2, 1, k, 4, ido ) - cc_offset ] - cc[ ccRef( 2, 3, k, 4, ido ) - cc_offset ];
112+
ti2 = cc[ ccRef( 2, 1, k, 4, ido ) - cc_offset ] + cc[ ccRef( 2, 3, k, 4, ido ) - cc_offset ];
113+
tr4 = cc[ ccRef( 2, 2, k, 4, ido ) - cc_offset ] - cc[ ccRef( 2, 4, k, 4, ido ) - cc_offset ];
114+
ti3 = cc[ ccRef( 2, 2, k, 4, ido ) - cc_offset ] + cc[ ccRef( 2, 4, k, 4, ido ) - cc_offset ];
115+
tr1 = cc[ ccRef( 1, 1, k, 4, ido ) - cc_offset ] - cc[ ccRef( 1, 3, k, 4, ido ) - cc_offset ];
116+
tr2 = cc[ ccRef( 1, 1, k, 4, ido ) - cc_offset ] + cc[ ccRef( 1, 3, k, 4, ido ) - cc_offset ];
117+
ti4 = cc[ ccRef( 1, 4, k, 4, ido ) - cc_offset ] - cc[ ccRef( 1, 2, k, 4, ido ) - cc_offset ];
118+
tr3 = cc[ ccRef( 1, 2, k, 4, ido ) - cc_offset ] + cc[ ccRef( 1, 4, k, 4, ido ) - cc_offset ];
119+
ch[ chRef( 1, k, 1, l1, ido ) - ch_offset ] = tr2 + tr3;
120+
ch[ chRef( 1, k, 3, l1, ido ) - ch_offset ] = tr2 - tr3;
121+
ch[ chRef( 2, k, 1, l1, ido ) - ch_offset ] = ti2 + ti3;
122+
ch[ chRef( 2, k, 3, l1, ido ) - ch_offset ] = ti2 - ti3;
123+
ch[ chRef( 1, k, 2, l1, ido ) - ch_offset ] = tr1 + tr4;
124+
ch[ chRef( 1, k, 4, l1, ido ) - ch_offset ] = tr1 - tr4;
125+
ch[ chRef( 2, k, 2, l1, ido ) - ch_offset ] = ti1 + ti4;
126+
ch[ chRef( 2, k, 4, l1, ido ) - ch_offset ] = ti1 - ti4;
127+
}
128+
} else {
129+
for ( k = 1; k <= l1; ++k ) {
130+
for ( i = 2; i <= ido; i += 2 ) {
131+
ti1 = cc[ ccRef( i, 1, k, 4, ido ) - cc_offset ] - cc[ ccRef( i, 3, k, 4, ido ) - cc_offset ];
132+
ti2 = cc[ ccRef( i, 1, k, 4, ido ) - cc_offset ] + cc[ ccRef( i, 3, k, 4, ido ) - cc_offset ];
133+
ti3 = cc[ ccRef( i, 2, k, 4, ido ) - cc_offset ] + cc[ ccRef( i, 4, k, 4, ido ) - cc_offset ];
134+
tr4 = cc[ ccRef( i, 2, k, 4, ido ) - cc_offset ] - cc[ ccRef( i, 4, k, 4, ido ) - cc_offset ];
135+
tr1 = cc[ ccRef( i - 1, 1, k, 4, ido ) - cc_offset ] - cc[ ccRef( i - 1, 3, k, 4, ido ) - cc_offset ];
136+
tr2 = cc[ ccRef( i - 1, 1, k, 4, ido ) - cc_offset ] + cc[ ccRef( i - 1, 3, k, 4, ido ) - cc_offset ];
137+
ti4 = cc[ ccRef( i - 1, 4, k, 4, ido ) - cc_offset ] - cc[ ccRef( i - 1, 2, k, 4, ido ) - cc_offset ];
138+
tr3 = cc[ ccRef( i - 1, 2, k, 4, ido ) - cc_offset ] + cc[ ccRef( i - 1, 4, k, 4, ido ) - cc_offset ];
139+
ch[ chRef( i - 1, k, 1, l1, ido ) - ch_offset ] = tr2 + tr3;
140+
cr3 = tr2 - tr3;
141+
ch[ chRef( i, k, 1, l1, ido ) - ch_offset ] = ti2 + ti3;
142+
ci3 = ti2 - ti3;
143+
cr2 = tr1 + tr4;
144+
cr4 = tr1 - tr4;
145+
ci2 = ti1 + ti4;
146+
ci4 = ti1 - ti4;
147+
ch[ chRef( i - 1, k, 2, l1, ido ) - ch_offset ] = ( wa1[ i - 1 - 1 ] * cr2 ) + ( wa1[ i - 1 ] * ci2 );
148+
ch[ chRef( i, k, 2, l1, ido ) - ch_offset ] = ( wa1[ i - 1 - 1 ] * ci2 ) - ( wa1[ i - 1 ] * cr2 );
149+
ch[ chRef( i - 1, k, 3, l1, ido ) - ch_offset ] = ( wa2[ i - 1 - 1 ] * cr3 ) + ( wa2[ i - 1 ] * ci3 );
150+
ch[ chRef( i, k, 3, l1, ido ) - ch_offset ] = ( wa2[ i - 1 - 1 ] * ci3 ) - ( wa2[ i - 1 ] * cr3 );
151+
ch[ chRef( i - 1, k, 4, l1, ido ) - ch_offset ] = ( wa3[ i - 1 - 1 ] * cr4 ) + ( wa3[ i - 1 ] * ci4 );
152+
ch[ chRef( i, k, 4, l1, ido ) - ch_offset ] = ( wa3[ i - 1 - 1 ] * ci4 ) - ( wa3[ i - 1 ] * cr4 );
153+
}
154+
}
155+
}
156+
}
157+
158+
159+
// EXPORTS //
160+
161+
module.exports = passf4;

0 commit comments

Comments
 (0)