From addf74e4f23209dcf8b604dd48d413521f72979a Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Sun, 9 Aug 2026 15:18:50 +0530 Subject: [PATCH 1/4] feat: add fft/base/fftpack/ndarray/cosqi --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../fft/base/fftpack/ndarray/cosqi/README.md | 136 ++++++++ .../ndarray/cosqi/benchmark/benchmark.js | 115 +++++++ .../base/fftpack/ndarray/cosqi/docs/repl.txt | 44 +++ .../ndarray/cosqi/docs/types/index.d.ts | 76 +++++ .../fftpack/ndarray/cosqi/docs/types/test.ts | 63 ++++ .../fftpack/ndarray/cosqi/examples/index.js | 36 ++ .../base/fftpack/ndarray/cosqi/lib/index.js | 63 ++++ .../base/fftpack/ndarray/cosqi/lib/main.js | 86 +++++ .../base/fftpack/ndarray/cosqi/package.json | 66 ++++ .../base/fftpack/ndarray/cosqi/test/test.js | 315 ++++++++++++++++++ 10 files changed, 1000 insertions(+) create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/README.md create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/examples/index.js create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/index.js create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/main.js create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/package.json create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/README.md b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/README.md new file mode 100644 index 000000000000..f161182957e9 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/README.md @@ -0,0 +1,136 @@ + + +# cosqi + +> Initialize a workspace array for performing a quarter-wave cosine transform on a one-dimensional ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var cosqi = require( '@stdlib/fft/base/fftpack/ndarray/cosqi' ); +``` + +#### cosqi( arrays ) + +Initializes a workspace array for performing a quarter-wave cosine 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 w = new Float64Vector( ( 3*N ) + 34 ); + +var out = cosqi( [ w, len ] ); +// returns + +var bool = ( out === w ); +// returns true + +var cosineTable = slice( w, new Slice( 0, N ) ); +// returns [ ~0.98, ~0.92, ~0.83, ~0.7, ~0.56, ~0.38, ~0.2, ~0.0 ] + +var twiddleFactors = slice( w, new Slice( 2*N, 3*N ) ); +// returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] + +var factors = slice( w, new Slice( 3*N, ( 3*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 cosqi = require( '@stdlib/fft/base/fftpack/ndarray/cosqi' ); + +var N = 8; + +var w = new Float64Vector( ( 3*N ) + 34 ); +console.log( ndarray2array( w ) ); + +var len = scalar2ndarray( N, { + 'dtype': 'int32' +}); + +var out = cosqi( [ w, len ] ); +console.log( ndarray2array( out ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js new file mode 100644 index 000000000000..861bf41cc1d1 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js @@ -0,0 +1,115 @@ +/** +* @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 zeros = require( '@stdlib/ndarray/zeros' ); +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 cosqi = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - sequence length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var len; + var w; + + len = scalar2ndarray( N, options ); + w = zeros( [ ( 3*N ) + 34 ], options ); + + 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 = cosqi( [ w, 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/cosqi/docs/repl.txt b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/repl.txt new file mode 100644 index 000000000000..3e449e9e8fbd --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/repl.txt @@ -0,0 +1,44 @@ + +{{alias}}( arrays ) + Initializes a workspace array for performing a quarter-wave cosine + 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 w = new {{alias:@stdlib/ndarray/vector/float64}}( ( 3*N ) + 34 ); + > var len = {{alias:@stdlib/ndarray/from-scalar}}( N, { 'dtype': 'int32' }); + > var out = {{alias}}( [ w, len ] ) + + > var bool = ( out === w ) + true + > var s = new {{alias:@stdlib/slice/ctor}}( 0, N ); + > var cosineTable = {{alias:@stdlib/ndarray/slice}}( w, s ) + [ ~0.98, ~0.92, ~0.83, ~0.7, ~0.56, ~0.38, ~0.2, ~0.0 ] + > s = new {{alias:@stdlib/slice/ctor}}( 2*N, 3*N ); + > var twiddleFactors = {{alias:@stdlib/ndarray/slice}}( w, s ) + [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] + > s = new {{alias:@stdlib/slice/ctor}}( 3*N, ( 3*N ) + 4 ); + > var factors = {{alias:@stdlib/ndarray/slice}}( w, s ) + [ 8, 2, 2, 4 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/index.d.ts b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/index.d.ts new file mode 100644 index 000000000000..01a07436dfae --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/index.d.ts @@ -0,0 +1,76 @@ +/* +* @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 quarter-wave cosine 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 w = new Float64Vector( ( 3*N ) + 34 ); +* +* var out = cosqi( [ w, len ] ); +* // returns +* +* var bool = ( out === w ); +* // returns true +* +* var cosineTable = slice( w, new Slice( 0, N ) ); +* // returns [ ~0.98, ~0.92, ~0.83, ~0.7, ~0.56, ~0.38, ~0.2, ~0.0 ] +* +* var twiddleFactors = slice( w, new Slice( 2*N, 3*N ) ); +* // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] +* +* var factors = slice( w, new Slice( 3*N, ( 3*N ) + 4 ) ); +* // returns [ 8, 2, 2, 4 ] +*/ +declare function cosqi( arrays: [ T, typedndarray ] ): T; + + +// EXPORTS // + +export = cosqi; diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/test.ts b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/test.ts new file mode 100644 index 000000000000..51b2f6a75024 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/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 cosqi = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const w = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const N = zeros( [], { + 'dtype': 'int32' + }); + + cosqi( [ w, N ] ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + cosqi( '10' ); // $ExpectError + cosqi( 10 ); // $ExpectError + cosqi( true ); // $ExpectError + cosqi( false ); // $ExpectError + cosqi( null ); // $ExpectError + cosqi( undefined ); // $ExpectError + cosqi( [] ); // $ExpectError + cosqi( {} ); // $ExpectError + cosqi( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const w = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const N = zeros( [], { + 'dtype': 'int32' + }); + + cosqi(); // $ExpectError + cosqi( [ w, N ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/examples/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/examples/index.js new file mode 100644 index 000000000000..aadd503244b6 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/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 cosqi = require( './../lib' ); + +var N = 8; + +var w = new Float64Vector( ( 3*N ) + 34 ); +console.log( ndarray2array( w ) ); + +var len = scalar2ndarray( N, { + 'dtype': 'int32' +}); + +var out = cosqi( [ w, len ] ); +console.log( ndarray2array( out ) ); diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/index.js new file mode 100644 index 000000000000..57bae4edf840 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/index.js @@ -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. +*/ + +'use strict'; + +/** +* Initialize a workspace array for performing a quarter-wave cosine transform on a one-dimensional ndarray. +* +* @module @stdlib/fft/base/fftpack/ndarray/cosqi +* +* @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 cosqi = require( '@stdlib/fft/base/fftpack/ndarray/cosqi' ); +* +* var N = 8; +* var len = scalar2ndarray( N, { +* 'dtype': 'int32' +* }); +* +* var w = new Float64Vector( ( 3*N ) + 34 ); +* +* var out = cosqi( [ w, len ] ); +* // returns +* +* var bool = ( out === w ); +* // returns true +* +* var cosineTable = slice( w, new Slice( 0, N ) ); +* // returns [ ~0.98, ~0.92, ~0.83, ~0.7, ~0.56, ~0.38, ~0.2, ~0.0 ] +* +* var twiddleFactors = slice( w, new Slice( 2*N, 3*N ) ); +* // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] +* +* var factors = slice( w, new Slice( 3*N, ( 3*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/cosqi/lib/main.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/main.js new file mode 100644 index 000000000000..e58b2a46586e --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/main.js @@ -0,0 +1,86 @@ +/** +* @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/cosqi' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); + + +// MAIN // + +/** +* Initializes a workspace array for performing a quarter-wave cosine 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 w = new Float64Vector( ( 3*N ) + 34 ); +* +* var out = cosqi( [ w, len ] ); +* // returns +* +* var bool = ( out === w ); +* // returns true +* +* var cosineTable = slice( w, new Slice( 0, N ) ); +* // returns [ ~0.98, ~0.92, ~0.83, ~0.7, ~0.56, ~0.38, ~0.2, ~0.0 ] +* +* var twiddleFactors = slice( w, new Slice( 2*N, 3*N ) ); +* // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] +* +* var factors = slice( w, new Slice( 3*N, ( 3*N ) + 4 ) ); +* // returns [ 8, 2, 2, 4 ] +*/ +function cosqi( arrays ) { + var w; + var N; + + w = arrays[ 0 ]; + N = ndarraylike2scalar( arrays[ 1 ] ); + strided( N, getData( w ), getStride( w, 0 ), getOffset( w ) ); + return w; +} + + +// EXPORTS // + +module.exports = cosqi; diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/package.json b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/package.json new file mode 100644 index 000000000000..90c3a92d244b --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/package.json @@ -0,0 +1,66 @@ +{ + "name": "@stdlib/fft/base/fftpack/ndarray/cosqi", + "version": "0.0.0", + "description": "Initialize a workspace array for performing a quarter-wave cosine 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", + "cosqi", + "fourier", + "transform", + "twiddle", + "cosine", + "workspace", + "initialization", + "real", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js new file mode 100644 index 000000000000..b1483282124b --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js @@ -0,0 +1,315 @@ +/** +* @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 cosqi = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Float64Array} 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 cosqi, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( cosqi.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function correctly initializes cosine, twiddle and integer factors in a one-dimensional ndarray `w`', function test( t ) { + var expectedTwiddles; + var expectedFactors; + var expectedCosines; + var wBuf; + var ulps; + var len; + var N; + var w; + var v; + var i; + var y; + var e; + + N = 8; + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + wBuf = new Float64Array( ( 3*N ) + 34 ); + w = vector( wBuf, ( 3*N ) + 34, 1, 0 ); + v = cosqi( [ w, len ] ); + t.strictEqual( v, w, 'returns expected workspace reference' ); + + expectedCosines = new Float64Array( [ 0.9807852804032304, 0.9238795325112867, 0.8314696123025452, 0.7071067811865476, 0.5555702330196023, 0.38268343236508984, 0.19509032201612833, 6.123233995736766e-17 ] ); + expectedTwiddles = new Float64Array( [ 0.7071067811865476, 0.7071067811865475, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expectedFactors = new Float64Array( [ 8, 2, 2, 4 ] ); + + ulps = 1; + for ( i = 0; i < expectedCosines.length; i++ ) { + y = wBuf[ i ]; + e = expectedCosines[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = wBuf[ ( 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 = wBuf[ ( 3*N ) + i ]; + e = expectedFactors[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = N; i < 2*N; i++ ) { + y = wBuf[ 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 expected; + var wBuf; + var len; + var w; + var N; + var v; + + N = 4; + wBuf = new Float64Array( [] ); + w = vector( wBuf, 0, 1, 0 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = cosqi( [ w, len ] ); + + expected = new Float64Array( [] ); + t.strictEqual( v, w, '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 expectedCosines; + var wBuf; + var ulps; + var len; + var w; + var y; + var e; + var i; + var N; + var v; + + N = 8; + wBuf = new Float64Array( ( 6*N ) + 68 ); + w = vector( wBuf, ( 3*N ) + 34, 2, 0 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = cosqi( [ w, len ] ); + + expectedCosines = new Float64Array( [ 0.9807852804032304, 0.9238795325112867, 0.8314696123025452, 0.7071067811865476, 0.5555702330196023, 0.38268343236508984, 0.19509032201612833, 6.123233995736766e-17 ] ); + expectedTwiddles = new Float64Array( [ 0.7071067811865476, 0.7071067811865475, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expectedFactors = new Float64Array( [ 8, 2, 2, 4 ] ); + + t.strictEqual( v, w, 'returns expected value' ); + + ulps = 1; + for ( i = 0; i < expectedCosines.length; i++ ) { + y = wBuf[ 2*i ]; + e = expectedCosines[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = wBuf[ ( 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 = wBuf[ ( 6*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 < N; i++ ) { + y = wBuf[ ( 2*N ) + ( 2*i ) ]; + e = 0.0; + t.strictEqual( y, e, 'returns expected value' ); + + y = wBuf[ ( 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 expectedCosines; + var wBuf; + var ulps; + var len; + var w; + var v; + var y; + var e; + var i; + var N; + + N = 8; + wBuf = new Float64Array( ( 3*N ) + 34 ); + w = vector( wBuf, ( 3*N ) + 34, -1, ( 3*N ) + 33 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = cosqi( [ w, len ] ); + t.strictEqual( v, w, 'returns expected value' ); + + expectedCosines = new Float64Array( [ 0.9807852804032304, 0.9238795325112867, 0.8314696123025452, 0.7071067811865476, 0.5555702330196023, 0.38268343236508984, 0.19509032201612833, 6.123233995736766e-17 ] ); + expectedTwiddles = new Float64Array( [ 0.7071067811865476, 0.7071067811865475, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expectedFactors = new Float64Array( [ 8.0, 2.0, 2.0, 4.0 ] ); + + ulps = 1; + for ( i = 0; i < expectedCosines.length; i++ ) { + y = wBuf[ ( 3*N ) + 33 - i ]; + e = expectedCosines[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = wBuf[ 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 = wBuf[ 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 < N; i++ ) { + y = wBuf[ ( 2*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 expectedCosines; + var wBuf; + var ulps; + var len; + var w; + var v; + var y; + var e; + var i; + var N; + + N = 8; + wBuf = new Float64Array( ( 3*N ) + 34 + 2 ); + w = vector( wBuf, ( 3*N ) + 34, 1, 2 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = cosqi( [ w, len ] ); + + t.strictEqual( v, w, 'returns expected value' ); + + expectedCosines = new Float64Array( [ 0.9807852804032304, 0.9238795325112867, 0.8314696123025452, 0.7071067811865476, 0.5555702330196023, 0.38268343236508984, 0.19509032201612833, 6.123233995736766e-17 ] ); + expectedTwiddles = new Float64Array( [ 0.7071067811865476, 0.7071067811865475, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expectedFactors = new Float64Array( [ 8.0, 2.0, 2.0, 4.0 ] ); + + ulps = 1; + for ( i = 0; i < expectedCosines.length; i++ ) { + y = wBuf[ i+2 ]; + e = expectedCosines[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = wBuf[ ( 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 = wBuf[ ( 3*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 < N; i++ ) { + y = wBuf[ N+i+2 ]; + e = 0.0; + t.strictEqual( y, e, 'returns expected value' ); + } + + t.end(); +}); From 51da61046b67c363b84ec91ad16a7027295dfed7 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 11 Aug 2026 08:40:48 +0530 Subject: [PATCH 2/4] test: use integers Signed-off-by: Gunj Joshi --- .../@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js index b1483282124b..d7d32eee87a6 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js @@ -227,7 +227,7 @@ tape( 'the function supports a one-dimensional ndarray having a negative stride' expectedCosines = new Float64Array( [ 0.9807852804032304, 0.9238795325112867, 0.8314696123025452, 0.7071067811865476, 0.5555702330196023, 0.38268343236508984, 0.19509032201612833, 6.123233995736766e-17 ] ); expectedTwiddles = new Float64Array( [ 0.7071067811865476, 0.7071067811865475, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - expectedFactors = new Float64Array( [ 8.0, 2.0, 2.0, 4.0 ] ); + expectedFactors = new Float64Array( [ 8, 2, 2, 4 ] ); ulps = 1; for ( i = 0; i < expectedCosines.length; i++ ) { @@ -284,7 +284,7 @@ tape( 'the function supports a one-dimensional ndarray having a non-zero offset' expectedCosines = new Float64Array( [ 0.9807852804032304, 0.9238795325112867, 0.8314696123025452, 0.7071067811865476, 0.5555702330196023, 0.38268343236508984, 0.19509032201612833, 6.123233995736766e-17 ] ); expectedTwiddles = new Float64Array( [ 0.7071067811865476, 0.7071067811865475, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - expectedFactors = new Float64Array( [ 8.0, 2.0, 2.0, 4.0 ] ); + expectedFactors = new Float64Array( [ 8, 2, 2, 4 ] ); ulps = 1; for ( i = 0; i < expectedCosines.length; i++ ) { From b8a1fd48f7abec16fffaadbcb48bfd5f4865d831 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Sat, 15 Aug 2026 15:11:20 +0530 Subject: [PATCH 3/4] bench: use correct dtype for len Signed-off-by: Gunj Joshi --- .../fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js index 861bf41cc1d1..486c73210539 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js @@ -34,6 +34,9 @@ var cosqi = require( './../lib' ); var options = { 'dtype': 'generic' }; +var nopts = { + 'dtype': 'int32' +}; // FUNCTIONS // @@ -49,7 +52,7 @@ function createBenchmark( N ) { var len; var w; - len = scalar2ndarray( N, options ); + len = scalar2ndarray( N, nopts ); w = zeros( [ ( 3*N ) + 34 ], options ); return benchmark; From 37a010dee8423c4102250277c47d27d513d472ed Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Mon, 24 Aug 2026 20:33:08 +0530 Subject: [PATCH 4/4] chore: move to generic namespace --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../ndarray/{ => generic}/cosqi/README.md | 29 +++++++++++++++++-- .../cosqi/benchmark/benchmark.js | 0 .../ndarray/{ => generic}/cosqi/docs/repl.txt | 11 +++---- .../{ => generic}/cosqi/docs/types/index.d.ts | 2 +- .../{ => generic}/cosqi/docs/types/test.ts | 0 .../{ => generic}/cosqi/examples/index.js | 0 .../ndarray/{ => generic}/cosqi/lib/index.js | 4 +-- .../ndarray/{ => generic}/cosqi/lib/main.js | 4 +-- .../ndarray/{ => generic}/cosqi/package.json | 2 +- .../ndarray/{ => generic}/cosqi/test/test.js | 4 +-- 10 files changed, 40 insertions(+), 16 deletions(-) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/README.md (64%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/benchmark/benchmark.js (100%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/docs/repl.txt (86%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/docs/types/index.d.ts (98%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/docs/types/test.ts (100%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/examples/index.js (100%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/lib/index.js (92%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/lib/main.js (95%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/package.json (95%) rename lib/node_modules/@stdlib/fft/base/fftpack/ndarray/{ => generic}/cosqi/test/test.js (98%) diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/README.md b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/README.md similarity index 64% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/README.md rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/README.md index f161182957e9..4c22c26580f4 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/README.md +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/README.md @@ -33,7 +33,7 @@ limitations under the License. ## Usage ```javascript -var cosqi = require( '@stdlib/fft/base/fftpack/ndarray/cosqi' ); +var cosqi = require( '@stdlib/fft/base/fftpack/ndarray/generic/cosqi' ); ``` #### cosqi( arrays ) @@ -84,7 +84,30 @@ The function has the following parameters: ## Notes -- If provided an empty one-dimensional input ndarray, the function returns the output ndarray unchanged. +- Let `N` equal the number of elements in the input ndarray. The input ndarray is divided into four sections: + + ```text + size = N N N 2+ceil(log2(N)/2) + ↓ ↓ ↓ ↓ + | cosine table | scratch / workspace | twiddle factors | radix factor table | + ↑ ↑ ↑ ↑ + i = 0 ... N ... 2N ... 3N ... + ``` + + - **cosine table**: a table of precomputed cosine coefficients used by quarter-wave cosine transforms. + - **scratch/workspace**: used as a scratch space when performing transforms. This section is not updated during initialization. + - **twiddle factors**: a table of reusable complex-exponential constants stored as cosine/sine pairs. + - **radix factor table**: a table containing the sequence length `N`, the number of factors into which `N` was decomposed, and the individual integer radix factors. + +- In general, an input ndarray should have `3N + 34` indexed elements (as `log2(N)/2 ≤ 32` for all `2^64`). During initialization, only the sections for storing the cosine coefficients, twiddle factors, and the factorization of `N` are updated. + +- The radix factor table is comprised as follows: + + ```text + | sequence_length | number_of_factors | integer_factors | + ``` + +- If provided an empty one-dimensional input ndarray, the function returns the input ndarray unchanged. @@ -100,7 +123,7 @@ The function has the following parameters: var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); -var cosqi = require( '@stdlib/fft/base/fftpack/ndarray/cosqi' ); +var cosqi = require( '@stdlib/fft/base/fftpack/ndarray/generic/cosqi' ); var N = 8; diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/benchmark/benchmark.js similarity index 100% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/benchmark/benchmark.js rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/benchmark/benchmark.js diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/repl.txt b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/docs/repl.txt similarity index 86% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/repl.txt rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/docs/repl.txt index 3e449e9e8fbd..a1b502351360 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/repl.txt +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/docs/repl.txt @@ -1,9 +1,9 @@ {{alias}}( arrays ) - Initializes a workspace array for performing a quarter-wave cosine - transform on a one-dimensional ndarray. + Initializes a workspace array for performing a quarter-wave cosine transform + on a one-dimensional ndarray. - If provided an empty input ndarray, the function returns the output ndarray + If provided an empty input ndarray, the function returns the input ndarray unchanged. Parameters @@ -18,13 +18,14 @@ Returns ------- out: ndarray - Output ndarray. + Input ndarray. Examples -------- > var N = 8; > var w = new {{alias:@stdlib/ndarray/vector/float64}}( ( 3*N ) + 34 ); - > var len = {{alias:@stdlib/ndarray/from-scalar}}( N, { 'dtype': 'int32' }); + > var opts = { 'dtype': 'int32' }; + > var len = {{alias:@stdlib/ndarray/from-scalar}}( N, opts ); > var out = {{alias}}( [ w, len ] ) > var bool = ( out === w ) diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/index.d.ts b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/docs/types/index.d.ts similarity index 98% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/index.d.ts rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/docs/types/index.d.ts index 01a07436dfae..5dc6105b8855 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/docs/types/index.d.ts @@ -38,7 +38,7 @@ type InputArray = floatndarray | genericndarray; * - a zero-dimensional ndarray containing the length of the sequence to transform. * * @param arrays - array-like object containing ndarrays -* @returns output ndarray +* @returns input ndarray * * @example * var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/test.ts b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/docs/types/test.ts similarity index 100% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/docs/types/test.ts rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/examples/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/examples/index.js similarity index 100% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/examples/index.js rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/examples/index.js diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/lib/index.js similarity index 92% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/index.js rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/lib/index.js index 57bae4edf840..b8bb27cc434a 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/index.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/lib/index.js @@ -21,14 +21,14 @@ /** * Initialize a workspace array for performing a quarter-wave cosine transform on a one-dimensional ndarray. * -* @module @stdlib/fft/base/fftpack/ndarray/cosqi +* @module @stdlib/fft/base/fftpack/ndarray/generic/cosqi * * @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 cosqi = require( '@stdlib/fft/base/fftpack/ndarray/cosqi' ); +* var cosqi = require( '@stdlib/fft/base/fftpack/ndarray/generic/cosqi' ); * * var N = 8; * var len = scalar2ndarray( N, { diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/main.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/lib/main.js similarity index 95% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/main.js rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/lib/main.js index e58b2a46586e..318fd3307a26 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/lib/main.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/lib/main.js @@ -23,7 +23,7 @@ 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/cosqi' ); +var strided = require( '@stdlib/fft/base/fftpack/generic/cosqi' ); var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); @@ -40,7 +40,7 @@ var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); * - a zero-dimensional ndarray containing the length of the sequence to transform. * * @param {ArrayLikeObject} arrays - array-like object containing ndarrays -* @returns {ndarrayLike} output ndarray +* @returns {ndarrayLike} input ndarray * * @example * var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/package.json b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/package.json similarity index 95% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/package.json rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/package.json index 90c3a92d244b..9678462efe63 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/package.json +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/fft/base/fftpack/ndarray/cosqi", + "name": "@stdlib/fft/base/fftpack/ndarray/generic/cosqi", "version": "0.0.0", "description": "Initialize a workspace array for performing a quarter-wave cosine transform on a one-dimensional ndarray.", "license": "Apache-2.0", diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/test/test.js similarity index 98% rename from lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js rename to lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/test/test.js index d7d32eee87a6..f184f2e82791 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/cosqi/test/test.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/generic/cosqi/test/test.js @@ -83,7 +83,7 @@ tape( 'the function correctly initializes cosine, twiddle and integer factors in wBuf = new Float64Array( ( 3*N ) + 34 ); w = vector( wBuf, ( 3*N ) + 34, 1, 0 ); v = cosqi( [ w, len ] ); - t.strictEqual( v, w, 'returns expected workspace reference' ); + t.strictEqual( v, w, 'returns expected value' ); expectedCosines = new Float64Array( [ 0.9807852804032304, 0.9238795325112867, 0.8314696123025452, 0.7071067811865476, 0.5555702330196023, 0.38268343236508984, 0.19509032201612833, 6.123233995736766e-17 ] ); expectedTwiddles = new Float64Array( [ 0.7071067811865476, 0.7071067811865475, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -117,7 +117,7 @@ tape( 'the function correctly initializes cosine, twiddle and integer factors in t.end(); }); -tape( 'if provided an empty ndarray, the function returns the output ndarray unchanged', function test( t ) { +tape( 'if provided an empty ndarray, the function returns the input ndarray unchanged', function test( t ) { var expected; var wBuf; var len;