From 681af6b77f6d3cb59f8a9d1564652d5c250f1c94 Mon Sep 17 00:00:00 2001 From: Aryan Sharma Date: Thu, 20 Aug 2026 01:53:29 +0530 Subject: [PATCH 1/8] feat: add C implementation for blas/ext/base/ndarray/sfill Signed-off-by: Aryan Sharma --- .../blas/ext/base/ndarray/sfill/README.md | 106 +++++++++ .../base/ndarray/sfill/benchmark/benchmark.js | 112 ++++++++++ .../base/ndarray/sfill/docs/types/index.d.ts | 57 +++++ .../ext/base/ndarray/sfill/docs/types/test.ts | 62 ++++++ .../ext/base/ndarray/sfill/examples/index.js | 35 +++ .../blas/ext/base/ndarray/sfill/lib/index.js | 66 ++++++ .../blas/ext/base/ndarray/sfill/lib/main.js | 76 +++++++ .../blas/ext/base/ndarray/sfill/package.json | 78 +++++++ .../blas/ext/base/ndarray/sfill/test/test.js | 77 +++++++ .../ext/base/ndarray/sfill/test/test.main.js | 205 ++++++++++++++++++ 10 files changed, 874 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/README.md new file mode 100644 index 000000000000..b0df2ace0b3a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/README.md @@ -0,0 +1,106 @@ + + +# sfill + +> Fill a single-precision floating-point ndarray with a specified scalar constant. + +
+ +## Usage + +```javascript +var sfill = require( '@stdlib/blas/ext/base/ndarray/sfill' ); +``` + +#### sfill( arrays ) + +Fills a single-precision floating-point ndarray with a specified scalar constant. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); + +var x = ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), [ 4 ], [ 1 ], 0, 'row-major' ); + +var alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' +}); + +var out = sfill( [ x, alpha ] ); +// returns + +var data = out.data; +// returns [ 5.0, 5.0, 5.0, 5.0 ] +``` + +The function accepts an array-like object containing one-dimensional `ndarrays`. + +- **x**: an input/output `ndarray` having type `float32`. +- **alpha**: a zero-dimensional `ndarray` containing the scalar constant to fill with. + +
+ + + +
+ +## Examples + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var sfill = require( '@stdlib/blas/ext/base/ndarray/sfill' ); + +var x = ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), [ 4 ], [ 1 ], 0, 'row-major' ); + +var alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' +}); + +var out = sfill( [ x, alpha ] ); + +console.log( out.data ); +// => [ 5.0, 5.0, 5.0, 5.0 ] +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js new file mode 100644 index 000000000000..8d59060ba918 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/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 uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var pkg = require( './../package.json' ).name; +var sfill = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Create a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10.0, 10.0, options ); + var buf = new Float32Array( x ); + var alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + var xNdarray = new ndarray( 'float32', buf, [ len ], [ 1 ], 0, 'row-major' ); + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = sfill( [ xNdarray, alpha ] ); + if ( isnanf( out.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( out.data[ i%len ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// 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( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/index.d.ts new file mode 100644 index 000000000000..db209cd19baa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/index.d.ts @@ -0,0 +1,57 @@ +/* +* @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 { float32ndarray, typedndarray } from '@stdlib/types/ndarray'; + +/** +* Fills a single-precision floating-point ndarray with a specified scalar constant. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input/output ndarray. +* - a zero-dimensional ndarray containing the scalar constant to fill with. +* +* @param arrays - array-like object containing ndarrays +* @returns input/output ndarray +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'float32' +* }); +* +* var out = sfill( [ x, alpha ] ); +* // returns +*/ +declare function sfill( arrays: [ float32ndarray, typedndarray ] ): float32ndarray; + + +// EXPORTS // + +export = sfill; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts new file mode 100644 index 000000000000..0c1555a39868 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts @@ -0,0 +1,62 @@ +/* +* @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. +*/ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +import sfill = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float32' + }); + const alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + + sfill( [ x, alpha ] ); // $ExpectType float32ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + sfill( '10' ); // $ExpectError + sfill( 10 ); // $ExpectError + sfill( true ); // $ExpectError + sfill( false ); // $ExpectError + sfill( null ); // $ExpectError + sfill( undefined ); // $ExpectError + sfill( [] ); // $ExpectError + sfill( {} ); // $ExpectError + sfill( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float32' + }); + const alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + + sfill(); // $ExpectError + sfill( [ x, alpha ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/examples/index.js new file mode 100644 index 000000000000..ac9a48e0f0f7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/examples/index.js @@ -0,0 +1,35 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var sfill = require( './../lib' ); + +var x = ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), [ 4 ], [ 1 ], 0, 'row-major' ); + +var alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' +}); + +var out = sfill( [ x, alpha ] ); + +console.log( out.data ); +// => [ 5.0, 5.0, 5.0, 5.0 ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js new file mode 100644 index 000000000000..37ba0914ecdd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js @@ -0,0 +1,66 @@ +/** +* @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'; + +/** +* Fills a single-precision floating-point ndarray with a specified scalar constant. +* +* @module @stdlib/blas/ext/base/ndarray/sfill +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var sfill = require( '@stdlib/blas/ext/base/ndarray/sfill' ); +* +* var x = ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'float32' +* }); +* +* var out = sfill( [ x, alpha ] ); +* // returns +* +* var data = out.data; +* // returns [ 5.0, 5.0, 5.0, 5.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var sfill; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + sfill = main; +} else { + sfill = tmp; +} + + +// EXPORTS // + +module.exports = sfill; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/main.js new file mode 100644 index 000000000000..84ddc1890011 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/main.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +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' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var strided = require( '@stdlib/blas/ext/base/sfill' ).ndarray; + + +// MAIN // + +/** +* Fills a single-precision floating-point ndarray with a specified scalar constant. +* +* ## Notes +* +* - The function expects the following ndarrays: +* +* - a one-dimensional input/output ndarray. +* - a zero-dimensional ndarray containing the scalar constant to fill with. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {ndarray} input/output ndarray +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ndarray = require( '@stdlib/ndarray/base/ctor' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* +* var x = ndarray( 'float32', new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ), [ 4 ], [ 1 ], 0, 'row-major' ); +* +* var alpha = scalar2ndarray( 5.0, { +* 'dtype': 'float32' +* }); +* +* var out = sfill( [ x, alpha ] ); +* // returns +* +* var data = out.data; +* // returns [ 5.0, 5.0, 5.0, 5.0 ] +*/ +function sfill( arrays ) { + var alpha; + var x; + + x = arrays[ 0 ]; + alpha = ndarraylike2scalar( arrays[ 1 ] ); + strided( numelDimension( x, 0 ), alpha, getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len + return x; +} + + +// EXPORTS // + +module.exports = sfill; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/package.json b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/package.json new file mode 100644 index 000000000000..a8ca87b17f48 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/package.json @@ -0,0 +1,78 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/sfill", + "version": "0.0.0", + "description": "Fill a single-precision floating-point strided array with a specified scalar constant.", + "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", + "browser": "./lib/main.js", + "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": { + "@stdlib/blas/ext/base/sfill": "^0.0.x", + "@stdlib/utils/define-read-only-property": "^0.0.x" + }, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "fill", + "assign", + "set", + "equal", + "copy", + "broadcast", + "constant", + "strided", + "array", + "ndarray", + "float32", + "float", + "single", + "float32array" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js new file mode 100644 index 000000000000..600f8f6f08c2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js @@ -0,0 +1,77 @@ +/** +* @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 tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var sfill = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sfill, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var sfill = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sfill, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var sfill; + var main; + + main = require( './../lib/main.js' ); + + sfill = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sfill, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js new file mode 100644 index 000000000000..4078660c9e43 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js @@ -0,0 +1,205 @@ +/** +* @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 tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var sfill = require( './../lib/main.js' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Float32Array} 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( 'float32', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sfill, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( sfill.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function fills a one-dimensional ndarray with a scalar constant', function test( t ) { + var alpha; + var x; + var v; + + x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + + v = sfill( [ vector( x, 6, 1, 0 ), alpha ] ); + t.strictEqual( v.data, x, 'returns expected value' ); + t.strictEqual( x[ 0 ], 5.0, 'returns expected value' ); + t.strictEqual( x[ 1 ], 5.0, 'returns expected value' ); + t.strictEqual( x[ 5 ], 5.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an empty ndarray, the function returns the ndarray unchanged', function test( t ) { + var alpha; + var x; + var v; + + x = new Float32Array( [] ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + + v = sfill( [ vector( x, 0, 1, 0 ), alpha ] ); + t.strictEqual( v.data, x, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { + var expected; + var alpha; + var x; + var v; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + expected = new Float32Array([ + 5.0, // 0 + 2.0, + 5.0, // 1 + -7.0, + 5.0, // 2 + 3.0, + 5.0, // 3 + 2.0 + ]); + + v = sfill( [ vector( x, 4, 2, 0 ), alpha ] ); + + t.strictEqual( v.data, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { + var expected; + var alpha; + var x; + var v; + + x = new Float32Array([ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + expected = new Float32Array([ + 5.0, // 3 + 2.0, + 5.0, // 2 + -7.0, + 5.0, // 1 + 3.0, + 5.0, // 0 + 2.0 + ]); + + v = sfill( [ vector( x, 4, -2, 6 ), alpha ] ); + + t.strictEqual( v.data, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { + var expected; + var alpha; + var x; + var v; + + x = new Float32Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ]); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + expected = new Float32Array([ + 2.0, + 5.0, // 0 + 2.0, + 5.0, // 1 + -2.0, + 5.0, // 2 + 3.0, + 5.0 // 3 + ]); + + v = sfill( [ vector( x, 4, 2, 1 ), alpha ] ); + + t.strictEqual( v.data, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + + t.end(); +}); From 6dfb3004bbef7ca0791800543da8e7ecbbfd1626 Mon Sep 17 00:00:00 2001 From: Aryan Sharma Date: Thu, 20 Aug 2026 02:13:30 +0530 Subject: [PATCH 2/8] style: fix linting and validation issues in sfill Signed-off-by: Aryan Sharma --- .../@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts | 2 ++ .../@stdlib/blas/ext/base/ndarray/sfill/lib/index.js | 2 +- .../@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts index 0c1555a39868..0690207c6731 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable space-in-parens */ + import zeros = require( '@stdlib/ndarray/zeros' ); import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); import sfill = require( './index' ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js index 37ba0914ecdd..c5da628c599b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Fills a single-precision floating-point ndarray with a specified scalar constant. +* Fill a single-precision floating-point ndarray with a specified scalar constant. * * @module @stdlib/blas/ext/base/ndarray/sfill * diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js index 4078660c9e43..5c647e9af5c2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js @@ -66,7 +66,7 @@ tape( 'the function fills a one-dimensional ndarray with a scalar constant', fun alpha = scalar2ndarray( 5.0, { 'dtype': 'float32' }); - + v = sfill( [ vector( x, 6, 1, 0 ), alpha ] ); t.strictEqual( v.data, x, 'returns expected value' ); t.strictEqual( x[ 0 ], 5.0, 'returns expected value' ); @@ -197,7 +197,7 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets', ]); v = sfill( [ vector( x, 4, 2, 1 ), alpha ] ); - + t.strictEqual( v.data, x, 'returns expected value' ); t.deepEqual( x, expected, 'returns expected value' ); From a4f13e17e3d8f0f9449027d16cc09edef3a9b31c Mon Sep 17 00:00:00 2001 From: Aryan Sharma Date: Thu, 20 Aug 2026 02:28:38 +0530 Subject: [PATCH 3/8] style: fix variable declaration order in sfill benchmark Signed-off-by: Aryan Sharma --- .../ext/base/ndarray/sfill/benchmark/benchmark.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js index 8d59060ba918..fb4aad87fca0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js @@ -49,12 +49,17 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = uniform( len, -10.0, 10.0, options ); - var buf = new Float32Array( x ); - var alpha = scalar2ndarray( 5.0, { + var xNdarray; + var alpha; + var buf; + var x; + + x = uniform( len, -10.0, 10.0, options ); + buf = new Float32Array( x ); + alpha = scalar2ndarray( 5.0, { 'dtype': 'float32' }); - var xNdarray = new ndarray( 'float32', buf, [ len ], [ 1 ], 0, 'row-major' ); + xNdarray = new ndarray( 'float32', buf, [ len ], [ 1 ], 0, 'row-major' ); return benchmark; From 15562183bd9edec66044b3bbe519573fc7c119d3 Mon Sep 17 00:00:00 2001 From: Aryan Sharma Date: Fri, 21 Aug 2026 02:52:03 +0530 Subject: [PATCH 4/8] test: consolidate tests and remove native fallback tests in sfill Signed-off-by: Aryan Sharma --- .../blas/ext/base/ndarray/sfill/test/test.js | 181 +++++++++++++--- .../ext/base/ndarray/sfill/test/test.main.js | 205 ------------------ 2 files changed, 154 insertions(+), 232 deletions(-) delete mode 100644 lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js index 600f8f6f08c2..94d12e398132 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js @@ -21,16 +21,27 @@ // MODULES // var tape = require( 'tape' ); -var proxyquire = require( 'proxyquire' ); -var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var sfill = require( './../lib' ); -// VARIABLES // +// FUNCTIONS // -var opts = { - 'skip': IS_BROWSER -}; +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Float32Array} 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( 'float32', buffer, [ length ], [ stride ], offset, 'row-major' ); +} // TESTS // @@ -41,37 +52,153 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { - var sfill = proxyquire( './../lib', { - '@stdlib/utils/try-require': tryRequire +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( sfill.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function fills a one-dimensional ndarray with a scalar constant', function test( t ) { + var alpha; + var x; + var v; + + x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' }); - t.strictEqual( sfill, mock, 'returns expected value' ); + v = sfill( [ vector( x, 6, 1, 0 ), alpha ] ); + t.strictEqual( v.data, x, 'returns expected value' ); + t.strictEqual( x[ 0 ], 5.0, 'returns expected value' ); + t.strictEqual( x[ 1 ], 5.0, 'returns expected value' ); + t.strictEqual( x[ 5 ], 5.0, 'returns expected value' ); + t.end(); +}); - function tryRequire() { - return mock; - } +tape( 'if provided an empty ndarray, the function returns the ndarray unchanged', function test( t ) { + var alpha; + var x; + var v; - function mock() { - // Mock... - } -}); + x = new Float32Array( [] ); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); -tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { - var sfill; - var main; + v = sfill( [ vector( x, 0, 1, 0 ), alpha ] ); + t.strictEqual( v.data, x, 'returns expected value' ); - main = require( './../lib/main.js' ); + t.end(); +}); - sfill = proxyquire( './../lib', { - '@stdlib/utils/try-require': tryRequire +tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { + var expected; + var alpha; + var x; + var v; + + x = new Float32Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' }); + expected = new Float32Array([ + 5.0, // 0 + 2.0, + 5.0, // 1 + -7.0, + 5.0, // 2 + 3.0, + 5.0, // 3 + 2.0 + ]); + + v = sfill( [ vector( x, 4, 2, 0 ), alpha ] ); + + t.strictEqual( v.data, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); +}); - t.strictEqual( sfill, main, 'returns expected value' ); +tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { + var expected; + var alpha; + var x; + var v; + + x = new Float32Array([ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + expected = new Float32Array([ + 5.0, // 3 + 2.0, + 5.0, // 2 + -7.0, + 5.0, // 1 + 3.0, + 5.0, // 0 + 2.0 + ]); + + v = sfill( [ vector( x, 4, -2, 6 ), alpha ] ); + + t.strictEqual( v.data, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); t.end(); +}); - function tryRequire() { - return new Error( 'Cannot find module' ); - } +tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { + var expected; + var alpha; + var x; + var v; + + x = new Float32Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ]); + alpha = scalar2ndarray( 5.0, { + 'dtype': 'float32' + }); + expected = new Float32Array([ + 2.0, + 5.0, // 0 + 2.0, + 5.0, // 1 + -2.0, + 5.0, // 2 + 3.0, + 5.0 // 3 + ]); + + v = sfill( [ vector( x, 4, 2, 1 ), alpha ] ); + + t.strictEqual( v.data, x, 'returns expected value' ); + t.deepEqual( x, expected, 'returns expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js deleted file mode 100644 index 5c647e9af5c2..000000000000 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.main.js +++ /dev/null @@ -1,205 +0,0 @@ -/** -* @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 tape = require( 'tape' ); -var Float32Array = require( '@stdlib/array/float32' ); -var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); -var sfill = require( './../lib/main.js' ); - - -// FUNCTIONS // - -/** -* Returns a one-dimensional ndarray. -* -* @private -* @param {Float32Array} 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( 'float32', buffer, [ length ], [ stride ], offset, 'row-major' ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof sfill, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function has an arity of 1', function test( t ) { - t.strictEqual( sfill.length, 1, 'has expected arity' ); - t.end(); -}); - -tape( 'the function fills a one-dimensional ndarray with a scalar constant', function test( t ) { - var alpha; - var x; - var v; - - x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); - alpha = scalar2ndarray( 5.0, { - 'dtype': 'float32' - }); - - v = sfill( [ vector( x, 6, 1, 0 ), alpha ] ); - t.strictEqual( v.data, x, 'returns expected value' ); - t.strictEqual( x[ 0 ], 5.0, 'returns expected value' ); - t.strictEqual( x[ 1 ], 5.0, 'returns expected value' ); - t.strictEqual( x[ 5 ], 5.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'if provided an empty ndarray, the function returns the ndarray unchanged', function test( t ) { - var alpha; - var x; - var v; - - x = new Float32Array( [] ); - alpha = scalar2ndarray( 5.0, { - 'dtype': 'float32' - }); - - v = sfill( [ vector( x, 0, 1, 0 ), alpha ] ); - t.strictEqual( v.data, x, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { - var expected; - var alpha; - var x; - var v; - - x = new Float32Array([ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 3 - 2.0 - ]); - alpha = scalar2ndarray( 5.0, { - 'dtype': 'float32' - }); - expected = new Float32Array([ - 5.0, // 0 - 2.0, - 5.0, // 1 - -7.0, - 5.0, // 2 - 3.0, - 5.0, // 3 - 2.0 - ]); - - v = sfill( [ vector( x, 4, 2, 0 ), alpha ] ); - - t.strictEqual( v.data, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { - var expected; - var alpha; - var x; - var v; - - x = new Float32Array([ - 1.0, // 3 - 2.0, - 2.0, // 2 - -7.0, - -2.0, // 1 - 3.0, - 4.0, // 0 - 2.0 - ]); - alpha = scalar2ndarray( 5.0, { - 'dtype': 'float32' - }); - expected = new Float32Array([ - 5.0, // 3 - 2.0, - 5.0, // 2 - -7.0, - 5.0, // 1 - 3.0, - 5.0, // 0 - 2.0 - ]); - - v = sfill( [ vector( x, 4, -2, 6 ), alpha ] ); - - t.strictEqual( v.data, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { - var expected; - var alpha; - var x; - var v; - - x = new Float32Array([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0 // 3 - ]); - alpha = scalar2ndarray( 5.0, { - 'dtype': 'float32' - }); - expected = new Float32Array([ - 2.0, - 5.0, // 0 - 2.0, - 5.0, // 1 - -2.0, - 5.0, // 2 - 3.0, - 5.0 // 3 - ]); - - v = sfill( [ vector( x, 4, 2, 1 ), alpha ] ); - - t.strictEqual( v.data, x, 'returns expected value' ); - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); From 7d45284ed44422e6637071e3edca9c21ef1a8ea1 Mon Sep 17 00:00:00 2001 From: Aryan Sharma Date: Fri, 21 Aug 2026 02:54:07 +0530 Subject: [PATCH 5/8] refactor: remove native implementation fallback in sfill Signed-off-by: Aryan Sharma --- .../ext/base/ndarray/sfill/benchmark/benchmark.js | 5 +---- .../blas/ext/base/ndarray/sfill/lib/index.js | 13 +------------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js index fb4aad87fca0..d640ac8912e0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js @@ -25,7 +25,6 @@ var uniform = require( '@stdlib/random/array/uniform' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); -var Float32Array = require( '@stdlib/array/float32' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var pkg = require( './../package.json' ).name; @@ -51,15 +50,13 @@ var options = { function createBenchmark( len ) { var xNdarray; var alpha; - var buf; var x; x = uniform( len, -10.0, 10.0, options ); - buf = new Float32Array( x ); alpha = scalar2ndarray( 5.0, { 'dtype': 'float32' }); - xNdarray = new ndarray( 'float32', buf, [ len ], [ 1 ], 0, 'row-major' ); + xNdarray = new ndarray( 'float32', [ len ], [ 1 ], 0, 'row-major' ); return benchmark; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js index c5da628c599b..4b88c3bd079e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js @@ -50,17 +50,6 @@ var isError = require( '@stdlib/assert/is-error' ); var main = require( './main.js' ); -// MAIN // - -var sfill; -var tmp = tryRequire( join( __dirname, './native.js' ) ); -if ( isError( tmp ) ) { - sfill = main; -} else { - sfill = tmp; -} - - // EXPORTS // -module.exports = sfill; +module.exports = main; From 69e1ac0454a1bf7e783b5c88a5183e0fc82d3348 Mon Sep 17 00:00:00 2001 From: Aryan Sharma Date: Fri, 21 Aug 2026 02:57:12 +0530 Subject: [PATCH 6/8] style: remove unused imports in sfill Signed-off-by: Aryan Sharma --- .../@stdlib/blas/ext/base/ndarray/sfill/lib/index.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js index 4b88c3bd079e..857a499fe37a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js @@ -44,9 +44,6 @@ // MODULES // -var join = require( 'path' ).join; -var tryRequire = require( '@stdlib/utils/try-require' ); -var isError = require( '@stdlib/assert/is-error' ); var main = require( './main.js' ); From 0398843750bb4f4632257a3763201f5a8a5c1b49 Mon Sep 17 00:00:00 2001 From: Aryan Sharma Date: Fri, 21 Aug 2026 04:14:24 +0530 Subject: [PATCH 7/8] style: fix variable usage and sort variable declarations in sfill Signed-off-by: Aryan Sharma --- .../base/ndarray/sfill/benchmark/benchmark.js | 12 ++++++------ .../blas/ext/base/ndarray/sfill/test/test.js | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js index d640ac8912e0..5a763e86642d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js @@ -48,15 +48,15 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var xNdarray; var alpha; var x; + var xNdarray; x = uniform( len, -10.0, 10.0, options ); alpha = scalar2ndarray( 5.0, { 'dtype': 'float32' }); - xNdarray = new ndarray( 'float32', [ len ], [ 1 ], 0, 'row-major' ); + xNdarray = new ndarray( 'float32', x, [ len ], [ 1 ], 0, 'row-major' ); return benchmark; @@ -67,8 +67,8 @@ function createBenchmark( len ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var out; var i; + var out; b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -95,11 +95,11 @@ function createBenchmark( len ) { * @private */ function main() { - var len; - var min; - var max; var f; var i; + var len; + var max; + var min; min = 1; // 10^min max = 6; // 10^max diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js index 94d12e398132..e98b3dec20a0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js @@ -59,8 +59,8 @@ tape( 'the function has an arity of 1', function test( t ) { tape( 'the function fills a one-dimensional ndarray with a scalar constant', function test( t ) { var alpha; - var x; var v; + var x; x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); alpha = scalar2ndarray( 5.0, { @@ -78,8 +78,8 @@ tape( 'the function fills a one-dimensional ndarray with a scalar constant', fun tape( 'if provided an empty ndarray, the function returns the ndarray unchanged', function test( t ) { var alpha; - var x; var v; + var x; x = new Float32Array( [] ); alpha = scalar2ndarray( 5.0, { @@ -93,10 +93,10 @@ tape( 'if provided an empty ndarray, the function returns the ndarray unchanged' }); tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { - var expected; var alpha; - var x; + var expected; var v; + var x; x = new Float32Array([ 1.0, // 0 @@ -130,10 +130,10 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', }); tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { - var expected; var alpha; - var x; + var expected; var v; + var x; x = new Float32Array([ 1.0, // 3 @@ -167,10 +167,10 @@ tape( 'the function supports one-dimensional ndarrays having negative strides', }); tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { - var expected; var alpha; - var x; + var expected; var v; + var x; x = new Float32Array([ 2.0, From 2f207d00c03757cd83432b0e9c6caa3d0f6c6280 Mon Sep 17 00:00:00 2001 From: Aryan Sharma Date: Fri, 21 Aug 2026 04:20:16 +0530 Subject: [PATCH 8/8] style: sort variable declarations by decreasing length in sfill Signed-off-by: Aryan Sharma --- .../base/ndarray/sfill/benchmark/benchmark.js | 10 +++++----- .../blas/ext/base/ndarray/sfill/test/test.js | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js index 5a763e86642d..b7534134e2f4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js @@ -48,9 +48,9 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { + var xNdarray; var alpha; var x; - var xNdarray; x = uniform( len, -10.0, 10.0, options ); alpha = scalar2ndarray( 5.0, { @@ -67,8 +67,8 @@ function createBenchmark( len ) { * @param {Benchmark} b - benchmark instance */ function benchmark( b ) { - var i; var out; + var i; b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -95,11 +95,11 @@ function createBenchmark( len ) { * @private */ function main() { - var f; - var i; var len; - var max; var min; + var max; + var f; + var i; min = 1; // 10^min max = 6; // 10^max diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js index e98b3dec20a0..94d12e398132 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js @@ -59,8 +59,8 @@ tape( 'the function has an arity of 1', function test( t ) { tape( 'the function fills a one-dimensional ndarray with a scalar constant', function test( t ) { var alpha; - var v; var x; + var v; x = new Float32Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); alpha = scalar2ndarray( 5.0, { @@ -78,8 +78,8 @@ tape( 'the function fills a one-dimensional ndarray with a scalar constant', fun tape( 'if provided an empty ndarray, the function returns the ndarray unchanged', function test( t ) { var alpha; - var v; var x; + var v; x = new Float32Array( [] ); alpha = scalar2ndarray( 5.0, { @@ -93,10 +93,10 @@ tape( 'if provided an empty ndarray, the function returns the ndarray unchanged' }); tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { - var alpha; var expected; - var v; + var alpha; var x; + var v; x = new Float32Array([ 1.0, // 0 @@ -130,10 +130,10 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', }); tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { - var alpha; var expected; - var v; + var alpha; var x; + var v; x = new Float32Array([ 1.0, // 3 @@ -167,10 +167,10 @@ tape( 'the function supports one-dimensional ndarrays having negative strides', }); tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { - var alpha; var expected; - var v; + var alpha; var x; + var v; x = new Float32Array([ 2.0,