From 21740d874ae1f4b122207d8db48b44aea33aff10 Mon Sep 17 00:00:00 2001 From: Arjan Date: Fri, 7 Aug 2026 16:22:59 +0530 Subject: [PATCH 1/9] feat: setup `blas/ext/base/gfill-rows` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/gfill-rows/lib/index.js | 45 +++++++++++ .../blas/ext/base/gfill-rows/lib/main.js | 80 +++++++++++++++++++ .../blas/ext/base/gfill-rows/lib/ndarray.js | 74 +++++++++++++++++ .../blas/ext/base/gfill-rows/package.json | 69 ++++++++++++++++ 4 files changed, 268 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/package.json diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/index.js new file mode 100644 index 000000000000..14f4da7c5479 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/index.js @@ -0,0 +1,45 @@ +/** +* @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'; + +/** +* Fill the rows of a matrix from a vector of fill values. +* +* @module @stdlib/blas/ext/base/gfill-rows +* +* @example +* var gfillRows = require( '@stdlib/blas/ext/base/gfill-rows' ); +* +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js new file mode 100644 index 000000000000..55e2e5297422 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js @@ -0,0 +1,80 @@ +/** +* @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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var format = require( '@stdlib/string/format' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Fills the rows of a matrix from a vector of fill values. +* +* @param {string} order - storage layout +* @param {integer} M - number of rows in `A` +* @param {integer} N - number of columns in `A` +* @param {Collection} alpha - vector containing fill values +* @param {Collection} A - input matrix +* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} seventh argument must be greater than or equal to max(1,M) for column-major or max(1,N) for row-major +* @returns {Collection} input matrix +* +* @example +* var alpha = [ 10.0, 20.0 ]; +* var A = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gfillRows( 'row-major', 2, 3, alpha, A, 3 ); +* // A => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] +*/ +function gfillRows( order, M, N, alpha, A, LDA ) { + var strideA1; + var strideA2; + var s; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + + if ( isColumnMajor( order ) ) { + s = M; + strideA1 = 1; + strideA2 = LDA; + } else { // order === 'row-major' + s = N; + strideA1 = LDA; + strideA2 = 1; + } + if ( LDA < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); + } + + return ndarray( M, N, alpha, 1, 0, A, strideA1, strideA2, 0 ); +} + + +// EXPORTS // + +module.exports = gfillRows; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js new file mode 100644 index 000000000000..2bc0884b6647 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js @@ -0,0 +1,74 @@ +/** +* @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 gfill = require( '@stdlib/blas/ext/base/gfill' ).ndarray; + + +// MAIN // + +/** +* Fills the rows of a matrix from a vector of fill values. +* +* @param {integer} M - number of rows in `A` +* @param {integer} N - number of columns in `A` +* @param {Collection} alpha - vector of fill values +* @param {integer} strideAlpha - stride length of `alpha` +* @param {NonNegativeInteger} offsetAlpha - starting index for `alpha` +* @param {Collection} A - input matrix +* @param {integer} strideA1 - stride length for the first dimension of `A` +* @param {integer} strideA2 - stride length for the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @returns {Collection} input matrix +* +* @example +* var alpha = [ 10.0, 20.0 ]; +* var A = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gfillRows( 2, 3, alpha, 1, 0, A, 3, 1, 0 ); +* // A => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] +*/ +function gfillRows( M, N, alpha, strideAlpha, offsetAlpha, A, strideA1, strideA2, offsetA ) { + var ia; + var ix; + var i; + + if ( M <= 0 || N <= 0 ) { + return A; + } + + // TODO: Column-major + + // Row-major + ia = offsetAlpha; + for ( i = 0; i < M; i++ ) { + ix = offsetA + (i * strideA1); + gfill( N, alpha[ ia ], A, strideA2, ix); + ia += strideAlpha; + } + + return A; +} + + +// EXPORTS // + +module.exports = gfillRows; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/package.json b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/package.json new file mode 100644 index 000000000000..3dfb3801124b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/blas/ext/base/gfill-rows", + "version": "0.0.0", + "description": "Fill the rows of a matrix from a vector of fill values.", + "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", + "row", + "assign", + "set", + "matrix", + "constant", + "strided", + "array", + "ndarray" + ], + "__stdlib__": {} +} From 066bd89162ba0dd5f12e936c8f885e05ba87956c Mon Sep 17 00:00:00 2001 From: Arjan Date: Fri, 7 Aug 2026 17:46:37 +0530 Subject: [PATCH 2/9] fix: add cache friendly traversal for column-major case --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/gfill-rows/lib/main.js | 4 ++-- .../blas/ext/base/gfill-rows/lib/ndarray.js | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js index 55e2e5297422..623705bc8af7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js @@ -39,7 +39,7 @@ var ndarray = require( './ndarray.js' ); * @param {Collection} A - input matrix * @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @throws {TypeError} first argument must be a valid order -* @throws {RangeError} seventh argument must be greater than or equal to max(1,M) for column-major or max(1,N) for row-major +* @throws {RangeError} sixth argument must be greater than or equal to max(1,M) for column-major or max(1,N) for row-major * @returns {Collection} input matrix * * @example @@ -68,7 +68,7 @@ function gfillRows( order, M, N, alpha, A, LDA ) { strideA2 = 1; } if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } return ndarray( M, N, alpha, 1, 0, A, strideA1, strideA2, 0 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js index 2bc0884b6647..ec6af92652db 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js @@ -50,12 +50,29 @@ function gfillRows( M, N, alpha, strideAlpha, offsetAlpha, A, strideA1, strideA2 var ia; var ix; var i; + var j; if ( M <= 0 || N <= 0 ) { return A; } - // TODO: Column-major + // TODO: handle accessorProtocol support + + // Column-major + if ( strideA1 === 1 ) { + ia = offsetAlpha; + for ( j = 0; j < N; j++ ) { + ix = offsetA + (j * strideA2); + ia = offsetAlpha; + for ( i = 0; i < M; i++ ) { + A[ ix ] = alpha[ ia ]; + ix += strideA1; + ia += strideAlpha; + } + } + + return A; + } // Row-major ia = offsetAlpha; From a0b54caa298a22194bb1c4af53f4d4dd00e26465 Mon Sep 17 00:00:00 2001 From: Arjan Date: Fri, 7 Aug 2026 17:59:09 +0530 Subject: [PATCH 3/9] chore: add examples/index.js --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../ext/base/gfill-rows/examples/index.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/examples/index.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/examples/index.js new file mode 100644 index 000000000000..4d81a53b83ab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/examples/index.js @@ -0,0 +1,31 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var gfillRows = require( './../lib' ); + +var alpha = [ 10.0, 20.0 ]; +var A = uniform( 6, -100, 100, { + 'dtype': 'float64' +}); +console.log( A ); + +gfillRows( 'row-major', 2, 3, alpha, A, 3 ); +console.log( A ); From fd768a67370fce3943ba803b8c6297dd2b29f13f Mon Sep 17 00:00:00 2001 From: Arjan Date: Sun, 9 Aug 2026 01:03:52 +0530 Subject: [PATCH 4/9] fix: add support for AccessorArrayLike alpha, A values --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/gfill-rows/lib/accessors.js | 181 ++++++++++++++++++ .../blas/ext/base/gfill-rows/lib/main.js | 34 ++-- .../blas/ext/base/gfill-rows/lib/ndarray.js | 49 +++-- 3 files changed, 227 insertions(+), 37 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/accessors.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/accessors.js new file mode 100644 index 000000000000..5b8e71a25876 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/accessors.js @@ -0,0 +1,181 @@ +/** +* @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'; + +// MAIN // + +/** +* Fills the rows of a matrix from a vector of fill values. +* +* @param {integer} M - number of rows in `X` +* @param {integer} N - number of columns in `X` +* @param {Object} alpha - object of fill values +* @param {Collection} alpha.data - fill value array data +* @param {Array} alpha.accessors - array element accessors +* @param {integer} strideAlpha - stride length of `alpha` +* @param {NonNegativeInteger} offsetAlpha - starting index for `alpha` +* @param {Object} X - input matrix object +* @param {Collection} X.data - input matrix data +* @param {Array} X.accessors - array element accessors +* @param {integer} strideX1 - stride length for the first dimension of `X` +* @param {integer} strideX2 - stride length for the second dimension of `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @returns {Collection} input matrix +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var alpha = arraylike2object( toAccessorArray( [ 10.0, 20.0 ] ) ); +* var X = arraylike2object( toAccessorArray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ) ); +* +* gfillRows( 2, 3, alpha, 1, 0, X, 1, 2, 0 ); +* // X.data => [ 10.0, 20.0, 10.0, 20.0, 10.0, 20.0 ] +*/ +function gfillRows( M, N, alpha, strideAlpha, offsetAlpha, X, strideX1, strideX2, offsetX ) { + var value; + var abuf; + var aget; + var xbuf; + var xset; + var ix; + var ia; + var i; + var j; + + // Column-major + if ( strideX1 === 1 ) { + if ( alpha.accessorProtocol && X.accessorProtocol ) { + // Cache references to array data, accessors + abuf = alpha.data; + aget = alpha.accessors[ 0 ]; + + xbuf = X.data; + xset = X.accessors[ 1 ]; + + for ( j = 0; j < N; j++ ) { + ix = offsetX + (j * strideX2); + ia = offsetAlpha; + for ( i = 0; i < M; i++ ) { + xset( xbuf, ix, aget( abuf, ia ) ); + ix += strideX1; + ia += strideAlpha; + } + } + } + + else if ( alpha.accessorProtocol ) { + // Cache references to array data, accessors + abuf = alpha.data; + aget = alpha.accessors[ 0 ]; + + for ( j = 0; j < N; j++ ) { + ix = offsetX + (j * strideX2); + ia = offsetAlpha; + for ( i = 0; i < M; i++ ) { + X[ ix ] = aget( abuf, ia ); + ix += strideX1; + ia += strideAlpha; + } + } + } + + else if ( X.accessorProtocol ) { + // Cache references to array data, accessors + xbuf = X.data; + xset = X.accessors[ 1 ]; + + for ( j = 0; j < N; j++ ) { + ix = offsetX + (j * strideX2); + ia = offsetAlpha; + for ( i = 0; i < M; i++ ) { + xset( xbuf, ix, alpha[ ia ] ); + ix += strideX1; + ia += strideAlpha; + } + } + } + + return X; + } + + // Row-major + if ( alpha.accessorProtocol && X.accessorProtocol ) { + // Cache references to array data, accessors + abuf = alpha.data; + aget = alpha.accessors[ 0 ]; + + xbuf = X.data; + xset = X.accessors[ 1 ]; + + for ( i = 0; i < M; i++ ) { + ix = offsetX + (i * strideX1); + ia = offsetAlpha + (i * strideAlpha); + + // Cache current rows fill value + value = aget( abuf, ia ); + for ( j = 0; j < N; j++ ) { + xset( xbuf, ix, value ); + ix += strideX2; + } + } + } + + else if ( alpha.accessorProtocol ) { + // Cache references to array data, accessors + abuf = alpha.data; + aget = alpha.accessors[ 0 ]; + + for ( i = 0; i < M; i++ ) { + ix = offsetX + (i * strideX1); + ia = offsetAlpha + (i * strideAlpha); + + // Cache current rows fill value + value = aget( abuf, ia ); + for ( j = 0; j < N; j++ ) { + X[ ix ] = value; + ix += strideX2; + } + } + } + + else if ( X.accessorProtocol ) { + // Cache references to array data, accessors + xbuf = X.data; + xset = X.accessors[ 1 ]; + + for ( i = 0; i < M; i++ ) { + ix = offsetX + (i * strideX1); + ia = offsetAlpha + (i * strideAlpha); + + value = alpha[ ia ]; + for ( j = 0; j < N; j++ ) { + xset( xbuf, ix, value ); + ix += strideX2; + } + } + } + + return X; +} + + +// EXPORTS // + +module.exports = gfillRows; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js index 623705bc8af7..9f112a4a700b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/main.js @@ -33,25 +33,25 @@ var ndarray = require( './ndarray.js' ); * Fills the rows of a matrix from a vector of fill values. * * @param {string} order - storage layout -* @param {integer} M - number of rows in `A` -* @param {integer} N - number of columns in `A` +* @param {integer} M - number of rows in `X` +* @param {integer} N - number of columns in `X` * @param {Collection} alpha - vector containing fill values -* @param {Collection} A - input matrix -* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Collection} X - input matrix +* @param {integer} LDX - stride of the first dimension of `X` (a.k.a., leading dimension of the matrix `X`) * @throws {TypeError} first argument must be a valid order * @throws {RangeError} sixth argument must be greater than or equal to max(1,M) for column-major or max(1,N) for row-major * @returns {Collection} input matrix * * @example * var alpha = [ 10.0, 20.0 ]; -* var A = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* var X = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * -* gfillRows( 'row-major', 2, 3, alpha, A, 3 ); -* // A => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] +* gfillRows( 'row-major', 2, 3, alpha, X, 3 ); +* // X => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] */ -function gfillRows( order, M, N, alpha, A, LDA ) { - var strideA1; - var strideA2; +function gfillRows( order, M, N, alpha, X, LDX ) { + var strideX1; + var strideX2; var s; if ( !isLayout( order ) ) { @@ -60,18 +60,18 @@ function gfillRows( order, M, N, alpha, A, LDA ) { if ( isColumnMajor( order ) ) { s = M; - strideA1 = 1; - strideA2 = LDA; + strideX1 = 1; + strideX2 = LDX; } else { // order === 'row-major' s = N; - strideA1 = LDA; - strideA2 = 1; + strideX1 = LDX; + strideX2 = 1; } - if ( LDA < max( 1, s ) ) { - throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); + if ( LDX < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDX ) ); } - return ndarray( M, N, alpha, 1, 0, A, strideA1, strideA2, 0 ); + return ndarray( M, N, alpha, 1, 0, X, strideX1, strideX2, 0 ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js index ec6af92652db..05ac5c85b7bf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/ndarray.js @@ -20,7 +20,9 @@ // MODULES // +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); var gfill = require( '@stdlib/blas/ext/base/gfill' ).ndarray; +var accessors = require( './accessors.js' ); // MAIN // @@ -28,61 +30,68 @@ var gfill = require( '@stdlib/blas/ext/base/gfill' ).ndarray; /** * Fills the rows of a matrix from a vector of fill values. * -* @param {integer} M - number of rows in `A` -* @param {integer} N - number of columns in `A` +* @param {integer} M - number of rows in `X` +* @param {integer} N - number of columns in `X` * @param {Collection} alpha - vector of fill values * @param {integer} strideAlpha - stride length of `alpha` * @param {NonNegativeInteger} offsetAlpha - starting index for `alpha` -* @param {Collection} A - input matrix -* @param {integer} strideA1 - stride length for the first dimension of `A` -* @param {integer} strideA2 - stride length for the second dimension of `A` -* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Collection} X - input matrix +* @param {integer} strideX1 - stride length for the first dimension of `X` +* @param {integer} strideX2 - stride length for the second dimension of `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` * @returns {Collection} input matrix * * @example * var alpha = [ 10.0, 20.0 ]; -* var A = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* var X = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; * -* gfillRows( 2, 3, alpha, 1, 0, A, 3, 1, 0 ); -* // A => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] +* gfillRows( 2, 3, alpha, 1, 0, X, 3, 1, 0 ); +* // X => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] */ -function gfillRows( M, N, alpha, strideAlpha, offsetAlpha, A, strideA1, strideA2, offsetA ) { +function gfillRows( M, N, alpha, strideAlpha, offsetAlpha, X, strideX1, strideX2, offsetX ) { var ia; var ix; + var oa; + var ox; var i; var j; if ( M <= 0 || N <= 0 ) { - return A; + return X; } - // TODO: handle accessorProtocol support + oa = arraylike2object( alpha ); + ox = arraylike2object( X ); + + if ( oa.accessorProtocol || ox.accessorProtocol ) { + return accessors( M, N, oa, strideAlpha, offsetAlpha, ox, strideX1, strideX2, offsetX ); + } // Column-major - if ( strideA1 === 1 ) { + if ( strideX1 === 1 ) { ia = offsetAlpha; for ( j = 0; j < N; j++ ) { - ix = offsetA + (j * strideA2); + ix = offsetX + (j * strideX2); ia = offsetAlpha; for ( i = 0; i < M; i++ ) { - A[ ix ] = alpha[ ia ]; - ix += strideA1; + X[ ix ] = alpha[ ia ]; + ix += strideX1; ia += strideAlpha; } } - return A; + return X; } // Row-major ia = offsetAlpha; for ( i = 0; i < M; i++ ) { - ix = offsetA + (i * strideA1); - gfill( N, alpha[ ia ], A, strideA2, ix); + ix = offsetX + (i * strideX1); + gfill( N, alpha[ ia ], X, strideX2, ix); ia += strideAlpha; } - return A; + return X; } From 5d788634af0428741f5084aea47e56eca00a8fef Mon Sep 17 00:00:00 2001 From: Arjan Date: Sun, 9 Aug 2026 09:04:21 +0530 Subject: [PATCH 5/9] chore: add typescript files --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../ext/base/gfill-rows/docs/types/index.d.ts | 110 ++++++++ .../ext/base/gfill-rows/docs/types/test.ts | 243 ++++++++++++++++++ 2 files changed, 353 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/docs/types/index.d.ts new file mode 100644 index 000000000000..f873fae20fb6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/docs/types/index.d.ts @@ -0,0 +1,110 @@ +/* +* @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 { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import { Layout } from '@stdlib/types/blas'; + +/** +* Input array. +*/ +type InputArray = AccessorArrayLike | Collection; + +/** +* Output array. +*/ +type OutputArray = AccessorArrayLike | Collection; + +/** +* Interface describing `gfillRows`. +*/ +interface Routine { + /** + * Fills the rows of a matrix from a vector of fill values. + * + * @param order - storage layout + * @param M - number of rows in `X` + * @param N - number of columns in `X` + * @param alpha - vector of fill values + * @param X - input matrix + * @param LDX - stride of the first dimension of `X` + * @returns `X` + * + * @example + * var alpha = [ 10.0, 20.0 ]; + * var X = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + * + * gfillRows( 'row-major', 2, 3, alpha, X, 3 ); + * // X => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] + */ + ( order: Layout, M: number, N: number, alpha: InputArray, X: InputArray, LDX: number ): OutputArray; + + /** + * Fills the rows of a matrix from a vector of fill values using alternative indexing semantics. + * + * @param order - storage layout + * @param M - number of rows in `X` + * @param N - number of columns in `X` + * @param alpha - vector of fill values + * @param strideAlpha - stride length of `alpha` + * @param offsetAlpha - starting index of `alpha` + * @param X - input matrix + * @param strideX1 - stride length for the first dimension of `X` + * @param strideX2 - stride length for the second dimension of `X` + * @param offsetX - starting offset of `X` + * @returns `X` + * + * @example + * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); + * + * var alpha = [ 10, 20 ]; + * var X = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; + * + * gfillRows.ndarray( 2, 3, toAccessorArray( alpha ), 1, 0, toAccessorArray( X ), 1, 2, 0 ); + * // X => [ 10.0, 20.0, 10.0, 20.0, 10.0, 20.0 ] + */ + ndarray( M: number, N: number, alpha: InputArray, strideAlpha: number, offsetAlpha: number, X: InputArray, strideX1: number, strideX2: number, offsetX: number ): OutputArray; +} + +/** +* Fills the rows of a matrix from a vector of fill values. +* +* @param order - storage layout +* @param M - number of rows in `X` +* @param N - number of columns in `X` +* @param alpha - vector of fill values +* @param X - input matrix +* @param LDX - stride of the first dimension of `X` +* @returns `X` +* +* @example +* var alpha = [ 10.0, 20.0 ]; +* var X = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gfillRows( 'row-major', 2, 3, alpha, X, 3 ); +* // X => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] +*/ +declare var gfillRows: Routine; + + +// EXPORTS // + +export = gfillRows; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/docs/types/test.ts new file mode 100644 index 000000000000..b3198cb0c664 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/docs/types/test.ts @@ -0,0 +1,243 @@ +/* +* @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 AccessorArray = require( '@stdlib/array/base/accessor' ); +import gfillRows = require( './index' ); + + +// TESTS // + +// The function returns a collection... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows( 'row-major', 2, 3, alpha, X, 3 ); // $ExpectType OutputArray +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows( 10, 2, 3, alpha, X, 3 ); // $ExpectError + gfillRows( true, 2, 3, alpha, X, 3 ); // $ExpectError + gfillRows( null, 2, 3, alpha, X, 3 ); // $ExpectError + gfillRows( undefined, 2, 3, alpha, X, 3 ); // $ExpectError + gfillRows( [], 2, 3, alpha, X, 3 ); // $ExpectError + gfillRows( {}, 2, 3, alpha, X, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows( 'row-major', '2', 3, alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', true, 3, alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', null, 3, alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', undefined, 3, alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', [], 3, alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', {}, 3, alpha, X, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows( 'row-major', 2, '3', alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, true, alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, null, alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, undefined, alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, [], alpha, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, {}, alpha, X, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a collection... +{ + const X = new Float64Array( 6 ); + + gfillRows( 'row-major', 2, 3, 10, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, true, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, null, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, undefined, X, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, {}, X, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a collection... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + + gfillRows( 'row-major', 2, 3, alpha, 10, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, true, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, null, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, undefined, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, {}, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows( 'row-major', 2, 3, alpha, X, '3' ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, X, true ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, X, null ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, X, undefined ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, X, [] ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, X, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows(); // $ExpectError + gfillRows( 'row-major' ); // $ExpectError + gfillRows( 'row-major', 2 ); // $ExpectError + gfillRows( 'row-major', 2, 3 ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, X ); // $ExpectError + gfillRows( 'row-major', 2, 3, alpha, X, 3, 0 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a collection... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectType OutputArray + gfillRows.ndarray( 2, 3, alpha, 1, 0, new AccessorArray( X ), 3, 1, 0 ); // $ExpectType OutputArray +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows.ndarray( '2', 3, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( true, 3, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( null, 3, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( undefined, 3, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( [], 3, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( {}, 3, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows.ndarray( 2, '3', alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, true, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, null, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, undefined, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, [], alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, {}, alpha, 1, 0, X, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... +{ + const X = new Float64Array( 6 ); + + gfillRows.ndarray( 2, 3, 10, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, true, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, null, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, undefined, 1, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, {}, 1, 0, X, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + gfillRows.ndarray( 2, 3, alpha, '0', 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, true, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, null, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, undefined, 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, [], 0, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, {}, 0, X, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + gfillRows.ndarray( 2, 3, alpha, 1, '0', X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, true, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, null, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, undefined, X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, [], X, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, {}, X, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a collection... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + + gfillRows.ndarray( 2, 3, alpha, 1, 0, 10, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, true, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, null, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, undefined, 3, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, {}, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, '1', 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, true, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, null, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, undefined, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, [], 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, {}, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1, '0' ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1, true ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1, null ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1, undefined ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1, [] ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1, {} ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const alpha = new Float64Array( [ 10.0, 20.0 ] ); + const X = new Float64Array( 6 ); + + gfillRows.ndarray(); // $ExpectError + gfillRows.ndarray( 2 ); // $ExpectError + gfillRows.ndarray( 2, 3 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1 ); // $ExpectError + gfillRows.ndarray( 2, 3, alpha, 1, 0, X, 3, 1, 0, 10 ); // $ExpectError +} From 8ed1dc57dc3acfce953b0020e7ab074640488192 Mon Sep 17 00:00:00 2001 From: Arjan Date: Sun, 9 Aug 2026 09:06:32 +0530 Subject: [PATCH 6/9] docs: add missing example for index.js --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/gfill-rows/lib/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/index.js index 14f4da7c5479..d33eb6728bf2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/lib/index.js @@ -26,6 +26,11 @@ * @example * var gfillRows = require( '@stdlib/blas/ext/base/gfill-rows' ); * +* var alpha = [ 10.0, 20.0 ]; +* var X = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; +* +* gfillRows( 'row-major', 2, 3, alpha, X, 3 ); +* // X => [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0 ] */ // MODULES // From 28dc5ce4dc37a6436887ecb69b40f68d8e240be8 Mon Sep 17 00:00:00 2001 From: Arjan Date: Sun, 9 Aug 2026 10:56:19 +0530 Subject: [PATCH 7/9] test: add base tests for general and ndarray interface --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/gfill-rows/test/test.js | 38 ++++ .../ext/base/gfill-rows/test/test.main.js | 203 ++++++++++++++++++ .../ext/base/gfill-rows/test/test.ndarray.js | 159 ++++++++++++++ 3 files changed, 400 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.js new file mode 100644 index 000000000000..eddf1dcf39b1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var gfillRows = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfillRows, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof gfillRows.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.main.js new file mode 100644 index 000000000000..84f4671617ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.main.js @@ -0,0 +1,203 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gfillRows = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfillRows, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( gfillRows.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var alpha = [ 1.0, 2.0 ]; + var X = [ 0.0, 0.0, 0.0, 0.0 ]; + gfillRows( value, 2, 2, alpha, X, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDX value (row-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var alpha = [ 1.0, 2.0 ]; + var X = [ 0.0, 0.0, 0.0, 0.0 ]; + gfillRows( 'row-major', 2, 2, alpha, X, value ); + }; + } +}); + +tape( 'the function throws an error if provided a sixth argument which is not a valid LDX value (column-major)', function test( t ) { + var values; + var i; + + values = [ 0, 1 ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + var alpha = [ 1.0, 2.0 ]; + var X = [ 0.0, 0.0, 0.0, 0.0 ]; + gfillRows( 'row-major', 2, 2, alpha, X, value ); + }; + } +}); + +tape( 'the function fills rows of `X` with fill values from `alpha` (row-major)', function test( t ) { + var expected; + var alpha; + var out; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gfillRows( 'row-major', 3, 3, alpha, X, 3 ); + + expected = [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0, 30.0, 30.0, 30.0 ]; + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills rows of `X` with fill values from `alpha` (row-major, accessors)', function test( t ) { + var expected; + var alpha; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gfillRows( 'row-major', 3, 3, toAccessorArray( alpha ), toAccessorArray( X ), 3 ); + + expected = [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0, 30.0, 30.0, 30.0 ]; + t.deepEqual( X, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills rows of `X` with fill values from `alpha` (column-major)', function test( t ) { + var expected; + var alpha; + var out; + var X; + + alpha = [ 10.0, 20.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gfillRows( 'column-major', 2, 3, alpha, X, 2 ); + + expected = [ 10.0, 20.0, 10.0, 20.0, 10.0, 20.0 ]; + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills rows of `X` with fill values from `alpha` (column-major, accessors)', function test( t ) { + var expected; + var alpha; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gfillRows( 'column-major', 2, 3, toAccessorArray( alpha ), toAccessorArray( X ), 2 ); + + expected = [ 10.0, 20.0, 10.0, 20.0, 10.0, 20.0 ]; + t.deepEqual( X, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `X` unchanged when `M` or `N` is equal to zero', function test( t ) { + var expected; + var alpha; + var out; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gfillRows( 'column-major', 0, 0, alpha, X, 3 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `X` unchanged when `M` or `N` is equal to zero (accessors)', function test( t ) { + var expected; + var alpha; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gfillRows( 'column-major', 0, 0, toAccessorArray( alpha ), toAccessorArray( X ), 3 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( X, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.ndarray.js new file mode 100644 index 000000000000..2ca3fff52546 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/test/test.ndarray.js @@ -0,0 +1,159 @@ +/** +* @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 toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gfillRows = require( './../lib' ).ndarray; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gfillRows, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function fills rows of `X` with fill values from `alpha` (row-major)', function test( t ) { + var expected; + var alpha; + var out; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gfillRows( 3, 3, alpha, 1, 0, X, 3, 1, 0 ); + + expected = [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0, 30.0, 30.0, 30.0 ]; + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills rows of `X` with fill values from `alpha` (row-major, accessors)', function test( t ) { + var expected; + var alpha; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gfillRows( 3, 3, toAccessorArray( alpha ), 1, 0, toAccessorArray( X ), 3, 1, 0 ); + + expected = [ 10.0, 10.0, 10.0, 20.0, 20.0, 20.0, 30.0, 30.0, 30.0 ]; + t.deepEqual( X, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills rows of `X` with fill values from `alpha` (column-major)', function test( t ) { + var expected; + var alpha; + var out; + var X; + + alpha = [ 10.0, 20.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gfillRows( 2, 3, alpha, 1, 0, X, 1, 2, 0 ); + + expected = [ 10.0, 20.0, 10.0, 20.0, 10.0, 20.0 ]; + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function fills rows of `X` with fill values from `alpha` (column-major, accessors)', function test( t ) { + var expected; + var alpha; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gfillRows( 2, 3, toAccessorArray( alpha ), 1, 0, toAccessorArray( X ), 1, 2, 0 ); + + expected = [ 10.0, 20.0, 10.0, 20.0, 10.0, 20.0 ]; + t.deepEqual( X, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `X` unchanged when `M` or `N` is equal to zero', function test( t ) { + var expected; + var alpha; + var out; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gfillRows( 0, 0, alpha, 1, 0, X, 3, 1, 0 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function leaves `X` unchanged when `M` or `N` is equal to zero (accessors)', function test( t ) { + var expected; + var alpha; + var X; + + alpha = [ 10.0, 20.0, 30.0 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gfillRows( 0, 0, toAccessorArray( alpha ), 1, 0, toAccessorArray( X ), 3, 1, 0 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( X, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `alpha` offset', function test( t ) { + var expected; + var alpha; + var out; + var X; + + alpha = [ 10.0, 20.0, 30 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gfillRows( 2, 3, alpha, 1, 1, X, 1, 2, 0 ); + + expected = [ 20.0, 30.0, 20.0, 30.0, 20.0, 30.0 ]; + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `X` offset', function test( t ) { + var expected; + var alpha; + var out; + var X; + + alpha = [ 10.0, 20.0, 30 ]; + X = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gfillRows( 2, 3, alpha, 1, 1, X, 1, 2, 1 ); + + expected = [ 0.0, 20.0, 30.0, 20.0, 30.0, 20.0, 30.0 ]; + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); From 197eda4e1f7dc966a183d5b448c7df4fc63c7f9e Mon Sep 17 00:00:00 2001 From: Arjan Date: Sun, 9 Aug 2026 12:02:16 +0530 Subject: [PATCH 8/9] bench: add benchmarks for general and ndarray interface --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/gfill-rows/benchmark/benchmark.js | 112 ++++++++++++++++ .../gfill-rows/benchmark/benchmark.ndarray.js | 126 ++++++++++++++++++ 2 files changed, 238 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.js new file mode 100644 index 000000000000..339de4e74d42 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gfillRows = require( './../lib' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var alpha = zeros( N, 'generic' ); + var X = zeros( N*N, 'generic' ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = gfillRows( order, N, N, alpha, X, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..30a47f1dbb3e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.ndarray.js @@ -0,0 +1,126 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var zeros = require( '@stdlib/array/zeros' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gfillRows = require( './../lib' ).ndarray; + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var alpha; + var sx1; + var sx2; + var X; + + alpha = zeros( N, 'generic' ); + X = zeros( N*N, 'generic' ); + + if ( isColumnMajor( order ) ) { + sx1 = 1; + sx2 = N; + } else { // order === 'row-major' + sx1 = N; + sx2 = 1; + } + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = gfillRows( N, N, alpha, 1, 0, X, sx1, sx2, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:ndarray:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); From 7bcfd43a95e622295c27614c58568d655f8ca651 Mon Sep 17 00:00:00 2001 From: Arjan Date: Sun, 9 Aug 2026 12:27:05 +0530 Subject: [PATCH 9/9] bench: change from square matrix to rectangle matrix --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: na - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/gfill-rows/benchmark/benchmark.js | 45 ++++++++++++------- .../gfill-rows/benchmark/benchmark.ndarray.js | 37 +++++++-------- 2 files changed, 47 insertions(+), 35 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.js index 339de4e74d42..bcc14c914b21 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.js @@ -23,8 +23,6 @@ var bench = require( '@stdlib/bench' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var zeros = require( '@stdlib/array/zeros' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var gfillRows = require( './../lib' ); @@ -45,12 +43,23 @@ var LAYOUTS = [ * * @private * @param {string} order - storage layout -* @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} M - number of elements along each row +* @param {PositiveInteger} N - number of elements along each column * @returns {Function} benchmark function */ -function createBenchmark( order, N ) { - var alpha = zeros( N, 'generic' ); - var X = zeros( N*N, 'generic' ); +function createBenchmark( order, M, N ) { + var alpha; + var ldx; + var X; + + if ( order === 'column-major' ) { + ldx = M; + } else { + ldx = N; + } + + alpha = zeros( M, 'generic' ); + X = zeros( M*N, 'generic' ); return benchmark; /** @@ -65,7 +74,7 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = gfillRows( order, N, N, alpha, X, N ); + z = gfillRows( order, M, N, alpha, X, ldx ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } @@ -88,23 +97,25 @@ function createBenchmark( order, N ) { * @private */ function main() { - var min; - var max; + var shapes = [ + [ 10, 100000 ], + [ 100, 10000 ], + [ 1000, 1000 ], + [ 10000, 100 ], + [ 100000, 10 ] + ]; + var shape; var ord; - var N; var f; var i; var k; - min = 1; // 10^min - max = 6; // 10^max - for ( k = 0; k < LAYOUTS.length; k++ ) { ord = LAYOUTS[ k ]; - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - f = createBenchmark( ord, N ); - bench( format( '%s::square_matrix:order=%s,size=%d', pkg, ord, N*N ), f ); + for ( i = 0; i < shapes.length; i++ ) { + shape = shapes[ i ]; + f = createBenchmark( ord, shape[ 0 ], shape[ 1 ] ); + bench( format( '%s::matrix:ndarray:order=%s:M=%d:N=%d:size=%d', pkg, ord, shape[ 0 ], shape[ 1 ], shape[ 0 ] * shape[ 1 ] ), f ); } } } diff --git a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.ndarray.js index 30a47f1dbb3e..d84529815a9b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gfill-rows/benchmark/benchmark.ndarray.js @@ -23,8 +23,6 @@ var bench = require( '@stdlib/bench' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var zeros = require( '@stdlib/array/zeros' ); -var pow = require( '@stdlib/math/base/special/pow' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; @@ -46,21 +44,22 @@ var LAYOUTS = [ * * @private * @param {string} order - storage layout -* @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} M - number of elements along each row +* @param {PositiveInteger} N - number of elements along each column * @returns {Function} benchmark function */ -function createBenchmark( order, N ) { +function createBenchmark( order, M, N ) { var alpha; var sx1; var sx2; var X; - alpha = zeros( N, 'generic' ); - X = zeros( N*N, 'generic' ); + alpha = zeros( M, 'generic' ); + X = zeros( M*N, 'generic' ); if ( isColumnMajor( order ) ) { sx1 = 1; - sx2 = N; + sx2 = M; } else { // order === 'row-major' sx1 = N; sx2 = 1; @@ -79,7 +78,7 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = gfillRows( N, N, alpha, 1, 0, X, sx1, sx2, 0 ); + z = gfillRows( M, N, alpha, 1, 0, X, sx1, sx2, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } @@ -102,23 +101,25 @@ function createBenchmark( order, N ) { * @private */ function main() { - var min; - var max; + var shapes = [ + [ 10, 100000 ], + [ 100, 10000 ], + [ 1000, 1000 ], + [ 10000, 100 ], + [ 100000, 10 ] + ]; + var shape; var ord; - var N; var f; var i; var k; - min = 1; // 10^min - max = 6; // 10^max - for ( k = 0; k < LAYOUTS.length; k++ ) { ord = LAYOUTS[ k ]; - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - f = createBenchmark( ord, N ); - bench( format( '%s::square_matrix:ndarray:order=%s,size=%d', pkg, ord, N*N ), f ); + for ( i = 0; i < shapes.length; i++ ) { + shape = shapes[ i ]; + f = createBenchmark( ord, shape[ 0 ], shape[ 1 ] ); + bench( format( '%s::matrix:ndarray:order=%s:M=%d:N=%d:size=%d', pkg, ord, shape[ 0 ], shape[ 1 ], shape[ 0 ] * shape[ 1 ] ), f ); } } }