diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/README.md b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/README.md new file mode 100644 index 000000000000..51471dc4f061 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/README.md @@ -0,0 +1,133 @@ + + +# cffti + +> Initialize a workspace array for performing a complex-valued Fourier transform on a one-dimensional ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var cffti = require( '@stdlib/fft/base/fftpack/ndarray/cffti' ); +``` + +#### cffti( arrays ) + +Initializes a workspace array for performing a complex-valued Fourier transform on a one-dimensional ndarray. + +```javascript +var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var Slice = require( '@stdlib/slice/ctor' ); +var slice = require( '@stdlib/ndarray/slice' ); + +var N = 8; +var len = scalar2ndarray( N, { + 'dtype': 'int32' +}); + +var workspace = new Float64Vector( ( 4*N ) + 34 ); + +var out = cffti( [ workspace, len ] ); +// returns + +var bool = ( out === workspace ); +// returns true + +var twiddleFactors = slice( workspace, new Slice( 2*N, 4*N ) ); +// returns [ 1, 0, ~0.707, ~0.707, ~0, 1, ~-0.707, ~0.707, 1, 0, 1, 0, 1, 0, ~0, -1 ] + +var factors = slice( workspace, new Slice( 4*N, ( 4*N ) + 4 ) ); +// returns [ 8, 2, 2, 4 ] +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the length of the sequence to transform. + +
+ + + +
+ +## Notes + +- If provided an empty one-dimensional input ndarray, the function returns the output ndarray unchanged. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var cffti = require( '@stdlib/fft/base/fftpack/ndarray/cffti' ); + +var N = 8; + +var workspace = new Float64Vector( ( 4*N ) + 34 ); +console.log( ndarray2array( workspace ) ); + +var len = scalar2ndarray( N, { + 'dtype': 'int32' +}); + +var out = cffti( [ workspace, len ] ); +console.log( ndarray2array( out ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/benchmark/benchmark.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/benchmark/benchmark.js new file mode 100644 index 000000000000..d09ff08d8be1 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/benchmark/benchmark.js @@ -0,0 +1,106 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var cffti = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - sequence length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var workspace = new Float64Vector( ( 4*N ) + 34 ); + var len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = cffti( [ workspace, len ] ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( v.get( 2*N ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var lengths; + var N; + var f; + var i; + + lengths = [ + 8, + 16, + 32, + 64, + 128, + 256, + 512, + 1024 + ]; + + for ( i = 0; i < lengths.length; i++ ) { + N = lengths[ i ]; + f = createBenchmark( N ); + bench( format( '%s:N=%d', pkg, N ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/repl.txt b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/repl.txt new file mode 100644 index 000000000000..b6a8843deb1d --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/repl.txt @@ -0,0 +1,41 @@ + +{{alias}}( arrays ) + Initializes a workspace array for performing a complex-valued Fourier + transform on a one-dimensional ndarray. + + If provided an empty input ndarray, the function returns the output ndarray + unchanged. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays: + + - a one-dimensional input ndarray. + - a zero-dimensional ndarray containing the length of the sequence to + transform. + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var N = 8; + > var workspace = new {{alias:@stdlib/ndarray/vector/float64}}( ( 4*N ) + 34 ); + > var len = {{alias:@stdlib/ndarray/from-scalar}}( N, { 'dtype': 'int32' }); + > var out = {{alias}}( [ workspace, len ] ) + + > var bool = ( out === workspace ) + true + > var s = new {{alias:@stdlib/slice/ctor}}( 2*N, 4*N ); + > var twiddleFactors = {{alias:@stdlib/ndarray/slice}}( workspace, s ) + + > s = new {{alias:@stdlib/slice/ctor}}( 4*N, ( 4*N ) + 4 ); + > var factors = {{alias:@stdlib/ndarray/slice}}( workspace, s ) + [ 8, 2, 2, 4 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/types/index.d.ts b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/types/index.d.ts new file mode 100644 index 000000000000..2dde515a9a9f --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/types/index.d.ts @@ -0,0 +1,73 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { typedndarray, floatndarray, genericndarray } from '@stdlib/types/ndarray'; + +/** +* Input array. +*/ +type InputArray = floatndarray | genericndarray; + +/** +* Initializes a workspace array for performing a complex-valued Fourier transform on a one-dimensional ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray containing the length of the sequence to transform. +* +* @param arrays - array-like object containing ndarrays +* @returns output ndarray +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var slice = require( '@stdlib/ndarray/slice' ); +* +* var N = 8; +* var len = scalar2ndarray( N, { +* 'dtype': 'int32' +* }); +* +* var workspace = new Float64Vector( ( 4*N ) + 34 ); +* +* var out = cffti( [ workspace, len ] ); +* // returns +* +* var bool = ( out === workspace ); +* // returns true +* +* var twiddleFactors = slice( workspace, new Slice( 2*N, 4*N ) ); +* // returns [ 1, 0, ~0.707, ~0.707, ~0, 1, ~-0.707, ~0.707, 1, 0, 1, 0, 1, 0, ~0, -1 ] +* +* var factors = slice( workspace, new Slice( 4*N, ( 4*N ) + 4 ) ); +* // returns [ 8, 2, 2, 4 ] +*/ +declare function cffti( arrays: [ T, typedndarray ] ): T; + + +// EXPORTS // + +export = cffti; diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/types/test.ts b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/types/test.ts new file mode 100644 index 000000000000..97aa18a81059 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/docs/types/test.ts @@ -0,0 +1,63 @@ +/* +* @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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import cffti = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const workspace = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const N = zeros( [], { + 'dtype': 'int32' + }); + + cffti( [ workspace, N ] ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + cffti( '10' ); // $ExpectError + cffti( 10 ); // $ExpectError + cffti( true ); // $ExpectError + cffti( false ); // $ExpectError + cffti( null ); // $ExpectError + cffti( undefined ); // $ExpectError + cffti( [] ); // $ExpectError + cffti( {} ); // $ExpectError + cffti( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const workspace = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const N = zeros( [], { + 'dtype': 'int32' + }); + + cffti(); // $ExpectError + cffti( [ workspace, N ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/examples/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/examples/index.js new file mode 100644 index 000000000000..b56c7eabcb5f --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/examples/index.js @@ -0,0 +1,36 @@ +/** +* @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. +*/ + +'use strict'; + +var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var cffti = require( './../lib' ); + +var N = 8; + +var workspace = new Float64Vector( ( 4*N ) + 34 ); +console.log( ndarray2array( workspace ) ); + +var len = scalar2ndarray( N, { + 'dtype': 'int32' +}); + +var out = cffti( [ workspace, len ] ); +console.log( ndarray2array( out ) ); diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/lib/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/lib/index.js new file mode 100644 index 000000000000..62e0449bbf6c --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/lib/index.js @@ -0,0 +1,60 @@ +/** +* @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. +*/ + +'use strict'; + +/** +* Initialize a workspace array for performing a complex-valued Fourier transform on a one-dimensional ndarray. +* +* @module @stdlib/fft/base/fftpack/ndarray/cffti +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var slice = require( '@stdlib/ndarray/slice' ); +* var cffti = require( '@stdlib/fft/base/fftpack/ndarray/cffti' ); +* +* var N = 8; +* var len = scalar2ndarray( N, { +* 'dtype': 'int32' +* }); +* +* var workspace = new Float64Vector( ( 4*N ) + 34 ); +* +* var out = cffti( [ workspace, len ] ); +* // returns +* +* var bool = ( out === workspace ); +* // returns true +* +* var twiddleFactors = slice( workspace, new Slice( 2*N, 4*N ) ); +* // returns [ 1, 0, ~0.707, ~0.707, ~0, 1, ~-0.707, ~0.707, 1, 0, 1, 0, 1, 0, ~0, -1 ] +* +* var factors = slice( workspace, new Slice( 4*N, ( 4*N ) + 4 ) ); +* // returns [ 8, 2, 2, 4 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/lib/main.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/lib/main.js new file mode 100644 index 000000000000..ea54a77753ac --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/lib/main.js @@ -0,0 +1,83 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var strided = require( '@stdlib/fft/base/fftpack/cffti' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); + + +// MAIN // + +/** +* Initializes a workspace array for performing a complex-valued Fourier transform on a one-dimensional ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input ndarray. +* - a zero-dimensional ndarray containing the length of the sequence to transform. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {ndarrayLike} output ndarray +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var slice = require( '@stdlib/ndarray/slice' ); +* +* var N = 8; +* var len = scalar2ndarray( N, { +* 'dtype': 'int32' +* }); +* +* var workspace = new Float64Vector( ( 4*N ) + 34 ); +* +* var out = cffti( [ workspace, len ] ); +* // returns +* +* var bool = ( out === workspace ); +* // returns true +* +* var twiddleFactors = slice( workspace, new Slice( 2*N, 4*N ) ); +* // returns [ 1, 0, ~0.707, ~0.707, ~0, 1, ~-0.707, ~0.707, 1, 0, 1, 0, 1, 0, ~0, -1 ] +* +* var factors = slice( workspace, new Slice( 4*N, ( 4*N ) + 4 ) ); +* // returns [ 8, 2, 2, 4 ] +*/ +function cffti( arrays ) { + var workspace; + var N; + + workspace = arrays[ 0 ]; + N = ndarraylike2scalar( arrays[ 1 ] ); + strided( N, getData( workspace ), getStride( workspace, 0 ), getOffset( workspace ) ); // eslint-disable-line max-len + return workspace; +} + + +// EXPORTS // + +module.exports = cffti; diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/package.json b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/package.json new file mode 100644 index 000000000000..eecd2feb0f31 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/fft/base/fftpack/ndarray/cffti", + "version": "0.0.0", + "description": "Initialize a workspace array for performing a complex-valued Fourier transform on a one-dimensional ndarray.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "fft", + "fftpack", + "cffti", + "fourier", + "transform", + "twiddle", + "workspace", + "initialization", + "complex", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/test/test.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/test/test.js new file mode 100644 index 000000000000..2fc8eeccf7e5 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cffti/test/test.js @@ -0,0 +1,283 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var Float64Array = require( '@stdlib/array/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var getData = require( '@stdlib/ndarray/data-buffer' ); +var cffti = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'float64', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof cffti, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( cffti.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function correctly initializes twiddle and integer factors in a one-dimensional ndarray `workspace`', function test( t ) { + var expectedTwiddles; + var expectedFactors; + var workspaceBuf; + var workspace; + var ulps; + var len; + var N; + var v; + var i; + var y; + var e; + + N = 8; + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + workspaceBuf = new Float64Array( ( 4*N ) + 34 ); + workspace = vector( workspaceBuf, ( 4*N ) + 34, 1, 0 ); + v = cffti( [ workspace, len ] ); + t.strictEqual( v, workspace, 'returns expected workspace reference' ); + + expectedTwiddles = new Float64Array( [ 1.0, 0.0, 0.7071067811865476, 0.7071067811865475, 6.123233995736766e-17, 1.0, -0.7071067811865476, 0.7071067811865476, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, -1.8369701987210297e-16, -1.0 ] ); + expectedFactors = new Float64Array( [ 8, 2, 2, 4 ] ); + + ulps = 1; + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = workspaceBuf[ ( 2*N ) + i ]; + e = expectedTwiddles[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < expectedFactors.length; i++ ) { + y = workspaceBuf[ ( 4*N ) + i ]; + e = expectedFactors[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < 2*N; i++ ) { + y = workspaceBuf[ i ]; + e = 0.0; + t.strictEqual( y, e, 'returns expected value' ); + } + + t.end(); +}); + +tape( 'if provided an empty ndarray, the function returns the output ndarray unchanged', function test( t ) { + var workspaceBuf; + var workspace; + var expected; + var len; + var N; + var v; + + N = 4; + workspaceBuf = new Float64Array( [] ); + workspace = vector( workspaceBuf, 0, 1, 0 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = cffti( [ workspace, len ] ); + + expected = new Float64Array( [] ); + t.strictEqual( v, workspace, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( getData( v ), expected ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a one-dimensional ndarray having a non-unit stride', function test( t ) { + var expectedTwiddles; + var expectedFactors; + var workspaceBuf; + var workspace; + var ulps; + var len; + var y; + var e; + var i; + var N; + var v; + + N = 8; + workspaceBuf = new Float64Array( ( 8*N ) + 68 ); + workspace = vector( workspaceBuf, ( 4*N ) + 34, 2, 0 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = cffti( [ workspace, len ] ); + + expectedTwiddles = new Float64Array( [ 1.0, 0.0, 0.7071067811865476, 0.7071067811865475, 6.123233995736766e-17, 1.0, -0.7071067811865476, 0.7071067811865476, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, -1.8369701987210297e-16, -1.0 ] ); + expectedFactors = new Float64Array( [ 8, 2, 2, 4 ] ); + + t.strictEqual( v, workspace, 'returns expected value' ); + + ulps = 1; + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = workspaceBuf[ ( 4*N ) + ( 2*i ) ]; + e = expectedTwiddles[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < expectedFactors.length; i++ ) { + y = workspaceBuf[ ( 8*N ) + ( 2*i ) ]; + e = expectedFactors[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < 2*N; i++ ) { + y = workspaceBuf[ 2*i ]; + e = 0.0; + t.strictEqual( y, e, 'returns expected value' ); + + y = workspaceBuf[ ( 4*N ) + ( 2*i ) + 1 ]; + t.strictEqual( y, e, 'returns expected value' ); + } + + t.end(); +}); + +tape( 'the function supports a one-dimensional ndarray having a negative stride', function test( t ) { + var expectedTwiddles; + var expectedFactors; + var workspaceBuf; + var workspace; + var ulps; + var len; + var v; + var y; + var e; + var i; + var N; + + N = 8; + workspaceBuf = new Float64Array( ( 4*N ) + 34 ); + workspace = vector( workspaceBuf, ( 4*N ) + 34, -1, ( 4*N ) + 33 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = cffti( [ workspace, len ] ); + t.strictEqual( v, workspace, 'returns expected value' ); + + expectedTwiddles = new Float64Array( [ 1.0, 0.0, 0.7071067811865476, 0.7071067811865475, 6.123233995736766e-17, 1.0, -0.7071067811865476, 0.7071067811865476, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, -1.8369701987210297e-16, -1.0 ] ); + expectedFactors = new Float64Array( [ 8.0, 2.0, 2.0, 4.0 ] ); + + ulps = 1; + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = workspaceBuf[ ( 2*N ) + 33 - i ]; + e = expectedTwiddles[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < expectedFactors.length; i++ ) { + y = workspaceBuf[ 33 - i ]; + e = expectedFactors[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < 2*N; i++ ) { + y = workspaceBuf[ ( 4*N ) + 33 - i ]; + e = 0.0; + t.strictEqual( y, e, 'returns expected value' ); + } + + t.end(); +}); + +tape( 'the function supports a one-dimensional ndarray having a non-zero offset', function test( t ) { + var expectedTwiddles; + var expectedFactors; + var workspaceBuf; + var workspace; + var ulps; + var len; + var v; + var y; + var e; + var i; + var N; + + N = 8; + workspaceBuf = new Float64Array( ( 4*N ) + 34 + 2 ); + workspace = vector( workspaceBuf, ( 4*N ) + 34, 1, 2 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = cffti( [ workspace, len ] ); + + t.strictEqual( v, workspace, 'returns expected value' ); + + expectedTwiddles = new Float64Array( [ 1.0, 0.0, 0.7071067811865476, 0.7071067811865475, 6.123233995736766e-17, 1.0, -0.7071067811865476, 0.7071067811865476, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, -1.8369701987210297e-16, -1.0 ] ); + expectedFactors = new Float64Array( [ 8.0, 2.0, 2.0, 4.0 ] ); + + ulps = 1; + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = workspaceBuf[ ( 2*N ) + i + 2 ]; + e = expectedTwiddles[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < expectedFactors.length; i++ ) { + y = workspaceBuf[ ( 4*N ) + i + 2 ]; + e = expectedFactors[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < 2*N; i++ ) { + y = workspaceBuf[ i+2 ]; + e = 0.0; + t.strictEqual( y, e, 'returns expected value' ); + } + + t.end(); +});