From 2968353d39158f3fd47f732727620ff80a819ba6 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Tue, 16 Dec 2025 20:13:51 +0530 Subject: [PATCH 1/4] feat: add @stdlib/blas/ext/base/ndarray/sfill --- .../blas/ext/base/ndarray/sfill/README.md | 114 +++++++++++++ .../base/ndarray/sfill/benchmark/benchmark.js | 115 +++++++++++++ .../blas/ext/base/ndarray/sfill/docs/repl.txt | 28 ++++ .../base/ndarray/sfill/docs/types/index.d.ts | 48 ++++++ .../ext/base/ndarray/sfill/docs/types/test.ts | 64 ++++++++ .../ext/base/ndarray/sfill/examples/index.js | 33 ++++ .../blas/ext/base/ndarray/sfill/lib/index.js | 46 ++++++ .../blas/ext/base/ndarray/sfill/lib/main.js | 58 +++++++ .../blas/ext/base/ndarray/sfill/package.json | 69 ++++++++ .../blas/ext/base/ndarray/sfill/test/test.js | 152 ++++++++++++++++++ 10 files changed, 727 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/repl.txt 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 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..d4411a5a9926 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/README.md @@ -0,0 +1,114 @@ + + +# sfill + +> Fill a single-precision floating-point ndarray with a specified value. + +
+ +
+ + + +
+ +## Usage + +```javascript +var sfill = require( '@stdlib/blas/ext/base/ndarray/sfill' ); +``` + +#### sfill( x, alpha ) + +Fills a single-precision floating-point ndarray `x` with a specified value `alpha`. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var array = require( '@stdlib/ndarray/array' ); + +var x = array( new Float32Array( [ 1.0, 2.0, 3.0 ] ) ); + +sfill( x, 5.0 ); + +var xbuf = x.data; +// returns [ 5.0, 5.0, 5.0 ] +``` + +The function has the following parameters: + +- **x**: input ndarray. +- **alpha**: fill value. + +
+ + + +
+ +## Notes + +- If provided an ndarray with a length of `0`, the function returns the ndarray unchanged. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Float32Array = require( '@stdlib/array/float32' ); +var array = require( '@stdlib/ndarray/array' ); +var sfill = require( '@stdlib/blas/ext/base/ndarray/sfill' ); + +var xbuf = discreteUniform( 10, -100, 100, { + 'dtype': 'float32' +}); +var x = array( xbuf ); +console.log( x.data ); + +sfill( x, 5.0 ); +console.log( x.data ); +``` + +
+ + + + + + + + + + + + + + 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..f204a03d26cb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/benchmark/benchmark.js @@ -0,0 +1,115 @@ +/** +* @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 array = require( '@stdlib/ndarray/array' ); +var isFloat32Array = require( '@stdlib/assert/is-float32array' ); +var pkg = require( './../package.json' ).name; +var sfill = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var i; + + x = array( new Float32Array( 10 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + sfill( x, 5.0 ); + if ( x.data[ 0 ] !== 5.0 ) { + b.fail( 'should fill ndarray' ); + } + } + b.toc(); + if ( !isFloat32Array( x.data ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::ndarray,len=10', function benchmark( b ) { + var x; + var i; + + x = array( new Float32Array( 10 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + sfill( x, 5.0 ); + if ( x.data[ 0 ] !== 5.0 ) { + b.fail( 'should fill ndarray' ); + } + } + b.toc(); + if ( !isFloat32Array( x.data ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::ndarray,len=100', function benchmark( b ) { + var x; + var i; + + x = array( new Float32Array( 100 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + sfill( x, 5.0 ); + if ( x.data[ 0 ] !== 5.0 ) { + b.fail( 'should fill ndarray' ); + } + } + b.toc(); + if ( !isFloat32Array( x.data ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::ndarray,len=1000', function benchmark( b ) { + var x; + var i; + + x = array( new Float32Array( 1000 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + sfill( x, 5.0 ); + if ( x.data[ 0 ] !== 5.0 ) { + b.fail( 'should fill ndarray' ); + } + } + b.toc(); + if ( !isFloat32Array( x.data ) ) { + b.fail( 'should return an ndarray' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/repl.txt new file mode 100644 index 000000000000..4a0b82257a1d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( x, alpha ) + Fills a single-precision floating-point ndarray with a specified value. + + Parameters + ---------- + x: float32ndarray + Input ndarray. + + alpha: number + Fill value. + + Returns + ------- + out: float32ndarray + Input ndarray. + + Examples + -------- + > var x = {{alias:@stdlib/ndarray/array}}( new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ) ); + > {{alias}}( x, 5.0 ) + + > x.data + [ 5.0, 5.0, 5.0 ] + + See Also + -------- + 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..b9d063139980 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/index.d.ts @@ -0,0 +1,48 @@ +/* +* @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 { float32ndarray } from '@stdlib/types/ndarray'; + +/** +* Fills a single-precision floating-point ndarray with a specified value. +* +* @param x - input ndarray +* @param alpha - fill value +* @returns input ndarray +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( new Float32Array( [ 1.0, 2.0, 3.0 ] ) ); +* +* sfill( x, 5.0 ); +* +* var xbuf = x.data; +* // returns [ 5.0, 5.0, 5.0 ] +*/ +declare function sfill( x: float32ndarray, alpha: number ): 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..9c0e189b659d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts @@ -0,0 +1,64 @@ +/* +* @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 zeros = require( '@stdlib/ndarray/zeros' ); +import sfill = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { 'dtype': 'float32' } ); + + sfill( x, 5.0 ); // $ExpectType float32ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an ndarray... +{ + sfill( 5, 5.0 ); // $ExpectError + sfill( true, 5.0 ); // $ExpectError + sfill( false, 5.0 ); // $ExpectError + sfill( null, 5.0 ); // $ExpectError + sfill( undefined, 5.0 ); // $ExpectError + sfill( [ 1, 2, 3 ], 5.0 ); // $ExpectError + sfill( {}, 5.0 ); // $ExpectError + sfill( ( x: number ): number => x, 5.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = zeros( [ 10 ], { 'dtype': 'float32' } ); + + sfill( x, '5' ); // $ExpectError + sfill( x, true ); // $ExpectError + sfill( x, false ); // $ExpectError + sfill( x, null ); // $ExpectError + sfill( x, [] ); // $ExpectError + sfill( x, {} ); // $ExpectError + sfill( x, ( 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' } ); + + sfill(); // $ExpectError + sfill( x ); // $ExpectError + sfill( x, 5.0, 10 ); // $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..cf05e5c4a3b6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/examples/index.js @@ -0,0 +1,33 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Float32Array = require( '@stdlib/array/float32' ); +var array = require( '@stdlib/ndarray/array' ); +var sfill = require( './../lib' ); + +var xbuf = discreteUniform( 10, -100, 100, { + 'dtype': 'float32' +}); +var x = array( xbuf ); +console.log( x.data ); + +sfill( x, 5.0 ); +console.log( x.data ); 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..1e0712c6a509 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/index.js @@ -0,0 +1,46 @@ +/** +* @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'; + +/** +* Fill a single-precision floating-point ndarray with a specified value. +* +* @module @stdlib/blas/ext/base/ndarray/sfill +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var array = require( '@stdlib/ndarray/array' ); +* var sfill = require( '@stdlib/blas/ext/base/ndarray/sfill' ); +* +* var x = array( new Float32Array( [ 1.0, 2.0, 3.0 ] ) ); +* +* sfill( x, 5.0 ); +* +* var xbuf = x.data; +* // returns [ 5.0, 5.0, 5.0 ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; 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..7c337fe333ab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/lib/main.js @@ -0,0 +1,58 @@ +/** +* @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 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 strided = require( '@stdlib/blas/ext/base/sfill' ).ndarray; + + +// MAIN // + +/** +* Fills a single-precision floating-point ndarray with a specified value. +* +* @param {float32ndarray} x - input ndarray +* @param {number} alpha - fill value +* @returns {float32ndarray} input ndarray +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var array = require( '@stdlib/ndarray/array' ); +* +* var x = array( new Float32Array( [ 1.0, 2.0, 3.0 ] ) ); +* +* sfill( x, 5.0 ); +* +* var xbuf = x.data; +* // returns [ 5.0, 5.0, 5.0 ] +*/ +function sfill( x, alpha ) { + strided( numelDimension( x, 0 ), alpha, getData( x ), getStride( x, 0 ), getOffset( x ) ); + 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..97915f241e88 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/blas/ext/base/ndarray/sfill", + "version": "0.0.0", + "description": "Fill a single-precision floating-point ndarray with a specified value.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "fill", + "assign", + "set", + "strided", + "array", + "ndarray", + "float32", + "float32array", + "single" + ], + "__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..0b68d8fc6e34 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/test/test.js @@ -0,0 +1,152 @@ +/** +* @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 array = require( '@stdlib/ndarray/array' ); +var sfill = require( './../lib' ); + + +// 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 2', function test( t ) { + t.strictEqual( sfill.length, 2, 'has expected arity' ); + t.end(); +}); + +tape( 'the function fills an ndarray with a specified value', function test( t ) { + var expected; + var x; + + x = array( new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) ); + expected = new Float32Array( [ 5.0, 5.0, 5.0, 5.0, 5.0 ] ); + + sfill( x, 5.0 ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the input ndarray', function test( t ) { + var x; + var y; + + x = array( new Float32Array( [ 1.0, 2.0, 3.0 ] ) ); + y = sfill( x, 5.0 ); + + t.strictEqual( y, x, 'returns input ndarray' ); + t.end(); +}); + +tape( 'the function supports an ndarray having a stride greater than 1', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float32Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + x = array( xbuf, { + 'shape': [ 3 ], + 'strides': [ 2 ], + 'offset': 0 + }); + expected = new Float32Array( [ 5.0, 2.0, 5.0, 4.0, 5.0 ] ); + + sfill( x, 5.0 ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an ndarray having a negative stride', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float32Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + x = array( xbuf, { + 'shape': [ 3 ], + 'strides': [ -2 ], + 'offset': 4 + }); + expected = new Float32Array( [ 5.0, 2.0, 5.0, 4.0, 5.0 ] ); + + sfill( x, 5.0 ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an ndarray having an offset', function test( t ) { + var expected; + var xbuf; + var x; + + xbuf = new Float32Array([ + 1.0, + 2.0, // 0 + 3.0, // 1 + 4.0, // 2 + 5.0 + ]); + x = array( xbuf, { + 'shape': [ 3 ], + 'strides': [ 1 ], + 'offset': 1 + }); + expected = new Float32Array( [ 1.0, 5.0, 5.0, 5.0, 5.0 ] ); + + sfill( x, 5.0 ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an ndarray having a length of `0`, the function returns the ndarray unchanged', function test( t ) { + var expected; + var x; + + x = array( new Float32Array( [] ) ); + expected = new Float32Array( [] ); + + sfill( x, 5.0 ); + + t.deepEqual( x.data, expected, 'returns expected value' ); + t.end(); +}); From dc083b0a9dc6e9dfcb04843e4ca7b2dda8bcdf23 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Tue, 16 Dec 2025 20:25:13 +0530 Subject: [PATCH 2/4] fixed some minor things --- .../ext/base/ndarray/sfill/examples/index.js | 1 - .../blas/ext/base/ndarray/sfill/lib/main.js | 6 +++++- .../blas/ext/base/ndarray/sfill/test/test.js | 19 ++++--------------- 3 files changed, 9 insertions(+), 17 deletions(-) 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 index cf05e5c4a3b6..796e236968e1 100644 --- 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 @@ -19,7 +19,6 @@ 'use strict'; var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); -var Float32Array = require( '@stdlib/array/float32' ); var array = require( '@stdlib/ndarray/array' ); var sfill = require( './../lib' ); 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 index 7c337fe333ab..1c08a7e87b2e 100644 --- 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 @@ -48,7 +48,11 @@ var strided = require( '@stdlib/blas/ext/base/sfill' ).ndarray; * // returns [ 5.0, 5.0, 5.0 ] */ function sfill( x, alpha ) { - strided( numelDimension( x, 0 ), alpha, getData( x ), getStride( x, 0 ), getOffset( x ) ); + var N = numelDimension( x, 0 ); + var stride = getStride( x, 0 ); + var offset = getOffset( x ); + + strided( N, alpha, getData( x ), stride, offset ); return x; } 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 0b68d8fc6e34..4a9fdb91d4a0 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 @@ -22,6 +22,7 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); var array = require( '@stdlib/ndarray/array' ); var sfill = require( './../lib' ); @@ -75,11 +76,7 @@ tape( 'the function supports an ndarray having a stride greater than 1', functio 4.0, 5.0 // 2 ]); - x = array( xbuf, { - 'shape': [ 3 ], - 'strides': [ 2 ], - 'offset': 0 - }); + x = new ndarray( 'float32', xbuf, [ 3 ], [ 2 ], 0, 'row-major' ); expected = new Float32Array( [ 5.0, 2.0, 5.0, 4.0, 5.0 ] ); sfill( x, 5.0 ); @@ -100,11 +97,7 @@ tape( 'the function supports an ndarray having a negative stride', function test 4.0, 5.0 // 0 ]); - x = array( xbuf, { - 'shape': [ 3 ], - 'strides': [ -2 ], - 'offset': 4 - }); + x = new ndarray( 'float32', xbuf, [ 3 ], [ -2 ], 4, 'row-major' ); expected = new Float32Array( [ 5.0, 2.0, 5.0, 4.0, 5.0 ] ); sfill( x, 5.0 ); @@ -125,11 +118,7 @@ tape( 'the function supports an ndarray having an offset', function test( t ) { 4.0, // 2 5.0 ]); - x = array( xbuf, { - 'shape': [ 3 ], - 'strides': [ 1 ], - 'offset': 1 - }); + x = new ndarray( 'float32', xbuf, [ 3 ], [ 1 ], 1, 'row-major' ); expected = new Float32Array( [ 1.0, 5.0, 5.0, 5.0, 5.0 ] ); sfill( x, 5.0 ); From 854d97c2ce27364b996b79a6d783d4e0e7509c4d Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Tue, 16 Dec 2025 20:33:04 +0530 Subject: [PATCH 3/4] fixed some minor things --- .../@stdlib/blas/ext/base/ndarray/sfill/docs/types/test.ts | 2 ++ .../@stdlib/blas/ext/base/ndarray/sfill/lib/main.js | 4 ++-- 2 files changed, 4 insertions(+), 2 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 9c0e189b659d..94346daa70b1 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 sfill = require( './index' ); 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 index 1c08a7e87b2e..f90e561225cc 100644 --- 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 @@ -48,9 +48,9 @@ var strided = require( '@stdlib/blas/ext/base/sfill' ).ndarray; * // returns [ 5.0, 5.0, 5.0 ] */ function sfill( x, alpha ) { - var N = numelDimension( x, 0 ); - var stride = getStride( x, 0 ); var offset = getOffset( x ); + var stride = getStride( x, 0 ); + var N = numelDimension( x, 0 ); strided( N, alpha, getData( x ), stride, offset ); return x; From 980522091e813dd5d5ba88ed4f8b3c9acb5da644 Mon Sep 17 00:00:00 2001 From: Aman Singh Date: Fri, 19 Dec 2025 18:26:49 +0530 Subject: [PATCH 4/4] docs: update return annotations to use ndarray instance notation --- .../@stdlib/blas/ext/base/ndarray/sfill/README.md | 6 ++---- .../@stdlib/blas/ext/base/ndarray/sfill/docs/repl.txt | 4 +--- .../blas/ext/base/ndarray/sfill/docs/types/index.d.ts | 6 ++---- .../@stdlib/blas/ext/base/ndarray/sfill/lib/index.js | 6 ++---- 4 files changed, 7 insertions(+), 15 deletions(-) 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 index d4411a5a9926..c9396aa1ab36 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/README.md @@ -46,10 +46,8 @@ var array = require( '@stdlib/ndarray/array' ); var x = array( new Float32Array( [ 1.0, 2.0, 3.0 ] ) ); -sfill( x, 5.0 ); - -var xbuf = x.data; -// returns [ 5.0, 5.0, 5.0 ] +var out = sfill( x, 5.0 ); +// returns [ 5.0, 5.0, 5.0 ] ``` The function has the following parameters: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/repl.txt index 4a0b82257a1d..1a92a5277ece 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/sfill/docs/repl.txt @@ -19,9 +19,7 @@ -------- > var x = {{alias:@stdlib/ndarray/array}}( new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ) ); > {{alias}}( x, 5.0 ) - - > x.data - [ 5.0, 5.0, 5.0 ] + [ 5.0, 5.0, 5.0 ] See Also -------- 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 index b9d063139980..536dbce16d85 100644 --- 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 @@ -35,10 +35,8 @@ import { float32ndarray } from '@stdlib/types/ndarray'; * * var x = array( new Float32Array( [ 1.0, 2.0, 3.0 ] ) ); * -* sfill( x, 5.0 ); -* -* var xbuf = x.data; -* // returns [ 5.0, 5.0, 5.0 ] +* var out = sfill( x, 5.0 ); +* // returns [ 5.0, 5.0, 5.0 ] */ declare function sfill( x: float32ndarray, alpha: number ): float32ndarray; 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 1e0712c6a509..604a9d3f60cf 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 @@ -30,10 +30,8 @@ * * var x = array( new Float32Array( [ 1.0, 2.0, 3.0 ] ) ); * -* sfill( x, 5.0 ); -* -* var xbuf = x.data; -* // returns [ 5.0, 5.0, 5.0 ] +* var out = sfill( x, 5.0 ); +* // returns [ 5.0, 5.0, 5.0 ] */ // MODULES //