From 87ea9c025de9249621e3aee45e328141da05ef36 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Tue, 3 Jun 2025 09:36:43 +0000 Subject: [PATCH 01/20] feat: add base 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/dlange/lib/base.js | 137 ++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js new file mode 100644 index 000000000000..d9aa4096fb6a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -0,0 +1,137 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var dlassq = require( '@stdlib/lapack/base/dlassq' ).ndarray; +var Float64Array = require( '@stdlib/array/float64' ); +var min = require( '@stdlib/math/base/special/min' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); + + +// MAIN // + +/** +* Returns the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. +* +* ## Notes +* +* - use `norm` = `M`, to calculate the element with the largest absolute value +* - use `norm` = `O`, to calculate the one norm +* - use `norm` = `I`, to calculate the infinity norm +* - use `norm` = `F`, to calculate the frobenius norm +* +* @private +* @param {string} norm - specifies the type of norm to be calculated +* @param {Float64Array} M - number of rows in `A` +* @param {Float64Array} N - number of columns in `A` +* @param {Float64Array} A - input array +* @param {Float64Array} strideA1 - stride of the first dimension of `A` +* @param {Float64Array} strideA2 - stride of the second dimension of `A` +* @param {Float64Array} offsetA - starting index of `A` +* @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} strideWork - stride length of `work` +* @param {Float64Array} offsetWork - starting index of `work` +* @returns {number} required norm value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* var work = new Float64Array( 3 ); +* +* var out = dlange( 'F', 3, 4, A, 4, 1, 0, work, 1, 0 ); +* // returns ~25.5 +*/ +function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len + var value; + var temp; + var sum; + var out; + var i; + var j; + + if ( min( M, N ) === 0 ) { + value = 0.0; + } + + else if ( norm === 'M' ) { + value = 0.0; + for ( i = 0; i < M; i++ ) { + for ( j = 0; j < N; j++ ) { + temp = A[ offsetA + (i*strideA1) + (j*strideA2) ]; + if ( value < temp || isnan( temp ) ) { + value = temp; + } + } + } + } + + else if ( norm === 'O' ) { + value = 0; + for ( j = 0; j < N; j++ ) { + sum = 0; + for ( i = 0; i < M; i++ ) { + sum += abs( A[ offsetA + (i*strideA1) + (j*strideA2) ] ); + } + if ( value < sum || isnan( sum ) ) { + value = sum; + } + } + } + + else if ( norm === 'I' ) { + for ( i = 0; i < M; i++ ) { + work[ offsetWork + (i*strideWork) ] = 0.0; + } + + for ( j = 0; j < N; j++ ) { + for ( i = 0; i < M; i++ ) { + work[ offsetWork + (i*strideWork) ] += abs( A[ offsetA + (i*strideA1) + (j*strideA2) ] ); // eslint-disable-line max-len + } + } + + value = 0; + + for ( i = 0; i < M; i++ ) { + temp = work[ offsetWork + (i*strideWork) ]; + if ( value < temp || isnan( temp ) ) { + value = temp; + } + } + } + + else if ( norm === 'F' ) { + out = new Float64Array( [ 0.0, 1.0 ] ); + for ( i = 0; i < N; i++ ) { + dlassq( M, A, strideA1, offsetA + (i*strideA2), out[ 0 ], out[ 1 ], out, 1, 0 ); // eslint-disable-line max-len + } + value = out[ 0 ] * sqrt( out[ 1 ] ); + } + + return value; +} + + +// EXPORTS // + +module.exports = dlange; From a6a19f3a6bfe710751f4467c9a64b3e5ce4e47ac Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Tue, 3 Jun 2025 10:48:38 +0000 Subject: [PATCH 02/20] feat: add main exports --- 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/dlange/lib/base.js | 18 ++-- .../@stdlib/lapack/base/dlange/lib/dlange.js | 92 +++++++++++++++++++ .../@stdlib/lapack/base/dlange/lib/index.js | 58 ++++++++++++ .../lapack/base/dlange/lib/isoperation.js | 62 +++++++++++++ .../@stdlib/lapack/base/dlange/lib/main.js | 35 +++++++ .../@stdlib/lapack/base/dlange/lib/ndarray.js | 72 +++++++++++++++ 6 files changed, 328 insertions(+), 9 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index d9aa4096fb6a..ff4bcaa4f610 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -35,10 +35,10 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); * * ## Notes * -* - use `norm` = `M`, to calculate the element with the largest absolute value -* - use `norm` = `O`, to calculate the one norm -* - use `norm` = `I`, to calculate the infinity norm -* - use `norm` = `F`, to calculate the frobenius norm +* - use `norm` = `max`, to calculate the element with the largest absolute value +* - use `norm` = `one`, to calculate the one norm +* - use `norm` = `infinity`, to calculate the infinity norm +* - use `norm` = `frobenius`, to calculate the frobenius norm * * @private * @param {string} norm - specifies the type of norm to be calculated @@ -59,7 +59,7 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); * var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); * var work = new Float64Array( 3 ); * -* var out = dlange( 'F', 3, 4, A, 4, 1, 0, work, 1, 0 ); +* var out = dlange( 'frobenius', 3, 4, A, 4, 1, 0, work, 1, 0 ); * // returns ~25.5 */ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len @@ -74,7 +74,7 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o value = 0.0; } - else if ( norm === 'M' ) { + else if ( norm === 'max' ) { value = 0.0; for ( i = 0; i < M; i++ ) { for ( j = 0; j < N; j++ ) { @@ -86,7 +86,7 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o } } - else if ( norm === 'O' ) { + else if ( norm === 'one' ) { value = 0; for ( j = 0; j < N; j++ ) { sum = 0; @@ -99,7 +99,7 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o } } - else if ( norm === 'I' ) { + else if ( norm === 'infinity' ) { for ( i = 0; i < M; i++ ) { work[ offsetWork + (i*strideWork) ] = 0.0; } @@ -120,7 +120,7 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o } } - else if ( norm === 'F' ) { + else if ( norm === 'frobenius' ) { out = new Float64Array( [ 0.0, 1.0 ] ); for ( i = 0; i < N; i++ ) { dlassq( M, A, strideA1, offsetA + (i*strideA2), out[ 0 ], out[ 1 ], out, 1, 0 ); // eslint-disable-line max-len diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js new file mode 100644 index 000000000000..147c6ab1a239 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -0,0 +1,92 @@ +/** +* @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 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 isOperation = require( './isoperation.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Returns the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. +* +* ## Notes +* +* - use `norm` = `max`, to calculate the element with the largest absolute value +* - use `norm` = `one`, to calculate the one norm +* - use `norm` = `infinity`, to calculate the infinity norm +* - use `norm` = `frobenius`, to calculate the frobenius norm +* +* @private +* @param {string} order - storage layout +* @param {string} norm - specifies the type of norm to be calculated +* @param {Float64Array} M - number of rows in `A` +* @param {Float64Array} N - number of columns in `A` +* @param {Float64Array} A - input array +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be a valid operation +* @throws {RangeError} sixth argument must be greater than or equal to max(1,N) +* @returns {number} required norm value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* var work = new Float64Array( 3 ); +* +* var out = dlange( 'row-major', 'frobenius', 3, 4, A, 4, work ); +* // returns ~25.5 +*/ +function dlange( order, norm, M, N, A, LDA, work ) { + var sa1; + var sa2; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isOperation( norm ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a valid operation. Value: `%s`.', norm ) ); + } + if ( isRowMajor( order ) && LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Sixth 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( norm, M, N, A, sa1, sa2, 0, work, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dlange; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js new file mode 100644 index 000000000000..c72ba68f81ca --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js @@ -0,0 +1,58 @@ +/** +* @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'; + +/** +* LAPACK routine to calculate the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. +* +* @module @stdlib/lapack/base/dlange +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlange = require( '@stdlib/lapack/base/dlange' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* var work = new Float64Array( 3 ); +* +* var out = dlange( 'row-major', 'frobenius', 3, 4, A, 4, work ); +* // returns ~25.5 +*/ + +// 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 dlange; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlange = main; +} else { + dlange = tmp; +} + + +// EXPORTS // + +module.exports = dlange; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js new file mode 100644 index 000000000000..daadd8922e4a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js @@ -0,0 +1,62 @@ +/** +* @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 contains = require( '@stdlib/array/base/assert/contains' ).factory; + + +// VARIABLES // + +var JOBS = [ 'max', 'infinity', 'one', 'frobenius' ]; + + +// MAIN // + +/** +* Tests whether an input value is a supported operation. +* +* @name isOperation +* @type {Function} +* @param {*} v - value to test +* @returns {boolean} boolean indicating whether an input value is a supported job +* +* @example +* var bool = isOperation( 'max' ); +* // returns true +* +* bool = isOperation( 'frobenius' ); +* // returns true +* +* bool = isOperation( 'max' ); +* // returns true +* +* bool = isOperation( 'infinity' ); +* // returns true +* +* bool = isOperation( 'foo' ); +* // returns false +*/ +var isOperation = contains( JOBS ); + + +// EXPORTS // + +module.exports = isOperation; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js new file mode 100644 index 000000000000..9b733faf588f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlange = require( './dlange.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlange, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlange; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js new file mode 100644 index 000000000000..e28d4aa41d73 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -0,0 +1,72 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var isOperation = require( './isoperation.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Returns the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. +* +* ## Notes +* +* - use `norm` = `max`, to calculate the element with the largest absolute value +* - use `norm` = `one`, to calculate the one norm +* - use `norm` = `infinity`, to calculate the infinity norm +* - use `norm` = `frobenius`, to calculate the frobenius norm +* +* @param {string} norm - specifies the type of norm to be calculated +* @param {Float64Array} M - number of rows in `A` +* @param {Float64Array} N - number of columns in `A` +* @param {Float64Array} A - input array +* @param {Float64Array} strideA1 - stride of the first dimension of `A` +* @param {Float64Array} strideA2 - stride of the second dimension of `A` +* @param {Float64Array} offsetA - starting index of `A` +* @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} strideWork - stride length of `work` +* @param {Float64Array} offsetWork - starting index of `work` +* @throws {TypeError} first argument must be a valid operation +* @returns {number} required norm value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* var work = new Float64Array( 3 ); +* +* var out = dlange( 'frobenius', 3, 4, A, 4, 1, 0, work, 1, 0 ); +* // returns ~25.5 +*/ +function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len + if ( !isOperation( norm ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid operation. Value: `%s`.', norm ) ); + } + return base( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dlange; From d51e004dd59823eb28e9f0d716576a96e756711f Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Tue, 3 Jun 2025 18:04:18 +0000 Subject: [PATCH 03/20] test: add initial 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: 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dlange/lib/base.js | 2 +- .../@stdlib/lapack/base/dlange/lib/dlange.js | 2 +- .../@stdlib/lapack/base/dlange/lib/index.js | 2 +- .../@stdlib/lapack/base/dlange/lib/main.js | 2 +- .../@stdlib/lapack/base/dlange/lib/ndarray.js | 2 +- .../fixtures/frobenius_norm_column_major.json | 20 ++ .../fixtures/frobenius_norm_row_major.json | 20 ++ .../fixtures/infinity_norm_column_major.json | 20 ++ .../fixtures/infinity_norm_row_major.json | 20 ++ .../fixtures/max_element_column_major.json | 20 ++ .../test/fixtures/max_element_row_major.json | 20 ++ .../test/fixtures/one_norm_column_major.json | 20 ++ .../test/fixtures/one_norm_row_major.json | 20 ++ .../lapack/base/dlange/test/test.dlange.js | 292 ++++++++++++++++++ .../@stdlib/lapack/base/dlange/test/test.js | 82 +++++ 15 files changed, 539 insertions(+), 5 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/frobenius_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/frobenius_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/infinity_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/infinity_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/max_element_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/max_element_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/test.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index ff4bcaa4f610..31b82e2cdb49 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/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. diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js index 147c6ab1a239..c9d91f88ad5c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.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/dlange/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js index c72ba68f81ca..5436caa39f92 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.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/dlange/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js index 9b733faf588f..a511305c5d68 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.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/dlange/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js index e28d4aa41d73..918331199fc5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/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. diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/frobenius_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/frobenius_norm_column_major.json new file mode 100644 index 000000000000..d019cd5ec45d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/frobenius_norm_column_major.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/frobenius_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/frobenius_norm_row_major.json new file mode 100644 index 000000000000..393cf4cdb455 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/frobenius_norm_row_major.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/infinity_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/infinity_norm_column_major.json new file mode 100644 index 000000000000..e09a0408ac91 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/infinity_norm_column_major.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "expected": 30.0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/infinity_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/infinity_norm_row_major.json new file mode 100644 index 000000000000..1c72dd8e6bae --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/infinity_norm_row_major.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "expected": 30.0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/max_element_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/max_element_column_major.json new file mode 100644 index 000000000000..e7d59f3b26f2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/max_element_column_major.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "expected": 12.0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/max_element_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/max_element_row_major.json new file mode 100644 index 000000000000..aa5cb6c6abd3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/max_element_row_major.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "expected": 12.0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_column_major.json new file mode 100644 index 000000000000..d3ff510f2cfe --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_column_major.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "expected": 33.0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_row_major.json new file mode 100644 index 000000000000..ac71656d7b98 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_row_major.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ 0.0, 0.0, 0.0 ], + "strideWork": 1, + "offsetWork": 0, + "expected": 33.0 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js new file mode 100644 index 000000000000..11c678c54943 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js @@ -0,0 +1,292 @@ +/** +* @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. +*/ + +/* eslint-disable id-length */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlange = require( './../lib/dlange.js' ); + + +// FIXTURES // + +var ONE_NORM_ROW_MAJOR = require( './fixtures/one_norm_row_major.json' ); +var ONE_NORM_COLUMN_MAJOR = require( './fixtures/one_norm_column_major.json' ); +var INFINITY_NORM_ROW_MAJOR = require( './fixtures/infinity_norm_row_major.json' ); +var INFINITY_NORM_COLUMN_MAJOR = require( './fixtures/infinity_norm_column_major.json' ); +var MAX_ELEMENT_ROW_MAJOR = require( './fixtures/max_element_row_major.json' ); +var MAX_ELEMENT_COLUMN_MAJOR = require( './fixtures/max_element_column_major.json' ); +var FROBENIUS_NORM_ROW_MAJOR = require( './fixtures/frobenius_norm_row_major.json' ); +var FROBENIUS_NORM_COLUMN_MAJOR = require( './fixtures/frobenius_norm_column_major.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlange, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dlange.length, 7, '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 work; + var A; + var i; + + data = FROBENIUS_NORM_ROW_MAJOR; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + 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() { + dlange( value, data.norm, data.M, data.N, A, data.LDA, work ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a valid operation', function test( t ) { + var values; + var data; + var work; + var A; + var i; + + data = FROBENIUS_NORM_ROW_MAJOR; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + 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() { + dlange( data.order, value, data.M, data.N, A, data.LDA, work ); + }; + } +}); + +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 work; + var A; + var i; + + data = FROBENIUS_NORM_ROW_MAJOR; + + values = [ + 0, + 1, + 2, + 3 + ]; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + 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() { + dlange( data.order, data.norm, data.M, data.N, A, value, work ); + }; + } +}); + +tape( 'the function calculates the one norm for a given matrix A (row-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = ONE_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, data.M, data.N, A, data.LDA, work ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (column-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = ONE_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, data.M, data.N, A, data.LDA, work ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (row-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = INFINITY_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, data.M, data.N, A, data.LDA, work ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (column-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = INFINITY_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, data.M, data.N, A, data.LDA, work ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (row-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = FROBENIUS_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, data.M, data.N, A, data.LDA, work ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (column-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = FROBENIUS_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, data.M, data.N, A, data.LDA, work ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (row-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MAX_ELEMENT_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, data.M, data.N, A, data.LDA, work ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (column-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MAX_ELEMENT_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, data.M, data.N, A, data.LDA, work ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js new file mode 100644 index 000000000000..41c9b5de040a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dlange = 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 dlange, '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 dlange.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 dlange = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlange, 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 dlange; + var main; + + main = require( './../lib/dlange.js' ); + + dlange = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlange, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); From 5653d0f85ecd38ca1b988982fcd1285eae833eca Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Tue, 3 Jun 2025 18:23:08 +0000 Subject: [PATCH 04/20] test: add initial ndarray 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: 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/dlange/test/test.dlange.js | 16 ++ .../lapack/base/dlange/test/test.ndarray.js | 237 ++++++++++++++++++ 2 files changed, 253 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js index 11c678c54943..1a3822e967d6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js @@ -163,6 +163,22 @@ tape( 'the function throws an error if provided a fourth argument which is not a } }); +tape( 'the function returns zero if number of rows or columns is zero', function test( t ) { + var data; + var work; + var out; + var A; + + data = ONE_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.order, data.norm, 0, data.N, A, data.LDA, work ); + t.strictEqual( out, 0.0, 'returns expected value' ); + t.end(); +}); + tape( 'the function calculates the one norm for a given matrix A (row-major)', function test( t ) { var data; var work; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js new file mode 100644 index 000000000000..eb8f288ee4a3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js @@ -0,0 +1,237 @@ +/** +* @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. +*/ + +/* eslint-disable id-length, max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlange = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var ONE_NORM_ROW_MAJOR = require( './fixtures/one_norm_row_major.json' ); +var ONE_NORM_COLUMN_MAJOR = require( './fixtures/one_norm_column_major.json' ); +var INFINITY_NORM_ROW_MAJOR = require( './fixtures/infinity_norm_row_major.json' ); +var INFINITY_NORM_COLUMN_MAJOR = require( './fixtures/infinity_norm_column_major.json' ); +var MAX_ELEMENT_ROW_MAJOR = require( './fixtures/max_element_row_major.json' ); +var MAX_ELEMENT_COLUMN_MAJOR = require( './fixtures/max_element_column_major.json' ); +var FROBENIUS_NORM_ROW_MAJOR = require( './fixtures/frobenius_norm_row_major.json' ); +var FROBENIUS_NORM_COLUMN_MAJOR = require( './fixtures/frobenius_norm_column_major.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlange, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dlange.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a second argument which is not a valid operation', function test( t ) { + var values; + var data; + var work; + var A; + var i; + + data = FROBENIUS_NORM_ROW_MAJOR; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + 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() { + dlange( value, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + }; + } +}); + +tape( 'the function returns zero if number of rows or columns is zero', function test( t ) { + var data; + var work; + var out; + var A; + + data = ONE_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, 0, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (row-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = ONE_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (column-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = ONE_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (row-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = INFINITY_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (column-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = INFINITY_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (row-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = FROBENIUS_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (column-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = FROBENIUS_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (row-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MAX_ELEMENT_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (column-major)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MAX_ELEMENT_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); From 861ec2c1c64603edaf65fa7a8e1eaa00e31a7010 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 03:43:35 +0000 Subject: [PATCH 05/20] refactor: pointer arithmetic --- 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/dlange/lib/base.js | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 31b82e2cdb49..7f276566770e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -67,6 +67,9 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o var temp; var sum; var out; + var ia1; + var ia2; + var iw; var i; var j; @@ -76,47 +79,65 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o else if ( norm === 'max' ) { value = 0.0; + ia1 = offsetA; for ( i = 0; i < M; i++ ) { + ia2 = 0; for ( j = 0; j < N; j++ ) { - temp = A[ offsetA + (i*strideA1) + (j*strideA2) ]; + temp = A[ ia1 + ia2 ]; if ( value < temp || isnan( temp ) ) { value = temp; } + ia2 += strideA2; } + ia1 += strideA1; } } else if ( norm === 'one' ) { value = 0; + ia1 = offsetA; for ( j = 0; j < N; j++ ) { sum = 0; + ia2 = 0; for ( i = 0; i < M; i++ ) { - sum += abs( A[ offsetA + (i*strideA1) + (j*strideA2) ] ); + sum += abs( A[ ia1 + ia2 ] ); + ia2 += strideA1; } if ( value < sum || isnan( sum ) ) { value = sum; } + ia1 += strideA2; } } else if ( norm === 'infinity' ) { + iw = offsetWork; for ( i = 0; i < M; i++ ) { - work[ offsetWork + (i*strideWork) ] = 0.0; + work[ iw ] = 0.0; + iw += strideWork; } + ia1 = offsetA; for ( j = 0; j < N; j++ ) { + ia2 = 0; + iw = offsetWork; for ( i = 0; i < M; i++ ) { - work[ offsetWork + (i*strideWork) ] += abs( A[ offsetA + (i*strideA1) + (j*strideA2) ] ); // eslint-disable-line max-len + work[ iw ] += abs( A[ ia1 + ia2 ] ); + iw += strideWork; + ia2 += strideA1; } + ia1 += strideA2; } value = 0; + iw = offsetWork; for ( i = 0; i < M; i++ ) { - temp = work[ offsetWork + (i*strideWork) ]; + temp = work[ iw ]; if ( value < temp || isnan( temp ) ) { value = temp; } + iw += strideWork; } } From 3c69a60fef0cfc3475f949d4710aa23599398440 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 04:25:18 +0000 Subject: [PATCH 06/20] test: add all 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: 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 --- --- .../frobenius_norm_column_major.json | 52 ++ .../frobenius_norm_row_major.json | 52 ++ .../infinity_norm_column_major.json | 52 ++ .../infinity_norm_row_major.json | 52 ++ .../max_element_column_major.json | 52 ++ .../large_strides/max_element_row_major.json | 52 ++ .../large_strides/one_norm_column_major.json | 52 ++ .../large_strides/one_norm_row_major.json | 52 ++ .../frobenius_norm_column_major.json | 37 ++ .../frobenius_norm_row_major.json | 37 ++ .../infinity_norm_column_major.json | 37 ++ .../infinity_norm_row_major.json | 37 ++ .../max_element_column_major.json | 37 ++ .../mixed_strides/max_element_row_major.json | 37 ++ .../mixed_strides/one_norm_column_major.json | 37 ++ .../mixed_strides/one_norm_row_major.json | 37 ++ .../frobenius_norm_column_major.json | 37 ++ .../frobenius_norm_row_major.json | 37 ++ .../infinity_norm_column_major.json | 37 ++ .../infinity_norm_row_major.json | 37 ++ .../max_element_column_major.json | 37 ++ .../max_element_row_major.json | 37 ++ .../one_norm_column_major.json | 37 ++ .../negative_strides/one_norm_row_major.json | 37 ++ .../offsets/frobenius_norm_column_major.json | 39 ++ .../offsets/frobenius_norm_row_major.json | 39 ++ .../offsets/infinity_norm_column_major.json | 39 ++ .../offsets/infinity_norm_row_major.json | 39 ++ .../offsets/max_element_column_major.json | 39 ++ .../offsets/max_element_row_major.json | 39 ++ .../offsets/one_norm_column_major.json | 39 ++ .../fixtures/offsets/one_norm_row_major.json | 39 ++ .../lapack/base/dlange/test/test.ndarray.js | 548 ++++++++++++++++++ 33 files changed, 1868 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/frobenius_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/frobenius_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/infinity_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/infinity_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/max_element_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/max_element_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/frobenius_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/frobenius_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/infinity_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/infinity_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/max_element_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/max_element_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/frobenius_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/frobenius_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/infinity_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/infinity_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/max_element_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/max_element_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/frobenius_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/frobenius_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/infinity_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/infinity_norm_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/max_element_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/max_element_row_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_column_major.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_row_major.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/frobenius_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/frobenius_norm_column_major.json new file mode 100644 index 000000000000..8168d1896b13 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/frobenius_norm_column_major.json @@ -0,0 +1,52 @@ +{ + "order": "column-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 7.0, + 9999.0, + 8.0, + 9999.0, + 9.0, + 9999.0, + 10.0, + 9999.0, + 11.0, + 9999.0, + 12.0, + 9999.0 + ], + "LDA": 3, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "strideWork": 2, + "offsetWork": 0, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/frobenius_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/frobenius_norm_row_major.json new file mode 100644 index 000000000000..ef0b68f136c2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/frobenius_norm_row_major.json @@ -0,0 +1,52 @@ +{ + "order": "row-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ + 1.0, + 9999.0, + 4.0, + 9999.0, + 7.0, + 9999.0, + 10.0, + 9999.0, + 2.0, + 9999.0, + 5.0, + 9999.0, + 8.0, + 9999.0, + 11.0, + 9999.0, + 3.0, + 9999.0, + 6.0, + 9999.0, + 9.0, + 9999.0, + 12.0, + 9999.0 + ], + "LDA": 4, + "strideA1": 8, + "strideA2": 2, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "strideWork": 2, + "offsetWork": 0, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/infinity_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/infinity_norm_column_major.json new file mode 100644 index 000000000000..052dc8b4e32e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/infinity_norm_column_major.json @@ -0,0 +1,52 @@ +{ + "order": "column-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 7.0, + 9999.0, + 8.0, + 9999.0, + 9.0, + 9999.0, + 10.0, + 9999.0, + 11.0, + 9999.0, + 12.0, + 9999.0 + ], + "LDA": 3, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "strideWork": 2, + "offsetWork": 0, + "expected": 30 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/infinity_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/infinity_norm_row_major.json new file mode 100644 index 000000000000..2974f5891f0e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/infinity_norm_row_major.json @@ -0,0 +1,52 @@ +{ + "order": "row-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ + 1.0, + 9999.0, + 4.0, + 9999.0, + 7.0, + 9999.0, + 10.0, + 9999.0, + 2.0, + 9999.0, + 5.0, + 9999.0, + 8.0, + 9999.0, + 11.0, + 9999.0, + 3.0, + 9999.0, + 6.0, + 9999.0, + 9.0, + 9999.0, + 12.0, + 9999.0 + ], + "LDA": 4, + "strideA1": 8, + "strideA2": 2, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "strideWork": 2, + "offsetWork": 0, + "expected": 30 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/max_element_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/max_element_column_major.json new file mode 100644 index 000000000000..e9c4eabd709d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/max_element_column_major.json @@ -0,0 +1,52 @@ +{ + "order": "column-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 7.0, + 9999.0, + 8.0, + 9999.0, + 9.0, + 9999.0, + 10.0, + 9999.0, + 11.0, + 9999.0, + 12.0, + 9999.0 + ], + "LDA": 3, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "strideWork": 2, + "offsetWork": 0, + "expected": 12 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/max_element_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/max_element_row_major.json new file mode 100644 index 000000000000..50e75dd2987d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/max_element_row_major.json @@ -0,0 +1,52 @@ +{ + "order": "row-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ + 1.0, + 9999.0, + 4.0, + 9999.0, + 7.0, + 9999.0, + 10.0, + 9999.0, + 2.0, + 9999.0, + 5.0, + 9999.0, + 8.0, + 9999.0, + 11.0, + 9999.0, + 3.0, + 9999.0, + 6.0, + 9999.0, + 9.0, + 9999.0, + 12.0, + 9999.0 + ], + "LDA": 4, + "strideA1": 8, + "strideA2": 2, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "strideWork": 2, + "offsetWork": 0, + "expected": 12 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_column_major.json new file mode 100644 index 000000000000..e3a3f7541e9d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_column_major.json @@ -0,0 +1,52 @@ +{ + "order": "column-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 7.0, + 9999.0, + 8.0, + 9999.0, + 9.0, + 9999.0, + 10.0, + 9999.0, + 11.0, + 9999.0, + 12.0, + 9999.0 + ], + "LDA": 3, + "strideA1": 2, + "strideA2": 6, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "strideWork": 2, + "offsetWork": 0, + "expected": 33 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_row_major.json new file mode 100644 index 000000000000..25b303fd2951 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_row_major.json @@ -0,0 +1,52 @@ +{ + "order": "row-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ + 1.0, + 9999.0, + 4.0, + 9999.0, + 7.0, + 9999.0, + 10.0, + 9999.0, + 2.0, + 9999.0, + 5.0, + 9999.0, + 8.0, + 9999.0, + 11.0, + 9999.0, + 3.0, + 9999.0, + 6.0, + 9999.0, + 9.0, + 9999.0, + 12.0, + 9999.0 + ], + "LDA": 4, + "strideA1": 8, + "strideA2": 2, + "offsetA": 0, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 9999.0, + 0.0, + 9999.0, + 0.0, + 9999.0 + ], + "strideWork": 2, + "offsetWork": 0, + "expected": 33 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/frobenius_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/frobenius_norm_column_major.json new file mode 100644 index 000000000000..84aeade96f67 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/frobenius_norm_column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ + 10.0, + 11.0, + 12.0, + 7.0, + 8.0, + 9.0, + 4.0, + 5.0, + 6.0, + 1.0, + 2.0, + 3.0 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": -3, + "offsetA": 9, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 0, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/frobenius_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/frobenius_norm_row_major.json new file mode 100644 index 000000000000..7f662e050a6a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/frobenius_norm_row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ + 3.0, + 6.0, + 9.0, + 12.0, + 2.0, + 5.0, + 8.0, + 11.0, + 1.0, + 4.0, + 7.0, + 10.0 + ], + "LDA": 4, + "strideA1": -4, + "strideA2": 1, + "offsetA": 8, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 0, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/infinity_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/infinity_norm_column_major.json new file mode 100644 index 000000000000..b2569fe02d1e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/infinity_norm_column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ + 10.0, + 11.0, + 12.0, + 7.0, + 8.0, + 9.0, + 4.0, + 5.0, + 6.0, + 1.0, + 2.0, + 3.0 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": -3, + "offsetA": 9, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 0, + "expected": 30 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/infinity_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/infinity_norm_row_major.json new file mode 100644 index 000000000000..ac8f48218d25 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/infinity_norm_row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ + 3.0, + 6.0, + 9.0, + 12.0, + 2.0, + 5.0, + 8.0, + 11.0, + 1.0, + 4.0, + 7.0, + 10.0 + ], + "LDA": 4, + "strideA1": -4, + "strideA2": 1, + "offsetA": 8, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 0, + "expected": 30 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/max_element_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/max_element_column_major.json new file mode 100644 index 000000000000..9657df72105f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/max_element_column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ + 10.0, + 11.0, + 12.0, + 7.0, + 8.0, + 9.0, + 4.0, + 5.0, + 6.0, + 1.0, + 2.0, + 3.0 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": -3, + "offsetA": 9, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 0, + "expected": 12 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/max_element_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/max_element_row_major.json new file mode 100644 index 000000000000..9977ce92a76d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/max_element_row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ + 3, + 6, + 9, + 12, + 2, + 5, + 8, + 11, + 1, + 4, + 7, + 10 + ], + "LDA": 4, + "strideA1": -4, + "strideA2": 1, + "offsetA": 8, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 0, + "expected": 12 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_column_major.json new file mode 100644 index 000000000000..56aaec953541 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ + 10.0, + 11.0, + 12.0, + 7.0, + 8.0, + 9.0, + 4.0, + 5.0, + 6.0, + 1.0, + 2.0, + 3.0 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": -3, + "offsetA": 9, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 0, + "expected": 33 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_row_major.json new file mode 100644 index 000000000000..4f3b3c9bb2c2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ + 3.0, + 6.0, + 9.0, + 12.0, + 2.0, + 5.0, + 8.0, + 11.0, + 1.0, + 4.0, + 7.0, + 10.0 + ], + "LDA": 4, + "strideA1": -4, + "strideA2": 1, + "offsetA": 8, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 0, + "expected": 33 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/frobenius_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/frobenius_norm_column_major.json new file mode 100644 index 000000000000..5083600df887 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/frobenius_norm_column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ + 12.0, + 11.0, + 10.0, + 9.0, + 8.0, + 7.0, + 6.0, + 5.0, + 4.0, + 3.0, + 2.0, + 1.0 + ], + "LDA": 3, + "strideA1": -1, + "strideA2": -3, + "offsetA": 11, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": -1, + "offsetWork": 2, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/frobenius_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/frobenius_norm_row_major.json new file mode 100644 index 000000000000..646c9f821998 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/frobenius_norm_row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ + 12.0, + 9.0, + 6.0, + 3.0, + 11.0, + 8.0, + 5.0, + 2.0, + 10.0, + 7.0, + 4.0, + 1.0 + ], + "LDA": 4, + "strideA1": -4, + "strideA2": -1, + "offsetA": 11, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": -1, + "offsetWork": 2, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/infinity_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/infinity_norm_column_major.json new file mode 100644 index 000000000000..2a3196b91235 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/infinity_norm_column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ + 12.0, + 11.0, + 10.0, + 9.0, + 8.0, + 7.0, + 6.0, + 5.0, + 4.0, + 3.0, + 2.0, + 1.0 + ], + "LDA": 3, + "strideA1": -1, + "strideA2": -3, + "offsetA": 11, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": -1, + "offsetWork": 2, + "expected": 30 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/infinity_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/infinity_norm_row_major.json new file mode 100644 index 000000000000..6314f68541a4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/infinity_norm_row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ + 12.0, + 9.0, + 6.0, + 3.0, + 11.0, + 8.0, + 5.0, + 2.0, + 10.0, + 7.0, + 4.0, + 1.0 + ], + "LDA": 4, + "strideA1": -4, + "strideA2": -1, + "offsetA": 11, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": -1, + "offsetWork": 2, + "expected": 30 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/max_element_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/max_element_column_major.json new file mode 100644 index 000000000000..2d9f4a261acd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/max_element_column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ + 12.0, + 11.0, + 10.0, + 9.0, + 8.0, + 7.0, + 6.0, + 5.0, + 4.0, + 3.0, + 2.0, + 1.0 + ], + "LDA": 3, + "strideA1": -1, + "strideA2": -3, + "offsetA": 11, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": -1, + "offsetWork": 2, + "expected": 12 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/max_element_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/max_element_row_major.json new file mode 100644 index 000000000000..5b5270fa1c6b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/max_element_row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ + 12.0, + 9.0, + 6.0, + 3.0, + 11.0, + 8.0, + 5.0, + 2.0, + 10.0, + 7.0, + 4.0, + 1.0 + ], + "LDA": 4, + "strideA1": -4, + "strideA2": -1, + "offsetA": 11, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": -1, + "offsetWork": 2, + "expected": 12 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_column_major.json new file mode 100644 index 000000000000..7391e569578b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_column_major.json @@ -0,0 +1,37 @@ +{ + "order": "column-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ + 12.0, + 11.0, + 10.0, + 9.0, + 8.0, + 7.0, + 6.0, + 5.0, + 4.0, + 3.0, + 2.0, + 1.0 + ], + "LDA": 3, + "strideA1": -1, + "strideA2": -3, + "offsetA": 11, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": -1, + "offsetWork": 2, + "expected": 33 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_row_major.json new file mode 100644 index 000000000000..b324bcf6d1aa --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_row_major.json @@ -0,0 +1,37 @@ +{ + "order": "row-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ + 12.0, + 9.0, + 6.0, + 3.0, + 11.0, + 8.0, + 5.0, + 2.0, + 10.0, + 7.0, + 4.0, + 1.0 + ], + "LDA": 4, + "strideA1": -4, + "strideA2": -1, + "offsetA": 11, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 0.0, + 0.0, + 0.0 + ], + "strideWork": -1, + "offsetWork": 2, + "expected": 33 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/frobenius_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/frobenius_norm_column_major.json new file mode 100644 index 000000000000..8b76307a3faa --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/frobenius_norm_column_major.json @@ -0,0 +1,39 @@ +{ + "order": "column-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ + 9999.0, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 9999.0, + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 1, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/frobenius_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/frobenius_norm_row_major.json new file mode 100644 index 000000000000..20da98f12127 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/frobenius_norm_row_major.json @@ -0,0 +1,39 @@ +{ + "order": "row-major", + "norm": "frobenius", + "M": 3, + "N": 4, + "A": [ + 9999.0, + 1.0, + 4.0, + 7.0, + 10.0, + 2.0, + 5.0, + 8.0, + 11.0, + 3.0, + 6.0, + 9.0, + 12.0 + ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 1, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 9999.0, + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 1, + "expected": 25.495097567963924 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/infinity_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/infinity_norm_column_major.json new file mode 100644 index 000000000000..2cc1f968c9b7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/infinity_norm_column_major.json @@ -0,0 +1,39 @@ +{ + "order": "column-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ + 9999.0, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 9999.0, + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 1, + "expected": 30 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/infinity_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/infinity_norm_row_major.json new file mode 100644 index 000000000000..e66529cedf46 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/infinity_norm_row_major.json @@ -0,0 +1,39 @@ +{ + "order": "row-major", + "norm": "infinity", + "M": 3, + "N": 4, + "A": [ + 9999.0, + 1.0, + 4.0, + 7.0, + 10.0, + 2.0, + 5.0, + 8.0, + 11.0, + 3.0, + 6.0, + 9.0, + 12.0 + ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 1, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 9999.0, + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 1, + "expected": 30 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/max_element_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/max_element_column_major.json new file mode 100644 index 000000000000..ea84859af5a7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/max_element_column_major.json @@ -0,0 +1,39 @@ +{ + "order": "column-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ + 9999.0, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 9999.0, + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 1, + "expected": 12 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/max_element_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/max_element_row_major.json new file mode 100644 index 000000000000..697141cde7aa --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/max_element_row_major.json @@ -0,0 +1,39 @@ +{ + "order": "row-major", + "norm": "max", + "M": 3, + "N": 4, + "A": [ + 9999.0, + 1.0, + 4.0, + 7.0, + 10.0, + 2.0, + 5.0, + 8.0, + 11.0, + 3.0, + 6.0, + 9.0, + 12.0 + ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 1, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 9999.0, + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 1, + "expected": 12 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_column_major.json new file mode 100644 index 000000000000..312aa88354c7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_column_major.json @@ -0,0 +1,39 @@ +{ + "order": "column-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ + 9999.0, + 1.0, + 2.0, + 3.0, + 4.0, + 5.0, + 6.0, + 7.0, + 8.0, + 9.0, + 10.0, + 11.0, + 12.0 + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 1, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 9999.0, + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 1, + "expected": 33 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_row_major.json new file mode 100644 index 000000000000..4bdb3f53f26d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_row_major.json @@ -0,0 +1,39 @@ +{ + "order": "row-major", + "norm": "one", + "M": 3, + "N": 4, + "A": [ + 9999.0, + 1.0, + 4.0, + 7.0, + 10.0, + 2.0, + 5.0, + 8.0, + 11.0, + 3.0, + 6.0, + 9.0, + 12.0 + ], + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 1, + "A_mat": [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ], + "work": [ + 9999.0, + 0.0, + 0.0, + 0.0 + ], + "strideWork": 1, + "offsetWork": 1, + "expected": 33 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js index eb8f288ee4a3..fb8a050420fa 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js @@ -38,6 +38,42 @@ var MAX_ELEMENT_COLUMN_MAJOR = require( './fixtures/max_element_column_major.jso var FROBENIUS_NORM_ROW_MAJOR = require( './fixtures/frobenius_norm_row_major.json' ); var FROBENIUS_NORM_COLUMN_MAJOR = require( './fixtures/frobenius_norm_column_major.json' ); +var OFFSET_ONE_NORM_ROW_MAJOR = require( './fixtures/offsets/one_norm_row_major.json' ); +var OFFSET_ONE_NORM_COLUMN_MAJOR = require( './fixtures/offsets/one_norm_column_major.json' ); +var OFFSET_INFINITY_NORM_ROW_MAJOR = require( './fixtures/offsets/infinity_norm_row_major.json' ); +var OFFSET_INFINITY_NORM_COLUMN_MAJOR = require( './fixtures/offsets/infinity_norm_column_major.json' ); +var OFFSET_MAX_ELEMENT_ROW_MAJOR = require( './fixtures/offsets/max_element_row_major.json' ); +var OFFSET_MAX_ELEMENT_COLUMN_MAJOR = require( './fixtures/offsets/max_element_column_major.json' ); +var OFFSET_FROBENIUS_NORM_ROW_MAJOR = require( './fixtures/offsets/frobenius_norm_row_major.json' ); +var OFFSET_FROBENIUS_NORM_COLUMN_MAJOR = require( './fixtures/offsets/frobenius_norm_column_major.json' ); + +var NEGATIVE_STRIDES_ONE_NORM_ROW_MAJOR = require( './fixtures/negative_strides/one_norm_row_major.json' ); +var NEGATIVE_STRIDES_ONE_NORM_COLUMN_MAJOR = require( './fixtures/negative_strides/one_norm_column_major.json' ); +var NEGATIVE_STRIDES_INFINITY_NORM_ROW_MAJOR = require( './fixtures/negative_strides/infinity_norm_row_major.json' ); +var NEGATIVE_STRIDES_INFINITY_NORM_COLUMN_MAJOR = require( './fixtures/negative_strides/infinity_norm_column_major.json' ); +var NEGATIVE_STRIDES_MAX_ELEMENT_ROW_MAJOR = require( './fixtures/negative_strides/max_element_row_major.json' ); +var NEGATIVE_STRIDES_MAX_ELEMENT_COLUMN_MAJOR = require( './fixtures/negative_strides/max_element_column_major.json' ); +var NEGATIVE_STRIDES_FROBENIUS_NORM_ROW_MAJOR = require( './fixtures/negative_strides/frobenius_norm_row_major.json' ); +var NEGATIVE_STRIDES_FROBENIUS_NORM_COLUMN_MAJOR = require( './fixtures/negative_strides/frobenius_norm_column_major.json' ); + +var MIXED_STRIDES_ONE_NORM_ROW_MAJOR = require( './fixtures/mixed_strides/one_norm_row_major.json' ); +var MIXED_STRIDES_ONE_NORM_COLUMN_MAJOR = require( './fixtures/mixed_strides/one_norm_column_major.json' ); +var MIXED_STRIDES_INFINITY_NORM_ROW_MAJOR = require( './fixtures/mixed_strides/infinity_norm_row_major.json' ); +var MIXED_STRIDES_INFINITY_NORM_COLUMN_MAJOR = require( './fixtures/mixed_strides/infinity_norm_column_major.json' ); +var MIXED_STRIDES_MAX_ELEMENT_ROW_MAJOR = require( './fixtures/mixed_strides/max_element_row_major.json' ); +var MIXED_STRIDES_MAX_ELEMENT_COLUMN_MAJOR = require( './fixtures/mixed_strides/max_element_column_major.json' ); +var MIXED_STRIDES_FROBENIUS_NORM_ROW_MAJOR = require( './fixtures/mixed_strides/frobenius_norm_row_major.json' ); +var MIXED_STRIDES_FROBENIUS_NORM_COLUMN_MAJOR = require( './fixtures/mixed_strides/frobenius_norm_column_major.json' ); + +var LARGE_STRIDES_ONE_NORM_ROW_MAJOR = require( './fixtures/large_strides/one_norm_row_major.json' ); +var LARGE_STRIDES_ONE_NORM_COLUMN_MAJOR = require( './fixtures/large_strides/one_norm_column_major.json' ); +var LARGE_STRIDES_INFINITY_NORM_ROW_MAJOR = require( './fixtures/large_strides/infinity_norm_row_major.json' ); +var LARGE_STRIDES_INFINITY_NORM_COLUMN_MAJOR = require( './fixtures/large_strides/infinity_norm_column_major.json' ); +var LARGE_STRIDES_MAX_ELEMENT_ROW_MAJOR = require( './fixtures/large_strides/max_element_row_major.json' ); +var LARGE_STRIDES_MAX_ELEMENT_COLUMN_MAJOR = require( './fixtures/large_strides/max_element_column_major.json' ); +var LARGE_STRIDES_FROBENIUS_NORM_ROW_MAJOR = require( './fixtures/large_strides/frobenius_norm_row_major.json' ); +var LARGE_STRIDES_FROBENIUS_NORM_COLUMN_MAJOR = require( './fixtures/large_strides/frobenius_norm_column_major.json' ); + // TESTS // @@ -235,3 +271,515 @@ tape( 'the function calculates the maximum absolute value for a given matrix A ( t.strictEqual( out, data.expected, 'returns expected value' ); t.end(); }); + +tape( 'the function calculates the one norm for a given matrix A (row-major) (offsets)', function test( t ) { + var data; + var work; + var out; + var A; + + data = OFFSET_ONE_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (column-major) (offsets)', function test( t ) { + var data; + var work; + var out; + var A; + + data = OFFSET_ONE_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (row-major) (offsets)', function test( t ) { + var data; + var work; + var out; + var A; + + data = OFFSET_INFINITY_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (column-major) (offsets)', function test( t ) { + var data; + var work; + var out; + var A; + + data = OFFSET_INFINITY_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (row-major) (offsets)', function test( t ) { + var data; + var work; + var out; + var A; + + data = OFFSET_FROBENIUS_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (column-major) (offsets)', function test( t ) { + var data; + var work; + var out; + var A; + + data = OFFSET_FROBENIUS_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (row-major) (offsets)', function test( t ) { + var data; + var work; + var out; + var A; + + data = OFFSET_MAX_ELEMENT_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (column-major) (offsets)', function test( t ) { + var data; + var work; + var out; + var A; + + data = OFFSET_MAX_ELEMENT_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (row-major) (negative strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = NEGATIVE_STRIDES_ONE_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (column-major) (negative strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = NEGATIVE_STRIDES_ONE_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (row-major) (negative strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = NEGATIVE_STRIDES_INFINITY_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (column-major) (negative strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = NEGATIVE_STRIDES_INFINITY_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (row-major) (negative strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = NEGATIVE_STRIDES_FROBENIUS_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (column-major) (negative strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = NEGATIVE_STRIDES_FROBENIUS_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (row-major) (negative strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = NEGATIVE_STRIDES_MAX_ELEMENT_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (column-major) (negative strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = NEGATIVE_STRIDES_MAX_ELEMENT_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (row-major) (mixed strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MIXED_STRIDES_ONE_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (column-major) (mixed strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MIXED_STRIDES_ONE_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (row-major) (mixed strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MIXED_STRIDES_INFINITY_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (column-major) (mixed strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MIXED_STRIDES_INFINITY_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (row-major) (mixed strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MIXED_STRIDES_FROBENIUS_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (column-major) (mixed strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MIXED_STRIDES_FROBENIUS_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (row-major) (mixed strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MIXED_STRIDES_MAX_ELEMENT_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (column-major) (mixed strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = MIXED_STRIDES_MAX_ELEMENT_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (row-major) (large strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = LARGE_STRIDES_ONE_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the one norm for a given matrix A (column-major) (large strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = LARGE_STRIDES_ONE_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (row-major) (large strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = LARGE_STRIDES_INFINITY_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the infinity norm for a given matrix A (column-major) (large strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = LARGE_STRIDES_INFINITY_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (row-major) (large strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = LARGE_STRIDES_FROBENIUS_NORM_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the frobenius norm for a given matrix A (column-major) (large strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = LARGE_STRIDES_FROBENIUS_NORM_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (row-major) (large strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = LARGE_STRIDES_MAX_ELEMENT_ROW_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the maximum absolute value for a given matrix A (column-major) (large strides)', function test( t ) { + var data; + var work; + var out; + var A; + + data = LARGE_STRIDES_MAX_ELEMENT_COLUMN_MAJOR; + + A = new Float64Array( data.A ); + work = new Float64Array( data.work ); + + out = dlange( data.norm, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA, work, data.strideWork, data.offsetWork ); + t.strictEqual( out, data.expected, 'returns expected value' ); + t.end(); +}); From df66e944d5f9d52c38e905261dabfeb9b35cf120 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 05:04:01 +0000 Subject: [PATCH 07/20] feat: add benchmarks and examples --- 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: passed - 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/dlange/benchmark/benchmark.js | 129 ++++++++++++++++ .../dlange/benchmark/benchmark.ndarray.js | 141 ++++++++++++++++++ .../lapack/base/dlange/examples/index.js | 39 +++++ .../@stdlib/lapack/base/dlange/package.json | 72 +++++++++ 4 files changed, 381 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/package.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js new file mode 100644 index 000000000000..4ec683f95bbf --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js @@ -0,0 +1,129 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +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 Float64Array = require( '@stdlib/array/float64' ); +var pkg = require( './../package.json' ).name; +var dlange = require( './../lib/dlange.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var NORMS = [ + 'max', + 'one', + 'infinity', + 'frobenius' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @param {string} norm - specifies the type of norm to be calculated +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N, norm ) { + var work; + var A; + + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + work = new Float64Array( N ); + 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 = dlange( order, norm, N, N, A, N, work ); + 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 norm; + var min; + var max; + var ord; + var N; + var f; + var i; + var j; + 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++ ) { + for ( j = 0; j < NORMS.length; j++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + norm = NORMS[ j ]; + f = createBenchmark( ord, N, norm ); + bench( pkg+'::square_matrix:order='+ord+',norm='+norm+',size='+(N*N), f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..2641ed72ce58 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js @@ -0,0 +1,141 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pkg = require( './../package.json' ).name; +var dlange = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var NORMS = [ + 'max', + 'one', + 'infinity', + 'frobenius' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @param {string} norm - specifies the type of norm to be calculated +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N, norm ) { + var work; + var sa1; + var sa2; + var A; + + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + work = new Float64Array( N ); + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { + sa1 = N; + sa2 = 1; + } + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dlange( norm, N, N, A, sa1, sa2, 0, work, 1, 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 norm; + var min; + var max; + var ord; + var N; + var f; + var i; + var j; + 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++ ) { + for ( j = 0; j < NORMS.length; j++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + norm = NORMS[ j ]; + f = createBenchmark( ord, N, norm ); + bench( pkg+'::square_matrix:order='+ord+',norm='+norm+',size='+(N*N), f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js new file mode 100644 index 000000000000..5ee136ff2248 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js @@ -0,0 +1,39 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dlange = require( './../lib' ); + +// Specify matrix meta data: +var shape = [ 3, 4 ]; +var strides = [ 4, 1 ]; +var offset = 0; +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); // eslint-disable-line max-len +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +var work = new Float64Array( 3 ); + +// Calculate the infinity norm: +var out = dlange( order, 'infinity', shape[ 0 ], shape[ 1 ], A, strides[ 0 ], work ); +console.log( 'Infinity norm: ', out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/package.json b/lib/node_modules/@stdlib/lapack/base/dlange/package.json new file mode 100644 index 000000000000..33dd757212d7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/lapack/base/dlange", + "version": "0.0.0", + "description": "LAPACK routine to calculate the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix A.", + "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", + "dlange", + "norm", + "max", + "frobenius", + "permute", + "permutedims", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} From b8950555b7a849854538d81374516196d6e18db6 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 05:52:17 +0000 Subject: [PATCH 08/20] docs: add index.d.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: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../lapack/base/dlange/docs/types/index.d.ts | 149 ++++++++++++++++++ .../@stdlib/lapack/base/dlange/lib/base.js | 14 +- .../@stdlib/lapack/base/dlange/lib/dlange.js | 4 +- .../@stdlib/lapack/base/dlange/lib/ndarray.js | 14 +- 4 files changed, 165 insertions(+), 16 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts new file mode 100644 index 000000000000..eadfdde54501 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts @@ -0,0 +1,149 @@ +/* +* @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'; + +/** +* Norm parameter. +* +* ## Notes +* +* The norm parameter can be one of the following: +* +* - 'max': finds the maximum absolute value +* - 'infinity': finds the infinity norm +* - 'one': finds the one norm +* - 'frobenius': finds the frobenius norm +*/ +type Norm = 'max' | 'one' | 'infinity' | 'frobenius'; + +/** +* Interface describing `dlange`. +*/ +interface Routine { + /** + * Returns the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. + * + * ## Notes + * + * - use `norm` = `max`, to calculate the element with the largest absolute value + * - use `norm` = `one`, to calculate the one norm + * - use `norm` = `infinity`, to calculate the infinity norm + * - use `norm` = `frobenius`, to calculate the frobenius norm + * + * @param order - storage layout + * @param norm - specifies the type of norm to be calculated + * @param M - number of rows in `A` + * @param N - number of columns in `A` + * @param A - input array + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array + * @returns required norm value + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); + * var work = new Float64Array( 3 ); + * + * var out = dlange( 'row-major', 'frobenius', 3, 4, A, 4, work ); + * // returns ~25.5 + */ + ( order: Layout, norm: Norm, M: number, N: number, A: Float64Array, LDA: number, work: Float64Array ): number; + + /** + * Returns the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. + * + * ## Notes + * + * - use `norm` = `max`, to calculate the element with the largest absolute value + * - use `norm` = `one`, to calculate the one norm + * - use `norm` = `infinity`, to calculate the infinity norm + * - use `norm` = `frobenius`, to calculate the frobenius norm + * + * @param norm - specifies the type of norm to be calculated + * @param M - number of rows in `A` + * @param N - number of columns in `A` + * @param A - input array + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index of `A` + * @param work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array + * @param strideWork - stride length of `work` + * @param offsetWork - starting index of `work` + * @returns required norm value + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); + * var work = new Float64Array( 3 ); + * + * var out = dlange.ndarray( 'frobenius', 3, 4, A, 4, 1, 0, work, 1, 0 ); + * // returns ~25.5 + */ + ndarray( norm: Norm, M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, work: Float64Array, strideWork: number, offsetWork: number ): number; +} + +/** +* Returns the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. +* +* ## Notes +* +* - use `norm` = `max`, to calculate the element with the largest absolute value +* - use `norm` = `one`, to calculate the one norm +* - use `norm` = `infinity`, to calculate the infinity norm +* - use `norm` = `frobenius`, to calculate the frobenius norm +* +* @param order - storage layout +* @param norm - specifies the type of norm to be calculated +* @param M - number of rows in `A` +* @param N - number of columns in `A` +* @param A - input array +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @returns required norm value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* var work = new Float64Array( 3 ); +* +* var out = dlange( 'row-major', 'frobenius', 3, 4, A, 4, work ); +* // returns ~25.5 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* var work = new Float64Array( 3 ); +* +* var out = dlange.ndarray( 'frobenius', 3, 4, A, 4, 1, 0, work, 1, 0 ); +* // returns ~25.5 +*/ +declare var dlange: Routine; + + +// EXPORTS // + +export = dlange; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 7f276566770e..00d19e48ac46 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -42,15 +42,15 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); * * @private * @param {string} norm - specifies the type of norm to be calculated -* @param {Float64Array} M - number of rows in `A` -* @param {Float64Array} N - number of columns in `A` +* @param {NonNegativeInteger} M - number of rows in `A` +* @param {NonNegativeInteger} N - number of columns in `A` * @param {Float64Array} A - input array -* @param {Float64Array} strideA1 - stride of the first dimension of `A` -* @param {Float64Array} strideA2 - stride of the second dimension of `A` -* @param {Float64Array} offsetA - starting index of `A` +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index of `A` * @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array -* @param {Float64Array} strideWork - stride length of `work` -* @param {Float64Array} offsetWork - starting index of `work` +* @param {integer} strideWork - stride length of `work` +* @param {NonNegativeInteger} offsetWork - starting index of `work` * @returns {number} required norm value * * @example diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js index c9d91f88ad5c..49b6fdff3650 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -44,8 +44,8 @@ var base = require( './base.js' ); * @private * @param {string} order - storage layout * @param {string} norm - specifies the type of norm to be calculated -* @param {Float64Array} M - number of rows in `A` -* @param {Float64Array} N - number of columns in `A` +* @param {NonNegativeInteger} M - number of rows in `A` +* @param {NonNegativeInteger} N - number of columns in `A` * @param {Float64Array} A - input array * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js index 918331199fc5..08f4ddcf08c0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -38,15 +38,15 @@ var base = require( './base.js' ); * - use `norm` = `frobenius`, to calculate the frobenius norm * * @param {string} norm - specifies the type of norm to be calculated -* @param {Float64Array} M - number of rows in `A` -* @param {Float64Array} N - number of columns in `A` +* @param {NonNegativeInteger} M - number of rows in `A` +* @param {NonNegativeInteger} N - number of columns in `A` * @param {Float64Array} A - input array -* @param {Float64Array} strideA1 - stride of the first dimension of `A` -* @param {Float64Array} strideA2 - stride of the second dimension of `A` -* @param {Float64Array} offsetA - starting index of `A` +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index of `A` * @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array -* @param {Float64Array} strideWork - stride length of `work` -* @param {Float64Array} offsetWork - starting index of `work` +* @param {integer} strideWork - stride length of `work` +* @param {NonNegativeInteger} offsetWork - starting index of `work` * @throws {TypeError} first argument must be a valid operation * @returns {number} required norm value * From e5bd831c5af855b339c8943d28daed79158047c0 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 06:24:56 +0000 Subject: [PATCH 09/20] 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/dlange/docs/types/test.ts | 326 ++++++++++++++++++ 1 file changed, 326 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts new file mode 100644 index 000000000000..0e7c3545f65b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts @@ -0,0 +1,326 @@ +/* +* @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 dlange = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange( 'row-major', 'max', 2, 2, A, 2, work ); // $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 ); + const work = new Float64Array( 1 ); + + dlange( 5, 'max', 2, 2, A, 2, work ); // $ExpectError + dlange( true, 'max', 2, 2, A, 2, work ); // $ExpectError + dlange( false, 'max', 2, 2, A, 2, work ); // $ExpectError + dlange( null, 'max', 2, 2, A, 2, work ); // $ExpectError + dlange( void 0, 'max', 2, 2, A, 2, work ); // $ExpectError + dlange( [], 'max', 2, 2, A, 2, work ); // $ExpectError + dlange( {}, 'max', 2, 2, A, 2, work ); // $ExpectError + dlange( ( x: number ): number => x, 'max', 2, 2, A, 2, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange( 'row-major', 5, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', true, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', false, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', null, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', void 0, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', [], 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', {}, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', ( x: number ): number => x, 2, 2, A, 2, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange( 'row-major', 'max', '5', 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', true, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', false, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', null, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', void 0, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', [], 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', {}, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', ( x: number ): number => x, 2, A, 2, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange( 'row-major', 'max', 2, '2', A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, true, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, false, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, null, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, void 0, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, [], A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, {}, A, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, ( x: number ): number => x, A, 2, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const work = new Float64Array( 1 ); + + dlange( 'row-major', 'max', 2, 2, '5', 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, 5, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, true, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, false, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, null, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, void 0, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, [], 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, {}, 2, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, ( x: number ): number => x, 2, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange( 'row-major', 'max', 2, 2, A, '2', work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, true, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, false, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, null, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, void 0, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, [], work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, {}, work ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, ( x: number ): number => x, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const A = new Float64Array( 4 ); + + dlange( 'row-major', 'max', 2, 2, A, 2, '5' ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, 5 ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, true ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, false ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, null ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, void 0 ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, [] ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, {} ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, ( 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 ); + const work = new Float64Array( 1 ); + + dlange(); // $ExpectError + dlange( 'row-major' ); // $ExpectError + dlange( 'row-major', 'max' ); // $ExpectError + dlange( 'row-major', 'max', 2 ); // $ExpectError + dlange( 'row-major', 'max', 2, 2 ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2 ); // $ExpectError + dlange( 'row-major', 'max', 2, 2, A, 2, work, 1 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $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 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 5, 2, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( true, 2, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( false, 2, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( null, 2, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( void 0, 2, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( [], 2, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( {}, 2, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( ( x: number ): number => x, 2, 2, A, 2, 1, work, 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 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', '2', 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', true, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', false, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', null, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', void 0, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', [], 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', {}, 2, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', ( x: number ): number => x, 2, A, 2, 1, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', 2, '2', A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, true, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, false, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, null, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, void 0, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, [], A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, {}, A, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, ( x: number ): number => x, A, 2, 1, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', 2, 2, '5', 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, 5, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, true, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, false, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, null, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, void 0, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, [], 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, {}, 2, 1, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, ( x: number ): number => x, 2, 1, work, 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 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', 2, 2, A, '2', 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, true, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, false, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, null, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, void 0, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, [], 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, {}, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, ( x: number ): number => x, 1, 0, work, 1, 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 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', 2, 2, A, 2, '1', 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, true, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, false, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, null, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, void 0, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, [], 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, {}, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, ( x: number ): number => x, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', 2, 2, A, 2, 1, '0', work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, true, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, false, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, null, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, void 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, [], work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, {}, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, ( x: number ): number => x, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +{ + const A = new Float64Array( 4 ); + + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, '5', 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, 5, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, true, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, false, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, null, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, void 0, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, [], 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, {}, 1, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, '1', 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, true, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, false, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, null, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, void 0, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, [], 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, {}, 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( 4 ); + const work = new Float64Array( 1 ); + + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, '0' ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, true ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, false ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, null ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, void 0 ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, [] ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, {} ); // $ExpectError + dlange.ndarray( 'max', 2, 2, A, 2, 1, 0, work, 1, ( 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 ); + const work = new Float64Array( 1 ); + + dlange.ndarray(); // $ExpectError + dlange.ndarray( 'row-major' ); // $ExpectError + dlange.ndarray( 'row-major', 'max' ); // $ExpectError + dlange.ndarray( 'row-major', 'max', 2 ); // $ExpectError + dlange.ndarray( 'row-major', 'max', 2, 2 ); // $ExpectError + dlange.ndarray( 'row-major', 'max', 2, 2, A ); // $ExpectError + dlange.ndarray( 'row-major', 'max', 2, 2, A, 2 ); // $ExpectError + dlange.ndarray( 'row-major', 'max', 2, 2, A, 2, 1 ); // $ExpectError + dlange.ndarray( 'row-major', 'max', 2, 2, A, 2, 1, work ); // $ExpectError + dlange.ndarray( 'row-major', 'max', 2, 2, A, 2, 1, work, 1 ); // $ExpectError + dlange.ndarray( 'row-major', 'max', 2, 2, A, 2, 1, work, 1, 0, 1 ); // $ExpectError +} From 9883b180c90fe83d011fd85a86ff3c1d91b6e689 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 16:06:15 +0000 Subject: [PATCH 10/20] refactor: loop reordering --- 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/dlange/lib/base.js | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 00d19e48ac46..7a7d3c93634c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -22,6 +22,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var dlassq = require( '@stdlib/lapack/base/dlassq' ).ndarray; +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); var Float64Array = require( '@stdlib/array/float64' ); var min = require( '@stdlib/math/base/special/min' ); var abs = require( '@stdlib/math/base/special/abs' ); @@ -79,17 +80,32 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o else if ( norm === 'max' ) { value = 0.0; - ia1 = offsetA; - for ( i = 0; i < M; i++ ) { - ia2 = 0; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ia1 = offsetA; + for ( i = 0; i < M; i++ ) { + ia2 = 0; + for ( j = 0; j < N; j++ ) { + temp = A[ ia1 + ia2 ]; + if ( value < temp || isnan( temp ) ) { + value = temp; + } + ia2 += strideA2; + } + ia1 += strideA1; + } + } else { + ia1 = offsetA; for ( j = 0; j < N; j++ ) { - temp = A[ ia1 + ia2 ]; - if ( value < temp || isnan( temp ) ) { - value = temp; + ia2 = 0; + for ( i = 0; i < M; i++ ) { + temp = A[ ia1 + ia2 ]; + if ( value < temp || isnan( temp ) ) { + value = temp; + } + ia2 += strideA1; } - ia2 += strideA2; + ia1 += strideA2; } - ia1 += strideA1; } } @@ -117,16 +133,30 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o iw += strideWork; } - ia1 = offsetA; - for ( j = 0; j < N; j++ ) { - ia2 = 0; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ia1 = offsetA; iw = offsetWork; for ( i = 0; i < M; i++ ) { - work[ iw ] += abs( A[ ia1 + ia2 ] ); + ia2 = 0; + for ( j = 0; j < N; j++ ) { + work[ iw ] += abs( A[ ia1 + ia2 ] ); + ia2 += strideA2; + } + ia1 += strideA1; iw += strideWork; - ia2 += strideA1; } - ia1 += strideA2; + } else { + ia1 = offsetA; + for ( j = 0; j < N; j++ ) { + ia2 = 0; + iw = offsetWork; + for ( i = 0; i < M; i++ ) { + work[ iw ] += abs( A[ ia1 + ia2 ] ); + iw += strideWork; + ia2 += strideA1; + } + ia1 += strideA2; + } } value = 0; From 2e8ed5c3a38466d70e337a051e094b7faf06643f Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 16:22:10 +0000 Subject: [PATCH 11/20] 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: 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/dlange/lib/base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 7a7d3c93634c..a7b9bae1c5ab 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -110,10 +110,10 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o } else if ( norm === 'one' ) { - value = 0; + value = 0.0; ia1 = offsetA; for ( j = 0; j < N; j++ ) { - sum = 0; + sum = 0.0; ia2 = 0; for ( i = 0; i < M; i++ ) { sum += abs( A[ ia1 + ia2 ] ); @@ -159,7 +159,7 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o } } - value = 0; + value = 0.0; iw = offsetWork; for ( i = 0; i < M; i++ ) { From bc637896f3629dc18d524d17c4f853c5482a8b6c Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 16:47:06 +0000 Subject: [PATCH 12/20] 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: 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/dlange/lib/base.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index a7b9bae1c5ab..28a8bf7d5ceb 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -23,6 +23,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var dlassq = require( '@stdlib/lapack/base/dlassq' ).ndarray; var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var dasumpw = require( '@stdlib/blas/ext/base/dasumpw' ).ndarray; var Float64Array = require( '@stdlib/array/float64' ); var min = require( '@stdlib/math/base/special/min' ); var abs = require( '@stdlib/math/base/special/abs' ); @@ -113,12 +114,7 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o value = 0.0; ia1 = offsetA; for ( j = 0; j < N; j++ ) { - sum = 0.0; - ia2 = 0; - for ( i = 0; i < M; i++ ) { - sum += abs( A[ ia1 + ia2 ] ); - ia2 += strideA1; - } + sum = dasumpw( M, A, strideA1, ia1 ); if ( value < sum || isnan( sum ) ) { value = sum; } From 42175c086882ea231000358f998eecadfcc07695 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 16:58:20 +0000 Subject: [PATCH 13/20] 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: 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/dlange/lib/base.js | 4 +++- .../@stdlib/lapack/base/dlange/lib/isoperation.js | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 28a8bf7d5ceb..4579bee6106d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -169,8 +169,10 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o else if ( norm === 'frobenius' ) { out = new Float64Array( [ 0.0, 1.0 ] ); + ia1 = offsetA; for ( i = 0; i < N; i++ ) { - dlassq( M, A, strideA1, offsetA + (i*strideA2), out[ 0 ], out[ 1 ], out, 1, 0 ); // eslint-disable-line max-len + dlassq( M, A, strideA1, ia1, out[ 0 ], out[ 1 ], out, 1, 0 ); + ia1 += strideA2; } value = out[ 0 ] * sqrt( out[ 1 ] ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js index daadd8922e4a..b457d2978b37 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js @@ -25,7 +25,7 @@ var contains = require( '@stdlib/array/base/assert/contains' ).factory; // VARIABLES // -var JOBS = [ 'max', 'infinity', 'one', 'frobenius' ]; +var NORMS = [ 'max', 'infinity', 'one', 'frobenius' ]; // MAIN // @@ -36,7 +36,7 @@ var JOBS = [ 'max', 'infinity', 'one', 'frobenius' ]; * @name isOperation * @type {Function} * @param {*} v - value to test -* @returns {boolean} boolean indicating whether an input value is a supported job +* @returns {boolean} boolean indicating whether an input value is a supported norm * * @example * var bool = isOperation( 'max' ); @@ -54,7 +54,7 @@ var JOBS = [ 'max', 'infinity', 'one', 'frobenius' ]; * bool = isOperation( 'foo' ); * // returns false */ -var isOperation = contains( JOBS ); +var isOperation = contains( NORMS ); // EXPORTS // From 5cbf09d9b8d89b7a4656d9e1b89c102dec537b09 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Wed, 4 Jun 2025 19:51:06 +0000 Subject: [PATCH 14/20] refactor: move branches to separate functions --- 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/dlange/lib/base.js | 317 ++++++++++++------ 1 file changed, 219 insertions(+), 98 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 4579bee6106d..efc2bf70ed74 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -23,27 +23,117 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var dlassq = require( '@stdlib/lapack/base/dlassq' ).ndarray; var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var dasumpw = require( '@stdlib/blas/ext/base/dasumpw' ).ndarray; +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var dasum = require( '@stdlib/blas/base/dasum' ).ndarray; var Float64Array = require( '@stdlib/array/float64' ); var min = require( '@stdlib/math/base/special/min' ); -var abs = require( '@stdlib/math/base/special/abs' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var abs = require( '@stdlib/math/base/special/abs' ); -// MAIN // +// FUNCTIONS // /** -* Returns the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. +* Returns the value of the one norm of a real matrix `A`. * -* ## Notes +* @private +* @param {NonNegativeInteger} M - number of rows in `A` +* @param {NonNegativeInteger} N - number of columns in `A` +* @param {Float64Array} A - input array +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index of `A` +* @returns {number} required norm value * -* - use `norm` = `max`, to calculate the element with the largest absolute value -* - use `norm` = `one`, to calculate the one norm -* - use `norm` = `infinity`, to calculate the infinity norm -* - use `norm` = `frobenius`, to calculate the frobenius norm +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* +* var out = oneNorm( 3, 4, A, 4, 1, 0 ); +* // returns 33.0 +*/ +function oneNorm( M, N, A, strideA1, strideA2, offsetA ) { + var value; + var ia1; + var sum; + var j; + + value = 0.0; + ia1 = offsetA; + for ( j = 0; j < N; j++ ) { + sum = dasum( M, A, strideA1, ia1 ); + if ( value < sum || isnan( sum ) ) { + value = sum; + } + ia1 += strideA2; + } + return value; +} + +/** +* Returns the absolute value of the maximum element of a real matrix `A`. +* +* @private +* @param {NonNegativeInteger} M - number of rows in `A` +* @param {NonNegativeInteger} N - number of columns in `A` +* @param {Float64Array} A - input array +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index of `A` +* @returns {number} required norm value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* +* var out = maxAbs( 3, 4, A, 4, 1, 0 ); +* // returns 12.0 +*/ +function maxAbs( M, N, A, strideA1, strideA2, offsetA ) { + var value; + var temp; + var da0; + var da1; + var ia; + var sa; + var sh; + var S0; + var S1; + var o; + var i; + var j; + + value = 0.0; + + // Resolve the loop interchange order: + o = loopOrder( [ M, N ], [ strideA1, strideA2 ] ); + sh = o.sh; + sa = o.sx; + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0*sa[0] ); + ia = offsetA; + + for ( i = 0; i < S1; i++ ) { + for ( j = 0; j < S0; j++ ) { + temp = A[ ia ]; + if ( value < temp || isnan( temp ) ) { + value = temp; + } + ia += da0; + } + ia += da1; + } + return value; +} + +/** +* Returns the value of the infinity norm of a real matrix `A`. * * @private -* @param {string} norm - specifies the type of norm to be calculated * @param {NonNegativeInteger} M - number of rows in `A` * @param {NonNegativeInteger} N - number of columns in `A` * @param {Float64Array} A - input array @@ -61,123 +151,154 @@ var sqrt = require( '@stdlib/math/base/special/sqrt' ); * var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); * var work = new Float64Array( 3 ); * -* var out = dlange( 'frobenius', 3, 4, A, 4, 1, 0, work, 1, 0 ); -* // returns ~25.5 +* var out = infinityNorm( 3, 4, A, 4, 1, 0, work, 1, 0 ); +* // returns 30.0 */ -function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len +function infinityNorm( M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len var value; var temp; - var sum; - var out; var ia1; var ia2; var iw; var i; var j; - if ( min( M, N ) === 0 ) { - value = 0.0; + iw = offsetWork; + for ( i = 0; i < M; i++ ) { + work[ iw ] = 0.0; + iw += strideWork; } - else if ( norm === 'max' ) { - value = 0.0; - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - ia1 = offsetA; - for ( i = 0; i < M; i++ ) { - ia2 = 0; - for ( j = 0; j < N; j++ ) { - temp = A[ ia1 + ia2 ]; - if ( value < temp || isnan( temp ) ) { - value = temp; - } - ia2 += strideA2; - } - ia1 += strideA1; - } - } else { - ia1 = offsetA; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ia1 = offsetA; + iw = offsetWork; + for ( i = 0; i < M; i++ ) { + ia2 = 0; for ( j = 0; j < N; j++ ) { - ia2 = 0; - for ( i = 0; i < M; i++ ) { - temp = A[ ia1 + ia2 ]; - if ( value < temp || isnan( temp ) ) { - value = temp; - } - ia2 += strideA1; - } - ia1 += strideA2; + work[ iw ] += abs( A[ ia1 + ia2 ] ); + ia2 += strideA2; } + ia1 += strideA1; + iw += strideWork; } - } - - else if ( norm === 'one' ) { - value = 0.0; + } else { ia1 = offsetA; for ( j = 0; j < N; j++ ) { - sum = dasumpw( M, A, strideA1, ia1 ); - if ( value < sum || isnan( sum ) ) { - value = sum; + ia2 = 0; + iw = offsetWork; + for ( i = 0; i < M; i++ ) { + work[ iw ] += abs( A[ ia1 + ia2 ] ); + iw += strideWork; + ia2 += strideA1; } ia1 += strideA2; } } - else if ( norm === 'infinity' ) { - iw = offsetWork; - for ( i = 0; i < M; i++ ) { - work[ iw ] = 0.0; - iw += strideWork; - } + value = 0.0; - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - ia1 = offsetA; - iw = offsetWork; - for ( i = 0; i < M; i++ ) { - ia2 = 0; - for ( j = 0; j < N; j++ ) { - work[ iw ] += abs( A[ ia1 + ia2 ] ); - ia2 += strideA2; - } - ia1 += strideA1; - iw += strideWork; - } - } else { - ia1 = offsetA; - for ( j = 0; j < N; j++ ) { - ia2 = 0; - iw = offsetWork; - for ( i = 0; i < M; i++ ) { - work[ iw ] += abs( A[ ia1 + ia2 ] ); - iw += strideWork; - ia2 += strideA1; - } - ia1 += strideA2; - } + iw = offsetWork; + for ( i = 0; i < M; i++ ) { + temp = work[ iw ]; + if ( value < temp || isnan( temp ) ) { + value = temp; } + iw += strideWork; + } - value = 0.0; + return value; +} - iw = offsetWork; - for ( i = 0; i < M; i++ ) { - temp = work[ iw ]; - if ( value < temp || isnan( temp ) ) { - value = temp; - } - iw += strideWork; - } +/** +* Returns the absolute value of the frobenius norm of a real matrix `A`. +* +* @private +* @param {NonNegativeInteger} M - number of rows in `A` +* @param {NonNegativeInteger} N - number of columns in `A` +* @param {Float64Array} A - input array +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index of `A` +* @returns {number} required norm value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* +* var out = frobeniusNorm( 3, 4, A, 4, 1, 0 ); +* // returns ~25.5 +*/ +function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { + var ia1; + var out; + var i; + + ia1 = offsetA; + out = new Float64Array( [ 0.0, 1.0 ] ); + for ( i = 0; i < N; i++ ) { + dlassq( M, A, strideA1, ia1, out[ 0 ], out[ 1 ], out, 1, 0 ); + ia1 += strideA2; } - else if ( norm === 'frobenius' ) { - out = new Float64Array( [ 0.0, 1.0 ] ); - ia1 = offsetA; - for ( i = 0; i < N; i++ ) { - dlassq( M, A, strideA1, ia1, out[ 0 ], out[ 1 ], out, 1, 0 ); - ia1 += strideA2; - } - value = out[ 0 ] * sqrt( out[ 1 ] ); + return out[ 0 ] * sqrt( out[ 1 ] ); +} + + +// MAIN // + +/** +* Returns the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. +* +* ## Notes +* +* - use `norm` = `max`, to calculate the element with the largest absolute value +* - use `norm` = `one`, to calculate the one norm +* - use `norm` = `infinity`, to calculate the infinity norm +* - use `norm` = `frobenius`, to calculate the frobenius norm +* +* @private +* @param {string} norm - specifies the type of norm to be calculated +* @param {NonNegativeInteger} M - number of rows in `A` +* @param {NonNegativeInteger} N - number of columns in `A` +* @param {Float64Array} A - input array +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index of `A` +* @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {integer} strideWork - stride length of `work` +* @param {NonNegativeInteger} offsetWork - starting index of `work` +* @returns {number} required norm value +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* var work = new Float64Array( 3 ); +* +* var out = dlange( 'frobenius', 3, 4, A, 4, 1, 0, work, 1, 0 ); +* // returns ~25.5 +*/ +function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len + if ( min( M, N ) === 0 ) { + return 0.0; } - return value; + if ( norm === 'max' ) { + return maxAbs( M, N, A, strideA1, strideA2, offsetA ); + } + + if ( norm === 'one' ) { + return oneNorm( M, N, A, strideA1, strideA2, offsetA ); + } + + if ( norm === 'infinity' ) { + return infinityNorm( M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ); // eslint-disable-line max-len + } + + if ( norm === 'frobenius' ) { + return frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ); + } } From 651c006638253b78c3f0b8046ffe12b549c5aa6c Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 6 Jun 2025 04:29:53 +0000 Subject: [PATCH 15/20] refactor: better error messages --- 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/dlange/lib/base.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js | 3 ++- .../@stdlib/lapack/base/dlange/lib/isoperation.js | 2 +- .../@stdlib/lapack/base/dlange/lib/ndarray.js | 3 ++- .../@stdlib/lapack/base/dlange/lib/norms.json | 8 ++++++++ 5 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/norms.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index efc2bf70ed74..f6e5625c092c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -140,7 +140,7 @@ function maxAbs( M, N, A, strideA1, strideA2, offsetA ) { * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index of `A` -* @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} work - work array, should have `M` indexed elements * @param {integer} strideWork - stride length of `work` * @param {NonNegativeInteger} offsetWork - starting index of `work` * @returns {number} required norm value diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js index 49b6fdff3650..ca6747481d5e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -26,6 +26,7 @@ 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 isOperation = require( './isoperation.js' ); +var NORMS = require( './norms.json' ).norms; var base = require( './base.js' ); @@ -71,7 +72,7 @@ function dlange( order, norm, M, N, A, LDA, work ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } if ( !isOperation( norm ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a valid operation. Value: `%s`.', norm ) ); + throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', NORMS.join( '", "' ), norm ) ); } if ( isRowMajor( order ) && LDA < max( 1, N ) ) { throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js index b457d2978b37..6e7ae177c2df 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/isoperation.js @@ -25,7 +25,7 @@ var contains = require( '@stdlib/array/base/assert/contains' ).factory; // VARIABLES // -var NORMS = [ 'max', 'infinity', 'one', 'frobenius' ]; +var NORMS = require( './norms.json' ).norms; // MAIN // diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js index 08f4ddcf08c0..a6b37572c6dd 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -22,6 +22,7 @@ var format = require( '@stdlib/string/format' ); var isOperation = require( './isoperation.js' ); +var NORMS = require( './norms.json' ).norms; var base = require( './base.js' ); @@ -61,7 +62,7 @@ var base = require( './base.js' ); */ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len if ( !isOperation( norm ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a valid operation. Value: `%s`.', norm ) ); + throw new TypeError( format( 'invalid argument. Second argument must be one of the following: "%s". Value: `%s`.', NORMS.join( '", "' ), norm ) ); } return base( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/norms.json b/lib/node_modules/@stdlib/lapack/base/dlange/lib/norms.json new file mode 100644 index 000000000000..1cf4845a3f75 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/norms.json @@ -0,0 +1,8 @@ +{ + "norms": [ + "max", + "one", + "infinity", + "frobenius" + ] +} From 6e0d355ec6fde705de38280fc4ba9f45c3281f74 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 6 Jun 2025 05:25:09 +0000 Subject: [PATCH 16/20] docs: add readme --- 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: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dlange/README.md | 347 ++++++++++++++++++ .../lapack/base/dlange/docs/types/index.d.ts | 6 +- .../lapack/base/dlange/examples/index.js | 9 +- .../@stdlib/lapack/base/dlange/lib/base.js | 2 +- .../@stdlib/lapack/base/dlange/lib/dlange.js | 2 +- .../@stdlib/lapack/base/dlange/lib/ndarray.js | 2 +- 6 files changed, 360 insertions(+), 8 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/README.md diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/README.md b/lib/node_modules/@stdlib/lapack/base/dlange/README.md new file mode 100644 index 000000000000..46d92d334be5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/README.md @@ -0,0 +1,347 @@ + + +# dlange + +> Compute an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. + +
+ +The `dlange` routine computes the value of a specified norm of a real M-by-N matrix `A`. The norm to be computed is selected using the parameter `norm`, which may specify the **Max norm**, **One norm**, **Infinity norm**, or **Frobenius norm**. + +The supported norms are: + +- **Max Absolute Value** (`norm` = `'max'`): returns the largest absolute element in `A`. + + + +```math +\|A\|_{\max} = \max_{i,j} |a_{i,j}| +``` + + + +- **One Norm** (`norm` = `'one'`): returns the maximum absolute column sum in `A`. + + + +```math +\|A\|_1 = \max_j \sum_{i=1}^M |a_{i,j}| +``` + + + +- **Infinity Norm** (`norm` = `'infinity'`): returns the maximum absolute row sum in `A`. + + + +```math +\|A\|_{\infty} = \max_i \sum_{j=1}^N |a_{i,j}| +``` + + + +- **Frobenius Norm** (`norm` = `'frobenius'`): returns the square root of the sum of the squares of all elements in `A`. + + + +```math +\|A\|_F = \left(\sum_{i=1}^M \sum_{j=1}^N |a_{i,j}|^2 \right)^{1/2} +``` + + + +
+ + + +
+ +## Usage + +```javascript +var dlange = require( '@stdlib/lapack/base/dlange' ); +``` + +#### dlange( N, DL, D, DU, DU2, IPIV ) + +Computes the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); + +/* + A = [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ] +*/ + +var work = new Float64Array( 3 ); +var out = dlange( 'row-major', 'frobenius', 3, 4, A, 4, work ); +// returns ~25.5 +``` + +The function has the following parameters: + +- **order**: storage layout. +- **norm**: specifies the type of norm to be calculated, should be one of the following: `max`, `one`, `frobenius` or `infinity`. +- **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`). +- **work**: [`Float64Array`][mdn-float64array] used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array. + +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' ); + +var A0 = new Float64Array( [ 0.0, 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +var work0 = new Float64Array( 4 ); + +/* + A = [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ] +*/ + +// Create offset views... +var A = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var work = new Float64Array( work0.buffer, work0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = dlange( 'row-major', 'frobenius', 3, 4, A, 4, work ); +// returns ~25.5 +``` + + + +#### dlange.ndarray( norm, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) + +Computes the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A` using alternative indexing semantics. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); + +/* + A = [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ] +*/ + +var work = new Float64Array( 3 ); +var out = dlange.ndarray( 'frobenius', 3, 4, A, 4, 1, 0, work, 1, 0 ); +// returns ~25.5 +``` + +The function has the following additional parameters: + +- **norm**: specifies the type of norm to be calculated, should be one of the following: `max`, `one`, `frobenius` or `infinity`. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **strideA1**: stride of the first dimension of `A`. +- **strideA2**: stride of the second dimension of `A`. +- **offsetA**: starting index for `A`. +- **work**: [`Float64Array`][mdn-float64array] used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array. +- **strideWork**: stride length of `work`. +- **offsetWork**: starting index of `work`. + +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( [ 0.0, 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); + +/* + A = [ + [ 1.0, 4.0, 7.0, 10.0 ], + [ 2.0, 5.0, 8.0, 11.0 ], + [ 3.0, 6.0, 9.0, 12.0 ] + ] +*/ + +var work = new Float64Array( 4 ); +var out = dlange.ndarray( 'frobenius', 3, 4, A, 4, 1, 1, work, 1, 1 ); +// returns ~25.5 +``` + +
+ + + +
+ +## Notes + +- `dlange()` corresponds to the [LAPACK][LAPACK] routine [`dlange`][lapack-dlange]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var dlange = require( '@stdlib/lapack/base/dlange' ); + +// Specify matrix meta data: +var shape = [ 3, 4 ]; +var strides = [ 4, 1 ]; +var offset = 0; +var N = numel( shape ); +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var A = uniform( N, -10, 10, { + 'dtype': 'float64' +}); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +var work = new Float64Array( shape[ 0 ] ); + +// Calculate the infinity norm: +var out = dlange( order, 'infinity', shape[ 0 ], shape[ 1 ], A, strides[ 0 ], work ); +console.log( 'Infinity norm: ', 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/dlange/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts index eadfdde54501..9790195c2232 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts @@ -56,7 +56,7 @@ interface Routine { * @param N - number of columns in `A` * @param A - input array * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) - * @param work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array + * @param work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array * @returns required norm value * * @example @@ -87,7 +87,7 @@ interface Routine { * @param strideA1 - stride of the first dimension of `A` * @param strideA2 - stride of the second dimension of `A` * @param offsetA - starting index of `A` - * @param work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array + * @param work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array * @param strideWork - stride length of `work` * @param offsetWork - starting index of `work` * @returns required norm value @@ -120,7 +120,7 @@ interface Routine { * @param N - number of columns in `A` * @param A - input array * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array * @returns required norm value * * @example diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js index 5ee136ff2248..86f36cc33967 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js @@ -20,19 +20,24 @@ var Float64Array = require( '@stdlib/array/float64' ); var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var numel = require( '@stdlib/ndarray/base/numel' ); var dlange = require( './../lib' ); // Specify matrix meta data: var shape = [ 3, 4 ]; var strides = [ 4, 1 ]; var offset = 0; +var N = numel( shape ); var order = 'row-major'; // Create a matrix stored in linear memory: -var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); // eslint-disable-line max-len +var A = uniform( N, -10, 10, { + 'dtype': 'float64' +}); console.log( ndarray2array( A, shape, strides, offset, order ) ); -var work = new Float64Array( 3 ); +var work = new Float64Array( shape[ 0 ] ); // Calculate the infinity norm: var out = dlange( order, 'infinity', shape[ 0 ], shape[ 1 ], A, strides[ 0 ], work ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index f6e5625c092c..453c82393528 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -265,7 +265,7 @@ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index of `A` -* @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array * @param {integer} strideWork - stride length of `work` * @param {NonNegativeInteger} offsetWork - starting index of `work` * @returns {number} required norm value diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js index ca6747481d5e..ca0dc32b3af1 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -49,7 +49,7 @@ var base = require( './base.js' ); * @param {NonNegativeInteger} N - number of columns in `A` * @param {Float64Array} A - input array * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array * @throws {TypeError} first argument must be a valid order * @throws {TypeError} second argument must be a valid operation * @throws {RangeError} sixth argument must be greater than or equal to max(1,N) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js index a6b37572c6dd..801e1c33b859 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -45,7 +45,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 - starting index of `A` -* @param {Float64Array} work - only used to compute the infinity norm, expects `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array * @param {integer} strideWork - stride length of `work` * @param {NonNegativeInteger} offsetWork - starting index of `work` * @throws {TypeError} first argument must be a valid operation From d0d96eded33302fec572e5e2e36c854c1d33dfd3 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 6 Jun 2025 05:42:23 +0000 Subject: [PATCH 17/20] 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: passed - 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: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dlange/README.md | 4 +- .../@stdlib/lapack/base/dlange/docs/repl.txt | 108 ++++++++++++++++++ 2 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/README.md b/lib/node_modules/@stdlib/lapack/base/dlange/README.md index 46d92d334be5..a6fcf485fd06 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlange/README.md @@ -20,7 +20,7 @@ limitations under the License. # dlange -> Compute an `LU` factorization of a real tridiagonal matrix `A` using elimination with partial pivoting and row interchanges. +> LAPACK routine to compute the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`.
@@ -80,7 +80,7 @@ The supported norms are: var dlange = require( '@stdlib/lapack/base/dlange' ); ``` -#### dlange( N, DL, D, DU, DU2, IPIV ) +#### dlange( norm, M, N, A, LDA, work ) Computes the value of the one norm, or the frobenius norm, or the infinity norm, or the element with the largest absolute value of a real matrix `A`. diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt new file mode 100644 index 000000000000..fb4a70807666 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt @@ -0,0 +1,108 @@ + +{{alias}}( order, norm, M, N, A, LDA, work ) + Computes the value of the one norm, or the frobenius norm, or the infinity + norm, or the element with the largest absolute value of a real 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'. + + norm: string + Specifies the type of norm to be calculated, should be one of the + following: `max`, `one`, `frobenius` or `infinity`. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Float64Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + work: Float64Array + Work array used to compute the infinity norm, should have `M` indexed + elements if computing the infinity norm otherwise pass a dummy array. + + Returns + ------- + Required norm: number + Value of the required norm. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var work = new {{alias:@stdlib/array/float64}}( 1 ); + > var order = 'row-major'; + > var norm = 'max'; + > {{alias}}( order, norm, 2, 2, A, 2, work ) + 4.0 + + +{{alias}}.ndarray( norm, M, N, A, sa1, sa2, oa, work, sw, ow ) + Computes the value of the one norm, or the frobenius norm, or the infinity + norm, or the element with the largest absolute value of a real 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 + ---------- + norm: string + Specifies the type of norm to be calculated, should be one of the + following: `max`, `one`, `frobenius` or `infinity`. + + 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`. + + work: Float64Array + Work array used to compute the infinity norm, should have `M` indexed + elements if computing the infinity norm otherwise pass a dummy array. + + sw: integer + Stride length for `work`. + + ow: integer + Starting index for `work`. + + Returns + ------- + Required norm: number + Value of the required norm. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var work = new {{alias:@stdlib/array/float64}}( 1 ); + > var norm = 'max'; + > {{alias}}.ndarray( norm, 2, 2, A, 2, 1, 0, work, 1, 0 ) + 4.0 + + See Also + -------- From fafa6278c1b0c064bad3842b6afc9f19489d24a9 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 6 Jun 2025 06:36:38 +0000 Subject: [PATCH 18/20] refactor: optimise 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/dlange/lib/base.js | 102 ++++++++++++------ .../large_strides/one_norm_column_major.json | 3 +- .../large_strides/one_norm_row_major.json | 3 +- .../mixed_strides/one_norm_column_major.json | 1 + .../mixed_strides/one_norm_row_major.json | 1 + .../one_norm_column_major.json | 3 +- .../negative_strides/one_norm_row_major.json | 3 +- .../offsets/one_norm_column_major.json | 1 + .../fixtures/offsets/one_norm_row_major.json | 1 + .../test/fixtures/one_norm_column_major.json | 2 +- .../test/fixtures/one_norm_row_major.json | 2 +- 11 files changed, 84 insertions(+), 38 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 453c82393528..83cb73d1cf93 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -43,31 +43,71 @@ var abs = require( '@stdlib/math/base/special/abs' ); * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index of `A` +* @param {Float64Array} work - work array, should have `N` indexed elements +* @param {integer} strideWork - stride length of `work` +* @param {NonNegativeInteger} offsetWork - starting index of `work` * @returns {number} required norm value * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 4.0, 7.0, 10.0, 2.0, 5.0, 8.0, 11.0, 3.0, 6.0, 9.0, 12.0 ] ); +* var work = new Float64Array( 4 ); * -* var out = oneNorm( 3, 4, A, 4, 1, 0 ); +* var out = oneNorm( 3, 4, A, 4, 1, 0, work, 1, 0 ); * // returns 33.0 */ -function oneNorm( M, N, A, strideA1, strideA2, offsetA ) { +function oneNorm( M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len var value; + var temp; var ia1; + var ia2; var sum; + var iw; + var i; var j; - value = 0.0; - ia1 = offsetA; - for ( j = 0; j < N; j++ ) { - sum = dasum( M, A, strideA1, ia1 ); - if ( value < sum || isnan( sum ) ) { - value = sum; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + iw = offsetWork; + for ( i = 0; i < N; i++ ) { + work[ iw ] = 0.0; + iw += strideWork; + } + + ia1 = offsetA; + for ( j = 0; j < M; j++ ) { + ia2 = 0; + iw = offsetWork; + for ( i = 0; i < N; i++ ) { + work[ iw ] += abs( A[ ia1 + ia2 ] ); + iw += strideWork; + ia2 += strideA2; + } + ia1 += strideA1; + } + + value = 0.0; + + iw = offsetWork; + for ( i = 0; i < N; i++ ) { + temp = work[ iw ]; + if ( value < temp || isnan( temp ) ) { + value = temp; + } + iw += strideWork; + } + } else { + value = 0.0; + ia1 = offsetA; + for ( j = 0; j < N; j++ ) { + sum = dasum( M, A, strideA1, ia1 ); + if ( value < sum || isnan( sum ) ) { + value = sum; + } + ia1 += strideA2; } - ia1 += strideA2; } + return value; } @@ -157,31 +197,30 @@ function maxAbs( M, N, A, strideA1, strideA2, offsetA ) { function infinityNorm( M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ) { // eslint-disable-line max-len var value; var temp; + var sum; var ia1; var ia2; var iw; var i; var j; - iw = offsetWork; - for ( i = 0; i < M; i++ ) { - work[ iw ] = 0.0; - iw += strideWork; - } - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + value = 0.0; ia1 = offsetA; - iw = offsetWork; - for ( i = 0; i < M; i++ ) { - ia2 = 0; - for ( j = 0; j < N; j++ ) { - work[ iw ] += abs( A[ ia1 + ia2 ] ); - ia2 += strideA2; + for ( j = 0; j < M; j++ ) { + sum = dasum( N, A, strideA2, ia1 ); + if ( value < sum || isnan( sum ) ) { + value = sum; } ia1 += strideA1; - iw += strideWork; } } else { + iw = offsetWork; + for ( i = 0; i < M; i++ ) { + work[ iw ] = 0.0; + iw += strideWork; + } + ia1 = offsetA; for ( j = 0; j < N; j++ ) { ia2 = 0; @@ -193,19 +232,18 @@ function infinityNorm( M, N, A, strideA1, strideA2, offsetA, work, strideWork, o } ia1 += strideA2; } - } - value = 0.0; + value = 0.0; - iw = offsetWork; - for ( i = 0; i < M; i++ ) { - temp = work[ iw ]; - if ( value < temp || isnan( temp ) ) { - value = temp; + iw = offsetWork; + for ( i = 0; i < M; i++ ) { + temp = work[ iw ]; + if ( value < temp || isnan( temp ) ) { + value = temp; + } + iw += strideWork; } - iw += strideWork; } - return value; } @@ -289,7 +327,7 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideWork, o } if ( norm === 'one' ) { - return oneNorm( M, N, A, strideA1, strideA2, offsetA ); + return oneNorm( M, N, A, strideA1, strideA2, offsetA, work, strideWork, offsetWork ); // eslint-disable-line max-len } if ( norm === 'infinity' ) { diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_column_major.json index e3a3f7541e9d..dd569ff5fdc0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_column_major.json @@ -44,7 +44,8 @@ 0.0, 9999.0, 0.0, - 9999.0 + 9999.0, + 0.0 ], "strideWork": 2, "offsetWork": 0, diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_row_major.json index 25b303fd2951..5fc3b3ce02a9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/large_strides/one_norm_row_major.json @@ -44,7 +44,8 @@ 0.0, 9999.0, 0.0, - 9999.0 + 9999.0, + 0.0 ], "strideWork": 2, "offsetWork": 0, diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_column_major.json index 56aaec953541..2d98efec5366 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_column_major.json @@ -27,6 +27,7 @@ [ 3.0, 6.0, 9.0, 12.0 ] ], "work": [ + 0.0, 0.0, 0.0, 0.0 diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_row_major.json index 4f3b3c9bb2c2..abcae4cc6cdb 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/mixed_strides/one_norm_row_major.json @@ -27,6 +27,7 @@ [ 3.0, 6.0, 9.0, 12.0 ] ], "work": [ + 0.0, 0.0, 0.0, 0.0 diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_column_major.json index 7391e569578b..bbcaaee943a4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_column_major.json @@ -27,11 +27,12 @@ [ 3.0, 6.0, 9.0, 12.0 ] ], "work": [ + 0.0, 0.0, 0.0, 0.0 ], "strideWork": -1, - "offsetWork": 2, + "offsetWork": 3, "expected": 33 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_row_major.json index b324bcf6d1aa..0bf377ac7517 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/negative_strides/one_norm_row_major.json @@ -27,11 +27,12 @@ [ 3.0, 6.0, 9.0, 12.0 ] ], "work": [ + 0.0, 0.0, 0.0, 0.0 ], "strideWork": -1, - "offsetWork": 2, + "offsetWork": 3, "expected": 33 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_column_major.json index 312aa88354c7..7cae90820429 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_column_major.json @@ -31,6 +31,7 @@ 9999.0, 0.0, 0.0, + 0.0, 0.0 ], "strideWork": 1, diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_row_major.json index 4bdb3f53f26d..29234b10ef58 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/offsets/one_norm_row_major.json @@ -31,6 +31,7 @@ 9999.0, 0.0, 0.0, + 0.0, 0.0 ], "strideWork": 1, diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_column_major.json index d3ff510f2cfe..b88f0138f8a6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_column_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_column_major.json @@ -13,7 +13,7 @@ [ 2.0, 5.0, 8.0, 11.0 ], [ 3.0, 6.0, 9.0, 12.0 ] ], - "work": [ 0.0, 0.0, 0.0 ], + "work": [ 0.0, 0.0, 0.0, 0.0 ], "strideWork": 1, "offsetWork": 0, "expected": 33.0 diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_row_major.json index ac71656d7b98..413d4c9fb034 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_row_major.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/fixtures/one_norm_row_major.json @@ -13,7 +13,7 @@ [ 2.0, 5.0, 8.0, 11.0 ], [ 3.0, 6.0, 9.0, 12.0 ] ], - "work": [ 0.0, 0.0, 0.0 ], + "work": [ 0.0, 0.0, 0.0, 0.0 ], "strideWork": 1, "offsetWork": 0, "expected": 33.0 From 086fc3cd61ba670d9572a7b82552d813f2b00d47 Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 6 Jun 2025 06:39:01 +0000 Subject: [PATCH 19/20] refactor: optimise 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/dlange/lib/base.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 83cb73d1cf93..0295a75c9051 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -268,18 +268,30 @@ function infinityNorm( M, N, A, strideA1, strideA2, offsetA, work, strideWork, o * // returns ~25.5 */ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { + var value; var ia1; var out; var i; - ia1 = offsetA; out = new Float64Array( [ 0.0, 1.0 ] ); - for ( i = 0; i < N; i++ ) { - dlassq( M, A, strideA1, ia1, out[ 0 ], out[ 1 ], out, 1, 0 ); - ia1 += strideA2; + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ia1 = offsetA; + for ( i = 0; i < M; i++ ) { + dlassq( N, A, strideA2, ia1, out[ 0 ], out[ 1 ], out, 1, 0 ); + ia1 += strideA1; + } + value = out[ 0 ] * sqrt( out[ 1 ] ); + } else { + ia1 = offsetA; + for ( i = 0; i < N; i++ ) { + dlassq( M, A, strideA1, ia1, out[ 0 ], out[ 1 ], out, 1, 0 ); + ia1 += strideA2; + } + value = out[ 0 ] * sqrt( out[ 1 ] ); } - return out[ 0 ] * sqrt( out[ 1 ] ); + return value; } From 44c54a93014116c2d71939e42ac8b1dfb73763ee Mon Sep 17 00:00:00 2001 From: Aayush Khanna Date: Fri, 6 Jun 2025 08:20:16 +0000 Subject: [PATCH 20/20] docs: update docs --- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dlange/README.md | 8 ++- .../@stdlib/lapack/base/dlange/docs/repl.txt | 10 ++-- .../lapack/base/dlange/docs/types/index.d.ts | 30 ++++++------ .../@stdlib/lapack/base/dlange/lib/base.js | 49 ++++++++++--------- .../@stdlib/lapack/base/dlange/lib/dlange.js | 10 ++-- .../@stdlib/lapack/base/dlange/lib/ndarray.js | 10 ++-- 6 files changed, 64 insertions(+), 53 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/README.md b/lib/node_modules/@stdlib/lapack/base/dlange/README.md index a6fcf485fd06..9214f4821f95 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlange/README.md @@ -112,7 +112,9 @@ The function has the following parameters: - **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`). -- **work**: [`Float64Array`][mdn-float64array] used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array. +- **work**: [`Float64Array`][mdn-float64array] used as a temporary workspace. + +`work` should have `N` indexed elements if calculating the one norm in a row-major layout and `M` indexed elements if calculating the infinity norm in column-major layout, in all other cases it is fine to pass a dummy [`Float64Array`][mdn-float64array]. Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -175,10 +177,12 @@ The function has the following additional parameters: - **strideA1**: stride of the first dimension of `A`. - **strideA2**: stride of the second dimension of `A`. - **offsetA**: starting index for `A`. -- **work**: [`Float64Array`][mdn-float64array] used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array. +- **work**: [`Float64Array`][mdn-float64array] used as a temporary workspace - **strideWork**: stride length of `work`. - **offsetWork**: starting index of `work`. +`work` should have `N` indexed elements if calculating the one norm in a row-major layout and `M` indexed elements if calculating the infinity norm in column-major layout, in all other cases it is fine to pass a dummy [`Float64Array`][mdn-float64array]. + 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, diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt index fb4a70807666..9693558d1e79 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt @@ -30,8 +30,9 @@ matrix `A`). work: Float64Array - Work array used to compute the infinity norm, should have `M` indexed - elements if computing the infinity norm otherwise pass a dummy array. + Temporary workspace array. `work` should have `N` indexed elements if + computing the one norm in row-major layout and `M` indexed elements + if computing infinity norm in column-major layout. Returns ------- @@ -82,8 +83,9 @@ Starting index for `A`. work: Float64Array - Work array used to compute the infinity norm, should have `M` indexed - elements if computing the infinity norm otherwise pass a dummy array. + Temporary workspace array. `work` should have `N` indexed elements if + computing the one norm in row-major layout and `M` indexed elements + if computing infinity norm in column-major layout. sw: integer Stride length for `work`. diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts index 9790195c2232..57dd3df1a34b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts @@ -45,10 +45,10 @@ interface Routine { * * ## Notes * - * - use `norm` = `max`, to calculate the element with the largest absolute value - * - use `norm` = `one`, to calculate the one norm - * - use `norm` = `infinity`, to calculate the infinity norm - * - use `norm` = `frobenius`, to calculate the frobenius norm + * - use `norm` = `max` to calculate the element with the largest absolute value + * - use `norm` = `one` to calculate the one norm, work should have `N` indexed elements if row-major layout is used + * - use `norm` = `infinity` to calculate the infinity norm, work should have `M` indexed elements if column-major layout is used + * - use `norm` = `frobenius` to calculate the frobenius norm * * @param order - storage layout * @param norm - specifies the type of norm to be calculated @@ -56,7 +56,7 @@ interface Routine { * @param N - number of columns in `A` * @param A - input array * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) - * @param work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array + * @param work - temporary workspace array * @returns required norm value * * @example @@ -75,10 +75,10 @@ interface Routine { * * ## Notes * - * - use `norm` = `max`, to calculate the element with the largest absolute value - * - use `norm` = `one`, to calculate the one norm - * - use `norm` = `infinity`, to calculate the infinity norm - * - use `norm` = `frobenius`, to calculate the frobenius norm + * - use `norm` = `max` to calculate the element with the largest absolute value + * - use `norm` = `one` to calculate the one norm, work should have `N` indexed elements if row-major layout is used + * - use `norm` = `infinity` to calculate the infinity norm, work should have `M` indexed elements if column-major layout is used + * - use `norm` = `frobenius` to calculate the frobenius norm * * @param norm - specifies the type of norm to be calculated * @param M - number of rows in `A` @@ -87,7 +87,7 @@ interface Routine { * @param strideA1 - stride of the first dimension of `A` * @param strideA2 - stride of the second dimension of `A` * @param offsetA - starting index of `A` - * @param work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array + * @param work - temporary workspace array * @param strideWork - stride length of `work` * @param offsetWork - starting index of `work` * @returns required norm value @@ -109,10 +109,10 @@ interface Routine { * * ## Notes * -* - use `norm` = `max`, to calculate the element with the largest absolute value -* - use `norm` = `one`, to calculate the one norm -* - use `norm` = `infinity`, to calculate the infinity norm -* - use `norm` = `frobenius`, to calculate the frobenius norm +* - use `norm` = `max` to calculate the element with the largest absolute value +* - use `norm` = `one` to calculate the one norm, work should have `N` indexed elements if row-major layout is used +* - use `norm` = `infinity` to calculate the infinity norm, work should have `M` indexed elements if column-major layout is used +* - use `norm` = `frobenius` to calculate the frobenius norm * * @param order - storage layout * @param norm - specifies the type of norm to be calculated @@ -120,7 +120,7 @@ interface Routine { * @param N - number of columns in `A` * @param A - input array * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param work - temporary workspace array * @returns required norm value * * @example diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js index 0295a75c9051..45fe1aca8f5a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -43,7 +43,7 @@ var abs = require( '@stdlib/math/base/special/abs' ); * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index of `A` -* @param {Float64Array} work - work array, should have `N` indexed elements +* @param {Float64Array} work - work array, should have `N` indexed elements if row-major layout is used * @param {integer} strideWork - stride length of `work` * @param {NonNegativeInteger} offsetWork - starting index of `work` * @returns {number} required norm value @@ -180,7 +180,7 @@ function maxAbs( M, N, A, strideA1, strideA2, offsetA ) { * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index of `A` -* @param {Float64Array} work - work array, should have `M` indexed elements +* @param {Float64Array} work - work array, should have `M` indexed elements if column-major layout is used * @param {integer} strideWork - stride length of `work` * @param {NonNegativeInteger} offsetWork - starting index of `work` * @returns {number} required norm value @@ -268,30 +268,35 @@ function infinityNorm( M, N, A, strideA1, strideA2, offsetA, work, strideWork, o * // returns ~25.5 */ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { - var value; - var ia1; var out; + var da0; + var da1; + var S1; + var S2; + var ia; var i; out = new Float64Array( [ 0.0, 1.0 ] ); if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - ia1 = offsetA; - for ( i = 0; i < M; i++ ) { - dlassq( N, A, strideA2, ia1, out[ 0 ], out[ 1 ], out, 1, 0 ); - ia1 += strideA1; - } - value = out[ 0 ] * sqrt( out[ 1 ] ); + S1 = M; + S2 = N; + da0 = strideA2; + da1 = strideA1; } else { - ia1 = offsetA; - for ( i = 0; i < N; i++ ) { - dlassq( M, A, strideA1, ia1, out[ 0 ], out[ 1 ], out, 1, 0 ); - ia1 += strideA2; - } - value = out[ 0 ] * sqrt( out[ 1 ] ); + S1 = N; + S2 = M; + da0 = strideA1; + da1 = strideA2; } - return value; + ia = offsetA; + for ( i = 0; i < S1; i++ ) { + dlassq( S2, A, da0, ia, out[ 0 ], out[ 1 ], out, 1, 0 ); + ia += da1; + } + + return out[ 0 ] * sqrt( out[ 1 ] ); } @@ -302,10 +307,10 @@ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { * * ## Notes * -* - use `norm` = `max`, to calculate the element with the largest absolute value -* - use `norm` = `one`, to calculate the one norm -* - use `norm` = `infinity`, to calculate the infinity norm -* - use `norm` = `frobenius`, to calculate the frobenius norm +* - use `norm` = `max` to calculate the element with the largest absolute value +* - use `norm` = `one` to calculate the one norm, work should have `N` indexed elements if row-major layout is used +* - use `norm` = `infinity` to calculate the infinity norm, work should have `M` indexed elements if column-major layout is used +* - use `norm` = `frobenius` to calculate the frobenius norm * * @private * @param {string} norm - specifies the type of norm to be calculated @@ -315,7 +320,7 @@ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index of `A` -* @param {Float64Array} work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} work - temporary workspace array * @param {integer} strideWork - stride length of `work` * @param {NonNegativeInteger} offsetWork - starting index of `work` * @returns {number} required norm value diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js index ca0dc32b3af1..f1f87144403f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -37,10 +37,10 @@ var base = require( './base.js' ); * * ## Notes * -* - use `norm` = `max`, to calculate the element with the largest absolute value -* - use `norm` = `one`, to calculate the one norm -* - use `norm` = `infinity`, to calculate the infinity norm -* - use `norm` = `frobenius`, to calculate the frobenius norm +* - use `norm` = `max` to calculate the element with the largest absolute value +* - use `norm` = `one` to calculate the one norm, work should have `N` indexed elements if row-major layout is used +* - use `norm` = `infinity` to calculate the infinity norm, work should have `M` indexed elements if column-major layout is used +* - use `norm` = `frobenius` to calculate the frobenius norm * * @private * @param {string} order - storage layout @@ -49,7 +49,7 @@ var base = require( './base.js' ); * @param {NonNegativeInteger} N - number of columns in `A` * @param {Float64Array} A - input array * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param {Float64Array} work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} work - temporary workspace array * @throws {TypeError} first argument must be a valid order * @throws {TypeError} second argument must be a valid operation * @throws {RangeError} sixth argument must be greater than or equal to max(1,N) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js index 801e1c33b859..1aebe3259365 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -33,10 +33,10 @@ var base = require( './base.js' ); * * ## Notes * -* - use `norm` = `max`, to calculate the element with the largest absolute value -* - use `norm` = `one`, to calculate the one norm -* - use `norm` = `infinity`, to calculate the infinity norm -* - use `norm` = `frobenius`, to calculate the frobenius norm +* - use `norm` = `max` to calculate the element with the largest absolute value +* - use `norm` = `one` to calculate the one norm, work should have `N` indexed elements if row-major layout is used +* - use `norm` = `infinity` to calculate the infinity norm, work should have `M` indexed elements if column-major layout is used +* - use `norm` = `frobenius` to calculate the frobenius norm * * @param {string} norm - specifies the type of norm to be calculated * @param {NonNegativeInteger} M - number of rows in `A` @@ -45,7 +45,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 - starting index of `A` -* @param {Float64Array} work - only used to compute the infinity norm, should have `M` indexed elements if computing the infinity norm otherwise it's fine to pass a dummy array +* @param {Float64Array} work - temporary workspace array * @param {integer} strideWork - stride length of `work` * @param {NonNegativeInteger} offsetWork - starting index of `work` * @throws {TypeError} first argument must be a valid operation