From 03b91668c38f119c788e8cf42d7bc027ebbff9d6 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Sun, 14 Dec 2025 22:48:26 +0530 Subject: [PATCH 1/9] feat: implement ndarray/srev package --- .../blas/ext/base/ndarray/srev/README.md | 102 ++++++++++++++ .../base/ndarray/srev/benchmark/benchmark.js | 60 ++++++++ .../blas/ext/base/ndarray/srev/docs/repl.txt | 29 ++++ .../base/ndarray/srev/docs/types/index.d.ts | 45 ++++++ .../ext/base/ndarray/srev/docs/types/test.ts | 49 +++++++ .../ext/base/ndarray/srev/examples/index.js | 34 +++++ .../blas/ext/base/ndarray/srev/lib/index.js | 45 ++++++ .../blas/ext/base/ndarray/srev/lib/main.js | 128 ++++++++++++++++++ .../blas/ext/base/ndarray/srev/package.json | 87 ++++++++++++ .../blas/ext/base/ndarray/srev/test/test.js | 90 ++++++++++++ 10 files changed, 669 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md new file mode 100644 index 000000000000..10bac0d0d202 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md @@ -0,0 +1,102 @@ + + +# srev + +> Reverse the elements of a one-dimensional single-precision floating-point ndarray. + +
+ +
+ + + +
+ +## Usage + +```javascript +var srev = require( '@stdlib/blas/ext/base/ndarray/srev' ); +``` + +#### srev( arrays ) + +Reverses the elements of a one-dimensional single-precision floating-point ndarray. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); + +var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); + +srev( [ x ] ); +// xbuf => [ 3.0, 2.0, 1.0 ] +``` + +The function accepts the following arguments: + +- **arrays**: array-like object containing one one-dimensional `Float32` ndarray. + +
+ + + +
+ +## Examples + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var srev = require( '@stdlib/blas/ext/base/ndarray/srev' ); + +var xbuf, x, i; + +xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +x = new ndarray( 'float32', xbuf, [ 6 ], [ -1 ], 5, 'row-major' ); + +srev( [ x ] ); + +console.log( 'x:' ); +for ( i = 0; i < 6; i++ ) { + console.log( x.get( i ) ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js new file mode 100644 index 000000000000..5485f7005b91 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var srev = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var len; + var buf; + var x; + var i; + + len = 100; + buf = new Float32Array( len ); + for ( i = 0; i < len; i++ ) { + buf[ i ] = uniform( -10.0, 10.0 ); + } + x = new ndarray( 'float32', buf, [ len ], [ 1 ], 0, 'row-major' ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + srev( [ x ] ); + if ( isnan( x.get( i%len ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( x.get( i%len ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt new file mode 100644 index 000000000000..68353d451c8c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt @@ -0,0 +1,29 @@ + +// Create a Float32Array: +var Float32Array = require( '@stdlib/array/float32' ); +var xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +// Define a strided array: +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var x = new ndarray( 'float32', xbuf, [ 6 ], [ -1 ], 5, 'row-major' ); + +// Import the function: +var srev = require( '@stdlib/blas/ext/base/ndarray/srev' ); + +// Reverse elements: +srev( [ x ] ); + +// Check the underlying buffer: +xbuf +// => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] + +// Check the array contents: +x.data +// => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] + +// Access elements via the ndarray instance: +x.get( 0 ) +// => 1.0 + +x.get( 5 ) +// => 6.0 diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts new file mode 100644 index 000000000000..aea1fa91c190 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts @@ -0,0 +1,45 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 } from '@stdlib/types/ndarray'; + +/** +* Reverses the elements of a one-dimensional single-precision floating-point ndarray. +* +* @param arrays - array-like object containing one input ndarray +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); +* +* srev( [ x ] ); +* // xbuf => [ 3.0, 2.0, 1.0 ] +*/ +declare function srev( arrays: ArrayLike ): void; + + +// EXPORTS // + +export = srev; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts new file mode 100644 index 000000000000..eb33b13699a1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts @@ -0,0 +1,49 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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. +*/ + +import Float32Array = require( '@stdlib/array/float32' ); +import ndarray = require( '@stdlib/ndarray/base/ctor' ); +import srev = require( './index' ); + + +// TESTS // + +// The function returns void... +{ + const xbuf = new Float32Array( 10 ); + const x = new ndarray( 'float32', xbuf, [ 10 ], [ 1 ], 0, 'row-major' ); + + srev( [ x ] ); // $ExpectType void +} + +// The compiler throws an error if the function is provided a first argument which is not an array-like object containing ndarrays... +{ + srev( 'abc' ); // $ExpectError + srev( 3.14 ); // $ExpectError + srev( true ); // $ExpectError + srev( false ); // $ExpectError + srev( null ); // $ExpectError + srev( undefined ); // $ExpectError + srev( [ '1' ] ); // $ExpectError + srev( {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an insufficient number of arguments... +{ + srev(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js new file mode 100644 index 000000000000..96f1440090d6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var srev = require( './../lib' ); + +var xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new ndarray( 'float32', xbuf, [ 6 ], [ -1 ], 5, 'row-major' ); + +console.log( 'Original:' ); +console.log( x.data ); + +srev( [ x ] ); + +console.log( 'Reversed:' ); +console.log( x.data ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js new file mode 100644 index 000000000000..b6c1abd44af8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Reverse the elements of a one-dimensional single-precision floating-point ndarray. +* +* @module @stdlib/blas/ext/base/ndarray/srev +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var srev = require( '@stdlib/blas/ext/base/ndarray/srev' ); +* +* var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); +* +* srev( [ x ] ); +* // xbuf => [ 3.0, 2.0, 1.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js new file mode 100644 index 000000000000..ead5afcd2a37 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js @@ -0,0 +1,128 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 floor = require( '@stdlib/math/base/special/floor' ); +var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); + + +// VARIABLES // + +var M = 3; + + +// MAIN // + +/** +* Reverses the elements of a one-dimensional single-precision floating-point ndarray. +* +* @param {ArrayLikeObject} arrays - array-like object containing one input ndarray +* @returns {void} +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* +* var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); +* +* srev( [ x ] ); +* // xbuf => [ 3.0, 2.0, 1.0 ] +*/ +function srev( arrays ) { + var strideX; + var offset; + var tmp; + var ix; + var iy; + var m; + var n; + var i; + var x; + var N; + var d; + + x = arrays[ 0 ]; + N = numelDimension( x, 0 ); + + if ( N <= 0 ) { + return; + } + d = getData( x ); + strideX = getStride( x, 0 ); + offset = getOffset( x ); + + n = floor( N/2 ); + ix = offset; + + // Use loop unrolling if the stride is equal to `1`... + if ( strideX === 1 ) { + m = n % M; + iy = ix + N - 1; + + // If we have a remainder, run a clean-up loop... + if ( m > 0 ) { + for ( i = 0; i < m; i++ ) { + tmp = d[ ix ]; + d[ ix ] = d[ iy ]; + d[ iy ] = tmp; + ix += strideX; + iy -= strideX; + } + } + if ( n < M ) { + return; + } + for ( i = m; i < n; i += M ) { + tmp = d[ ix ]; + d[ ix ] = d[ iy ]; + d[ iy ] = tmp; + + tmp = d[ ix+1 ]; + d[ ix+1 ] = d[ iy-1 ]; + d[ iy-1 ] = tmp; + + tmp = d[ ix+2 ]; + d[ ix+2 ] = d[ iy-2 ]; + d[ iy-2 ] = tmp; + + ix += M; + iy -= M; + } + return; + } + iy = ix + ( ( N-1 ) * strideX ); + for ( i = 0; i < n; i++ ) { + tmp = d[ ix ]; + d[ ix ] = d[ iy ]; + d[ iy ] = tmp; + ix += strideX; + iy -= strideX; + } +} + + +// EXPORTS // + +module.exports = srev; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json new file mode 100644 index 000000000000..13679bdab557 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json @@ -0,0 +1,87 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/srev", + "version": "0.0.0", + "description": "Reverse the elements of a one-dimensional single-precision floating-point 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": { + "test": "make test", + "test-cov": "make test-cov", + "examples": "make examples", + "benchmark": "make benchmark" + }, + "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": { + "@stdlib/math/base/special/floor": "^0.2.2", + "@stdlib/ndarray/base/data-buffer": "^0.2.1", + "@stdlib/ndarray/base/numel-dimension": "^0.2.1", + "@stdlib/ndarray/base/offset": "^0.2.1", + "@stdlib/ndarray/base/stride": "^0.2.1", + "@stdlib/utils/library-manifest": "^0.2.2" + }, + "devDependencies": { + "@stdlib/array/float32": "^0.2.2", + "@stdlib/ndarray/base/ctor": "^0.2.2", + "@stdlib/random/base/randu": "^0.2.1", + "tape": "git+https://github.com/kgryte/tape.git#fix/globby", + "istanbul": "^0.4.1", + "tap-min": "git+https://github.com/Planeshifter/tap-min.git", + "bench": "git+https://github.com/kgryte/bench.git" + }, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdblas", + "blas", + "ext", + "extension", + "linear", + "algebra", + "ndarray", + "array", + "reverse", + "srev", + "float32", + "float", + "single" + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js new file mode 100644 index 000000000000..1b02471c3dc4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js @@ -0,0 +1,90 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var srev = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof srev, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function reverses a strided array in-place (positive stride)', function test( t ) { + var expected; + var buf; + var x; + + buf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new ndarray( 'float32', buf, [ 6 ], [ 1 ], 0, 'row-major' ); + srev( [ x ] ); + + expected = new Float32Array( [ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + t.deepEqual( buf, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function reverses a strided array in-place (negative stride)', function test( t ) { + var expected; + var buf; + var x; + + buf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new ndarray( 'float32', buf, [ 6 ], [ -1 ], 5, 'row-major' ); + srev( [ x ] ); + + expected = new Float32Array( [ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + t.deepEqual( buf, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function reverses a strided array in-place (offset)', function test( t ) { + var expected; + var buf; + var x; + + buf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + x = new ndarray( 'float32', buf, [ 4 ], [ 1 ], 1, 'row-major' ); + srev( [ x ] ); + + expected = new Float32Array( [ 1.0, 5.0, 4.0, 3.0, 2.0, 6.0 ] ); + t.deepEqual( buf, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns undefined', function test( t ) { + var buf; + var x; + var v; + + buf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + x = new ndarray( 'float32', buf, [ 3 ], [ 1 ], 0, 'row-major' ); + v = srev( [ x ] ); + + t.strictEqual( v, undefined, 'returns undefined' ); + t.end(); +}); From 992d287e22e2434f96d58959ad6e5d45353c55bb Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Sun, 14 Dec 2025 22:59:29 +0530 Subject: [PATCH 2/9] fix: resolve CI linting errors --- .../blas/ext/base/ndarray/srev/README.md | 4 +- .../blas/ext/base/ndarray/srev/docs/repl.txt | 48 +++++++++++-------- .../blas/ext/base/ndarray/srev/package.json | 3 +- 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md index 10bac0d0d202..8aeb703b9242 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md @@ -68,7 +68,9 @@ var Float32Array = require( '@stdlib/array/float32' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var srev = require( '@stdlib/blas/ext/base/ndarray/srev' ); -var xbuf, x, i; +var xbuf; +var x; +var i; xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); x = new ndarray( 'float32', xbuf, [ 6 ], [ -1 ], 5, 'row-major' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt index 68353d451c8c..2560209aa078 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt @@ -1,29 +1,35 @@ -// Create a Float32Array: -var Float32Array = require( '@stdlib/array/float32' ); -var xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +{{alias}}( arrays ) + Reverses the elements of a one-dimensional single-precision floating-point + ndarray. -// Define a strided array: -var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var x = new ndarray( 'float32', xbuf, [ 6 ], [ -1 ], 5, 'row-major' ); -// Import the function: -var srev = require( '@stdlib/blas/ext/base/ndarray/srev' ); + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing a one-dimensional input ndarray. -// Reverse elements: -srev( [ x ] ); -// Check the underlying buffer: -xbuf -// => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] + Returns + ------- + out: void + The input ndarray is modified in-place. -// Check the array contents: -x.data -// => [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] -// Access elements via the ndarray instance: -x.get( 0 ) -// => 1.0 + Examples + -------- + > var xbuf = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); + > var dt = 'float32'; + > var sh = [ xbuf.length ]; + > var sx = [ 1 ]; + > var ox = 0; + > var ord = 'row-major'; + > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); + > {{alias}}( [ x ] ) + > xbuf + [ 3.0, 2.0, 1.0 ] + + + See Also + -------- -x.get( 5 ) -// => 6.0 diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json index 13679bdab557..860805bc776c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json @@ -41,8 +41,7 @@ "@stdlib/ndarray/base/data-buffer": "^0.2.1", "@stdlib/ndarray/base/numel-dimension": "^0.2.1", "@stdlib/ndarray/base/offset": "^0.2.1", - "@stdlib/ndarray/base/stride": "^0.2.1", - "@stdlib/utils/library-manifest": "^0.2.2" + "@stdlib/ndarray/base/stride": "^0.2.1" }, "devDependencies": { "@stdlib/array/float32": "^0.2.2", From cc12f35db4576b6f05b4451bc0d95b374c2f6fa6 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Sun, 14 Dec 2025 23:04:55 +0530 Subject: [PATCH 3/9] fix: add semicolon in repl.txt and eslint disable for tape --- .../@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/test/test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt index 2560209aa078..938e5686b066 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt @@ -25,7 +25,7 @@ > var ox = 0; > var ord = 'row-major'; > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); - > {{alias}}( [ x ] ) + > {{alias}}( [ x ] ); > xbuf [ 3.0, 2.0, 1.0 ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js index 1b02471c3dc4..b8819577955e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js @@ -20,7 +20,7 @@ // MODULES // -var tape = require( 'tape' ); +var tape = require( 'tape' ); // eslint-disable-line node/no-unpublished-require var Float32Array = require( '@stdlib/array/float32' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var srev = require( './../lib' ); From 54e9b0594c9470bdcf8cd62d3513f02a38505764 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Fri, 19 Dec 2025 18:57:44 +0530 Subject: [PATCH 4/9] docs: update return annotations to use ndarray instance notation --- lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt | 3 +-- .../@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/lib/index.js | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md index 8aeb703b9242..1ab1e7371340 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md @@ -48,7 +48,7 @@ var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); srev( [ x ] ); -// xbuf => [ 3.0, 2.0, 1.0 ] +// returns [ 3.0, 2.0, 1.0 ] ``` The function accepts the following arguments: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt index 938e5686b066..331a4051ab0c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt @@ -26,8 +26,7 @@ > var ord = 'row-major'; > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); > {{alias}}( [ x ] ); - > xbuf - [ 3.0, 2.0, 1.0 ] + [ 3.0, 2.0, 1.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts index aea1fa91c190..6b3058dee0af 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts @@ -35,7 +35,7 @@ import { ndarray } from '@stdlib/types/ndarray'; * var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); * * srev( [ x ] ); -* // xbuf => [ 3.0, 2.0, 1.0 ] +* // returns [ 3.0, 2.0, 1.0 ] */ declare function srev( arrays: ArrayLike ): void; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js index b6c1abd44af8..1ff2d7be291e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js @@ -31,8 +31,8 @@ * var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); * -* srev( [ x ] ); -* // xbuf => [ 3.0, 2.0, 1.0 ] +* var out = srev( [ x ] ); +* // returns [ 3.0, 2.0, 1.0 ] */ // MODULES // From 7fd19f5cd1cc78f58e54bfbf165625d430f4917f Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Fri, 19 Dec 2025 19:02:51 +0530 Subject: [PATCH 5/9] fix: use mutation notation for void-returning srev function --- lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt | 1 + .../@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/lib/index.js | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md index 1ab1e7371340..b5fa661af16f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md @@ -48,7 +48,7 @@ var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); srev( [ x ] ); -// returns [ 3.0, 2.0, 1.0 ] +// x => [ 3.0, 2.0, 1.0 ] ``` The function accepts the following arguments: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt index 331a4051ab0c..0e90426972b7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt @@ -26,6 +26,7 @@ > var ord = 'row-major'; > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); > {{alias}}( [ x ] ); + > x [ 3.0, 2.0, 1.0 ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts index 6b3058dee0af..730fdc20cd46 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts @@ -35,7 +35,7 @@ import { ndarray } from '@stdlib/types/ndarray'; * var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); * * srev( [ x ] ); -* // returns [ 3.0, 2.0, 1.0 ] +* // x => [ 3.0, 2.0, 1.0 ] */ declare function srev( arrays: ArrayLike ): void; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js index 1ff2d7be291e..c2f1feb8abfd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js @@ -32,7 +32,7 @@ * var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); * * var out = srev( [ x ] ); -* // returns [ 3.0, 2.0, 1.0 ] +* // x => [ 3.0, 2.0, 1.0 ] */ // MODULES // From ed070a3699b927814730e9342e93c7ee9f97f7a9 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Sun, 21 Dec 2025 17:45:55 +0530 Subject: [PATCH 6/9] fix: apply all dsorthp pattern fixes to srev --- .../blas/ext/base/ndarray/srev/README.md | 10 +- .../base/ndarray/srev/benchmark/benchmark.js | 94 ++++++++++++++----- .../blas/ext/base/ndarray/srev/docs/repl.txt | 4 +- .../base/ndarray/srev/docs/types/index.d.ts | 7 +- .../ext/base/ndarray/srev/docs/types/test.ts | 7 +- .../ext/base/ndarray/srev/examples/index.js | 17 ++-- .../blas/ext/base/ndarray/srev/lib/index.js | 2 +- .../blas/ext/base/ndarray/srev/lib/main.js | 7 +- 8 files changed, 100 insertions(+), 48 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md index b5fa661af16f..12629bff985c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md @@ -38,22 +38,26 @@ var srev = require( '@stdlib/blas/ext/base/ndarray/srev' ); #### srev( arrays ) -Reverses the elements of a one-dimensional single-precision floating-point ndarray. +Reverses the elements of a one-dimensional single-precision floating-point ndarray in-place. ```javascript var Float32Array = require( '@stdlib/array/float32' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); srev( [ x ] ); // x => [ 3.0, 2.0, 1.0 ] + +var arr = ndarray2array( x ); +// returns [ 3.0, 2.0, 1.0 ] ``` -The function accepts the following arguments: +The function has the following parameters: -- **arrays**: array-like object containing one one-dimensional `Float32` ndarray. +- **arrays**: array-like object containing a single one-dimensional input ndarray. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js index 5485f7005b91..631b1b2256e2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js @@ -21,40 +21,86 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float32Array = require( '@stdlib/array/float32' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var pow = require( '@stdlib/math/base/special/pow' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var uniform = require( '@stdlib/random/base/uniform' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var srev = require( './../lib' ); -// MAIN // +// VARIABLES // -bench( pkg, function benchmark( b ) { - var len; - var buf; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var xbuf; var x; - var i; - len = 100; - buf = new Float32Array( len ); - for ( i = 0; i < len; i++ ) { - buf[ i ] = uniform( -10.0, 10.0 ); - } - x = new ndarray( 'float32', buf, [ len ], [ 1 ], 0, 'row-major' ); + xbuf = uniform( len, -10.0, 10.0, options ); + x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' ); - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - srev( [ x ] ); - if ( isnan( x.get( i%len ) ) ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + srev( [ x ] ); + if ( xbuf[ 0 ] !== xbuf[ 0 ] ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( xbuf[ 0 ] !== xbuf[ 0 ] ) { b.fail( 'should not return NaN' ); } + b.pass( 'benchmark finished' ); + b.end(); } - b.toc(); - if ( isnan( x.get( i%len ) ) ) { - b.fail( 'should not return NaN' ); +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); } - b.pass( 'benchmark finished' ); - b.end(); -}); +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt index 0e90426972b7..16772a97c4de 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/repl.txt @@ -26,8 +26,8 @@ > var ord = 'row-major'; > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, sx, ox, ord ); > {{alias}}( [ x ] ); - > x - [ 3.0, 2.0, 1.0 ] + > var data = x.data + [ 3.0, 2.0, 1.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts index 730fdc20cd46..e37269308d6a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts @@ -25,17 +25,20 @@ import { ndarray } from '@stdlib/types/ndarray'; /** * Reverses the elements of a one-dimensional single-precision floating-point ndarray. * -* @param arrays - array-like object containing one input ndarray +* @param arrays - array-like object containing a single one-dimensional input ndarray * * @example * var Float32Array = require( '@stdlib/array/float32' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * * var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); * * srev( [ x ] ); -* // x => [ 3.0, 2.0, 1.0 ] +* +* var arr = ndarray2array( x ); +* // returns [ 3.0, 2.0, 1.0 ] */ declare function srev( arrays: ArrayLike ): void; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts index eb33b13699a1..cdbdf2605451 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts @@ -16,8 +16,7 @@ * limitations under the License. */ -import Float32Array = require( '@stdlib/array/float32' ); -import ndarray = require( '@stdlib/ndarray/base/ctor' ); +import zeros = require( '@stdlib/ndarray/base/zeros' ); import srev = require( './index' ); @@ -25,9 +24,7 @@ import srev = require( './index' ); // The function returns void... { - const xbuf = new Float32Array( 10 ); - const x = new ndarray( 'float32', xbuf, [ 10 ], [ 1 ], 0, 'row-major' ); - + const x = zeros( 'float32', [ 10 ], 'row-major' ); srev( [ x ] ); // $ExpectType void } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js index 96f1440090d6..37974d991eb3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js @@ -18,17 +18,16 @@ 'use strict'; -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); var srev = require( './../lib' ); -var xbuf = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -var x = new ndarray( 'float32', xbuf, [ 6 ], [ -1 ], 5, 'row-major' ); - -console.log( 'Original:' ); -console.log( x.data ); +var xbuf = discreteUniform( 10, -50, 50, { + 'dtype': 'float32' +}); +var x = new ndarray( 'float32', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); srev( [ x ] ); - -console.log( 'Reversed:' ); -console.log( x.data ); +console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js index c2f1feb8abfd..478e3232aec1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js @@ -31,7 +31,7 @@ * var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); * -* var out = srev( [ x ] ); +* srev( [ x ] ); * // x => [ 3.0, 2.0, 1.0 ] */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js index ead5afcd2a37..51933019b1c3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js @@ -37,18 +37,21 @@ var M = 3; /** * Reverses the elements of a one-dimensional single-precision floating-point ndarray. * -* @param {ArrayLikeObject} arrays - array-like object containing one input ndarray +* @param {ArrayLikeObject} arrays - array-like object containing a single one-dimensional input ndarray * @returns {void} * * @example * var Float32Array = require( '@stdlib/array/float32' ); +* var ndarray2array = require( '@stdlib/ndarray/to-array' ); * var ndarray = require( '@stdlib/ndarray/base/ctor' ); * * var xbuf = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * var x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 0, 'row-major' ); * * srev( [ x ] ); -* // xbuf => [ 3.0, 2.0, 1.0 ] +* +* var arr = ndarray2array( x ); +* // returns [ 3.0, 2.0, 1.0 ] */ function srev( arrays ) { var strideX; From c94548aea31e6b00fb4a068bba9d3a971500b67a Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Mon, 22 Dec 2025 07:53:07 +0530 Subject: [PATCH 7/9] fix: srev benchmark - use @stdlib/string/format per RFC #8647 --- .../@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js index 631b1b2256e2..0a1f11b99a24 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js @@ -24,6 +24,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); var pow = require( '@stdlib/math/base/special/pow' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var srev = require( './../lib' ); @@ -99,7 +100,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( pkg+':len='+len, f ); + bench( format( '%s:len=%d', pkg, len ), f ); } } From 4758f53612bc5f13919583b876da83a9278b35d4 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Sun, 11 Jan 2026 10:55:33 +0530 Subject: [PATCH 8/9] fix package.json file and test.j --- .../blas/ext/base/ndarray/srev/package.json | 28 ++++--------------- .../blas/ext/base/ndarray/srev/test/test.js | 2 +- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json index 860805bc776c..e9d3a77e359f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/package.json @@ -22,12 +22,7 @@ "test": "./test" }, "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "scripts": {}, "homepage": "https://github.com/stdlib-js/stdlib", "repository": { "type": "git", @@ -36,22 +31,8 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/math/base/special/floor": "^0.2.2", - "@stdlib/ndarray/base/data-buffer": "^0.2.1", - "@stdlib/ndarray/base/numel-dimension": "^0.2.1", - "@stdlib/ndarray/base/offset": "^0.2.1", - "@stdlib/ndarray/base/stride": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array/float32": "^0.2.2", - "@stdlib/ndarray/base/ctor": "^0.2.2", - "@stdlib/random/base/randu": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "bench": "git+https://github.com/kgryte/bench.git" - }, + "dependencies": {}, + "devDependencies": {}, "engines": { "node": ">=0.10.0", "npm": ">2.7.0" @@ -82,5 +63,6 @@ "float32", "float", "single" - ] + ], + "__stdlib__": {} } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js index b8819577955e..1b02471c3dc4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js @@ -20,7 +20,7 @@ // MODULES // -var tape = require( 'tape' ); // eslint-disable-line node/no-unpublished-require +var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var srev = require( './../lib' ); From 6d6486fc846b8773cfd0a12df5f57985d531d226 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sun, 11 Jan 2026 05:35:58 +0000 Subject: [PATCH 9/9] chore: update copyright years --- lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/examples/index.js | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js | 2 +- .../@stdlib/blas/ext/base/ndarray/srev/test/test.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md index 12629bff985c..72aad260fc39 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js index 0a1f11b99a24..2e2984b9f186 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts index e37269308d6a..53b31344b2f6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts index cdbdf2605451..e10b152aa525 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js index 37974d991eb3..e9483fb008a8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js index 478e3232aec1..59308dc69836 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js index 51933019b1c3..c45a36f35a3d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js index 1b02471c3dc4..49e111a97a11 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/srev/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* 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.