Skip to content

Commit c59a7be

Browse files
committed
feat: radf3, minor clean-up
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
1 parent c96d70d commit c59a7be

File tree

4 files changed

+152
-3
lines changed

4 files changed

+152
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function radb4( ido, l1, cc, ch, wa1, wa2, wa3 ) {
126126
if ( ido < 2 ) {
127127
return;
128128
}
129-
if ( ido != 2 ) {
129+
if ( ido !== 2 ) {
130130
idp2 = ido + 2;
131131
for ( k = 1; k <= l1; ++k ) {
132132
for ( i = 3; i <= ido; i += 2 ) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function radbg( ido, ip, l1, idl1, cc, c1, c2, ch, ch2, wa ) {
126126
// Parameter adjustments...
127127
chOffset = 1 + ( ido * ( 1 + l1 ) );
128128
c1Offset = 1 + ( ido * ( 1 + l1 ) );
129-
ccOffset = 1 + ido * ( 1 + ip );
129+
ccOffset = 1 + ( ido * ( 1 + ip ) );
130130
ch2Offset = 1 + idl1;
131131
c2Offset = 1 + idl1;
132132

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function radf2( ido, l1, cc, ch, wa1 ) {
9191

9292
// Parameter adjustments...
9393
chOffset = 1 + ( ido * 3 );
94-
ccOffset = 1 + ido * ( 1 + l1 );
94+
ccOffset = 1 + ( ido * ( 1 + l1 ) );
9595

9696
// Function body:
9797
for ( k = 1; k <= l1; ++k ) {
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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( './ch_ref.js' );
66+
var ccRef = require( './cc_ref.js' );
67+
68+
69+
// VARIABLES //
70+
71+
var taur = -0.5;
72+
var taui = 0.866025403784439;
73+
74+
75+
// MAIN //
76+
77+
/**
78+
* Performs the forward FFT of length 3 for real-valued sequences.
79+
*
80+
* @private
81+
* @param {number} ido - number of real values for each transform
82+
* @param {number} l1 - length of the input sequences
83+
* @param {Float64Array} cc - input array containing sequences to be transformed
84+
* @param {Float64Array} ch - output array containing transformed sequences
85+
* @param {Float64Array} wa1 - first array of twiddle factors
86+
* @param {Float64Array} wa2 - second array of twiddle factors
87+
* @returns {void}
88+
*/
89+
function radf3( ido, l1, cc, ch, wa1, wa2 ) {
90+
var chOffset;
91+
var ccOffset;
92+
var idp2;
93+
var tr3;
94+
var tr2;
95+
var ti3;
96+
var ti2;
97+
var dr3;
98+
var dr2;
99+
var di3;
100+
var di2;
101+
var cr2;
102+
var ci2;
103+
var ic;
104+
var i;
105+
var k;
106+
107+
// Parameter adjustments...
108+
chOffset = 1 + ( ido << 2 );
109+
ccOffset = 1 + ( ido * ( 1 + l1 ) );
110+
111+
// Function body:
112+
for ( k = 1; k <= l1; ++k ) {
113+
cr2 = cc[ ccRef( 1, k, 2, l1, ido ) - ccOffset ] + cc[ ccRef( 1, k, 3, l1, ido ) - ccOffset ];
114+
ch[ chRef( 1, 1, k, 3, ido ) - chOffset ] = cc[ ccRef( 1, k, 1, l1, ido ) - ccOffset ] + cr2;
115+
ch[ chRef( 1, 3, k, 3, ido ) - chOffset ] = taui * ( cc[ ccRef( 1, k, 3, l1, ido ) - ccOffset ] - cc[ ccRef( 1, k, 2, l1, ido ) - ccOffset ] );
116+
ch[ chRef( ido, 2, k, 3, ido ) - chOffset ] = ( cc[ ccRef( 1, k, 1, l1, ido ) - ccOffset ] + taur ) * cr2;
117+
}
118+
if ( ido === 1 ) {
119+
return;
120+
}
121+
idp2 = ido + 2;
122+
for ( k = 1; k <= l1; ++k ) {
123+
for ( i = 3; i <= ido; i += 2 ) {
124+
ic = idp2 - i;
125+
dr2 = ( wa1[ i - 2 - 1 ] * cc[ ccRef( i - 1, k, 2, l1, ido ) - ccOffset ]) + ( wa1[ i - 1 - 1 ] * cc[ ccRef( i, k, 2, l1, ido ) - ccOffset ] );
126+
di2 = ( wa1[ i - 2 - 1 ] * cc[ ccRef( i, k, 2, l1, ido ) - ccOffset ]) - ( wa1[ i - 1 - 1 ] * cc[ ccRef( i - 1, k, 2, l1, ido ) - ccOffset ] );
127+
dr3 = ( wa2[ i - 2 - 1 ] * cc[ ccRef( i - 1, k, 3, l1, ido ) - ccOffset ]) + ( wa2[ i - 1 - 1 ] * cc[ ccRef( i, k, 3, l1, ido ) - ccOffset ] );
128+
di3 = ( wa2[ i - 2 - 1 ] * cc[ ccRef( i, k, 3, l1, ido ) - ccOffset ]) - ( wa2[ i - 1 - 1 ] * cc[ ccRef( i - 1, k, 3, l1, ido ) - ccOffset ] );
129+
cr2 = dr2 + dr3;
130+
ci2 = di2 + di3;
131+
ch[ chRef( i - 1, 1, k, 3, ido ) - chOffset ] = cc[ ccRef( i - 1, k, 1, l1, ido ) - ccOffset ] + cr2;
132+
ch[ chRef( i, 1, k, 3, ido ) - chOffset ] = cc[ ccRef( i, k, 1, l1, ido ) - ccOffset ] + ci2;
133+
tr2 = cc[ ccRef( i - 1, k, 1, l1, ido ) - ccOffset ] + ( taur * cr2 );
134+
ti2 = cc[ ccRef( i, k, 1, l1, ido ) - ccOffset ] + ( taur * ci2 );
135+
tr3 = taui * ( di2 - di3 );
136+
ti3 = taui * ( dr3 - dr2 );
137+
ch[ chRef( i - 1, 3, k, 3, ido ) - chOffset ] = tr2 + tr3;
138+
ch[ chRef( ic - 1, 2, k, 3, ido ) - chOffset ] = tr2 - tr3;
139+
ch[ chRef( i, 3, k, 3, ido ) - chOffset ] = ti2 + ti3;
140+
ch[ chRef( ic, 2, k, 3, ido ) - chOffset ] = ti3 - ti2;
141+
}
142+
}
143+
144+
}
145+
146+
147+
// EXPORTS //
148+
149+
module.exports = radf3;

0 commit comments

Comments
 (0)