Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 33x 10x 10x 23x 33x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 34x 126x 126x 126x 126x 126x 126x 126x 126x 126x 126x 126x 126x 126x 126x 2524x 2524x 2524x 2524x 2524x 2524x 2524x 2524x 2524x 2524x 2524x 2524x 2524x 126x 126x 126x 34x 34x 34x 33x 1x 1x 1x 1x 1x | /**
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* ## Notice
*
* The original C code and copyright notice are from the [PFFFT library]{@link https://github.com/marton78/pffft/blob/0b4ee12c4ba45a4a8e567550c16d96d1679f50ce/src/fftpack.c}. The implementation follows the original, but has been modified for JavaScript.
*
* ```text
* Copyright (c) 2004 the University Corporation for Atmospheric
* Research ("UCAR"). All rights reserved. Developed by NCAR's
* Computational and Information Systems Laboratory, UCAR,
* www.cisl.ucar.edu.
*
* Redistribution and use of the Software in source and binary forms,
* with or without modification, is permitted provided that the
* following conditions are met:
*
* - Neither the names of NCAR's Computational and Information Systems
* Laboratory, the University Corporation for Atmospheric Research,
* nor the names of its sponsors or contributors may be used to
* endorse or promote products derived from this Software without
* specific prior written permission.
*
* - Redistributions of source code must retain the above copyright
* notices, this list of conditions, and the disclaimer below.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions, and the disclaimer below in the
* documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
* SOFTWARE.
* ```
*/
'use strict';
// MODULES //
var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
var floor = require( '@stdlib/math/base/special/floor' );
var sin = require( '@stdlib/math/base/special/sin' );
var cos = require( '@stdlib/math/base/special/cos' );
var decompose = require( '@stdlib/fft/base/fftpack/decompose' );
// VARIABLES //
var TRIAL_FACTORS = [ 4, 2, 3, 5 ];
// MAIN //
/**
* Initializes the working arrays for applying a Fourier transform to a real-valued sequence.
*
* @private
* @param {NonNegativeInteger} n - length of the sequence
* @param {Collection} wa - array of twiddle factors
* @param {integer} strideW - stride length for `wa`
* @param {NonNegativeInteger} offsetW - starting index for `wa`
* @param {Collection} ifac - array containing a radix factorization
* @param {integer} strideF - stride length for `ifac`
* @param {NonNegativeInteger} offsetF - starting index for `ifac`
* @returns {void}
*/
function rffti1( n, wa, strideW, offsetW, ifac, strideF, offsetF ) {
var argld;
var argh;
var nfm1;
var arg;
var ipm;
var ido;
var nf;
var fi;
var ip;
var l2;
var l1;
var ld;
var ii;
var is;
var k1;
var i;
var j;
// Decompose the sequence length into its radix factors:
nf = decompose( n, 4, TRIAL_FACTORS, 1, 0, ifac, strideF, offsetF );
// Compute the master angular step (i.e., the basic angle that generates all twiddles):
argh = TWO_PI / n;
// Initialize the index into the twiddle factor array:
is = 0;
// Compute the number of factors minus one:
nfm1 = nf - 1;
// Initialize a running product of factors already processed:
l1 = 1;
// If the number of radix factors is `1`, the only twiddle factor we need is `W_N^0 = 1`, which the main transform kernels already hard-code, so nothing to pre-compute...
if ( nfm1 === 0 ) {
return;
}
// Generate twiddle factors for each radix factor...
for ( k1 = 0; k1 < nfm1; k1++ ) {
// Resolve the next radix factor (C code: ifac[k1+2] with 1-based, JS: ifac[k1+2] with 0-based):
ip = ifac[ offsetF + ((k1+2)*strideF) ];
// Initialize a running offset used to step the angle:
ld = 0;
// Compute the length of the transform after including the current radix:
l2 = l1 * ip;
// Compute the number of data points in each sub-transform:
ido = floor( n / l2 );
// Compute the number of iterations for the inner loop:
ipm = ip - 1;
// Iterate over each butterfly column within the current radix...
for ( j = 0; j < ipm; j++ ) {
// Advance to the next column:
ld += l1;
// Initialize the index into the twiddle factor array:
i = is;
// Compute the angle step for this column:
argld = ld * argh;
// Initialize the harmonic counter:
fi = 0.0;
// Iterate over each non-trivial harmonic in the column...
for ( ii = 2; ii < ido; ii += 2 ) {
// Advance the index by 2 (for cosine and sine):
i += 2;
// Update the harmonic counter:
fi += 1.0;
// Compute the angle for this harmonic:
arg = fi * argld;
// Store the cosine and sine values:
wa[ offsetW + ( ( i-1 ) * strideW ) ] = cos( arg );
wa[ offsetW + ( i*strideW ) ] = sin( arg );
}
// Advance the index by the number of data points in each sub-transform:
is += ido;
}
// Update the running product of factors already processed:
l1 = l2;
}
}
// EXPORTS //
module.exports = rffti1;
|