From 030a34ab25db2d8d976e2a9f88780fb4da031d77 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Sat, 18 Jul 2026 07:16:08 +0530 Subject: [PATCH 1/4] feat: add initial implementation --- 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: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_license_headers status: passed --- --- .../base/fftpack/ndarray/rffti/lib/main.js | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/main.js diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/main.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/main.js new file mode 100644 index 000000000000..48ccc00789fe --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/main.js @@ -0,0 +1,85 @@ +/** +* @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/rffti' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); + + +// MAIN // + +/** +* Initializes a workspace array for performing a real-valued Fourier transform on a one-dimensional ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a zero-dimensional ndarray containing the length of the sequence to transform. +* - a one-dimensional input ndarray. +* +* @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 ndarray2array = require( '@stdlib/ndarray/to-array' ); +* +* var N = 8; +* var len = scalar2ndarray( N, { +* 'dtype': 'int32' +* }); +* +* var workspace = new Float64Vector( ( 2*N ) + 34 ); +* +* var out = rffti( [ len, workspace ] ); +* // returns +* +* var bool = ( out === workspace ); +* // returns true +* +* var workspaceArr = ndarray2array( workspace ); +* // returns +* +* var twiddleFactors = workspaceArr.slice( N, 2*N ); +* // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] +* +* var factors = workspaceArr.slice( 2*N, ( 2*N ) + 4 ); +* // returns [ 8, 2, 2, 4 ] +*/ +function rffti( arrays ) { + var workspace; + var N; + + N = ndarraylike2scalar( arrays[ 0 ] ); + workspace = arrays[ 1 ]; + strided( N, getData( workspace ), getStride( workspace, 0 ), getOffset( workspace ) ); // eslint-disable-line max-len + return workspace; +} + + +// EXPORTS // + +module.exports = rffti; From 60f690c5755a14b278818a533d680d93ce9e3251 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Sat, 18 Jul 2026 07:55:54 +0530 Subject: [PATCH 2/4] refactor: use ndarray/slice --- 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: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_license_headers status: passed --- --- .../fft/base/fftpack/ndarray/rffti/lib/main.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/main.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/main.js index 48ccc00789fe..43a4aabdc8a4 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/main.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/main.js @@ -45,7 +45,8 @@ var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); * @example * var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); * var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); -* var ndarray2array = require( '@stdlib/ndarray/to-array' ); +* var Slice = require( '@stdlib/slice/ctor' ); +* var slice = require( '@stdlib/ndarray/slice' ); * * var N = 8; * var len = scalar2ndarray( N, { @@ -60,14 +61,11 @@ var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); * var bool = ( out === workspace ); * // returns true * -* var workspaceArr = ndarray2array( workspace ); -* // returns +* var twiddleFactors = slice( workspace, new Slice( N, 2*N ) ); +* // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] * -* var twiddleFactors = workspaceArr.slice( N, 2*N ); -* // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] -* -* var factors = workspaceArr.slice( 2*N, ( 2*N ) + 4 ); -* // returns [ 8, 2, 2, 4 ] +* var factors = slice( workspace, new Slice( 2*N, ( 2*N ) + 4 ) ); +* // returns [ 8, 2, 2, 4 ] */ function rffti( arrays ) { var workspace; From a56e1f1da7afdf83c38e63a35e49459311d6c797 Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 21 Jul 2026 02:14:48 +0530 Subject: [PATCH 3/4] feat: add fft/base/fftpack/ndarray/rffti --- 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/rffti/README.md | 135 +++++++++ .../ndarray/rffti/benchmark/benchmark.js | 112 ++++++++ .../base/fftpack/ndarray/rffti/docs/repl.txt | 39 +++ .../ndarray/rffti/docs/types/index.d.ts | 68 +++++ .../fftpack/ndarray/rffti/docs/types/test.ts | 63 +++++ .../fftpack/ndarray/rffti/examples/index.js | 38 +++ .../base/fftpack/ndarray/rffti/lib/index.js | 60 ++++ .../base/fftpack/ndarray/rffti/package.json | 65 +++++ .../base/fftpack/ndarray/rffti/test/test.js | 256 ++++++++++++++++++ 9 files changed, 836 insertions(+) create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/README.md create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/examples/index.js create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/index.js create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/package.json create mode 100644 lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/test/test.js diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/README.md b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/README.md new file mode 100644 index 000000000000..7394e894e078 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/README.md @@ -0,0 +1,135 @@ + + +# rffti + +> Initialize a workspace array for performing a real-valued Fourier transform on a one-dimensional ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var rffti = require( '@stdlib/fft/base/fftpack/ndarray/rffti' ); +``` + +#### rffti( arrays ) + +Initializes a workspace array for performing a real-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( ( 2*N ) + 34 ); + +var out = rffti( [ len, workspace ] ); +// returns + +var bool = ( out === workspace ); +// returns true + +var twiddleFactors = slice( workspace, new Slice( N, 2*N ) ); +// returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] + +var factors = slice( workspace, new Slice( 2*N, ( 2*N ) + 4 ) ); +// returns [ 8, 2, 2, 4 ] +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays: + + - a zero-dimensional ndarray containing the length of the sequence to transform. + - a one-dimensional input ndarray. + +
+ + + +
+ +## 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 rffti = require( '@stdlib/fft/base/fftpack/ndarray/rffti' ); + +var opts = { + 'dtype': 'int32' +}; + +var N = 8; + +var workspace = new Float64Vector( ( 2*N ) + 34 ); +console.log( ndarray2array( workspace ) ); + +var len = scalar2ndarray( N, opts ); + +var out = rffti( [ len, workspace ] ); +console.log( ndarray2array( out ) ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js new file mode 100644 index 000000000000..189ebcffa1e5 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js @@ -0,0 +1,112 @@ +/** +* @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 rffti = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - sequence length +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var workspace = new Float64Vector( ( 2*N ) + 34 ); + var len = scalar2ndarray( N, 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 = rffti( [ len, workspace ] ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( v.get( 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/rffti/docs/repl.txt b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/repl.txt new file mode 100644 index 000000000000..dccdff0f39cd --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/repl.txt @@ -0,0 +1,39 @@ + +{{alias}}( arrays ) + Initializes a workspace array for performing a real-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 zero-dimensional ndarray containing the length of the sequence to + transform. + - a one-dimensional input ndarray. + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + > var N = 8; + > var workspace = new {{alias:@stdlib/ndarray/vector/float64}}( ( 2*N ) + 34 ); + > var len = {{alias:@stdlib/ndarray/from-scalar}}( N, { 'dtype': 'int32' }); + > var out = {{alias}}( [ len, workspace ] ) + + > var bool = ( out === workspace ) + true + > var twiddleFactors = {{alias:@stdlib/ndarray/slice}}( workspace, new {{alias:@stdlib/slice/ctor}}( N, 2*N ) ) + [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] + > var factors = {{alias:@stdlib/ndarray/slice}}( workspace, new {{alias:@stdlib/slice/ctor}}( 2*N, ( 2*N ) + 4 ) ) + [ 8, 2, 2, 4 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/types/index.d.ts b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/types/index.d.ts new file mode 100644 index 000000000000..6b827dfea080 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/types/index.d.ts @@ -0,0 +1,68 @@ +/* +* @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 { ndarray, float64ndarray } from '@stdlib/types/ndarray'; + +/** +* Initializes a workspace array for performing a real-valued Fourier transform on a one-dimensional ndarray. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a zero-dimensional ndarray containing the length of the sequence to transform. +* - a one-dimensional input ndarray. +* +* @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( ( 2*N ) + 34 ); +* +* var out = rffti( [ len, workspace ] ); +* // returns +* +* var bool = ( out === workspace ); +* // returns true +* +* var twiddleFactors = slice( workspace, new Slice( N, 2*N ) ); +* // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] +* +* var factors = slice( workspace, new Slice( 2*N, ( 2*N ) + 4 ) ); +* // returns [ 8, 2, 2, 4 ] +*/ +declare function rffti( arrays: [ ndarray, float64ndarray ] ): float64ndarray; + + +// EXPORTS // + +export = rffti; diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/types/test.ts b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/docs/types/test.ts new file mode 100644 index 000000000000..cb5cba80f1b3 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/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 rffti = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const workspace = zeros( [ 10 ], { + 'dtype': 'float64' + }); + const N = zeros( [], { + 'dtype': 'int32' + }); + + rffti( [ N, workspace ] ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + rffti( '10' ); // $ExpectError + rffti( 10 ); // $ExpectError + rffti( true ); // $ExpectError + rffti( false ); // $ExpectError + rffti( null ); // $ExpectError + rffti( undefined ); // $ExpectError + rffti( [] ); // $ExpectError + rffti( {} ); // $ExpectError + rffti( ( 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' + }); + + rffti(); // $ExpectError + rffti( [ N, workspace ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/examples/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/examples/index.js new file mode 100644 index 000000000000..04270542fb5f --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/examples/index.js @@ -0,0 +1,38 @@ +/** +* @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 rffti = require( './../lib' ); + +var opts = { + 'dtype': 'int32' +}; + +var N = 8; + +var workspace = new Float64Vector( ( 2*N ) + 34 ); +console.log( ndarray2array( workspace ) ); + +var len = scalar2ndarray( N, opts ); + +var out = rffti( [ len, workspace ] ); +console.log( ndarray2array( out ) ); diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/index.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/lib/index.js new file mode 100644 index 000000000000..a211755d6c5c --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/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 real-valued Fourier transform on a one-dimensional ndarray. +* +* @module @stdlib/fft/base/fftpack/ndarray/rffti +* +* @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 rffti = require( '@stdlib/fft/base/fftpack/ndarray/rffti' ); +* +* var N = 8; +* var len = scalar2ndarray( N, { +* 'dtype': 'int32' +* }); +* +* var workspace = new Float64Vector( ( 2*N ) + 34 ); +* +* var out = rffti( [ len, workspace ] ); +* // returns +* +* var bool = ( out === workspace ); +* // returns true +* +* var twiddleFactors = slice( workspace, new Slice( N, 2*N ) ); +* // returns [ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ] +* +* var factors = slice( workspace, new Slice( 2*N, ( 2*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/rffti/package.json b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/package.json new file mode 100644 index 000000000000..4a473186e063 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/fft/base/fftpack/ndarray/rffti", + "version": "0.0.0", + "description": "Initialize a workspace array for performing a real-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", + "rffti", + "fourier", + "transform", + "twiddle", + "workspace", + "initialization", + "real", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/test/test.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/test/test.js new file mode 100644 index 000000000000..0a743d847968 --- /dev/null +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/test/test.js @@ -0,0 +1,256 @@ +/** +* @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 rffti = 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 rffti, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( rffti.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( ( 2 * N ) + 34 ); + workspace = vector( workspaceBuf, ( 2 * N ) + 34, 1, 0 ); + v = rffti( [ len, workspace ] ); + t.strictEqual( v, workspace, 'returns expected workspace reference' ); + + 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 < expectedTwiddles.length; i++ ) { + y = workspaceBuf[ 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[ ( 2 * N ) + i ]; + e = expectedFactors[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + 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 = rffti( [ len, workspace ] ); + + 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( ( 4 * N ) + 68 ); + workspace = vector( workspaceBuf, ( 2 * N ) + 34, 2, 0 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = rffti( [ len, workspace ] ); + + 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, workspace, 'returns expected value' ); + + ulps = 1; + for ( i = 0; i < expectedTwiddles.length; i++ ) { + y = workspaceBuf[ ( 2 * 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[ ( 4 * N ) + ( 2 * i ) ]; + e = expectedFactors[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + 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( ( 2 * N ) + 34 ); + workspace = vector( workspaceBuf, ( 2 * N ) + 34, -1, ( 2 * N ) + 33 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = rffti( [ len, workspace ] ); + t.strictEqual( v, workspace, 'returns expected value' ); + + 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 < expectedTwiddles.length; i++ ) { + y = workspaceBuf[ 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 ); + } + + 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( ( 2 * N ) + 34 + 2 ); + workspace = vector( workspaceBuf, ( 2 * N ) + 34, 1, 2 ); + len = scalar2ndarray( N, { + 'dtype': 'int32' + }); + + v = rffti( [ len, workspace ] ); + + t.strictEqual( v, workspace, 'returns expected value' ); + + 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 < expectedTwiddles.length; i++ ) { + y = workspaceBuf[ 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[ ( 2 * N ) + i + 2 ]; + e = expectedFactors[ i ]; + t.strictEqual( isAlmostSameValue( y, e, ulps ), true, 'within ' + ulps + ' ULPs. N: ' + N + '. y: ' + y + '. E: ' + e ); + } + + t.end(); +}); From 77183d917a7fc3a01da2b76a4a5dc4cede73019e Mon Sep 17 00:00:00 2001 From: Gunj Joshi Date: Tue, 21 Jul 2026 02:39:18 +0530 Subject: [PATCH 4/4] bench: use int32 --- 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: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - 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: na - task: lint_license_headers status: passed --- --- .../fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js index 189ebcffa1e5..de088b0d6d40 100644 --- a/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/fft/base/fftpack/ndarray/rffti/benchmark/benchmark.js @@ -32,7 +32,7 @@ var rffti = require( './../lib' ); // VARIABLES // var options = { - 'dtype': 'float64' + 'dtype': 'int32' };