diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/README.md b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/README.md index c1cfb51a4dc4..62f41d173d60 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/README.md +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/README.md @@ -40,35 +40,37 @@ limitations under the License. var rffti = require( '@stdlib/fft/base/fftpack/float32/rffti' ); ``` -#### rffti( N, workspace, strideW, offsetW ) +#### rffti( N, w, strideW, offsetW ) Initializes a single-precision floating-point workspace array for performing a real-valued Fourier transform. ```javascript var Float32Array = require( '@stdlib/array/float32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); var N = 8; -var workspace = new Float32Array( ( 2*N ) + 34 ); +var w = new Float32Array( ( 2*N ) + 34 ); -var out = rffti( N, workspace, 1, 0 ); +var out = rffti( N, w, 1, 0 ); // returns -var bool = ( out === workspace ); +var bool = ( out === w ); // returns true -var twiddleFactors = workspace.slice( N, 2*N ); +var twiddleFactors = w.slice( N, 2*N ); // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] -var factors = workspace.slice( 2*N, ( 2*N ) + 4 ); -// returns [ 8, 2, 2, 4 ] +var fview = new Uint32Array( w.buffer, w.byteOffset, w.length ); +var factors = fview.slice( 2*N, ( 2*N ) + 4 ); +// returns [ 8, 2, 2, 4 ] ``` The function accepts the following arguments: - **N**: length of the sequence to transform. -- **workspace**: workspace [`Float32Array`][@stdlib/array/float32]. -- **strideW**: stride length for `workspace`. -- **offsetW**: starting index for `workspace`. +- **w**: workspace [`Float32Array`][@stdlib/array/float32]. +- **strideW**: stride length for `w`. +- **offsetW**: starting index for `w`. @@ -116,26 +118,30 @@ The function accepts the following arguments: ```javascript var Float32Array = require( '@stdlib/array/float32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); var zeroTo = require( '@stdlib/array/zero-to' ); var logEach = require( '@stdlib/console/log-each' ); var rffti = require( '@stdlib/fft/base/fftpack/float32/rffti' ); var N = 8; -var workspace = new Float32Array( ( 2*N ) + 34 ); +var w = new Float32Array( ( 2*N ) + 34 ); -rffti( N, workspace, 1, 0 ); +rffti( N, w, 1, 0 ); console.log( 'Sequence length: %d', N ); console.log( 'Twiddle factors:' ); var idx = zeroTo( N, 'float32' ); -logEach( ' workspace[ %d ] = %0.4f', idx, workspace.slice( N, 2*N ) ); +logEach( ' w[ %d ] = %0.4f', idx, w.slice( N, 2*N ) ); + +// Create an unsigned integer view over the workspace to read the factorization section: +var fview = new Uint32Array( w.buffer, w.byteOffset, w.length ); console.log( 'Factorization:' ); -var nf = workspace[ (2*N)+1 ]; +var nf = fview[ (2*N)+1 ]; console.log( ' number of factors: %d', nf ); idx = zeroTo( nf, 'float32' ); -logEach( ' factor[ %d ]: %d', idx, workspace.slice( (2*N)+2, (2*N)+2+nf ) ); +logEach( ' factor[ %d ]: %d', idx, fview.slice( (2*N)+2, (2*N)+2+nf ) ); ``` diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/benchmark/benchmark.js b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/benchmark/benchmark.js index 78b1af2c5ae1..02c34758a604 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/benchmark/benchmark.js @@ -38,7 +38,7 @@ var rffti = require( './../lib' ); * @returns {Function} benchmark function */ function createBenchmark( N ) { - var workspace = new Float32Array( ( 2*N ) + 34 ); + var w = new Float32Array( ( 2*N ) + 34 ); return benchmark; /** @@ -52,13 +52,13 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - rffti( N, workspace, 1, 0 ); - if ( isnanf( workspace[ N ] ) ) { + rffti( N, w, 1, 0 ); + if ( isnanf( w[ N ] ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnanf( workspace[ N ] ) ) { + if ( isnanf( w[ N ] ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/repl.txt b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/repl.txt index 35609f414550..66686d25501a 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/repl.txt +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( N, workspace, strideW, offsetW ) +{{alias}}( N, w, strideW, offsetW ) Initializes a single-precision floating-point workspace array for performing a real-valued Fourier transform. @@ -23,14 +23,14 @@ N: integer Length of the sequence. - workspace: Float32Array + w: Float32Array Workspace array. strideW: integer - Stride length for `workspace`. + Stride length for `w`. offsetW: integer - Starting index for `workspace`. + Starting index for `w`. Returns ------- @@ -40,15 +40,16 @@ Examples -------- > var N = 8; - > var workspace = new {{alias:@stdlib/array/float32}}( ( 2*N ) + 34 ); - > var out = {{alias}}( N, workspace, 1, 0 ) + > var w = new {{alias:@stdlib/array/float32}}( ( 2*N ) + 34 ); + > var out = {{alias}}( N, w, 1, 0 ) - > var bool = ( out === workspace ) + > var bool = ( out === w ) true - > var twiddleFactors = workspace.slice( N, 2*N ) + > var twiddleFactors = w.slice( N, 2*N ) [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] - > var factors = workspace.slice( 2*N, ( 2*N ) + 4 ) - [ 8, 2, 2, 4 ] + > var fview = new {{alias:@stdlib/array/uint32}}( w.buffer, w.byteOffset, w.length ); + > var factors = fview.slice( 2*N, ( 2*N ) + 4 ) + [ 8, 2, 2, 4 ] See Also -------- diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/types/index.d.ts b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/types/index.d.ts index 4686b194ce28..f816ed2d6e7f 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/types/index.d.ts @@ -27,30 +27,32 @@ * - For single-point sequences (N=1), the function returns immediately as the FFT is the identity operation. * * @param N - length of the sequence -* @param workspace - workspace array -* @param strideW - stride length for `workspace` -* @param offsetW - starting index for `workspace` +* @param w - workspace array +* @param strideW - stride length for `w` +* @param offsetW - starting index for `w` * @returns workspace array * * @example * var Float32Array = require( '@stdlib/array/float32' ); +* var Uint32Array = require( '@stdlib/array/uint32' ); * * var N = 8; -* var workspace = new Float32Array( ( 2*N ) + 34 ); +* var w = new Float32Array( ( 2*N ) + 34 ); * -* var out = rffti( N, workspace, 1, 0 ); +* var out = rffti( N, w, 1, 0 ); * // returns * -* var bool = ( out === workspace ); +* var bool = ( out === w ); * // returns true * -* var twiddleFactors = workspace.slice( N, 2*N ); +* var twiddleFactors = w.slice( N, 2*N ); * // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] * -* var factors = workspace.slice( 2*N, ( 2*N ) + 4 ); -* // returns [ 8, 2, 2, 4 ] +* var fview = new Uint32Array( w.buffer, w.byteOffset, w.length ); +* var factors = fview.slice( 2*N, ( 2*N ) + 4 ); +* // returns [ 8, 2, 2, 4 ] */ -declare function rffti( N: number, workspace: Float32Array, strideW: number, offsetW: number ): Float32Array; +declare function rffti( N: number, w: Float32Array, strideW: number, offsetW: number ): Float32Array; // EXPORTS // diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/types/test.ts b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/types/test.ts index f55238ff456f..58adc84d33a1 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/types/test.ts +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/docs/types/test.ts @@ -23,23 +23,23 @@ import rffti = require( './index' ); // The function returns a Float32Array... { - const workspace = new Float32Array( ( 2*8 ) + 34 ); + const w = new Float32Array( ( 2*8 ) + 34 ); - rffti( 8, workspace, 1, 0 ); // $ExpectType Float32Array + rffti( 8, w, 1, 0 ); // $ExpectType Float32Array } // The compiler throws an error if the function is provided a first argument which is not a number... { - const workspace = new Float32Array( ( 2*8 ) + 34 ); + const w = new Float32Array( ( 2*8 ) + 34 ); - rffti( '8', workspace, 1, 0 ); // $ExpectError - rffti( true, workspace, 1, 0 ); // $ExpectError - rffti( false, workspace, 1, 0 ); // $ExpectError - rffti( null, workspace, 1, 0 ); // $ExpectError - rffti( void 0, workspace, 1, 0 ); // $ExpectError - rffti( [], workspace, 1, 0 ); // $ExpectError - rffti( {}, workspace, 1, 0 ); // $ExpectError - rffti( ( x: number ): number => x, workspace, 1, 0 ); // $ExpectError + rffti( '8', w, 1, 0 ); // $ExpectError + rffti( true, w, 1, 0 ); // $ExpectError + rffti( false, w, 1, 0 ); // $ExpectError + rffti( null, w, 1, 0 ); // $ExpectError + rffti( void 0, w, 1, 0 ); // $ExpectError + rffti( [], w, 1, 0 ); // $ExpectError + rffti( {}, w, 1, 0 ); // $ExpectError + rffti( ( x: number ): number => x, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float32Array... @@ -57,39 +57,39 @@ import rffti = require( './index' ); // The compiler throws an error if the function is provided a third argument which is not a number... { - const workspace = new Float32Array( ( 2*8 ) + 34 ); + const w = new Float32Array( ( 2*8 ) + 34 ); - rffti( 8, workspace, '1', 0 ); // $ExpectError - rffti( 8, workspace, true, 0 ); // $ExpectError - rffti( 8, workspace, false, 0 ); // $ExpectError - rffti( 8, workspace, null, 0 ); // $ExpectError - rffti( 8, workspace, void 0, 0 ); // $ExpectError - rffti( 8, workspace, [], 0 ); // $ExpectError - rffti( 8, workspace, {}, 0 ); // $ExpectError - rffti( 8, workspace, ( x: number ): number => x, 0 ); // $ExpectError + rffti( 8, w, '1', 0 ); // $ExpectError + rffti( 8, w, true, 0 ); // $ExpectError + rffti( 8, w, false, 0 ); // $ExpectError + rffti( 8, w, null, 0 ); // $ExpectError + rffti( 8, w, void 0, 0 ); // $ExpectError + rffti( 8, w, [], 0 ); // $ExpectError + rffti( 8, w, {}, 0 ); // $ExpectError + rffti( 8, w, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... { - const workspace = new Float32Array( ( 2*8 ) + 34 ); + const w = new Float32Array( ( 2*8 ) + 34 ); - rffti( 8, workspace, 1, '0' ); // $ExpectError - rffti( 8, workspace, 1, true ); // $ExpectError - rffti( 8, workspace, 1, false ); // $ExpectError - rffti( 8, workspace, 1, null ); // $ExpectError - rffti( 8, workspace, 1, void 0 ); // $ExpectError - rffti( 8, workspace, 1, [] ); // $ExpectError - rffti( 8, workspace, 1, {} ); // $ExpectError - rffti( 8, workspace, 1, ( x: number ): number => x ); // $ExpectError + rffti( 8, w, 1, '0' ); // $ExpectError + rffti( 8, w, 1, true ); // $ExpectError + rffti( 8, w, 1, false ); // $ExpectError + rffti( 8, w, 1, null ); // $ExpectError + rffti( 8, w, 1, void 0 ); // $ExpectError + rffti( 8, w, 1, [] ); // $ExpectError + rffti( 8, w, 1, {} ); // $ExpectError + rffti( 8, w, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { - const workspace = new Float32Array( ( 2*8 ) + 34 ); + const w = new Float32Array( ( 2*8 ) + 34 ); rffti(); // $ExpectError rffti( 8 ); // $ExpectError - rffti( 8, workspace ); // $ExpectError - rffti( 8, workspace, 1 ); // $ExpectError - rffti( 8, workspace, 1, 0, 123 ); // $ExpectError + rffti( 8, w ); // $ExpectError + rffti( 8, w, 1 ); // $ExpectError + rffti( 8, w, 1, 0, 123 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/examples/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/examples/index.js index 0fd4800f9809..3154ab6f6833 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/examples/index.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/examples/index.js @@ -19,23 +19,27 @@ 'use strict'; var Float32Array = require( '@stdlib/array/float32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); var zeroTo = require( '@stdlib/array/zero-to' ); var logEach = require( '@stdlib/console/log-each' ); var rffti = require( './../lib' ); var N = 8; -var workspace = new Float32Array( ( 2*N ) + 34 ); +var w = new Float32Array( ( 2*N ) + 34 ); -rffti( N, workspace, 1, 0 ); +rffti( N, w, 1, 0 ); console.log( 'Sequence length: %d', N ); console.log( 'Twiddle factors:' ); var idx = zeroTo( N, 'float32' ); -logEach( ' workspace[ %d ] = %0.4f', idx, workspace.slice( N, 2*N ) ); +logEach( ' w[ %d ] = %0.4f', idx, w.slice( N, 2*N ) ); + +// Create an unsigned integer view over the workspace to read the factorization section: +var fview = new Uint32Array( w.buffer, w.byteOffset, w.length ); console.log( 'Factorization:' ); -var nf = workspace[ (2*N)+1 ]; +var nf = fview[ (2*N)+1 ]; console.log( ' number of factors: %d', nf ); idx = zeroTo( nf, 'float32' ); -logEach( ' factor[ %d ]: %d', idx, workspace.slice( (2*N)+2, (2*N)+2+nf ) ); +logEach( ' factor[ %d ]: %d', idx, fview.slice( (2*N)+2, (2*N)+2+nf ) ); diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/index.js index ffd3416519ec..3ce055847d7b 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/index.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/index.js @@ -25,22 +25,24 @@ * * @example * var Float32Array = require( '@stdlib/array/float32' ); +* var Uint32Array = require( '@stdlib/array/uint32' ); * var rffti = require( '@stdlib/fft/base/fftpack/float32/rffti' ); * * var N = 8; -* var workspace = new Float32Array( ( 2*N ) + 34 ); +* var w = new Float32Array( ( 2*N ) + 34 ); * -* var out = rffti( N, workspace, 1, 0 ); +* var out = rffti( N, w, 1, 0 ); * // returns * -* var bool = ( out === workspace ); +* var bool = ( out === w ); * // returns true * -* var twiddleFactors = workspace.slice( N, 2*N ); +* var twiddleFactors = w.slice( N, 2*N ); * // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] * -* var factors = workspace.slice( 2*N, ( 2*N ) + 4 ); -* // returns [ 8, 2, 2, 4 ] +* var fview = new Uint32Array( w.buffer, w.byteOffset, w.length ); +* var factors = fview.slice( 2*N, ( 2*N ) + 4 ); +* // returns [ 8, 2, 2, 4 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/main.js b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/main.js index 5254ce02428b..6ca3a5fc8209 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/main.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/main.js @@ -129,45 +129,47 @@ var rffti1 = require( './rffti1.js' ); * In short, twiddle factors are cached roots of unity that allow each stage of the algorithm to rotate data quickly and predictably. * * @param {NonNegativeInteger} N - length of the sequence to transform -* @param {Float32Array} workspace - workspace array -* @param {integer} strideW - stride length for `workspace` -* @param {NonNegativeInteger} offsetW - starting index for `workspace` +* @param {Float32Array} w - workspace array +* @param {integer} strideW - stride length for `w` +* @param {NonNegativeInteger} offsetW - starting index for `w` * @returns {Float32Array} workspace array * * @example * var Float32Array = require( '@stdlib/array/float32' ); +* var Uint32Array = require( '@stdlib/array/uint32' ); * * var N = 8; -* var workspace = new Float32Array( ( 2*N ) + 34 ); +* var w = new Float32Array( ( 2*N ) + 34 ); * -* var out = rffti( N, workspace, 1, 0 ); +* var out = rffti( N, w, 1, 0 ); * // returns * -* var bool = ( out === workspace ); +* var bool = ( out === w ); * // returns true * -* var twiddleFactors = workspace.slice( N, 2*N ); +* var twiddleFactors = w.slice( N, 2*N ); * // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] * -* var factors = workspace.slice( 2*N, ( 2*N ) + 4 ); -* // returns [ 8, 2, 2, 4 ] +* var fview = new Uint32Array( w.buffer, w.byteOffset, w.length ); +* var factors = fview.slice( 2*N, ( 2*N ) + 4 ); +* // returns [ 8, 2, 2, 4 ] */ -function rffti( N, workspace, strideW, offsetW ) { +function rffti( N, w, strideW, offsetW ) { var offsetT; var offsetF; // When a sub-sequence is a single data point, the FFT is the identity, so no initialization necessary... if ( N === 1 ) { - return workspace; + return w; } // Resolve the starting indices for storing twiddle factors and factorization results: offsetT = offsetW + ( N*strideW ); // index offset for twiddle factors offsetF = offsetT + ( N*strideW ); // index offset for factorization results // Initialize a provided workspace array: - rffti1( N, workspace, strideW, offsetT, workspace, strideW, offsetF ); + rffti1( N, w, strideW, offsetT, w, strideW, offsetF ); - return workspace; + return w; } diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/rffti1.js b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/rffti1.js index 5015415708e6..930b3fe8affe 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/rffti1.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/lib/rffti1.js @@ -62,16 +62,15 @@ var sincosf = require( '@stdlib/math/base/special/sincosf' ).assign; var TWO_PI = require( '@stdlib/constants/float32/two-pi' ); -var floor = require( '@stdlib/math/base/special/floor' ); var f32 = require( '@stdlib/number/float64/base/to-float32' ); -var Float32Array = require( '@stdlib/array/float32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); var decompose = require( '@stdlib/fft/base/fftpack/float32/decompose' ); // VARIABLES // // Define a list of initial trial factors for FFT factorization: -var TRIAL_FACTORS = new Float32Array( [ 4.0, 2.0, 3.0, 5.0 ] ); +var TRIAL_FACTORS = new Uint32Array( [ 4, 2, 3, 5 ] ); // MAIN // @@ -92,6 +91,7 @@ var TRIAL_FACTORS = new Float32Array( [ 4.0, 2.0, 3.0, 5.0 ] ); function rffti1( N, twiddles, strideT, offsetT, factors, strideF, offsetF ) { var factor; var argld; + var fview; var argh; var fidx; var nf; @@ -107,8 +107,11 @@ function rffti1( N, twiddles, strideT, offsetT, factors, strideF, offsetF ) { var k; var j; + // Create a 32-bit unsigned integer view over the factors region of the workspace for storing integer factorization results: + fview = new Uint32Array( factors.buffer, factors.byteOffset, factors.length ); // eslint-disable-line max-len + // Decompose the sequence length into its radix factors: - nf = decompose( N, 4, TRIAL_FACTORS, 1, 0, factors, strideF, offsetF ); + nf = decompose( N, 4, TRIAL_FACTORS, 1, 0, fview, strideF, offsetF ); // 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 ( nf-1 === 0 ) { @@ -132,13 +135,13 @@ function rffti1( N, twiddles, strideT, offsetT, factors, strideF, offsetF ) { // Generate twiddle factors... for ( k = 0; k < nf-1; k++ ) { // Resolve the next radix factor: - factor = factors[ fidx ]; + factor = fview[ fidx ]; // Compute the length of the transform after including the current radix: l2 = factor * l1; // Compute the number of the "butterfly wings" (at this stage, the data is viewed as a `factor`-point transform of sub-vectors of length `l1`; `M` describes how many such vectors fit in the full array of length `N`): - M = floor( N / l2 ); + M = ( N / l2 ) >>> 0; // asm type annotation // Initialize a running offset used to step the angle: ld = 0; diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/test/test.js b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/test/test.js index d4a89a7d87b4..491b507f43f8 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/test/test.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/float32/rffti/test/test.js @@ -22,6 +22,7 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); +var Uint32Array = require( '@stdlib/array/uint32' ); var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); var rffti = require( './../lib' ); @@ -47,25 +48,25 @@ tape( 'the function has an arity of 4', function test( t ) { }); tape( 'the function returns a reference to the workspace array', function test( t ) { - var workspace; var out; + var w; var N; N = 8; - workspace = new Float32Array( ( 2*N ) + 34 ); - out = rffti( N, workspace, 1, 0 ); + w = new Float32Array( ( 2*N ) + 34 ); + out = rffti( N, w, 1, 0 ); - t.strictEqual( out, workspace, 'same reference' ); + t.strictEqual( out, w, 'same reference' ); t.end(); }); tape( 'the function correctly initializes twiddle factors (small sequence lengths)', function test( t ) { - var workspace; var expected; var lengths; var offsets; var ulps; var off; + var w; var y; var e; var N; @@ -80,12 +81,12 @@ tape( 'the function correctly initializes twiddle factors (small sequence length for ( k = 0; k < lengths.length; k++ ) { N = lengths[ k ]; off = offsets[ k ]; - workspace = new Float32Array( ( 2*N ) + 34 ); - rffti( N, workspace, 1, 0 ); + w = new Float32Array( ( 2*N ) + 34 ); + rffti( N, w, 1, 0 ); - t.strictEqual( workspace[ N-1 ], 0.0, 'returns expected value' ); + t.strictEqual( w[ N-1 ], 0.0, 'returns expected value' ); for ( i = 0; i < N; i++ ) { - y = workspace[ N+i ]; + y = w[ N+i ]; e = expected[ off+i ]; t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within '+ulps+' ULPs. N: '+N+'. y: '+y+'. E: '+e ); } @@ -94,12 +95,12 @@ tape( 'the function correctly initializes twiddle factors (small sequence length }); tape( 'the function correctly initializes twiddle factors (medium sequence lengths)', function test( t ) { - var workspace; var expected; var lengths; var offsets; var ulps; var off; + var w; var y; var e; var N; @@ -114,12 +115,12 @@ tape( 'the function correctly initializes twiddle factors (medium sequence lengt for ( k = 0; k < lengths.length; k++ ) { N = lengths[ k ]; off = offsets[ k ]; - workspace = new Float32Array( ( 2*N ) + 34 ); - rffti( N, workspace, 1, 0 ); + w = new Float32Array( ( 2*N ) + 34 ); + rffti( N, w, 1, 0 ); - t.strictEqual( workspace[ N-1 ], 0.0, 'returns expected value' ); + t.strictEqual( w[ N-1 ], 0.0, 'returns expected value' ); for ( i = 0; i < N; i++ ) { - y = workspace[ N+i ]; + y = w[ N+i ]; e = expected[ off+i ]; t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within '+ulps+' ULPs. N: '+N+'. y: '+y+'. E: '+e ); } @@ -128,12 +129,12 @@ tape( 'the function correctly initializes twiddle factors (medium sequence lengt }); tape( 'the function correctly initializes twiddle factors (large sequence lengths)', function test( t ) { - var workspace; var expected; var lengths; var offsets; var ulps; var off; + var w; var y; var e; var N; @@ -148,12 +149,12 @@ tape( 'the function correctly initializes twiddle factors (large sequence length for ( k = 0; k < lengths.length; k++ ) { N = lengths[ k ]; off = offsets[ k ]; - workspace = new Float32Array( ( 2*N ) + 34 ); - rffti( N, workspace, 1, 0 ); + w = new Float32Array( ( 2*N ) + 34 ); + rffti( N, w, 1, 0 ); - t.strictEqual( workspace[ N-1 ], 0.0, 'returns expected value' ); + t.strictEqual( w[ N-1 ], 0.0, 'returns expected value' ); for ( i = 0; i < N; i++ ) { - y = workspace[ N+i ]; + y = w[ N+i ]; e = expected[ off+i ]; t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within '+ulps+' ULPs. N: '+N+'. y: '+y+'. E: '+e ); } @@ -162,70 +163,74 @@ tape( 'the function correctly initializes twiddle factors (large sequence length }); tape( 'the function does not modify the scratch region of the workspace', function test( t ) { - var workspace; + var w; var N; var i; N = 8; - workspace = new Float32Array( ( 2*N ) + 34 ); + w = new Float32Array( ( 2*N ) + 34 ); - for ( i = 0; i < workspace.length; i++ ) { - workspace[ i ] = i + 1.0; + for ( i = 0; i < w.length; i++ ) { + w[ i ] = i + 1.0; } - rffti( N, workspace, 1, 0 ); + rffti( N, w, 1, 0 ); for ( i = 0; i < N; i++ ) { - t.strictEqual( workspace[ i ], i + 1.0, 'returns expected value' ); + t.strictEqual( w[ i ], i + 1.0, 'returns expected value' ); } t.end(); }); tape( 'the function does not modify the workspace when N is 1', function test( t ) { - var workspace; var expected; + var w; var N; var i; N = 1; - workspace = new Float32Array( ( 2*N ) + 34 ); - for ( i = 0; i < workspace.length; i++ ) { - workspace[ i ] = i + 1.0; + w = new Float32Array( ( 2*N ) + 34 ); + for ( i = 0; i < w.length; i++ ) { + w[ i ] = i + 1.0; } - expected = new Float32Array( workspace ); + expected = new Float32Array( w ); - rffti( N, workspace, 1, 0 ); + rffti( N, w, 1, 0 ); - t.deepEqual( workspace, expected, 'returns expected value' ); + t.deepEqual( w, expected, 'returns expected value' ); t.end(); }); tape( 'the function correctly handles stride and offset parameters', function test( t ) { - var workspace; var expected; var stride; var offset; + var fview; var nf; + var w; var N; var i; N = 8; stride = 2; offset = 3; - workspace = new Float32Array( offset + ( ( ( 2*N ) + 34 ) * stride ) ); + w = new Float32Array( offset + ( ( ( 2*N ) + 34 ) * stride ) ); - rffti( N, workspace, stride, offset ); + rffti( N, w, stride, offset ); - t.strictEqual( workspace[ offset + ( 2*N * stride ) ], N, 'returns expected value' ); + // Create an unsigned integer view over the workspace to read the factorization section: + fview = new Uint32Array( w.buffer, w.byteOffset, w.length ); - nf = workspace[ offset + ( ( ( 2*N ) + 1 ) * stride ) ]; + t.strictEqual( fview[ offset + ( 2*N * stride ) ], N, 'returns expected value' ); + + nf = fview[ offset + ( ( ( 2*N ) + 1 ) * stride ) ]; t.strictEqual( nf, 2, 'returns expected value' ); - t.strictEqual( workspace[ offset + ( ( ( 2*N ) + 2 ) * stride ) ], 2, 'returns expected value' ); - t.strictEqual( workspace[ offset + ( ( ( 2*N ) + 3 ) * stride ) ], 4, 'returns expected value' ); + t.strictEqual( fview[ offset + ( ( ( 2*N ) + 2 ) * stride ) ], 2, 'returns expected value' ); + t.strictEqual( fview[ offset + ( ( ( 2*N ) + 3 ) * stride ) ], 4, 'returns expected value' ); expected = new Float32Array( ( 2*N ) + 34 ); rffti( N, expected, 1, 0 ); for ( i = 0; i < N; i++ ) { - t.strictEqual( workspace[ offset + ( ( N+i ) * stride ) ], expected[ N+i ], 'returns expected value' ); + t.strictEqual( w[ offset + ( ( N+i ) * stride ) ], expected[ N+i ], 'returns expected value' ); } t.end(); });