From 279d9e027012696593d8d6897af48f9fc7e33dfb Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 11:19:24 +0000 Subject: [PATCH 01/31] feat: add base implementation for iladlr --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/lib/base.js | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js new file mode 100644 index 000000000000..b448fa5c5915 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var max = require( '@stdlib/math/base/special/max' ); + + +// MAIN // + +/** +* Finds the index of the last non zero row in a matrix `A`. +* +* @private +* @param {PositiveInteger} M - number of rows in `A` +* @param {PositiveInteger} N - number of columns in `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - index offset for `A` +* @returns {integer} permuted matrix `A` +* +* @example +* var Float64array = require( '@stdlib/array/float32' ); +* +* var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* +* var out = iladlr( 3, 2, A, 2, 1, 0 ); +* // returns 1 +*/ +function iladlr( M, N, A, strideA1, strideA2, offsetA ) { + var iladlr; + var ia1; + var ia2; + var i; + var j; + + if ( M === 0 || N === 0 ) { + return -1; // Invalid index + } + + ia1 = offsetA + ( (M-1) * strideA1 ); // A( M, 1 ) + ia2 = ia1 + ( (N-1) * strideA2 ); // A( M, N ) + + // Quick test for common case where corners are non-zero: + if ( A[ ia1 ] !== 0.0 || A[ ia2 ] !== 0.0 ) { + return M - 1; + } + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ia1 = offsetA + ( (M-1) * strideA1 ); // Tracks rows + for ( i = M - 1; i >= 0; i-- ) { + ia2 = 0; // Tracks columns + for ( j = 0; j < N; j++ ) { + if ( A[ ia1 + ia2 ] !== 0.0 ) { // Find the last row with a non-zero entry + return i; + } + ia2 += strideA2; + } + ia1 -= strideA1; + } + + // If we reach here, then all entries in the matrix are zero, return -1 (invalid index) + iladlr = -1; + } else { + ia2 = offsetA; // Tracks columns + iladlr = -1; // initialize iladlr, will return -1 (invalid index) if all entries are zero + + for ( j = 0; j < N; j++ ) { + i = M - 1; + ia1 = (M-1) * strideA1; // Tracks rows + while ( A[ ia1 + ia2 ] === 0.0 && i >= 0 ) { + i -= 1; + ia1 -= strideA1; + } + iladlr = max( i, iladlr ); + ia2 += strideA2; + } + } + + return iladlr; +} + + +// EXPORTS // + +module.exports = iladlr; From 7da1c238686f3fbc06c556dae7a5ee5cb50bc61d Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 11:35:46 +0000 Subject: [PATCH 02/31] feat: complete writing main implementation --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/lib/base.js | 6 +- .../@stdlib/lapack/base/iladlr/lib/iladlr.js | 76 +++++++++++++++++++ .../@stdlib/lapack/base/iladlr/lib/index.js | 57 ++++++++++++++ .../@stdlib/lapack/base/iladlr/lib/main.js | 35 +++++++++ .../@stdlib/lapack/base/iladlr/lib/ndarray.js | 54 +++++++++++++ 5 files changed, 225 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js index b448fa5c5915..b93936452901 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -36,10 +36,10 @@ var max = require( '@stdlib/math/base/special/max' ); * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` -* @returns {integer} permuted matrix `A` +* @returns {integer} index of the last row * * @example -* var Float64array = require( '@stdlib/array/float32' ); +* var Float64array = require( '@stdlib/array/float64' ); * * var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] * diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js new file mode 100644 index 000000000000..7078741d6398 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js @@ -0,0 +1,76 @@ +/** +* @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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. +* +* @param {string} order - storage layout +* @param {PositiveInteger} M - number of rows in `A` +* @param {PositiveInteger} N - number of columns in `A` +* @param {Float64Array} 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} fifth argument must be greater than or equal to max(1,N) +* @returns {integer} index of the last row +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* +* var out = iladlr( 'row-major', 3, 2, A, 2 ); +* // returns 1 +*/ +function iladlr( order, M, N, A, LDA ) { + var sa1; + var sa2; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isRowMajor( order ) && LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( M, N, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = iladlr; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/index.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/index.js new file mode 100644 index 000000000000..e186b0bf9b63 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/index.js @@ -0,0 +1,57 @@ +/** +* @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'; + +/** +* LAPACK routine to find the index of the last non zero row in a input matrix. +* +* @module @stdlib/lapack/base/iladlr +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* var iladlr = require( '@stdlib/lapack/base/iladlr' ); +* +* var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* +* var out = iladlr( 'row-major', 3, 2, A, 2 ); +* // returns 1 +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var iladlr; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + iladlr = main; +} else { + iladlr = tmp; +} + + +// EXPORTS // + +module.exports = iladlr; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/main.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/main.js new file mode 100644 index 000000000000..9984e10eee17 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/main.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var iladlr = require( './iladlr.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( iladlr, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = iladlr; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js new file mode 100644 index 000000000000..d2dcffe49f40 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js @@ -0,0 +1,54 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Finds the index of the last non zero row in a matrix `A`. +* +* @param {PositiveInteger} M - number of rows in `A` +* @param {PositiveInteger} N - number of columns in `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - index offset for `A` +* @returns {integer} index of the last row +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* +* var out = iladlr( 3, 2, A, 2, 1, 0 ); +* // returns 1 +*/ +function iladlr( M, N, A, strideA1, strideA2, offsetA ) { + return base( M, N, A, strideA1, strideA2, offsetA ); +} + + +// EXPORTS // + +module.exports = iladlr; From cfa7d5710127cb724759061fd49bb2ff49a66724 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 16:54:42 +0000 Subject: [PATCH 03/31] test: add basic tests --- .../iladlr/test/fixtures/column_major.json | 16 ++ .../test/fixtures/column_major_zeros.json | 16 ++ .../fixtures/large_strides/column_major.json | 29 +++ .../large_strides/column_major_zeros.json | 29 +++ .../fixtures/large_strides/row_major.json | 29 +++ .../large_strides/row_major_zeros.json | 29 +++ .../fixtures/mixed_strides/column_major.json | 23 +++ .../mixed_strides/column_major_zeros.json | 23 +++ .../fixtures/mixed_strides/row_major.json | 23 +++ .../mixed_strides/row_major_zeros.json | 23 +++ .../negative_strides/column_major.json | 23 +++ .../negative_strides/column_major_zeros.json | 23 +++ .../fixtures/negative_strides/row_major.json | 23 +++ .../negative_strides/row_major_zeros.json | 23 +++ .../test/fixtures/offsets/column_major.json | 24 +++ .../fixtures/offsets/column_major_zeros.json | 24 +++ .../test/fixtures/offsets/row_major.json | 24 +++ .../fixtures/offsets/row_major_zeros.json | 24 +++ .../base/iladlr/test/fixtures/row_major.json | 16 ++ .../iladlr/test/fixtures/row_major_zeros.json | 16 ++ .../lapack/base/iladlr/test/test.iladlr.js | 170 ++++++++++++++++ .../@stdlib/lapack/base/iladlr/test/test.js | 82 ++++++++ .../lapack/base/iladlr/test/test.ndarray.js | 181 ++++++++++++++++++ 23 files changed, 893 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/column_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/row_major_zeros.json create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/column_major.json new file mode 100644 index 000000000000..8fac692d36b4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/column_major.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "A": [ 1.0, 2.0, 0.0, 3.0, 4.0, 0.0 ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/column_major_zeros.json new file mode 100644 index 000000000000..73ca6f93970e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/column_major_zeros.json @@ -0,0 +1,16 @@ +{ + "order": "column-major", + "A": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major.json new file mode 100644 index 000000000000..afb7194fcaee --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major.json @@ -0,0 +1,29 @@ +{ + "order": "column-major", + "A": [ + 1, + 9999.0, + 2, + 9999.0, + 0.0, + 9999.0, + 3, + 9999.0, + 4, + 9999.0, + 0.0, + 9999.0 + ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major_zeros.json new file mode 100644 index 000000000000..1881676dae6e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major_zeros.json @@ -0,0 +1,29 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major.json new file mode 100644 index 000000000000..0a88f19e7ce8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major.json @@ -0,0 +1,29 @@ +{ + "order": "row-major", + "A": [ + 1, + 9999.0, + 2, + 9999.0, + 3, + 9999.0, + 4, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 3, + "N": 2, + "strideA1": 4, + "strideA2": 2, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major_zeros.json new file mode 100644 index 000000000000..50416c75b12b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major_zeros.json @@ -0,0 +1,29 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "M": 3, + "N": 2, + "strideA1": 4, + "strideA2": 2, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major.json new file mode 100644 index 000000000000..1ff87cbf0e1a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major.json @@ -0,0 +1,23 @@ +{ + "order": "column-major", + "A": [ + 3, + 4, + 0.0, + 1, + 2, + 0 + ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": -3, + "offsetA": 3, + "LDA": 3, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major_zeros.json new file mode 100644 index 000000000000..d8af7823044b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major_zeros.json @@ -0,0 +1,23 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": -3, + "offsetA": 3, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major.json new file mode 100644 index 000000000000..063baf28a7d7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major.json @@ -0,0 +1,23 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 3, + 4, + 1, + 2 + ], + "M": 3, + "N": 2, + "strideA1": -2, + "strideA2": 1, + "offsetA": 4, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major_zeros.json new file mode 100644 index 000000000000..cf2d9d05f366 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major_zeros.json @@ -0,0 +1,23 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": -2, + "strideA2": 1, + "offsetA": 4, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major.json new file mode 100644 index 000000000000..706e93e057d0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major.json @@ -0,0 +1,23 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 4, + 3, + 0.0, + 2, + 1 + ], + "M": 3, + "N": 2, + "strideA1": -1, + "strideA2": -3, + "offsetA": 5, + "LDA": 3, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major_zeros.json new file mode 100644 index 000000000000..66c579cd6072 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major_zeros.json @@ -0,0 +1,23 @@ +{ + "order": "column-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": -1, + "strideA2": -3, + "offsetA": 5, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major.json new file mode 100644 index 000000000000..610c4ba73896 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major.json @@ -0,0 +1,23 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 4, + 3, + 2, + 1 + ], + "M": 3, + "N": 2, + "strideA1": -2, + "strideA2": -1, + "offsetA": 5, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major_zeros.json new file mode 100644 index 000000000000..54f0db891e33 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major_zeros.json @@ -0,0 +1,23 @@ +{ + "order": "row-major", + "A": [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ], + "M": 3, + "N": 2, + "strideA1": -2, + "strideA2": -1, + "offsetA": 5, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major.json new file mode 100644 index 000000000000..141812b58ae7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major.json @@ -0,0 +1,24 @@ +{ + "order": "column-major", + "A": [ + 9999.0, + 1, + 2, + 0.0, + 3, + 4, + 0 + ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "LDA": 3, + "A_mat": [ + [ 1.0, 3.0 ], + [ 2.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major_zeros.json new file mode 100644 index 000000000000..8b9eaaad1797 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major_zeros.json @@ -0,0 +1,24 @@ +{ + "order": "column-major", + "A": [ + 9999.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0 + ], + "M": 3, + "N": 2, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "LDA": 3, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major.json new file mode 100644 index 000000000000..bc6d4b6b378b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major.json @@ -0,0 +1,24 @@ +{ + "order": "row-major", + "A": [ + 9999.0, + 1, + 2, + 3, + 4, + 0.0, + 0 + ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 1, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major_zeros.json new file mode 100644 index 000000000000..82c4e120b470 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major_zeros.json @@ -0,0 +1,24 @@ +{ + "order": "row-major", + "A": [ + 9999.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0 + ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 1, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/row_major.json new file mode 100644 index 000000000000..cb56f8bee2e4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/row_major.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "A": [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ], + "expected": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/row_major_zeros.json new file mode 100644 index 000000000000..20eceeaad571 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/row_major_zeros.json @@ -0,0 +1,16 @@ +{ + "order": "row-major", + "A": [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], + "M": 3, + "N": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "LDA": 2, + "A_mat": [ + [ 0.0, 0.0 ], + [ 0.0, 0.0 ], + [ 0.0, 0.0 ] + ], + "expected": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js new file mode 100644 index 000000000000..7deb3fdc4f92 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js @@ -0,0 +1,170 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var iladlr = require( './../lib/iladlr.js' ); + + +// FIXTURES // + +var ROW_MAJOR_DATA = require( './fixtures/row_major.json' ); +var ROW_MAJOR_ZEROS = require( './fixtures/row_major_zeros.json' ); +var COLUMN_MAJOR_DATA = require( './fixtures/column_major.json' ); +var COLUMN_MAJOR_ZEROS = require( './fixtures/column_major_zeros.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof iladlr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( iladlr.length, 5, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var data; + var A; + var i; + + data = ROW_MAJOR_DATA; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( data.A ); + + 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() { + iladlr( value, data.M, data.N, A, data.LDA ); + }; + } +}); + +tape( 'the function throws an error if provided a fourth argument which is not a valid `LDA` value (row-major)', function test( t ) { + var values; + var data; + var A; + var i; + + data = ROW_MAJOR_DATA; + + values = [ + 0, + 1 + ]; + + A = new Float64Array( data.A ); + + 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() { + iladlr( data.order, data.M, data.N, A, value ); + }; + } +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.order, data.M, data.N, A, data.LDA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.order, data.M, data.N, A, data.LDA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.order, data.M, data.N, A, data.LDA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.order, data.M, data.N, A, data.LDA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js new file mode 100644 index 000000000000..91d2b8a57e4f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var iladlr = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof iladlr, '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 iladlr.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var iladlr = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( iladlr, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var iladlr; + var main; + + main = require( './../lib/iladlr.js' ); + + iladlr = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( iladlr, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js new file mode 100644 index 000000000000..7473d77f5a25 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js @@ -0,0 +1,181 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, id-length */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var iladlr = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var ROW_MAJOR_DATA = require( './fixtures/row_major.json' ); +var ROW_MAJOR_ZEROS = require( './fixtures/row_major_zeros.json' ); +var COLUMN_MAJOR_DATA = require( './fixtures/column_major.json' ); +var COLUMN_MAJOR_ZEROS = require( './fixtures/column_major_zeros.json' ); + +var OFFSET_ROW_MAJOR_DATA = require( './fixtures/offsets/row_major.json' ); +var OFFSET_ROW_MAJOR_ZEROS = require( './fixtures/offsets/row_major_zeros.json' ); +var OFFSET_COLUMN_MAJOR_DATA = require( './fixtures/offsets/column_major.json' ); +var OFFSET_COLUMN_MAJOR_ZEROS = require( './fixtures/offsets/column_major_zeros.json' ); + +var NEGATIVE_STRIDES_ROW_MAJOR_DATA = require( './fixtures/negative_strides/row_major.json' ); +var NEGATIVE_STRIDES_ROW_MAJOR_ZEROS = require( './fixtures/negative_strides/row_major_zeros.json' ); +var NEGATIVE_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/negative_strides/column_major.json' ); +var NEGATIVE_STRIDES_COLUMN_MAJOR_ZEROS = require( './fixtures/negative_strides/column_major_zeros.json' ); + +var MIXED_STRIDES_ROW_MAJOR_DATA = require( './fixtures/mixed_strides/row_major.json' ); +var MIXED_STRIDES_ROW_MAJOR_ZEROS = require( './fixtures/mixed_strides/row_major_zeros.json' ); +var MIXED_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/mixed_strides/column_major.json' ); +var MIXED_STRIDES_COLUMN_MAJOR_ZEROS = require( './fixtures/mixed_strides/column_major_zeros.json' ); + +var LARGE_STRIDES_ROW_MAJOR_DATA = require( './fixtures/large_strides/row_major.json' ); +var LARGE_STRIDES_ROW_MAJOR_ZEROS = require( './fixtures/large_strides/row_major_zeros.json' ); +var LARGE_STRIDES_COLUMN_MAJOR_DATA = require( './fixtures/large_strides/column_major.json' ); +var LARGE_STRIDES_COLUMN_MAJOR_ZEROS = require( './fixtures/large_strides/column_major_zeros.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof iladlr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( iladlr.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major)', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major)', function test( t ) { + var data; + var out; + var A; + + data = COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); From 1a5ea04e39979a767eb73b0f3434530da7997661 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 16:57:05 +0000 Subject: [PATCH 04/31] test: add offset tests --- .../lapack/base/iladlr/test/test.ndarray.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js index 7473d77f5a25..5ca2f46e0e6b 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js @@ -124,12 +124,12 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major) (offsets)', function test( t ) { var data; var out; var A; - data = ROW_MAJOR_DATA; + data = OFFSET_ROW_MAJOR_DATA; A = new Float64Array( data.A ); out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); @@ -138,12 +138,12 @@ tape( 'the function returns the expected zero based index of the last non zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major) (offsets)', function test( t ) { var data; var out; var A; - data = COLUMN_MAJOR_DATA; + data = OFFSET_COLUMN_MAJOR_DATA; A = new Float64Array( data.A ); out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); @@ -152,12 +152,12 @@ tape( 'the function returns the expected zero based index of the last non zero r t.end(); }); -tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major)', function test( t ) { +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major) (offsets)', function test( t ) { var data; var out; var A; - data = ROW_MAJOR_ZEROS; + data = OFFSET_ROW_MAJOR_ZEROS; A = new Float64Array( data.A ); out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); @@ -166,12 +166,12 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major)', function test( t ) { +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major) (offsets)', function test( t ) { var data; var out; var A; - data = COLUMN_MAJOR_ZEROS; + data = OFFSET_COLUMN_MAJOR_ZEROS; A = new Float64Array( data.A ); out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); From 0247c51e1b206e2a5abe12d74d12a31d78b47ed3 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 17:00:47 +0000 Subject: [PATCH 05/31] test: add mixed strides tests --- .../lapack/base/iladlr/test/test.ndarray.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js index 5ca2f46e0e6b..33722500f496 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js @@ -179,3 +179,59 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.deepEqual( out, data.expected, 'returns expected value' ); t.end(); }); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major) (mixed strides)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major) (mixed strides)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major) (mixed strides)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major) (mixed strides)', function test( t ) { + var data; + var out; + var A; + + data = MIXED_STRIDES_COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); From d65d7182c8d7342e3b73485987a52ef7c1038175 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 17:02:10 +0000 Subject: [PATCH 06/31] test: add tests for negative strides --- .../lapack/base/iladlr/test/test.ndarray.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js index 33722500f496..85facb5cdf3b 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js @@ -235,3 +235,59 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.deepEqual( out, data.expected, 'returns expected value' ); t.end(); }); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major) (negative strides)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major) (negative strides)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major) (negative strides)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major) (negative strides)', function test( t ) { + var data; + var out; + var A; + + data = NEGATIVE_STRIDES_COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); From cd0f59a70dc213cb1f5767a5e5117774b01df915 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 17:03:29 +0000 Subject: [PATCH 07/31] test: add large strides --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/iladlr/test/test.ndarray.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js index 85facb5cdf3b..a6415b20e5df 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js @@ -291,3 +291,59 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.deepEqual( out, data.expected, 'returns expected value' ); t.end(); }); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major) (large strides)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major) (large strides)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_COLUMN_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (row-major) (large strides)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_ROW_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when all elements in a matrix are zero (column-major) (large strides)', function test( t ) { + var data; + var out; + var A; + + data = LARGE_STRIDES_COLUMN_MAJOR_ZEROS; + + A = new Float64Array( data.A ); + out = iladlr( data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + + t.deepEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); From 6bb91d923c7320dd3e95a342ef60de8f7e0e45ed Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 17:04:07 +0000 Subject: [PATCH 08/31] chore: copyright years --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/test/test.iladlr.js | 4 +--- lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js | 2 +- .../@stdlib/lapack/base/iladlr/test/test.ndarray.js | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js index 7deb3fdc4f92..671406cb7cb1 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable max-len */ - 'use strict'; // MODULES // diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js index 91d2b8a57e4f..a9c5f6fa1872 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js index a6415b20e5df..ae3260385692 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. From a5c4abd538d77468e94b3306515c8290f6e6feaa Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 17:07:42 +0000 Subject: [PATCH 09/31] chore: formatting fixtures json --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../test/fixtures/large_strides/column_major.json | 6 +++--- .../iladlr/test/fixtures/large_strides/row_major.json | 8 ++++---- .../test/fixtures/mixed_strides/column_major.json | 10 +++++----- .../iladlr/test/fixtures/mixed_strides/row_major.json | 8 ++++---- .../test/fixtures/negative_strides/column_major.json | 8 ++++---- .../test/fixtures/negative_strides/row_major.json | 8 ++++---- .../iladlr/test/fixtures/offsets/column_major.json | 10 +++++----- .../test/fixtures/offsets/column_major_zeros.json | 2 +- .../base/iladlr/test/fixtures/offsets/row_major.json | 10 +++++----- .../iladlr/test/fixtures/offsets/row_major_zeros.json | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major.json index afb7194fcaee..1dac55f33884 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/column_major.json @@ -3,13 +3,13 @@ "A": [ 1, 9999.0, - 2, + 2.0, 9999.0, 0.0, 9999.0, - 3, + 3.0, 9999.0, - 4, + 4.0, 9999.0, 0.0, 9999.0 diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major.json index 0a88f19e7ce8..e00599ebd71e 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/large_strides/row_major.json @@ -1,13 +1,13 @@ { "order": "row-major", "A": [ - 1, + 1.0, 9999.0, - 2, + 2.0, 9999.0, - 3, + 3.0, 9999.0, - 4, + 4.0, 9999.0, 0.0, 9999.0, diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major.json index 1ff87cbf0e1a..a07752170cac 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/column_major.json @@ -1,12 +1,12 @@ { "order": "column-major", "A": [ - 3, - 4, + 3.0, + 4.0, 0.0, - 1, - 2, - 0 + 1.0, + 2.0, + 0.0 ], "M": 3, "N": 2, diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major.json index 063baf28a7d7..1b4459caead4 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/mixed_strides/row_major.json @@ -3,10 +3,10 @@ "A": [ 0.0, 0.0, - 3, - 4, - 1, - 2 + 3.0, + 4.0, + 1.0, + 2.0 ], "M": 3, "N": 2, diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major.json index 706e93e057d0..367b7894d378 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/column_major.json @@ -2,11 +2,11 @@ "order": "column-major", "A": [ 0.0, - 4, - 3, + 4.0, + 3.0, 0.0, - 2, - 1 + 2.0, + 1.0 ], "M": 3, "N": 2, diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major.json index 610c4ba73896..839439058755 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/negative_strides/row_major.json @@ -3,10 +3,10 @@ "A": [ 0.0, 0.0, - 4, - 3, - 2, - 1 + 4.0, + 3.0, + 2.0, + 1.0 ], "M": 3, "N": 2, diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major.json index 141812b58ae7..0596ba5e7b81 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major.json @@ -2,12 +2,12 @@ "order": "column-major", "A": [ 9999.0, - 1, - 2, + 1.0, + 2.0, 0.0, - 3, - 4, - 0 + 3.0, + 4.0, + 0.0 ], "M": 3, "N": 2, diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major_zeros.json index 8b9eaaad1797..59b9a8f46fc3 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major_zeros.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/column_major_zeros.json @@ -7,7 +7,7 @@ 0.0, 0.0, 0.0, - 0 + 0.0 ], "M": 3, "N": 2, diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major.json index bc6d4b6b378b..b9507f8e23c4 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major.json @@ -2,12 +2,12 @@ "order": "row-major", "A": [ 9999.0, - 1, - 2, - 3, - 4, + 1.0, + 2.0, + 3.0, + 4.0, 0.0, - 0 + 0.0 ], "M": 3, "N": 2, diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major_zeros.json b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major_zeros.json index 82c4e120b470..fb91d1f7908b 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major_zeros.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/fixtures/offsets/row_major_zeros.json @@ -7,7 +7,7 @@ 0.0, 0.0, 0.0, - 0 + 0.0 ], "M": 3, "N": 2, From 942993049d729a4158eaad4fd8f4db689f9cc8ea Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 19:06:57 +0000 Subject: [PATCH 10/31] test: more tests --- 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 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: 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/iladlr/examples/index.js | 34 +++++++++++++++++++ .../lapack/base/iladlr/test/test.iladlr.js | 28 +++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/examples/index.js diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/examples/index.js b/lib/node_modules/@stdlib/lapack/base/iladlr/examples/index.js new file mode 100644 index 000000000000..9aa4f6f652ed --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var iladlr = require( './../lib' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0, 0.0 ] ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var out = iladlr( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js index 671406cb7cb1..73a3524a5227 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js @@ -111,6 +111,34 @@ tape( 'the function throws an error if provided a fourth argument which is not a } }); +tape( 'the function returns an invalid index (-1) when M is zero', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.order, 0, data.N, A, data.LDA ); + + t.deepEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns an invalid index (-1) when N is zero', function test( t ) { + var data; + var out; + var A; + + data = ROW_MAJOR_DATA; + + A = new Float64Array( data.A ); + out = iladlr( data.order, data.M, 0, A, data.LDA ); + + t.deepEqual( out, -1, 'returns expected value' ); + t.end(); +}); + tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major)', function test( t ) { var data; var out; From 2b55f10ba0685e8157146e841a94796a298af626 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 19:15:25 +0000 Subject: [PATCH 11/31] bench: add benchmarks --- 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 status: na - task: lint_package_json status: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/iladlr/benchmark/benchmark.js | 114 ++++++++++++++++ .../iladlr/benchmark/benchmark.ndarray.js | 125 ++++++++++++++++++ .../@stdlib/lapack/base/iladlr/package.json | 72 ++++++++++ 3 files changed, 311 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/package.json diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js new file mode 100644 index 000000000000..cf0718ee01c2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js @@ -0,0 +1,114 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var iladlr = require( './../lib/iladlr.js' ); + + +// 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 A; + + A = discreteUniform( N*N, 0.0, 1.0, { + 'dtype': 'float64' + }); + 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 = iladlr( order, N, N, A, N ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + 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( pkg+'::square_matrix:order='+ord+',size='+(N*N), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..c7d3afef1c1b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js @@ -0,0 +1,125 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var pkg = require( './../package.json' ).name; +var iladlr = require( './../lib/iladlr.js' ); + + +// 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 A; + + A = discreteUniform( N*N, 0.0, 1.0, { + 'dtype': 'float64' + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var sa1; + var sa2; + var z; + var i; + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = iladlr( order, N, N, A, sa1, sa2, 0 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + 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( pkg+'::square_matrix:order='+ord+',size='+(N*N), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/package.json b/lib/node_modules/@stdlib/lapack/base/iladlr/package.json new file mode 100644 index 000000000000..6b09dc700903 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/lapack/base/iladlr", + "version": "0.0.0", + "description": "LAPACK routine to find the index of the last non zero row in a input matrix.", + "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", + "lapack", + "iladlr", + "last", + "row", + "index", + "matrix", + "auxilary", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} From da8c58095f84cacba4fc79d0c37ab34bc21bdb9f Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 19:26:38 +0000 Subject: [PATCH 12/31] docs: add ts declaration file --- 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 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: na - task: lint_license_headers status: passed --- --- .../lapack/base/iladlr/docs/types/index.d.ts | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts new file mode 100644 index 000000000000..c83f29cd1c20 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts @@ -0,0 +1,101 @@ +/* +* @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 { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `iladlr`. +*/ +interface Routine { + /** + * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. + * + * @param order - storage layout + * @param M - number of rows in `A` + * @param N - number of columns in `A` + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @returns index of the last row + * + * @example + * var Float64array = require( '@stdlib/array/float64' ); + * + * var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] + * + * var out = iladlr( 'row-major', 3, 2, A, 2 ); + * // returns 1 + */ + ( order: Layout, M: number, N: number, A: Float64Array, LDA: number ): number; + + /** + * Finds the index of the last non zero row in a matrix `A`. + * + * @param M - number of rows in `A` + * @param N - number of columns in `A` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @returns index of the last row + * + * @example + * var Float64array = require( '@stdlib/array/float64' ); + * + * var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] + * + * var out = iladlr.ndarray( 3, 2, A, 2, 1, 0 ); + * // returns 1 + */ + ndarray( M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): number; +} + +/** +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. +* +* @param order - storage layout +* @param M - number of rows in `A` +* @param N - number of columns in `A` +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @returns index of the last row +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* +* var out = iladlr( 'row-major', 3, 2, A, 2 ); +* // returns 1 +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* +* var out = iladlr.ndarray( 3, 2, A, 2, 1, 0 ); +* // returns 1 +*/ +declare var iladlr: Routine; + + +// EXPORTS // + +export = iladlr; From b21fcc4bb08c8f2e4b79466a809a436018e02c30 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 19:53:47 +0000 Subject: [PATCH 13/31] docs: add test.ts --- 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 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: na - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../lapack/base/iladlr/docs/types/test.ts | 213 ++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/test.ts new file mode 100644 index 000000000000..cc1b35f47869 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/test.ts @@ -0,0 +1,213 @@ +/* +* @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 iladlr = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = new Float64Array( 4 ); + + iladlr( 'row-major', 2, 2, A, 2 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( 4 ); + + iladlr( 5, 2, 2, A, 2 ); // $ExpectError + iladlr( true, 2, 2, A, 2 ); // $ExpectError + iladlr( false, 2, 2, A, 2 ); // $ExpectError + iladlr( null, 2, 2, A, 2 ); // $ExpectError + iladlr( void 0, 2, 2, A, 2 ); // $ExpectError + iladlr( [], 2, 2, A, 2 ); // $ExpectError + iladlr( {}, 2, 2, A, 2 ); // $ExpectError + iladlr( ( x: number ): number => x, 2, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( 4 ); + + iladlr( 'row-major', '5', 2, A, 2 ); // $ExpectError + iladlr( 'row-major', true, 2, A, 2 ); // $ExpectError + iladlr( 'row-major', false, 2, A, 2 ); // $ExpectError + iladlr( 'row-major', null, 2, A, 2 ); // $ExpectError + iladlr( 'row-major', void 0, 2, A, 2 ); // $ExpectError + iladlr( 'row-major', [], 2, A, 2 ); // $ExpectError + iladlr( 'row-major', {}, 2, A, 2 ); // $ExpectError + iladlr( 'row-major', ( x: number ): number => x, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( 4 ); + + iladlr( 'row-major', 2, '5', A, 2 ); // $ExpectError + iladlr( 'row-major', 2, true, A, 2 ); // $ExpectError + iladlr( 'row-major', 2, false, A, 2 ); // $ExpectError + iladlr( 'row-major', 2, null, A, 2 ); // $ExpectError + iladlr( 'row-major', 2, void 0, A, 2 ); // $ExpectError + iladlr( 'row-major', 2, [], A, 2 ); // $ExpectError + iladlr( 'row-major', 2, {}, A, 2 ); // $ExpectError + iladlr( 'row-major', 2, ( x: number ): number => x, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + iladlr( 'row-major', 2, 2, '5', 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, 5, 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, true, 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, false, 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, null, 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, void 0, 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, [], 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, {}, 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 4 ); + + iladlr( 'row-major', 2, 2, A, '5' ); // $ExpectError + iladlr( 'row-major', 2, 2, A, true ); // $ExpectError + iladlr( 'row-major', 2, 2, A, false ); // $ExpectError + iladlr( 'row-major', 2, 2, A, null ); // $ExpectError + iladlr( 'row-major', 2, 2, A, void 0 ); // $ExpectError + iladlr( 'row-major', 2, 2, A, [] ); // $ExpectError + iladlr( 'row-major', 2, 2, A, {} ); // $ExpectError + iladlr( 'row-major', 2, 2, A, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( 4 ); + + iladlr(); // $ExpectError + iladlr( 'row-major' ); // $ExpectError + iladlr( 'row-major', 2 ); // $ExpectError + iladlr( 'row-major', 2, 2 ); // $ExpectError + iladlr( 'row-major', 2, 2, A ); // $ExpectError + iladlr( 'row-major', 2, 2, A, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const A = new Float64Array( 4 ); + + iladlr.ndarray( 2, 2, A, 2, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const A = new Float64Array( 4 ); + + iladlr.ndarray( '5', 2, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( true, 2, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( false, 2, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( null, 2, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( void 0, 2, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( [], 2, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( {}, 2, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( ( x: number ): number => x, 2, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( 4 ); + + iladlr.ndarray( 2, '5', A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, true, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, false, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, null, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, void 0, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, [], A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, {}, A, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, ( x: number ): number => x, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + iladlr.ndarray( 2, 2, '5', 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, 5, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, true, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, false, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, null, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, void 0, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, [], 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, {}, 2, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 4 ); + + iladlr.ndarray( 2, 2, A, '5', 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, true, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, false, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, null, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, void 0, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, [], 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, {}, 1, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 4 ); + + iladlr.ndarray( 2, 2, A, 2, '5', 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, true, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, false, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, null, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, void 0, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, [], 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, {}, 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 4 ); + + iladlr.ndarray( 2, 2, A, 2, 1, '5' ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1, true ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1, false ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1, null ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1, void 0 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1, [] ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1, {} ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments (6-argument version)... +{ + const A = new Float64Array( 4 ); + + iladlr.ndarray(); // $ExpectError + iladlr.ndarray( 2 ); // $ExpectError + iladlr.ndarray( 2, 2 ); // $ExpectError + iladlr.ndarray( 2, 2, A ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1 ); // $ExpectError + iladlr.ndarray( 2, 2, A, 2, 1, 0, 10 ); // $ExpectError +} From 8fe0be2b20c5487589c6e852915ba253f45a1183 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 20:20:23 +0000 Subject: [PATCH 14/31] docs: add REAMDE --- 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 status: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/README.md | 261 ++++++++++++++++++ .../@stdlib/lapack/base/iladlr/lib/ndarray.js | 2 +- 2 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/README.md diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/README.md b/lib/node_modules/@stdlib/lapack/base/iladlr/README.md new file mode 100644 index 000000000000..f25be116aaf0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/README.md @@ -0,0 +1,261 @@ + + +# iladlr + +> Find the index of the last non zero row in a matrix `A` + +
+ +## Usage + +```javascript +var iladlr = require( '@stdlib/lapack/base/iladlr' ); +``` + +#### iladlr( order, M, N, A, LDA ) + +Finds the index of the last non zero row in a matrix `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + +/* + A = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ] +*/ + +var out = iladlr( 'row-major', 3, 2, A, 2 ); +// returns 1 +``` + +The function has the following parameters: + +- **order**: storage layout. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var A0 = new Float64Array( [ 9999.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = iladlr( 'row-major', 3, 2, A1, 2 ); +// returns 1 +``` + +#### iladlr.ndarray( uplo, M, N, A, sa1, sa2, oa, B, sb1, sb2, ob ) + +Finds the index of the last non zero row in a matrix `A` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + +/* + A = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ] +*/ + +var out = iladlr.ndarray( 3, 2, A, 2, 1, 0 ); +// returns 1 +``` + +The function has the following parameters: + +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 9999.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); + +/* + A = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 0.0, 0.0 ] + ] +*/ + +var out = iladlr.ndarray( 3, 2, A, 2, 1, 1 ); +// returns 1 +``` + +
+ + + +
+ +## Notes + +- `iladlr()` corresponds to the [LAPACK][lapack] routine [`iladlr`][lapack-iladlr]. + +
+ + + +
+ +## Examples + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var iladlr = require( '@stdlib/lapack/base/iladlr' ); + +var shape = [ 3, 3 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 0.0, 0.0, 0.0 ] ); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var out = iladlr( order, shape[ 0 ], shape[ 1 ], A, strides[ 0 ] ); +console.log( out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js index d2dcffe49f40..71852d222dd9 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js @@ -26,7 +26,7 @@ var base = require( './base.js' ); // MAIN // /** -* Finds the index of the last non zero row in a matrix `A`. +* Finds the index of the last non zero row in a matrix `A` using alternative indexing semantics. * * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` From d2707a89e74bdaf230f488a5e0a7d7c4d2951fd1 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 20:40:24 +0000 Subject: [PATCH 15/31] docs: add repl.txt --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - 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: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/docs/repl.txt | 75 +++++++++++++++++++ .../lapack/base/iladlr/docs/types/index.d.ts | 6 +- 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt new file mode 100644 index 000000000000..a7fe8cb70383 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt @@ -0,0 +1,75 @@ + +{{alias}}( order, M, N, A, LDA ) + Finds the index of the last non zero row in a matrix `A`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Float64Array + Input matrix `A`. + + Returns + ------- + iladlr: integer + Zero based index of the last non-zero row. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 2, 2, A, 2 ) + 1 + + +{{alias}}.ndarray( M, N, A, sa1, sa2, oa ) + Finds the index of the last non zero row in a matrix `A` using alternative + indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Float64Array + Input matrix `A`. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + Returns + ------- + iladlr: integer + Zero based index of the last non-zero row. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( 2, 2, A, 2, 1, 0 ) + 1 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts index c83f29cd1c20..fa4d95a095ed 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts @@ -27,7 +27,7 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. + * Finds the index of the last non zero row in a matrix `A`. * * @param order - storage layout * @param M - number of rows in `A` @@ -47,7 +47,7 @@ interface Routine { ( order: Layout, M: number, N: number, A: Float64Array, LDA: number ): number; /** - * Finds the index of the last non zero row in a matrix `A`. + * Finds the index of the last non zero row in a matrix `A` using alternative indexing semantics. * * @param M - number of rows in `A` * @param N - number of columns in `A` @@ -68,7 +68,7 @@ interface Routine { } /** -* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. +* Finds the index of the last non zero row in a matrix `A`. * * @param order - storage layout * @param M - number of rows in `A` From 6a1e297d16177bd58a6e6f1f0961879e74b804a0 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 23 May 2025 20:42:02 +0000 Subject: [PATCH 16/31] chore: copyright years --- 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 status: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/iladlr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/README.md b/lib/node_modules/@stdlib/lapack/base/iladlr/README.md index f25be116aaf0..95f007cb390e 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/README.md +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +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. From 00bfabde710d9e792ccf5db4bdc40916d86ff37e Mon Sep 17 00:00:00 2001 From: Aayush Khanna <96649223+aayush0325@users.noreply.github.com> Date: Mon, 26 May 2025 02:28:45 +0530 Subject: [PATCH 17/31] docs: update description --- .../@stdlib/lapack/base/iladlr/docs/types/index.d.ts | 6 +++--- lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts index fa4d95a095ed..43d7d6502b98 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts @@ -34,7 +34,7 @@ interface Routine { * @param N - number of columns in `A` * @param A - input matrix * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) - * @returns index of the last row + * @returns index of the last non zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); @@ -54,7 +54,7 @@ interface Routine { * @param A - input matrix * @param strideA1 - stride of the first dimension of `A` * @param strideA2 - stride of the second dimension of `A` - * @returns index of the last row + * @returns index of the last non zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); @@ -75,7 +75,7 @@ interface Routine { * @param N - number of columns in `A` * @param A - input matrix * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @returns index of the last row +* @returns index of the last non zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js index 7078741d6398..937d9d7ea883 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js @@ -31,7 +31,7 @@ var base = require( './base.js' ); // MAIN // /** -* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. +* Finds the index of the last non zero row in a matrix `A`. * * @param {string} order - storage layout * @param {PositiveInteger} M - number of rows in `A` @@ -40,7 +40,7 @@ var base = require( './base.js' ); * @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} fifth argument must be greater than or equal to max(1,N) -* @returns {integer} index of the last row +* @returns {integer} index of the last non zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); From 3d91f56a6d679613fafaefe96c7b34a1e03d4f7a Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 19:59:46 +0000 Subject: [PATCH 18/31] refactor: cleanup --- 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 status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: 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 --- --- .../@stdlib/lapack/base/iladlr/README.md | 6 ++-- .../@stdlib/lapack/base/iladlr/docs/repl.txt | 4 +-- .../lapack/base/iladlr/docs/types/index.d.ts | 12 +++---- .../@stdlib/lapack/base/iladlr/lib/base.js | 33 ++++++++++--------- .../@stdlib/lapack/base/iladlr/lib/iladlr.js | 6 ++-- .../@stdlib/lapack/base/iladlr/lib/index.js | 2 +- .../@stdlib/lapack/base/iladlr/lib/ndarray.js | 4 +-- .../@stdlib/lapack/base/iladlr/package.json | 2 +- .../lapack/base/iladlr/test/test.iladlr.js | 6 ++-- .../lapack/base/iladlr/test/test.ndarray.js | 20 +++++------ 10 files changed, 48 insertions(+), 47 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/README.md b/lib/node_modules/@stdlib/lapack/base/iladlr/README.md index 95f007cb390e..b81a631d1537 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/README.md +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/README.md @@ -20,7 +20,7 @@ limitations under the License. # iladlr -> Find the index of the last non zero row in a matrix `A` +> Find the index of the last non-zero row in a matrix `A`
@@ -32,7 +32,7 @@ var iladlr = require( '@stdlib/lapack/base/iladlr' ); #### iladlr( order, M, N, A, LDA ) -Finds the index of the last non zero row in a matrix `A`. +Finds the index of the last non-zero row in a matrix `A`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -78,7 +78,7 @@ var out = iladlr( 'row-major', 3, 2, A1, 2 ); #### iladlr.ndarray( uplo, M, N, A, sa1, sa2, oa, B, sb1, sb2, ob ) -Finds the index of the last non zero row in a matrix `A` using alternative indexing semantics. +Finds the index of the last non-zero row in a matrix `A` using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt index a7fe8cb70383..957d891e5c2e 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( order, M, N, A, LDA ) - Finds the index of the last non zero row in a matrix `A`. + Finds the index of the last non-zero row in a matrix `A`. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -33,7 +33,7 @@ {{alias}}.ndarray( M, N, A, sa1, sa2, oa ) - Finds the index of the last non zero row in a matrix `A` using alternative + Finds the index of the last non-zero row in a matrix `A` using alternative indexing semantics. While typed array views mandate a view offset based on the underlying diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts index 43d7d6502b98..aba031fc9b6f 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts @@ -27,14 +27,14 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Finds the index of the last non zero row in a matrix `A`. + * Finds the index of the last non-zero row in a matrix `A`. * * @param order - storage layout * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) - * @returns index of the last non zero row + * @returns index of the last non-zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); @@ -47,14 +47,14 @@ interface Routine { ( order: Layout, M: number, N: number, A: Float64Array, LDA: number ): number; /** - * Finds the index of the last non zero row in a matrix `A` using alternative indexing semantics. + * Finds the index of the last non-zero row in a matrix `A` using alternative indexing semantics. * * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix * @param strideA1 - stride of the first dimension of `A` * @param strideA2 - stride of the second dimension of `A` - * @returns index of the last non zero row + * @returns index of the last non-zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); @@ -68,14 +68,14 @@ interface Routine { } /** -* Finds the index of the last non zero row in a matrix `A`. +* Finds the index of the last non-zero row in a matrix `A`. * * @param order - storage layout * @param M - number of rows in `A` * @param N - number of columns in `A` * @param A - input matrix * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @returns index of the last non zero row +* @returns index of the last non-zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js index b93936452901..51e2046421e1 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js @@ -27,7 +27,7 @@ var max = require( '@stdlib/math/base/special/max' ); // MAIN // /** -* Finds the index of the last non zero row in a matrix `A`. +* Finds the index of the last non-zero row in a matrix `A`. * * @private * @param {PositiveInteger} M - number of rows in `A` @@ -36,7 +36,7 @@ var max = require( '@stdlib/math/base/special/max' ); * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` -* @returns {integer} index of the last row +* @returns {integer} index of the last non-zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); @@ -79,21 +79,22 @@ function iladlr( M, N, A, strideA1, strideA2, offsetA ) { } // If we reach here, then all entries in the matrix are zero, return -1 (invalid index) - iladlr = -1; - } else { - ia2 = offsetA; // Tracks columns - iladlr = -1; // initialize iladlr, will return -1 (invalid index) if all entries are zero - - for ( j = 0; j < N; j++ ) { - i = M - 1; - ia1 = (M-1) * strideA1; // Tracks rows - while ( A[ ia1 + ia2 ] === 0.0 && i >= 0 ) { - i -= 1; - ia1 -= strideA1; - } - iladlr = max( i, iladlr ); - ia2 += strideA2; + return -1; + } + + // Column major + ia2 = offsetA; // Tracks columns + iladlr = -1; // initialize iladlr, will return -1 (invalid index) if all entries are zero + + for ( j = 0; j < N; j++ ) { + i = M - 1; + ia1 = (M-1) * strideA1; // Tracks rows + while ( A[ ia1 + ia2 ] === 0.0 && i >= 0 ) { + i -= 1; + ia1 -= strideA1; } + iladlr = max( i, iladlr ); + ia2 += strideA2; } return iladlr; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js index 937d9d7ea883..70430c3fe132 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js @@ -31,7 +31,7 @@ var base = require( './base.js' ); // MAIN // /** -* Finds the index of the last non zero row in a matrix `A`. +* Finds the index of the last non-zero row in a matrix `A`. * * @param {string} order - storage layout * @param {PositiveInteger} M - number of rows in `A` @@ -40,7 +40,7 @@ var base = require( './base.js' ); * @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} fifth argument must be greater than or equal to max(1,N) -* @returns {integer} index of the last non zero row +* @returns {integer} index of the last non-zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); @@ -58,7 +58,7 @@ function iladlr( order, M, N, A, LDA ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } if ( isRowMajor( order ) && LDA < max( 1, N ) ) { - throw new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/index.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/index.js index e186b0bf9b63..5d90f3841faf 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to find the index of the last non zero row in a input matrix. +* LAPACK routine to find the index of the last non-zero row in a input matrix. * * @module @stdlib/lapack/base/iladlr * diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js index 71852d222dd9..a982d557ff5d 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js @@ -26,7 +26,7 @@ var base = require( './base.js' ); // MAIN // /** -* Finds the index of the last non zero row in a matrix `A` using alternative indexing semantics. +* Finds the index of the last non-zero row in a matrix `A` using alternative indexing semantics. * * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` @@ -34,7 +34,7 @@ var base = require( './base.js' ); * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` -* @returns {integer} index of the last row +* @returns {integer} index of the last non-zero row * * @example * var Float64array = require( '@stdlib/array/float64' ); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/package.json b/lib/node_modules/@stdlib/lapack/base/iladlr/package.json index 6b09dc700903..be6f79b0635b 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/package.json +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/lapack/base/iladlr", "version": "0.0.0", - "description": "LAPACK routine to find the index of the last non zero row in a input matrix.", + "description": "LAPACK routine to find the index of the last non-zero row in a input matrix.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js index 73a3524a5227..d5fedba9f144 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js @@ -84,7 +84,7 @@ tape( 'the function throws an error if provided a first argument which is not a } }); -tape( 'the function throws an error if provided a fourth argument which is not a valid `LDA` value (row-major)', function test( t ) { +tape( 'the function throws an error if provided a fifth argument which is not a valid `LDA` value (row-major)', function test( t ) { var values; var data; var A; @@ -139,7 +139,7 @@ tape( 'the function returns an invalid index (-1) when N is zero', function test t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major)', function test( t ) { var data; var out; var A; @@ -153,7 +153,7 @@ tape( 'the function returns the expected zero based index of the last non zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major)', function test( t ) { var data; var out; var A; diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js index ae3260385692..a0bbb45c2cda 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js @@ -68,7 +68,7 @@ tape( 'the function has an arity of 6', function test( t ) { t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major)', function test( t ) { var data; var out; var A; @@ -82,7 +82,7 @@ tape( 'the function returns the expected zero based index of the last non zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major)', function test( t ) { var data; var out; var A; @@ -124,7 +124,7 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major) (offsets)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major) (offsets)', function test( t ) { var data; var out; var A; @@ -138,7 +138,7 @@ tape( 'the function returns the expected zero based index of the last non zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major) (offsets)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major) (offsets)', function test( t ) { var data; var out; var A; @@ -180,7 +180,7 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major) (mixed strides)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major) (mixed strides)', function test( t ) { var data; var out; var A; @@ -194,7 +194,7 @@ tape( 'the function returns the expected zero based index of the last non zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major) (mixed strides)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major) (mixed strides)', function test( t ) { var data; var out; var A; @@ -236,7 +236,7 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major) (negative strides)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major) (negative strides)', function test( t ) { var data; var out; var A; @@ -250,7 +250,7 @@ tape( 'the function returns the expected zero based index of the last non zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major) (negative strides)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major) (negative strides)', function test( t ) { var data; var out; var A; @@ -292,7 +292,7 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (row-major) (large strides)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major) (large strides)', function test( t ) { var data; var out; var A; @@ -306,7 +306,7 @@ tape( 'the function returns the expected zero based index of the last non zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non zero row of a matrix (column-major) (large strides)', function test( t ) { +tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major) (large strides)', function test( t ) { var data; var out; var A; From c0941f24d9d4390c0490fa32ad2b0cb5c6c1805e Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 00:47:35 -0700 Subject: [PATCH 19/31] refactor: optimize loops --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/lib/base.js | 116 ++++++++++++------ 1 file changed, 77 insertions(+), 39 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js index 51e2046421e1..ef7dac5dba04 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js @@ -21,7 +21,6 @@ // MODULES // var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var max = require( '@stdlib/math/base/special/max' ); // MAIN // @@ -29,6 +28,10 @@ var max = require( '@stdlib/math/base/special/max' ); /** * Finds the index of the last non-zero row in a matrix `A`. * +* ## Notes +* +* - If provided an empty matrix or a matrix containing only zeros, the function returns `-1` (i.e., an invalid index). +* * @private * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` @@ -45,59 +48,94 @@ var max = require( '@stdlib/math/base/special/max' ); * * var out = iladlr( 3, 2, A, 2, 1, 0 ); * // returns 1 +* +* @example +* var Float64array = require( '@stdlib/array/float64' ); +* +* var A = new Float64array( [ 1.0, 3.0, 0.0, 2.0, 4.0, 0.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 0.0, 0.0 ] ] +* +* var out = iladlr( 3, 2, A, 1, 3, 0 ); +* // returns 1 */ function iladlr( M, N, A, strideA1, strideA2, offsetA ) { - var iladlr; - var ia1; - var ia2; - var i; - var j; - - if ( M === 0 || N === 0 ) { - return -1; // Invalid index + var last; + var da0; + var da1; + var S0; + var S1; + var ia; + var i0; + var i1; + var k; + + // Check whether the matrix is an empty matrix... + if ( M <= 0 || N <= 0 ) { + return -1; } + // Compute the index of the first element in the last row: + ia = offsetA + ( (M-1) * strideA1 ); - ia1 = offsetA + ( (M-1) * strideA1 ); // A( M, 1 ) - ia2 = ia1 + ( (N-1) * strideA2 ); // A( M, N ) + // Compute the index offset for the last element in the last row: + last = ( N-1 ) * strideA2; - // Quick test for common case where corners are non-zero: - if ( A[ ia1 ] !== 0.0 || A[ ia2 ] !== 0.0 ) { + // Check for the common case where the first and last elements in the last row are non-zero... + if ( A[ ia ] !== 0.0 || A[ ia+last ] !== 0.0 ) { return M - 1; } - + // Search for the last row containing at least one non-zero element... if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - ia1 = offsetA + ( (M-1) * strideA1 ); // Tracks rows - for ( i = M - 1; i >= 0; i-- ) { - ia2 = 0; // Tracks columns - for ( j = 0; j < N; j++ ) { - if ( A[ ia1 + ia2 ] !== 0.0 ) { // Find the last row with a non-zero entry - return i; + S0 = N; + S1 = M; + + // Resolve loop offset (pointer) increments: + da0 = strideA2; + da1 = strideA1 - ( S0*strideA2 ); + + // Scan a row-major linear buffer from the last indexed element to the first indexed element, always moving in the same direction when both strides are the same sign, thus ensuring cache optimal traversal... + ia += last; + for ( i1 = S1-1; i1 >= 0; i1-- ) { + for ( i0 = 0; i0 < S0; i0++ ) { + if ( A[ ia ] !== 0.0 ) { + // We found a row with a non-zero element! + return i1; } - ia2 += strideA2; + ia -= da0; } - ia1 -= strideA1; + ia -= da1; } - - // If we reach here, then all entries in the matrix are zero, return -1 (invalid index) + // If we've made it here, then all entries in the matrix are zero: return -1; } - - // Column major - ia2 = offsetA; // Tracks columns - iladlr = -1; // initialize iladlr, will return -1 (invalid index) if all entries are zero - - for ( j = 0; j < N; j++ ) { - i = M - 1; - ia1 = (M-1) * strideA1; // Tracks rows - while ( A[ ia1 + ia2 ] === 0.0 && i >= 0 ) { - i -= 1; - ia1 -= strideA1; + // Column-major... + S0 = M; + S1 = N; + + // Resolve loop offset (pointer) increments: + da0 = strideA1; + da1 = strideA2; + + // Compute the index offset for the last element in each row: + last = offsetA + ( (S0-1)*da0 ); + + // Initialize an index of the last row in which a non-zero element was seen: + k = -1; + + // Finding the last non-zero row when a matrix is stored in column-major order requires effectively performing a full linear scan. In order to ensure cache-efficient traversal, scan up each column (otherwise, if we went row-by-row, we'd hop around linear memory, resulting in poor cache behavior)... + for ( i1 = 0; i1 < S1; i1++ ) { + // Reset the pointer to point to the last element in the current column: + ia = last + ( i1*da1 ); + + // Scan up the rows in a column looking for a non-zero element... + for ( i0 = S0-1; i0 > k; i0-- ) { // note: `k` serves as a lower row index bound, thus shrinking the number of rows we need to check when scanning columns + if ( A[ ia ] !== 0.0 ) { + // We found a non-zero element, which means we no longer have to search this row... + k = i0; + break; // note: in principle, if `k == M-1`, we could early return; however, this is a hot loop and adding an additional conditional is likely to degrade average performance in order to cater to what is effectively an edge case + } + ia -= da0; } - iladlr = max( i, iladlr ); - ia2 += strideA2; } - - return iladlr; + return k; } From 04bb1f109c2e796ab966ca8b639c00583a012abf Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:01:20 -0700 Subject: [PATCH 20/31] bench: measure worst case scenario --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/benchmark/benchmark.js | 7 +++---- .../lapack/base/iladlr/benchmark/benchmark.ndarray.js | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js index cf0718ee01c2..177cdcdbe15a 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js @@ -22,7 +22,7 @@ var bench = require( '@stdlib/bench' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var pow = require( '@stdlib/math/base/special/pow' ); var floor = require( '@stdlib/math/base/special/floor' ); var pkg = require( './../package.json' ).name; @@ -48,9 +48,7 @@ var LAYOUTS = [ * @returns {Function} benchmark function */ function createBenchmark( order, N ) { - var A; - - A = discreteUniform( N*N, 0.0, 1.0, { + var A = zeros( N*N, { 'dtype': 'float64' }); return benchmark; @@ -67,6 +65,7 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { + A[ 0 ] = i; z = iladlr( order, N, N, A, N ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js index c7d3afef1c1b..f0bb2ce4c6ef 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js @@ -24,7 +24,7 @@ var bench = require( '@stdlib/bench' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var floor = require( '@stdlib/math/base/special/floor' ); -var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); var pkg = require( './../package.json' ).name; var iladlr = require( './../lib/iladlr.js' ); @@ -49,9 +49,7 @@ var LAYOUTS = [ * @returns {Function} benchmark function */ function createBenchmark( order, N ) { - var A; - - A = discreteUniform( N*N, 0.0, 1.0, { + var A = zeros( N*N, { 'dtype': 'float64' }); return benchmark; @@ -78,6 +76,7 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { + A[ 0 ] = i; z = iladlr( order, N, N, A, sa1, sa2, 0 ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); From 1098885ca0fa1e3f6055c66620136e4679d2a78c Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:03:51 -0700 Subject: [PATCH 21/31] docs: add notes --- 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 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: na - task: lint_license_headers status: passed --- --- .../lapack/base/iladlr/docs/types/index.d.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts index aba031fc9b6f..5f0b3b67d58c 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/index.d.ts @@ -27,7 +27,11 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Finds the index of the last non-zero row in a matrix `A`. + * Returns the index of the last non-zero row in a matrix `A`. + * + * ## Notes + * + * - If provided an empty matrix or a matrix containing only zeros, the function returns `-1` (i.e., an invalid index). * * @param order - storage layout * @param M - number of rows in `A` @@ -47,7 +51,11 @@ interface Routine { ( order: Layout, M: number, N: number, A: Float64Array, LDA: number ): number; /** - * Finds the index of the last non-zero row in a matrix `A` using alternative indexing semantics. + * Returns the index of the last non-zero row in a matrix `A` using alternative indexing semantics. + * + * ## Notes + * + * - If provided an empty matrix or a matrix containing only zeros, the function returns `-1` (i.e., an invalid index). * * @param M - number of rows in `A` * @param N - number of columns in `A` @@ -68,7 +76,11 @@ interface Routine { } /** -* Finds the index of the last non-zero row in a matrix `A`. +* Returns the index of the last non-zero row in a matrix `A`. +* +* ## Notes +* +* - If provided an empty matrix or a matrix containing only zeros, the function returns `-1` (i.e., an invalid index). * * @param order - storage layout * @param M - number of rows in `A` From 9ce890f4bca934d4e38c46eb30684576537847ef Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:06:37 -0700 Subject: [PATCH 22/31] docs: add notes --- 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - 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: na - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/docs/repl.txt | 26 ++++++++++++------- .../lapack/base/iladlr/docs/types/test.ts | 2 +- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt index 957d891e5c2e..6a9c6b35d3c1 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/repl.txt @@ -1,10 +1,13 @@ {{alias}}( order, M, N, A, LDA ) - Finds the index of the last non-zero row in a matrix `A`. + Returns the index of the last non-zero row in a matrix `A`. Indexing is relative to the first index. To introduce an offset, use typed array views. + If provided an empty matrix or a matrix containing only zeros, the function + returns `-1` (i.e., an invalid index). + Parameters ---------- order: string @@ -22,8 +25,8 @@ Returns ------- - iladlr: integer - Zero based index of the last non-zero row. + out: integer + Zero-based index of the last non-zero row. Examples -------- @@ -32,14 +35,17 @@ 1 -{{alias}}.ndarray( M, N, A, sa1, sa2, oa ) - Finds the index of the last non-zero row in a matrix `A` using alternative +{{alias}}.ndarray( M, N, A, strideA1, strideA2, offsetA ) + Returns the index of the last non-zero row in a matrix `A` using alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. + If provided an empty matrix or a matrix containing only zeros, the method + returns `-1` (i.e., an invalid index). + Parameters ---------- M: integer @@ -51,19 +57,19 @@ A: Float64Array Input matrix `A`. - sa1: integer + strideA1: integer Stride of the first dimension of `A`. - sa2: integer + strideA2: integer Stride of the second dimension of `A`. - oa: integer + offsetA: integer Starting index for `A`. Returns ------- - iladlr: integer - Zero based index of the last non-zero row. + out: integer + Zero-based index of the last non-zero row. Examples -------- diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/test.ts index cc1b35f47869..63d392dcfb60 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/docs/types/test.ts @@ -199,7 +199,7 @@ import iladlr = require( './index' ); iladlr.ndarray( 2, 2, A, 2, 1, ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments (6-argument version)... +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { const A = new Float64Array( 4 ); From e5cc457d043b7e3259695b74a3843a02ddf8de16 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:12:46 -0700 Subject: [PATCH 23/31] docs: update descriptions --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js | 2 +- lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js | 2 +- lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js index ef7dac5dba04..fb0c1397441c 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/base.js @@ -26,7 +26,7 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); // MAIN // /** -* Finds the index of the last non-zero row in a matrix `A`. +* Returns the index of the last non-zero row in a matrix `A`. * * ## Notes * diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js index 70430c3fe132..4e24d5ada1a7 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js @@ -31,7 +31,7 @@ var base = require( './base.js' ); // MAIN // /** -* Finds the index of the last non-zero row in a matrix `A`. +* Returns the index of the last non-zero row in a matrix `A`. * * @param {string} order - storage layout * @param {PositiveInteger} M - number of rows in `A` diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js index a982d557ff5d..bc7f86fe358f 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/ndarray.js @@ -26,7 +26,7 @@ var base = require( './base.js' ); // MAIN // /** -* Finds the index of the last non-zero row in a matrix `A` using alternative indexing semantics. +* Returns the index of the last non-zero row in a matrix `A` using alternative indexing semantics. * * @param {PositiveInteger} M - number of rows in `A` * @param {PositiveInteger} N - number of columns in `A` From bdec61f6248cdd7bd694cfd4cb01e6be49c8c0db Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:22:58 -0700 Subject: [PATCH 24/31] docs: fix signature and add note --- 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 status: passed - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/README.md | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/README.md b/lib/node_modules/@stdlib/lapack/base/iladlr/README.md index b81a631d1537..accfadf1039a 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/README.md +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/README.md @@ -20,7 +20,7 @@ limitations under the License. # iladlr -> Find the index of the last non-zero row in a matrix `A` +> Find the index of the last non-zero row in a matrix `A`.
@@ -32,7 +32,7 @@ var iladlr = require( '@stdlib/lapack/base/iladlr' ); #### iladlr( order, M, N, A, LDA ) -Finds the index of the last non-zero row in a matrix `A`. +Returns the index of the last non-zero row in a matrix `A`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -66,19 +66,19 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -// Initial arrays... +// Initial array: var A0 = new Float64Array( [ 9999.0, 1.0, 2.0, 3.0, 4.0, 0.0, 0.0 ] ); -// Create offset views... +// Create an offset view: var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var out = iladlr( 'row-major', 3, 2, A1, 2 ); // returns 1 ``` -#### iladlr.ndarray( uplo, M, N, A, sa1, sa2, oa, B, sb1, sb2, ob ) +#### iladlr.ndarray( M, N, A, strideA1, strideA2, offsetA ) -Finds the index of the last non-zero row in a matrix `A` using alternative indexing semantics. +Returns the index of the last non-zero row in a matrix `A` using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -102,11 +102,11 @@ The function has the following parameters: - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input [`Float64Array`][mdn-float64array]. -- **sa1**: stride of the first dimension of `A`. -- **sa2**: stride of the second dimension of `A`. -- **oa**: starting index for `A`. +- **strideA1**: stride of the first dimension of `A`. +- **strideA2**: stride of the second dimension of `A`. +- **offsetA**: starting index for `A`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -133,6 +133,7 @@ var out = iladlr.ndarray( 3, 2, A, 2, 1, 1 ); ## Notes +- This routine is commonly used throughout LAPACK to shrink work domains (e.g., before bulge-chasing, deflation, or when trimming Householder panels), thus ensuring that higher-level routines operate only on numerically relevant sub-matrices. - `iladlr()` corresponds to the [LAPACK][lapack] routine [`iladlr`][lapack-iladlr].
From a03e16cb357f677fa7421604cef77f014c5e6996 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:26:06 -0700 Subject: [PATCH 25/31] refactor: add LDA check --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/lib/iladlr.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js index 4e24d5ada1a7..f592ee6e58dd 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js @@ -53,12 +53,17 @@ var base = require( './base.js' ); function iladlr( order, M, N, A, LDA ) { var sa1; var sa2; - + var s; if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } - if ( isRowMajor( order ) && LDA < max( 1, N ) ) { - throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + if ( isRowMajor( order ) ) { + s = N; + } else { + s = M; + } + if ( LDA < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); } if ( isColumnMajor( order ) ) { sa1 = 1; From 39c022be23845c56eb637c7193a253c225073759 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:26:37 -0700 Subject: [PATCH 26/31] refactor: use "fast" max --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js index f592ee6e58dd..2be94ef3fa32 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/lib/iladlr.js @@ -23,7 +23,7 @@ var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); -var max = require( '@stdlib/math/base/special/max' ); +var max = require( '@stdlib/math/base/special/fast/max' ); var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); From 38ad0f4c9ce0e09ae9b9702c2d4f11604d166d6f Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:30:26 -0700 Subject: [PATCH 27/31] test: add test --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/iladlr/test/test.iladlr.js | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js index d5fedba9f144..3e46359642f9 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.iladlr.js @@ -111,7 +111,34 @@ tape( 'the function throws an error if provided a fifth argument which is not a } }); -tape( 'the function returns an invalid index (-1) when M is zero', function test( t ) { +tape( 'the function throws an error if provided a fifth argument which is not a valid `LDA` value (column-major)', function test( t ) { + var values; + var data; + var A; + var i; + + data = COLUMN_MAJOR_DATA; + + values = [ + 0, + 1 + ]; + + A = new Float64Array( data.A ); + + 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() { + iladlr( data.order, data.M, data.N, A, value ); + }; + } +}); + +tape( 'the function returns an invalid index (-1) when M is less than or equal to zero', function test( t ) { var data; var out; var A; @@ -125,7 +152,7 @@ tape( 'the function returns an invalid index (-1) when M is zero', function test t.end(); }); -tape( 'the function returns an invalid index (-1) when N is zero', function test( t ) { +tape( 'the function returns an invalid index (-1) when N is less than or equal to zero', function test( t ) { var data; var out; var A; @@ -139,7 +166,7 @@ tape( 'the function returns an invalid index (-1) when N is zero', function test t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (row-major)', function test( t ) { var data; var out; var A; @@ -153,7 +180,7 @@ tape( 'the function returns the expected zero based index of the last non-zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (column-major)', function test( t ) { var data; var out; var A; From c5a007c43cfb9239a5dd60848e2001fb9569d3dc Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:32:03 -0700 Subject: [PATCH 28/31] test: update test descriptions --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/iladlr/test/test.ndarray.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js index a0bbb45c2cda..4556456a2eec 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/test/test.ndarray.js @@ -68,7 +68,7 @@ tape( 'the function has an arity of 6', function test( t ) { t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (row-major)', function test( t ) { var data; var out; var A; @@ -82,7 +82,7 @@ tape( 'the function returns the expected zero based index of the last non-zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (column-major)', function test( t ) { var data; var out; var A; @@ -124,7 +124,7 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major) (offsets)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (row-major) (offsets)', function test( t ) { var data; var out; var A; @@ -138,7 +138,7 @@ tape( 'the function returns the expected zero based index of the last non-zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major) (offsets)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (column-major) (offsets)', function test( t ) { var data; var out; var A; @@ -180,7 +180,7 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major) (mixed strides)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (row-major) (mixed strides)', function test( t ) { var data; var out; var A; @@ -194,7 +194,7 @@ tape( 'the function returns the expected zero based index of the last non-zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major) (mixed strides)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (column-major) (mixed strides)', function test( t ) { var data; var out; var A; @@ -236,7 +236,7 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major) (negative strides)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (row-major) (negative strides)', function test( t ) { var data; var out; var A; @@ -250,7 +250,7 @@ tape( 'the function returns the expected zero based index of the last non-zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major) (negative strides)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (column-major) (negative strides)', function test( t ) { var data; var out; var A; @@ -292,7 +292,7 @@ tape( 'the function returns an invalid index (-1) when all elements in a matrix t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (row-major) (large strides)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (row-major) (large strides)', function test( t ) { var data; var out; var A; @@ -306,7 +306,7 @@ tape( 'the function returns the expected zero based index of the last non-zero r t.end(); }); -tape( 'the function returns the expected zero based index of the last non-zero row of a matrix (column-major) (large strides)', function test( t ) { +tape( 'the function returns the expected zero-based index of the last non-zero row of a matrix (column-major) (large strides)', function test( t ) { var data; var out; var A; From 48e825495afdc1a76682f8f2bd27a02096c0dfdc Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:35:22 -0700 Subject: [PATCH 29/31] bench: fix array creation --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/benchmark/benchmark.js | 4 +--- .../@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js index 177cdcdbe15a..1df857ef424f 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.js @@ -48,9 +48,7 @@ var LAYOUTS = [ * @returns {Function} benchmark function */ function createBenchmark( order, N ) { - var A = zeros( N*N, { - 'dtype': 'float64' - }); + var A = zeros( N*N, 'float64' ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js index f0bb2ce4c6ef..631cdb4cc36a 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js @@ -49,9 +49,7 @@ var LAYOUTS = [ * @returns {Function} benchmark function */ function createBenchmark( order, N ) { - var A = zeros( N*N, { - 'dtype': 'float64' - }); + var A = zeros( N*N, 'float64' ); return benchmark; /** From b6e6251ee0f6f2b42125d9cbf2fb04a1afdef1ad Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:39:18 -0700 Subject: [PATCH 30/31] bench: fix require path --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js index 631cdb4cc36a..dcb70d798c2d 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js @@ -27,7 +27,7 @@ var floor = require( '@stdlib/math/base/special/floor' ); var zeros = require( '@stdlib/array/zeros' ); var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); var pkg = require( './../package.json' ).name; -var iladlr = require( './../lib/iladlr.js' ); +var iladlr = require( './../lib/ndarray.js' ); // VARIABLES // From a15b02604cdff811edf1571f2a148a4099f7031b Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 5 Jun 2025 01:44:49 -0700 Subject: [PATCH 31/31] bench: fix function invocation --- 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 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js index dcb70d798c2d..71a76c92f479 100644 --- a/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/iladlr/benchmark/benchmark.ndarray.js @@ -75,7 +75,7 @@ function createBenchmark( order, N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { A[ 0 ] = i; - z = iladlr( order, N, N, A, sa1, sa2, 0 ); + z = iladlr( N, N, A, sa1, sa2, 0 ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); }