From 0581fdfaf358e4e89384cf315e31f11f2bfe1223 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 29 Jul 2024 20:36:37 +0530 Subject: [PATCH 01/16] feat: init lapack/base/dlange --- .../@stdlib/lapack/base/dlange/lib/base.js | 183 ++++++++++++++++++ .../@stdlib/lapack/base/dlange/lib/dlange.js | 72 +++++++ .../@stdlib/lapack/base/dlange/lib/main.js | 35 ++++ .../@stdlib/lapack/base/dlange/lib/ndarray.js | 66 +++++++ 4 files changed, 356 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.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 new file mode 100644 index 00000000000..1de78c93263 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -0,0 +1,183 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var dlassq = require( '@stdlib/lapack/base/dlassq' ).ndarray; +var lowercase = require( '@stdlib/string/base/lowercase' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var Float64Array = require( '@stdlib/array/float64' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var min = require( '@stdlib/math/base/special/min' ); +var isnan = require( '@stdlib/assert/is-nan' ); + + +// MAIN // + +/** +* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* +* @private +* @param {string} order - storage layout +* @param {string} norm - specifies the value to be returned +* @param {NonNegativeInteger} M - number of rows of `A` +* @param {NonNegativeInteger} N - number of columns of `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 {PositiveInteger} offsetA - starting index for `A` +* @param {Float64Array} work - workspace array +* @param {integer} strideW - stride length for `work` +* @param {PositiveInteger} offsetW - starting index for `work` +* @returns {number} matrix norm +* +* @example +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); +* +* var out = dlange( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // out => 4.0 +*/ +function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { // eslint-disable-line max-params + var scale; + var value; + var sum; + var tmp; + var out; + var sa; + var i; + var j; + + norm = lowercase( norm ); + if ( min( M, N ) === 0.0 ) { + value = 0.0; + } else if ( norm === 'm' ) { + // Find max( abs( A[ i, j ] ) ) + value = 0.0; + if ( order === 'column-major' ) { + for ( j = 0; j < N; j++ ) { + sa = offsetA + ( j * strideA1 ); + for ( i = 0; i < M; i++ ) { + tmp = abs( A[ sa + ( i * strideA2 ) ] ); + if ( value <= tmp || isnan( tmp ) ) { + value = tmp; + } + } + } + return value; + } + // order === 'row-major' + for ( j = 0; j < N; j++ ) { + sa = offsetA + ( j * strideA2 ); + for ( i = 0; i < M; i++ ) { + tmp = abs( A[ sa + ( i * strideA1 ) ] ); + if ( value <= tmp || isnan( tmp ) ) { + value = tmp; + } + } + } + return value; + } + if ( norm === 'o' || norm === '1' ) { + // Find norm1( A ) + value = 0.0; + if ( order === 'column-major' ) { + for ( j = 0; j < N; j++ ) { + sum = 0.0; + sa = offsetA + ( j * strideA1 ); + for ( i = 0; i < M; i++ ) { + sum += abs( A[ sa + ( i * strideA2 ) ] ); + } + if ( value < sum || isnan( sum ) ) { + value = sum; + } + } + return value; + } + // order === 'row-major' + for ( i = 0; i < M; i++ ) { + sum = 0.0; + sa = offsetA + ( i * strideA2 ); + for ( j = 0; j < N; j++ ) { + sum += abs( A[ sa + ( j * strideA1 ) ] ); + } + if ( value < sum || isnan( sum ) ) { + value = sum; + } + } + return value; + } + if ( norm === 'i' ) { + // Find normI( A ) + for ( i = 0; i < M; i++ ) { + work[ offsetW + ( i * strideW ) ] = 0.0; + } + if ( order === 'column-major' ) { + for ( j = 0; j < N; j++ ) { + sa = offsetA + ( j * strideA1 ); + for ( i = 0; i < M; i++ ) { + work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA2 ) ] ); + } + } + } else { // order === 'row-major' + for ( i = 0; i < M; i++ ) { + sa = offsetA + ( i * strideA2 ); + for ( j = 0; j < N; j++ ) { + work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( j * strideA1 ) ] ); + } + } + } + value = 0.0; + for ( i = 0; i < M; i++ ) { + tmp = work[ offsetW + ( i * strideW ) ]; + if ( value < tmp || isnan( tmp ) ) { + value = tmp; + } + } + return value; + } + if ( norm === 'f' ) { + // Find normF( A ) + scale = 0.0; + sum = 1.0; + out = new Float64Array( 2 ); + if ( order === 'column-major' ) { + for ( j = 0; j < N; j++ ) { + out = dlassq( M, A, strideA2, offsetA + ( j * strideA1 ), scale, sum, out, 1, 0 ); + } + value = scale * sqrt( out[ 1 ] ); + return value; + } + // order === 'row-major' + for ( i = 0; i < M; i++ ) { + out = dlassq( N, A, strideA1, offsetA + ( i * strideA2 ), scale, sum, out, 1, 0 ); + } + } + return value; +} + + +// EXPORTS // + +module.exports = dlange; 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 00000000000..0842e27aa95 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* +* @param {string} order - storage layout +* @param {string} norm - specifies the value to be returned +* @param {NonNegativeInteger} M - number of rows of `A` +* @param {NonNegativeInteger} N - number of columns of `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 - workspace array +* @throws {TypeError} first argument must be a valid order +* @returns {number} matrix norm +* +* @example +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); +* +* var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); +* // out => 4.0 +*/ +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 ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( order, 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/main.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js new file mode 100644 index 00000000000..9b733faf588 --- /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 00000000000..3fca2630d5e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -0,0 +1,66 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* +* @param {string} order - storage layout +* @param {string} norm - specifies the value to be returned +* @param {NonNegativeInteger} M - number of rows of `A` +* @param {NonNegativeInteger} N - number of columns of `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 {PositiveInteger} offsetA - starting index for `A` +* @param {Float64Array} work - workspace array +* @param {integer} strideW - stride length for `work` +* @param {PositiveInteger} offsetW - starting index for `work` +* @throws {TypeError} first argument must be a valid order +* @returns {number} matrix norm +* +* @example +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); +* +* var out = dlange( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // out => 4.0 +*/ +function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { // eslint-disable-line max-params, max-len + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + return base( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dlange; From d3fc84d435a5848318d2a01e25eea2d6ff7ef18c Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 29 Jul 2024 21:06:41 +0530 Subject: [PATCH 02/16] chore: add other files --- .../@stdlib/lapack/base/dlange/README.md | 237 ++++++++++++ .../lapack/base/dlange/benchmark/benchmark.js | 108 ++++++ .../dlange/benchmark/benchmark.ndarray.js | 108 ++++++ .../lapack/base/dlange/docs/types/index.d.ts | 115 ++++++ .../lapack/base/dlange/docs/types/test.ts | 342 ++++++++++++++++++ .../lapack/base/dlange/examples/index.js | 29 ++ .../@stdlib/lapack/base/dlange/lib/index.js | 68 ++++ .../@stdlib/lapack/base/dlange/lib/ndarray.js | 4 +- .../@stdlib/lapack/base/dlange/package.json | 68 ++++ .../@stdlib/lapack/base/dlange/test/test.js | 82 +++++ 10 files changed, 1159 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/README.md 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/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlange/test/test.js 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 00000000000..f71614aafce --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/README.md @@ -0,0 +1,237 @@ + + +# dlange + +> Return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. + +
+ +## Usage + +```javascript +var dlange = require( '@stdlib/lapack/base/dlange' ); +``` + +#### dlange( order, norm, M, N, A, LDA, work ) + +Return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var work = new Float64Array( 2 ); + +var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); +// out => 6.0 +``` + +The function has the following parameters: + +- **order**: storage layout. +- **norm**: specifies the value to be returned. +- **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**: workspace 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' ); + +// Initial arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var WORK0 = new Float64Array( 4 ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var WORK1 = new Float64Array( WORK0.buffer, WORK0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = dlange( 'row-major', 'M', 2, 3, A1, 3, WORK1 ); +// out => 6.0 +``` + +#### dlange.ndarray( ord, norm, M, N, A, sa1, sa2, oa, work, sw, ow ) + +Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of 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, 2.0, 3.0, 4.0 ] ); +var work = new Float64Array( 2 ); + +var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +// out => 4.0 +``` + +The function has the following additional parameters: + +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A` +- **sw**: stride length for `work`. +- **ow**: starting index for `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, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var work = new Float64Array( 2 ); + +var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 2, work, 1, 0 ); +// out => 4.0 +``` + +
+ + + +
+ +## Notes + +- `dlange()` corresponds to the [LAPACK][lapack] routine [`dlange`][lapack-dlange]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlange = require( '@stdlib/lapack/base/dlange' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var work = new Float64Array( 2 ); + +var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); +// out => 6.0 +``` + +
+ + + + + +* * * + +
+ +## 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/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js new file mode 100644 index 00000000000..a742679f774 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js @@ -0,0 +1,108 @@ +/** +* @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 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 pkg = require( './../package.json' ).name; +var dlange = require( './../lib/dlange.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var values; + var opts; + var work; + var A; + + opts = { + 'dtype': 'float64' + }; + + values = [ 'M', '1', 'O', 'I', 'F', 'E' ]; + + A = uniform( N*N, -10.0, 10.0, opts ); + work = uniform( N, -10.0, 10.0, opts ); + 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( 'column-major', values[ i%values.length ], 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 min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':order=column-major,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 00000000000..e1176aa49ce --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js @@ -0,0 +1,108 @@ +/** +* @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 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 pkg = require( './../package.json' ).name; +var dlange = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var values; + var opts; + var work; + var A; + + opts = { + 'dtype': 'float64' + }; + + values = [ 'M', '1', 'O', 'I', 'F', 'E' ]; + + A = uniform( N*N, -10.0, 10.0, opts ); + work = uniform( N, -10.0, 10.0, opts ); + 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( 'column-major', values[ i%values.length ], N, N, A, 1, N, 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 min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:order=column-major,size='+(N*N), f ); + } +} + +main(); 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 00000000000..6a159cb75d6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts @@ -0,0 +1,115 @@ +/** +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `dlange`. +*/ +interface Routine { + /** + * Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. + * + * @param order - storage layout + * @param norm - specifies the value to be returned + * @param M - number of rows of `A` + * @param N - number of columns of `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 - workspace array + * @returns matrix norm + * + * @example + * var Float64Array = require( `@stdlib/array/float64` ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var work = new Float64Array( 2 ); + * + * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); + * // out => 4.0 + */ + ( order: Layout, norm: string, M: number, N: number, A: Float64Array, LDA: number, work: Float64Array ): number; + + /** + * Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. + * + * @param order - storage layout + * @param norm - specifies the value to be returned + * @param M - number of rows of `A` + * @param N - number of columns of `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 for `A` + * @param work - workspace array + * @param strideW - stride length for `work` + * @param offsetW - starting index for `work` + * @returns matrix norm + * + * @example + * var Float64Array = require( `@stdlib/array/float64` ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var work = new Float64Array( 2 ); + * + * var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); + * // out => 4.0 + */ + ndarray( order: Layout, norm: string, M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, work: Float64Array, strideW: number, offsetW: number ): number; +} + +/** +* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* +* @param order - storage layout +* @param norm - specifies the value to be returned +* @param M - number of rows of `A` +* @param N - number of columns of `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 - workspace array +* @returns matrix norm +* +* @example +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); +* +* var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); +* // out => 4.0 +* +* @example +* var Float64Array = require( `@stdlib/array/float64` ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); +* +* var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // out => 4.0 +*/ +declare var dlange: Routine; + + +// EXPORTS // + +export = dlange; 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 00000000000..3b8ae37ab65 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts @@ -0,0 +1,342 @@ +/* +* @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. +*/ + +import dlange = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange( 'row-major', 'M', 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 work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange( 5, 'M', 2, 2, A, 2, work ); // $ExpectError + dlange( true, 'M', 2, 2, A, 2, work ); // $ExpectError + dlange( false, 'M', 2, 2, A, 2, work ); // $ExpectError + dlange( null, 'M', 2, 2, A, 2, work ); // $ExpectError + dlange( void 0, 'M', 2, 2, A, 2, work ); // $ExpectError + dlange( [], 'M', 2, 2, A, 2, work ); // $ExpectError + dlange( {}, 'M', 2, 2, A, 2, work ); // $ExpectError + dlange( ( x: number ): number => x, 'M', 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 work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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 work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange( 'row-major', 'M', '5', 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', true, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', false, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', null, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', void 0, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', [], 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', {}, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', ( 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 work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange( 'row-major', 'M', 2, '5', A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, true, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, false, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, null, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, void 0, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, [], A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, {}, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 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( [ 0.0, 0.0, 0.0 ] ); + + dlange( 'row-major', 'M', 2, 2, '5', 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, 5, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, true, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, false, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, null, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, void 0, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, [], 2, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, {}, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 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 work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange( 'row-major', 'M', 2, 2, A, '5', work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, true, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, false, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, null, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, void 0, work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, [], work ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, {}, work ); // $ExpectError + dlange( 'row-major', 'M', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange( 'row-major', 'M', 2, 2, A, 2, '5' ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2, 5 ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2, true ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2, false ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2, null ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2, void 0 ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2, [] ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2, {} ); // $ExpectError + dlange( 'row-major', 'M', 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 work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange(); // $ExpectError + dlange( 'row-major' ); // $ExpectError + dlange( 'row-major', 'M' ); // $ExpectError + dlange( 'row-major', 'M', 2 ); // $ExpectError + dlange( 'row-major', 'M', 2, 2 ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2 ); // $ExpectError + dlange( 'row-major', 'M', 2, 2, A, 2, work, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', 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 work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 5, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( true, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( false, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( null, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( void 0, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( [], 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( {}, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( ( x: number ): number => x, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 5, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', true, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', false, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', null, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', void 0, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', [], 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', {}, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', ( x: number ): number => x, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', '5', 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', true, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', false, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', null, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', void 0, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', [], 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', {}, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', ( x: number ): number => x, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', 2, '5', A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, true, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, false, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, null, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, void 0, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, [], A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, {}, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, ( x: number ): number => x, A, 2, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + + dlange.ndarray( 'row-major', 'M', 2, 2, '5', 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, 5, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, true, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, false, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, null, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, void 0, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, [], 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, {}, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, ( x: number ): number => x, 2, 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 work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', 2, 2, A, '5', 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, true, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, false, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, null, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, void 0, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, [], 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, {}, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, ( x: number ): number => x, 1, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, '5', 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, true, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, false, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, null, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, void 0, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, [], 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, {}, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, ( x: number ): number => x, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, '5', work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, true, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, false, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, null, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, void 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, [], work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, {}, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, ( x: number ): number => x, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, '5', 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, 5, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, true, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, false, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, null, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, void 0, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, [], 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, {}, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, '5', 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, true, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, false, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, null, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, void 0, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, [], 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, {}, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, '5' ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, true ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, false ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, null ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, void 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, [] ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, {} ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray(); // $ExpectError + dlange.ndarray( 'row-major' ); // $ExpectError + dlange.ndarray( 'row-major', 'M' ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1 ); // $ExpectError + dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0, 10 ); // $ExpectError +} 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 00000000000..3d3c56637ad --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js @@ -0,0 +1,29 @@ +/** +* @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'; + +var Float64Array = require( '@stdlib/array/float64' ); +var dlange = require( './../lib' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var work = new Float64Array( 2 ); + +var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); +console.log( out ); +// out => 6.0 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 00000000000..f7360f38541 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js @@ -0,0 +1,68 @@ +/** +* @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 return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of 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, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); +* +* var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); +* // out => 4.0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlange = require( '@stdlib/lapack/base/dlange' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); +* +* var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // out => 4.0 +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var 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/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js index 3fca2630d5e..bce69c6fbe9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. * * @param {string} order - storage layout * @param {string} norm - specifies the value to be returned @@ -45,7 +45,7 @@ var base = require( './base.js' ); * @returns {number} matrix norm * * @example -* var Float64Array = require( `@stdlib/array/float64` ); +* var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); 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 00000000000..8e07fb1494b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/lapack/base/dlange", + "version": "0.0.0", + "description": "Return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of 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", + "absolute", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} 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 00000000000..56b6b40d299 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var 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 3ef8c38428e5dd1decca6f8caab69be194cb76c3 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 29 Jul 2024 21:53:07 +0530 Subject: [PATCH 03/16] fix: base implementation --- .../@stdlib/lapack/base/dlange/lib/base.js | 26 +++++++++---------- .../@stdlib/lapack/base/dlange/lib/dlange.js | 2 +- 2 files changed, 14 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 1de78c93263..8b210f67b73 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -51,7 +51,7 @@ var isnan = require( '@stdlib/assert/is-nan' ); * @returns {number} matrix norm * * @example -* var Float64Array = require( `@stdlib/array/float64` ); +* var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); @@ -105,9 +105,9 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride if ( order === 'column-major' ) { for ( j = 0; j < N; j++ ) { sum = 0.0; - sa = offsetA + ( j * strideA1 ); + sa = offsetA + ( j * strideA2 ); for ( i = 0; i < M; i++ ) { - sum += abs( A[ sa + ( i * strideA2 ) ] ); + sum += abs( A[ sa + ( i * strideA1 ) ] ); } if ( value < sum || isnan( sum ) ) { value = sum; @@ -116,11 +116,11 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride return value; } // order === 'row-major' - for ( i = 0; i < M; i++ ) { + for ( j = 0; j < N; j++ ) { sum = 0.0; - sa = offsetA + ( i * strideA2 ); - for ( j = 0; j < N; j++ ) { - sum += abs( A[ sa + ( j * strideA1 ) ] ); + sa = offsetA + ( j * strideA2 ); + for ( i = 0; i < M; i++ ) { + sum += abs( A[ sa + ( i * strideA1 ) ] ); } if ( value < sum || isnan( sum ) ) { value = sum; @@ -135,16 +135,16 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride } if ( order === 'column-major' ) { for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * strideA1 ); + sa = offsetA + ( j * strideA2 ); for ( i = 0; i < M; i++ ) { - work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA2 ) ] ); + work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA1 ) ] ); } } } else { // order === 'row-major' - for ( i = 0; i < M; i++ ) { - sa = offsetA + ( i * strideA2 ); - for ( j = 0; j < N; j++ ) { - work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( j * strideA1 ) ] ); + for ( j = 0; j < N; j++ ) { + sa = offsetA + ( j * strideA2 ); + for ( i = 0; i < M; i++ ) { + work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA1 ) ] ); } } } 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 0842e27aa95..41d08335ca5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -41,7 +41,7 @@ var base = require( './base.js' ); * @returns {number} matrix norm * * @example -* var Float64Array = require( `@stdlib/array/float64` ); +* var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); From ff0e955aacda163fa833f48fba0f5095029c13e8 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 29 Jul 2024 21:56:19 +0530 Subject: [PATCH 04/16] test: add ndarray and dlange implementation --- .../lapack/base/dlange/test/test.dlange.js | 307 ++++++++++++++++++ .../lapack/base/dlange/test/test.ndarray.js | 38 +++ 2 files changed, 345 insertions(+) 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.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 new file mode 100644 index 00000000000..0c7717a1762 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js @@ -0,0 +1,307 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlange = require( './../lib/dlange.js' ); + + +// 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 an invalid first argument', function test( t ) { + var values; + var work; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + work = new Float64Array( 4 ); + + 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, 'M', 2, 2, A, 2, work ); + }; + } +}); + +tape( 'the function returns maximum absolute value of elements of a square real matrix ( row-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); + expected = 4.0; + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns maximum absolute value of elements of a real matrix ( row-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); + expected = 6.0; + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns maximum absolute value of elements of a square real matrix ( column-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'column-major', 'M', 2, 2, A, 2, work ); + expected = 4.0; + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns maximum absolute value of elements of a real matrix ( column-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'column-major', 'M', 3, 2, A, 2, work ); + expected = 6.0; + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the one norm of a square real matrix ( row-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'row-major', '1', 2, 2, A, 2, work ); + expected = 6.0; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'O', 2, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'o', 2, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the one norm of a real matrix ( row-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'row-major', '1', 2, 3, A, 3, work ); + expected = 9.0; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'O', 2, 3, A, 3, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'o', 2, 3, A, 3, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the one norm of a square real matrix ( column-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'column-major', '1', 2, 2, A, 2, work ); + expected = 6.0; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'O', 2, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'o', 2, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the one norm of a real matrix ( column-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'column-major', '1', 3, 2, A, 2, work ); + expected = 10.0; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'O', 3, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'o', 3, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the infinity norm of a square real matrix ( row-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'row-major', 'I', 2, 2, A, 2, work ); + expected = 7.0; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'i', 2, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the infinity norm of a real matrix ( row-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + work = new Float64Array( 3 ); + + out = dlange( 'row-major', 'I', 2, 3, A, 3, work ); + expected = 15.0; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'i', 2, 3, A, 3, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the infinity norm of a square real matrix ( column-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'column-major', 'I', 2, 2, A, 2, work ); + expected = 7.0; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'i', 2, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the infinity norm of a real matrix ( column-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + work = new Float64Array( 3 ); + + out = dlange( 'column-major', 'I', 3, 2, A, 2, work ); + expected = 9.0; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'i', 3, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); 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 00000000000..780aba98965 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var dlange = require( './../lib/ndarray.js' ); + + +// 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 11', function test( t ) { + t.strictEqual( dlange.length, 11, 'returns expected value' ); + t.end(); +}); From 326d20e689b3b8d86ffd1e2b6947d31da11eed3f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 30 Jul 2024 18:38:04 +0530 Subject: [PATCH 05/16] chore: apply suggestion from code review --- lib/node_modules/@stdlib/lapack/base/dlange/README.md | 10 +++++----- .../@stdlib/lapack/base/dlange/docs/types/index.d.ts | 8 ++++---- .../@stdlib/lapack/base/dlange/examples/index.js | 1 - .../@stdlib/lapack/base/dlange/lib/base.js | 2 +- .../@stdlib/lapack/base/dlange/lib/dlange.js | 2 +- .../@stdlib/lapack/base/dlange/lib/index.js | 4 ++-- .../@stdlib/lapack/base/dlange/lib/ndarray.js | 2 +- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/README.md b/lib/node_modules/@stdlib/lapack/base/dlange/README.md index f71614aafce..761b3b85ed3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlange/README.md @@ -41,7 +41,7 @@ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var work = new Float64Array( 2 ); var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); -// out => 6.0 +// returns 6.0 ``` The function has the following parameters: @@ -70,7 +70,7 @@ var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd var WORK1 = new Float64Array( WORK0.buffer, WORK0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var out = dlange( 'row-major', 'M', 2, 3, A1, 3, WORK1 ); -// out => 6.0 +// returns 6.0 ``` #### dlange.ndarray( ord, norm, M, N, A, sa1, sa2, oa, work, sw, ow ) @@ -84,7 +84,7 @@ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var work = new Float64Array( 2 ); var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); -// out => 4.0 +// returns 4.0 ``` The function has the following additional parameters: @@ -104,7 +104,7 @@ var A = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); var work = new Float64Array( 2 ); var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 2, work, 1, 0 ); -// out => 4.0 +// returns 4.0 ``` @@ -135,7 +135,7 @@ var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var work = new Float64Array( 2 ); var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); -// out => 6.0 +// returns 6.0 ``` 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 6a159cb75d6..a448d87170f 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,7 +45,7 @@ interface Routine { * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); - * // out => 4.0 + * // returns 4.0 */ ( order: Layout, norm: string, M: number, N: number, A: Float64Array, LDA: number, work: Float64Array ): number; @@ -72,7 +72,7 @@ interface Routine { * var work = new Float64Array( 2 ); * * var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); - * // out => 4.0 + * // returns 4.0 */ ndarray( order: Layout, norm: string, M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, work: Float64Array, strideW: number, offsetW: number ): number; } @@ -96,7 +96,7 @@ interface Routine { * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); -* // out => 4.0 +* // returns 4.0 * * @example * var Float64Array = require( `@stdlib/array/float64` ); @@ -105,7 +105,7 @@ interface Routine { * var work = new Float64Array( 2 ); * * var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); -* // out => 4.0 +* // returns 4.0 */ declare var dlange: Routine; 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 3d3c56637ad..79a2b8c4998 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js @@ -26,4 +26,3 @@ var work = new Float64Array( 2 ); var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); console.log( out ); -// out => 6.0 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 8b210f67b73..4153187ff4d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -57,7 +57,7 @@ var isnan = require( '@stdlib/assert/is-nan' ); * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); -* // out => 4.0 +* // returns 4.0 */ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { // eslint-disable-line max-params var scale; 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 41d08335ca5..3b0dd23fe4d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -47,7 +47,7 @@ var base = require( './base.js' ); * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); -* // out => 4.0 +* // returns 4.0 */ function dlange( order, norm, M, N, A, LDA, work ) { var sa1; 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 f7360f38541..95f0d310c9f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js @@ -31,7 +31,7 @@ * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); -* // out => 4.0 +* // returns 4.0 * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -41,7 +41,7 @@ * var work = new Float64Array( 2 ); * * var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); -* // out => 4.0 +* // returns 4.0 */ // MODULES // 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 bce69c6fbe9..6307a93ecb3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -51,7 +51,7 @@ var base = require( './base.js' ); * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); -* // out => 4.0 +* // returns 4.0 */ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { // eslint-disable-line max-params, max-len if ( !isLayout( order ) ) { From f3d895cecf6ac24a33dc6f21aeb2580775218058 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 30 Jul 2024 19:39:39 +0530 Subject: [PATCH 06/16] fix: base implementation for Forbenius norm --- .../@stdlib/lapack/base/dlange/lib/base.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 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 4153187ff4d..1896e4da3c2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -60,7 +60,6 @@ var isnan = require( '@stdlib/assert/is-nan' ); * // returns 4.0 */ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { // eslint-disable-line max-params - var scale; var value; var sum; var tmp; @@ -159,20 +158,20 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride } if ( norm === 'f' ) { // Find normF( A ) - scale = 0.0; - sum = 1.0; - out = new Float64Array( 2 ); + out = new Float64Array( [ 0.0, 1.0 ] ); if ( order === 'column-major' ) { for ( j = 0; j < N; j++ ) { - out = dlassq( M, A, strideA2, offsetA + ( j * strideA1 ), scale, sum, out, 1, 0 ); + out = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), out[ 0 ], out[ 1 ], out, 1, 0 ); } - value = scale * sqrt( out[ 1 ] ); + value = out[ 0 ] * sqrt( out[ 1 ] ); return value; } // order === 'row-major' - for ( i = 0; i < M; i++ ) { - out = dlassq( N, A, strideA1, offsetA + ( i * strideA2 ), scale, sum, out, 1, 0 ); + for ( j = 0; j < N; j++ ) { + out = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), out[ 0 ], out[ 1 ], out, 1, 0 ); } + value = out[ 0 ] * sqrt( out[ 1 ] ); + return value; } return value; } From d77e531f4c4d68507279655207e123ec5819cbdb Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 30 Jul 2024 19:39:59 +0530 Subject: [PATCH 07/16] test: add tests for computation of Forbenius norm --- .../lapack/base/dlange/test/test.dlange.js | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) 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 0c7717a1762..9385859ae60 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 @@ -305,3 +305,83 @@ tape( 'the function returns the infinity norm of a real matrix ( column-major )' t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); + +tape( 'the function returns the Frobenius norm of a square real matrix ( row-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'row-major', 'F', 2, 2, A, 2, work ); + expected = 5.477225575051661; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'f', 2, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the Frobenius norm of a real matrix ( row-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + work = new Float64Array( 3 ); + + out = dlange( 'row-major', 'F', 2, 3, A, 3, work ); + expected = 9.539392014169456; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'f', 2, 3, A, 3, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the Frobenius norm of a square real matrix ( column-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); + work = new Float64Array( 2 ); + + out = dlange( 'column-major', 'F', 2, 2, A, 2, work ); + expected = 5.477225575051661; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'f', 2, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the Frobenius norm of a real matrix ( column-major )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + work = new Float64Array( 3 ); + + out = dlange( 'column-major', 'F', 3, 2, A, 2, work ); + expected = 7.681145747868608; + + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'f', 3, 2, A, 2, work ); + + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); From b940a3621f85f779b26f92fb1771a1a857c65d8e Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 30 Jul 2024 19:52:55 +0530 Subject: [PATCH 08/16] test: add ndarray tests --- .../lapack/base/dlange/test/test.ndarray.js | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) 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 780aba98965..f5c9f15e2a2 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 @@ -21,6 +21,7 @@ // MODULES // var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); var dlange = require( './../lib/ndarray.js' ); @@ -36,3 +37,140 @@ tape( 'the function has an arity of 11', function test( t ) { t.strictEqual( dlange.length, 11, 'returns expected value' ); t.end(); }); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var work; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + work = new Float64Array( 4 ); + + 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, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); + }; + } +}); + +tape( 'the function allows specifying offset for computation of norms ( offsetA = 4, offsetWork = 2 )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); + work = new Float64Array( [ 0.0, 0.0, 999.9, 999.9 ] ); + + out = dlange( 'row-major', 'M', 2, 2, A, 2, 1, 4, work, 1, 2 ); + expected = 4.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', '1', 2, 2, A, 2, 1, 4, work, 1, 2 ); + expected = 6.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'I', 2, 2, A, 2, 1, 4, work, 1, 2 ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'F', 2, 2, A, 2, 1, 4, work, 1, 2 ); + expected = 5.477225575051661; + t.strictEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function allows accessing elements from an input array which do not have contiguous column memory layout( row-major, strideA2 = 2, strideA1 = 3 )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 999.9, 2.0, 3.0, 999.9, 4.0 ] ); + work = new Float64Array( [ 0.0, 0.0, 999.9, 999.9 ] ); + + out = dlange( 'row-major', 'M', 2, 2, A, 3, 2, 4, work, 1, 2 ); + expected = 4.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', '1', 2, 2, A, 3, 2, 4, work, 1, 2 ); + expected = 6.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'I', 2, 2, A, 3, 2, 4, work, 1, 2 ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'F', 2, 2, A, 3, 2, 4, work, 1, 2 ); + expected = 5.477225575051661; + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function allows accessing elements from an input array which do not have contiguous column & row memory layout( row-major, strideA2 = 2, strideA1 = 6 )', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 999.9, 2.0, 999.9, 999.9, 999.9, 3.0, 999.9, 4.0 ] ); + work = new Float64Array( [ 0.0, 999.9, 0.0, 999.9 ] ); + + out = dlange( 'row-major', 'M', 2, 2, A, 6, 2, 4, work, 2, 1 ); + expected = 4.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', '1', 2, 2, A, 6, 2, 4, work, 2, 1 ); + expected = 6.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'I', 2, 2, A, 6, 2, 4, work, 2, 1 ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'F', 2, 2, A, 6, 2, 4, work, 2, 1 ); + expected = 5.477225575051661; + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports accessing elements in reverse order', function test( t ) { + var expected; + var work; + var out; + var A; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 4.0, 999.9, 3.0, 999.9, 999.9, 999.9, 2.0, 999.9, 1.0 ] ); + work = new Float64Array( [ 0.0, 999.9, 0.0, 999.9 ] ); + + out = dlange( 'row-major', 'M', 2, 2, A, -6, -2, 12, work, -1, 3 ); + expected = 4.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', '1', 2, 2, A, -6, -2, 12, work, -1, 3 ); + expected = 6.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'I', 2, 2, A, -6, -2, 12, work, -1, 3 ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'F', 2, 2, A, -6, -2, 12, work, -1, 3 ); + expected = 5.477225575051661; + t.strictEqual( out, expected, 'returns expected value' ); + t.end(); +}); From 1b13ca2ca8bb097e890f003a3c900cd72707921a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 31 Jul 2024 18:44:17 +0530 Subject: [PATCH 09/16] chore: add remaining files and refactor implementation --- .../@stdlib/lapack/base/dlange/README.md | 21 +- .../dlange/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/lapack/base/dlange/docs/repl.txt | 101 ++++++++ .../lapack/base/dlange/docs/types/index.d.ts | 21 +- .../lapack/base/dlange/docs/types/test.ts | 216 ++++++++---------- .../@stdlib/lapack/base/dlange/lib/base.js | 62 +++-- .../@stdlib/lapack/base/dlange/lib/dlange.js | 4 +- .../@stdlib/lapack/base/dlange/lib/index.js | 4 +- .../@stdlib/lapack/base/dlange/lib/ndarray.js | 17 +- .../@stdlib/lapack/base/dlange/package.json | 2 +- .../@stdlib/lapack/base/dlange/test/test.js | 1 + .../lapack/base/dlange/test/test.ndarray.js | 64 ++---- 12 files changed, 297 insertions(+), 218 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 761b3b85ed3..09049ce6e38 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 -> Return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +> Return the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A.
@@ -32,7 +32,7 @@ var dlange = require( '@stdlib/lapack/base/dlange' ); #### dlange( order, norm, M, N, A, LDA, work ) -Return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +Return the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -73,9 +73,9 @@ var out = dlange( 'row-major', 'M', 2, 3, A1, 3, WORK1 ); // returns 6.0 ``` -#### dlange.ndarray( ord, norm, M, N, A, sa1, sa2, oa, work, sw, ow ) +#### dlange.ndarray( norm, M, N, A, sa1, sa2, oa, work, sw, ow ) -Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. +Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -83,15 +83,20 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var work = new Float64Array( 2 ); -var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // returns 4.0 ``` -The function has the following additional parameters: +The function has the following parameters: +- **norm**: specifies the value to be returned. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. - **sa1**: stride of the first dimension of `A`. - **sa2**: stride of the second dimension of `A`. -- **oa**: starting index for `A` +- **oa**: starting index for `A`. +- **work**: workspace array. - **sw**: stride length for `work`. - **ow**: starting index for `work`. @@ -103,7 +108,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); var work = new Float64Array( 2 ); -var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 2, work, 1, 0 ); +var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 2, work, 1, 0 ); // returns 4.0 ``` 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 index e1176aa49ce..2a8415ff147 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js @@ -66,7 +66,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlange( 'column-major', values[ i%values.length ], N, N, A, 1, N, 0, work, 1, 0 ); + z = dlange( values[ i%values.length ], N, N, A, 1, N, 0, work, 1, 0 ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } 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 00000000000..c72d12e04ef --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt @@ -0,0 +1,101 @@ + +{{alias}}( order, norm, M, N, A, LDA, work ) + Return the value of one norm, or the Frobenius norm, or the infinity norm, + or the element of 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 value to be returned. + + 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 + Workspace array. + + Returns + ------- + out: number + Matrix norm. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var work = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); + > {{alias}}( 'row-major', 'M', 2, 2, A, 2, work ) + 4.0 + + +{{alias}}.ndarray( norm, M, N, A, sa1, sa2, oa, work, sw, ow ) + Returns the value of one norm, or the Frobenius norm, or the infinity norm, + or the element of 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 value to be returned. + + 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 + Workspace array. + + sw: integer + Stride of the workspace array. + + ow: integer + Starting index for the workspace array. + + Returns + ------- + out: number + Matrix norm. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); + > var work = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( 'M', 2, 2, A, 2, 1, 1, work, 1, 1 ) + 4.0 + + See Also + -------- 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 a448d87170f..b4f821eed66 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 @@ -39,20 +39,19 @@ interface Routine { * @returns matrix norm * * @example - * var Float64Array = require( `@stdlib/array/float64` ); + * var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); - * // returns 4.0 + * // out => 4.0 */ ( order: Layout, norm: string, M: number, N: number, A: Float64Array, LDA: number, work: Float64Array ): number; /** - * Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. + * Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. * - * @param order - storage layout * @param norm - specifies the value to be returned * @param M - number of rows of `A` * @param N - number of columns of `A` @@ -66,15 +65,15 @@ interface Routine { * @returns matrix norm * * @example - * var Float64Array = require( `@stdlib/array/float64` ); + * var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * - * var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); + * var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ - ndarray( order: Layout, norm: string, M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, work: Float64Array, strideW: number, offsetW: number ): number; + ndarray( norm: string, M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, work: Float64Array, strideW: number, offsetW: number ): number; } /** @@ -90,21 +89,21 @@ interface Routine { * @returns matrix norm * * @example -* var Float64Array = require( `@stdlib/array/float64` ); +* var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); -* // returns 4.0 +* // out => 4.0 * * @example -* var Float64Array = require( `@stdlib/array/float64` ); +* var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ declare var dlange: Routine; 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 index 3b8ae37ab65..247e47dff8b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts @@ -154,7 +154,7 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectType number + dlange.ndarray( 'M', 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... @@ -162,29 +162,29 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 5, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( true, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( false, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( null, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( void 0, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( [], 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( {}, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( ( x: number ): number => x, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 5, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( true, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( false, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( null, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( void 0, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( [], 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( {}, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( ( x: number ): number => x, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a second argument which is not a string... +// The compiler throws an error if the function is provided a second argument which is not a number... { const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 5, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', true, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', false, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', null, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', void 0, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', [], 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', {}, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', ( x: number ): number => x, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', '5', 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', true, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', false, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', null, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', void 0, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', [], 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', {}, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', ( x: number ): number => x, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -192,44 +192,44 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', '5', 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', true, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', false, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', null, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', void 0, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', [], 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', {}, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', ( x: number ): number => x, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, '5', A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, true, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, false, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, null, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, void 0, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, [], A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, {}, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, ( x: number ): number => x, A, 2, 1, 0, work, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fourth argument which is not a number... +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... { const work = new Float64Array( [ 0.0, 0.0 ] ); - const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', 2, '5', A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, true, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, false, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, null, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, void 0, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, [], A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, {}, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, ( x: number ): number => x, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, '5', 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, 5, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, true, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, false, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, null, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, void 0, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, [], 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, {}, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, ( x: number ): number => x, 2, 1, 0, work, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +// The compiler throws an error if the function is provided a fifth argument which is not a number... { const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', 2, 2, '5', 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, 5, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, true, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, false, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, null, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, void 0, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, [], 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, {}, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, ( x: number ): number => x, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, '5', 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, true, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, false, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, null, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, void 0, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, [], 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, {}, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 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... @@ -237,14 +237,14 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', 2, 2, A, '5', 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, true, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, false, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, null, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, void 0, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, [], 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, {}, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, ( x: number ): number => x, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, '5', 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, true, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, false, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, null, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, void 0, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, [], 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, {}, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 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... @@ -252,74 +252,59 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, '5', 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, true, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, false, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, null, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, void 0, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, [], 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, {}, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, ( x: number ): number => x, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, '5', work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, true, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, false, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, null, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, void 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, [], work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, {}, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 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 number... +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... { - const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, '5', work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, true, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, false, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, null, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, void 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, [], work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, {}, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, ( x: number ): number => x, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, '5', 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, 5, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, true, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, false, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, null, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, void 0, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, [], 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, {}, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 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 Float64Array... -{ - const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, '5', 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, 5, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, true, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, false, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, null, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, void 0, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, [], 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, {}, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a tenth argument which is not a number... +// The compiler throws an error if the function is provided a ninth argument which is not a number... { const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, '5', 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, true, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, false, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, null, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, void 0, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, [], 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, {}, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, ( x: number ): number => x, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, '5', 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, true, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, false, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, null, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, void 0, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, [], 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, {}, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, ( x: number ): number => x, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided an eleventh argument which is not a number... +// The compiler throws an error if the function is provided a tenth argument which is not a number... { const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, '5' ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, true ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, false ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, null ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, void 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, [] ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, {} ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, ( x: number ): number => x ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, '5' ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, true ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, false ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, null ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, void 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, [] ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, {} ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -328,15 +313,14 @@ import dlange = require( './index' ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); dlange.ndarray(); // $ExpectError - dlange.ndarray( 'row-major' ); // $ExpectError - dlange.ndarray( 'row-major', 'M' ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1 ); // $ExpectError - dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0, 10 ); // $ExpectError + dlange.ndarray( 'M' ); // $ExpectError + dlange.ndarray( 'M', 2 ); // $ExpectError + dlange.ndarray( 'M', 2, 2 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1 ); // $ExpectError + dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0, 10 ); // $ExpectError } 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 1896e4da3c2..ff404623c68 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 @@ // MODULES // +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); var dlassq = require( '@stdlib/lapack/base/dlassq' ).ndarray; var lowercase = require( '@stdlib/string/base/lowercase' ); var sqrt = require( '@stdlib/math/base/special/sqrt' ); @@ -34,10 +35,9 @@ var isnan = require( '@stdlib/assert/is-nan' ); // MAIN // /** -* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. * * @private -* @param {string} order - storage layout * @param {string} norm - specifies the value to be returned * @param {NonNegativeInteger} M - number of rows of `A` * @param {NonNegativeInteger} N - number of columns of `A` @@ -56,19 +56,35 @@ var isnan = require( '@stdlib/assert/is-nan' ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = dlange( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ -function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { // eslint-disable-line max-params +function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { + var order; var value; var sum; var tmp; var out; + var sa0; + var sa1; var sa; var i; var j; norm = lowercase( norm ); + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + // For row-major matrices, the last dimension has the fastest changing index... + order = 'row-major'; + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // order == 'column-major' + // For column-major matrices, the first dimension has the fastest changing index... + order = 'column-major'; + sa0 = strideA1; + sa1 = strideA2; + } + if ( min( M, N ) === 0.0 ) { value = 0.0; } else if ( norm === 'm' ) { @@ -76,9 +92,9 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride value = 0.0; if ( order === 'column-major' ) { for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * strideA1 ); + sa = offsetA + ( j * sa0 ); for ( i = 0; i < M; i++ ) { - tmp = abs( A[ sa + ( i * strideA2 ) ] ); + tmp = abs( A[ sa + ( i * sa1 ) ] ); if ( value <= tmp || isnan( tmp ) ) { value = tmp; } @@ -87,10 +103,10 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride return value; } // order === 'row-major' - for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * strideA2 ); - for ( i = 0; i < M; i++ ) { - tmp = abs( A[ sa + ( i * strideA1 ) ] ); + for ( j = 0; j < M; j++ ) { + sa = offsetA + ( j * sa1 ); + for ( i = 0; i < N; i++ ) { + tmp = abs( A[ sa + ( i * sa0 ) ] ); if ( value <= tmp || isnan( tmp ) ) { value = tmp; } @@ -104,9 +120,9 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride if ( order === 'column-major' ) { for ( j = 0; j < N; j++ ) { sum = 0.0; - sa = offsetA + ( j * strideA2 ); + sa = offsetA + ( j * sa1 ); for ( i = 0; i < M; i++ ) { - sum += abs( A[ sa + ( i * strideA1 ) ] ); + sum += abs( A[ sa + ( i * sa0 ) ] ); } if ( value < sum || isnan( sum ) ) { value = sum; @@ -115,11 +131,14 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride return value; } // order === 'row-major' + // For computing one norm, first dimension has the fastest changing index... + sa0 = strideA1; + sa1 = strideA2; for ( j = 0; j < N; j++ ) { sum = 0.0; - sa = offsetA + ( j * strideA2 ); + sa = offsetA + ( j * sa1 ); for ( i = 0; i < M; i++ ) { - sum += abs( A[ sa + ( i * strideA1 ) ] ); + sum += abs( A[ sa + ( i * sa0 ) ] ); } if ( value < sum || isnan( sum ) ) { value = sum; @@ -134,16 +153,19 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride } if ( order === 'column-major' ) { for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * strideA2 ); + sa = offsetA + ( j * sa1 ); for ( i = 0; i < M; i++ ) { - work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA1 ) ] ); + work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * sa0 ) ] ); } } } else { // order === 'row-major' + // For computing infinity norm, first dimension has the fastest changing index... + sa0 = strideA1; + sa1 = strideA2; for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * strideA2 ); + sa = offsetA + ( j * sa1 ); for ( i = 0; i < M; i++ ) { - work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA1 ) ] ); + work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * sa0 ) ] ); } } } @@ -161,14 +183,14 @@ function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, stride out = new Float64Array( [ 0.0, 1.0 ] ); if ( order === 'column-major' ) { for ( j = 0; j < N; j++ ) { - out = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), out[ 0 ], out[ 1 ], out, 1, 0 ); + out = dlassq( M, A, sa0, offsetA + ( j * sa1 ), out[ 0 ], out[ 1 ], out, 1, 0 ); } value = out[ 0 ] * sqrt( out[ 1 ] ); return value; } // order === 'row-major' for ( j = 0; j < N; j++ ) { - out = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), out[ 0 ], out[ 1 ], out, 1, 0 ); + out = dlassq( M, A, sa1, offsetA + ( j * sa0 ), out[ 0 ], out[ 1 ], out, 1, 0 ); } value = out[ 0 ] * sqrt( out[ 1 ] ); return 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 3b0dd23fe4d..c0efd36fa70 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. * * @param {string} order - storage layout * @param {string} norm - specifies the value to be returned @@ -63,7 +63,7 @@ function dlange( order, norm, M, N, A, LDA, work ) { sa1 = LDA; sa2 = 1; } - return base( order, norm, M, N, A, sa1, sa2, 0, work, 1, 0 ); + return base( norm, M, N, A, sa1, sa2, 0, work, 1, 0 ); } 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 95f0d310c9f..f0626fc1a9a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js @@ -31,7 +31,7 @@ * var work = new Float64Array( 2 ); * * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); -* // returns 4.0 +* // out => 4.0 * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -40,7 +40,7 @@ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange.ndarray( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ 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 6307a93ecb3..e4707db3239 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -16,21 +16,20 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // -var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); -var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); // MAIN // /** -* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. +* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. * -* @param {string} order - storage layout * @param {string} norm - specifies the value to be returned * @param {NonNegativeInteger} M - number of rows of `A` * @param {NonNegativeInteger} N - number of columns of `A` @@ -41,7 +40,6 @@ var base = require( './base.js' ); * @param {Float64Array} work - workspace array * @param {integer} strideW - stride length for `work` * @param {PositiveInteger} offsetW - starting index for `work` -* @throws {TypeError} first argument must be a valid order * @returns {number} matrix norm * * @example @@ -50,14 +48,11 @@ var base = require( './base.js' ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange( 'row-major', 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = dlange( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ -function dlange( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { // eslint-disable-line max-params, max-len - if ( !isLayout( order ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); - } - return base( order, norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); // eslint-disable-line max-len +function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { + return base( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/package.json b/lib/node_modules/@stdlib/lapack/base/dlange/package.json index 8e07fb1494b..b1059245706 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/lapack/base/dlange", "version": "0.0.0", - "description": "Return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A.", + "description": "Return the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js index 56b6b40d299..f9d9beab3ae 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js @@ -1,3 +1,4 @@ + /** * @license Apache-2.0 * 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 f5c9f15e2a2..b0bd4343880 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 @@ -33,39 +33,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 11', function test( t ) { - t.strictEqual( dlange.length, 11, 'returns expected value' ); +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 an invalid first argument', function test( t ) { - var values; - var work; - var A; - var i; - - values = [ - 'foo', - 'bar', - 'beep', - 'boop' - ]; - - A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - work = new Float64Array( 4 ); - - 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, 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); - }; - } -}); - tape( 'the function allows specifying offset for computation of norms ( offsetA = 4, offsetWork = 2 )', function test( t ) { var expected; var work; @@ -75,19 +47,19 @@ tape( 'the function allows specifying offset for computation of norms ( offsetA A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); work = new Float64Array( [ 0.0, 0.0, 999.9, 999.9 ] ); - out = dlange( 'row-major', 'M', 2, 2, A, 2, 1, 4, work, 1, 2 ); + out = dlange( 'M', 2, 2, A, 2, 1, 4, work, 1, 2 ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', '1', 2, 2, A, 2, 1, 4, work, 1, 2 ); + out = dlange( '1', 2, 2, A, 2, 1, 4, work, 1, 2 ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'I', 2, 2, A, 2, 1, 4, work, 1, 2 ); + out = dlange( 'I', 2, 2, A, 2, 1, 4, work, 1, 2 ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'F', 2, 2, A, 2, 1, 4, work, 1, 2 ); + out = dlange( 'F', 2, 2, A, 2, 1, 4, work, 1, 2 ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); @@ -103,19 +75,19 @@ tape( 'the function allows accessing elements from an input array which do not h A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 999.9, 2.0, 3.0, 999.9, 4.0 ] ); work = new Float64Array( [ 0.0, 0.0, 999.9, 999.9 ] ); - out = dlange( 'row-major', 'M', 2, 2, A, 3, 2, 4, work, 1, 2 ); + out = dlange( 'M', 2, 2, A, 3, 2, 4, work, 1, 2 ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', '1', 2, 2, A, 3, 2, 4, work, 1, 2 ); + out = dlange( '1', 2, 2, A, 3, 2, 4, work, 1, 2 ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'I', 2, 2, A, 3, 2, 4, work, 1, 2 ); + out = dlange( 'I', 2, 2, A, 3, 2, 4, work, 1, 2 ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'F', 2, 2, A, 3, 2, 4, work, 1, 2 ); + out = dlange( 'F', 2, 2, A, 3, 2, 4, work, 1, 2 ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); t.end(); @@ -130,19 +102,19 @@ tape( 'the function allows accessing elements from an input array which do not h A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 999.9, 2.0, 999.9, 999.9, 999.9, 3.0, 999.9, 4.0 ] ); work = new Float64Array( [ 0.0, 999.9, 0.0, 999.9 ] ); - out = dlange( 'row-major', 'M', 2, 2, A, 6, 2, 4, work, 2, 1 ); + out = dlange( 'M', 2, 2, A, 6, 2, 4, work, 2, 1 ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', '1', 2, 2, A, 6, 2, 4, work, 2, 1 ); + out = dlange( '1', 2, 2, A, 6, 2, 4, work, 2, 1 ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'I', 2, 2, A, 6, 2, 4, work, 2, 1 ); + out = dlange( 'I', 2, 2, A, 6, 2, 4, work, 2, 1 ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'F', 2, 2, A, 6, 2, 4, work, 2, 1 ); + out = dlange( 'F', 2, 2, A, 6, 2, 4, work, 2, 1 ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); t.end(); @@ -157,19 +129,19 @@ tape( 'the function supports accessing elements in reverse order', function test A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 4.0, 999.9, 3.0, 999.9, 999.9, 999.9, 2.0, 999.9, 1.0 ] ); work = new Float64Array( [ 0.0, 999.9, 0.0, 999.9 ] ); - out = dlange( 'row-major', 'M', 2, 2, A, -6, -2, 12, work, -1, 3 ); + out = dlange( 'M', 2, 2, A, -6, -2, 12, work, -1, 3 ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', '1', 2, 2, A, -6, -2, 12, work, -1, 3 ); + out = dlange( '1', 2, 2, A, -6, -2, 12, work, -1, 3 ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'I', 2, 2, A, -6, -2, 12, work, -1, 3 ); + out = dlange( 'I', 2, 2, A, -6, -2, 12, work, -1, 3 ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'F', 2, 2, A, -6, -2, 12, work, -1, 3 ); + out = dlange( 'F', 2, 2, A, -6, -2, 12, work, -1, 3 ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); t.end(); From 983a2923d5dcb36b15b2f0fb10838569cc7bdfd3 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 31 Jul 2024 18:47:43 +0530 Subject: [PATCH 10/16] chore: apply suggestion from code review --- lib/node_modules/@stdlib/lapack/base/dlange/README.md | 6 +++--- lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt | 6 +++--- .../@stdlib/lapack/base/dlange/docs/types/index.d.ts | 6 +++--- lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js | 2 +- lib/node_modules/@stdlib/lapack/base/dlange/package.json | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/README.md b/lib/node_modules/@stdlib/lapack/base/dlange/README.md index 09049ce6e38..ec6d3fd14f8 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 -> Return the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +> Return the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`.
@@ -32,7 +32,7 @@ var dlange = require( '@stdlib/lapack/base/dlange' ); #### dlange( order, norm, M, N, A, LDA, work ) -Return the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -75,7 +75,7 @@ var out = dlange( 'row-major', 'M', 2, 3, A1, 3, WORK1 ); #### dlange.ndarray( norm, M, N, A, sa1, sa2, oa, work, sw, ow ) -Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. +Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A` using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); 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 c72d12e04ef..3c8826d1d66 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( order, norm, M, N, A, LDA, work ) - Return the value of one norm, or the Frobenius norm, or the infinity norm, - or the element of largest absolute value of a real matrix A. + Returns the value of one norm, or the Frobenius norm, or the infinity norm, + or the element of largest absolute value of a real matrix `A`. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -46,7 +46,7 @@ {{alias}}.ndarray( norm, M, N, A, sa1, sa2, oa, work, sw, ow ) Returns the value of one norm, or the Frobenius norm, or the infinity norm, - or the element of largest absolute value of a real matrix A using + or the element of largest absolute value of a real matrix `A` using alternative indexing semantics. While typed array views mandate a view offset based on the underlying diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts index b4f821eed66..4875aa352aa 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 @@ -27,7 +27,7 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. + * Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. * * @param order - storage layout * @param norm - specifies the value to be returned @@ -50,7 +50,7 @@ interface Routine { ( order: Layout, norm: string, M: number, N: number, A: Float64Array, LDA: number, work: Float64Array ): number; /** - * Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. + * Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A` using alternative indexing semantics. * * @param norm - specifies the value to be returned * @param M - number of rows of `A` @@ -77,7 +77,7 @@ interface Routine { } /** -* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. * * @param order - storage layout * @param norm - specifies the value to be returned 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 ff404623c68..ffccad57e5a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -35,7 +35,7 @@ var isnan = require( '@stdlib/assert/is-nan' ); // MAIN // /** -* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. * * @private * @param {string} norm - specifies the value to be returned 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 c0efd36fa70..7269dcae141 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. * * @param {string} order - storage layout * @param {string} norm - specifies the value to be returned 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 f0626fc1a9a..c35cce798a4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A. +* LAPACK routine to return the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. * * @module @stdlib/lapack/base/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 index e4707db3239..138a9385bcc 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A using alternative indexing semantics. +* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A` using alternative indexing semantics. * * @param {string} norm - specifies the value to be returned * @param {NonNegativeInteger} M - number of rows of `A` diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/package.json b/lib/node_modules/@stdlib/lapack/base/dlange/package.json index b1059245706..34b6595a3e4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/lapack/base/dlange", "version": "0.0.0", - "description": "Return the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix A.", + "description": "Return the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From c5254fa42ab6ab74172f351dd2855a0be3c3d352 Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Wed, 31 Jul 2024 18:53:33 +0530 Subject: [PATCH 11/16] chore: apply suggestions from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dlange/package.json | 1 + lib/node_modules/@stdlib/lapack/base/dlange/test/test.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/package.json b/lib/node_modules/@stdlib/lapack/base/dlange/package.json index 34b6595a3e4..e7062860794 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/package.json @@ -57,6 +57,7 @@ "dlange", "norm", "absolute", + "Frobenius", "subroutines", "array", "ndarray", diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js index f9d9beab3ae..56b6b40d299 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js @@ -1,4 +1,3 @@ - /** * @license Apache-2.0 * From 300e35860b928ef46168c60b8df526b992ecd986 Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:22:51 +0530 Subject: [PATCH 12/16] chore: apply suggestion from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dlange/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/package.json b/lib/node_modules/@stdlib/lapack/base/dlange/package.json index e7062860794..34b6595a3e4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/package.json @@ -57,7 +57,6 @@ "dlange", "norm", "absolute", - "Frobenius", "subroutines", "array", "ndarray", From 94d1264e11945a33f4fda2d4b2a4fe78680405bb Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 1 Aug 2024 20:52:14 +0530 Subject: [PATCH 13/16] refactor: breakdown base implementation --- .../@stdlib/lapack/base/dlange/lib/base.js | 304 +++++++++++------- 1 file changed, 189 insertions(+), 115 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 ffccad57e5a..c4eac7a8c01 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -32,6 +32,191 @@ var min = require( '@stdlib/math/base/special/min' ); var isnan = require( '@stdlib/assert/is-nan' ); +// FUNCTIONS // + +/** +* Computes maximum absolute norm for given matrix `A`. +* +* @private +* @param {string} order - storage layout +* @param {NonNegativeInteger} M - number of rows of `A` +* @param {NonNegativeInteger} N - number of columns of `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 {PositiveInteger} offsetA - starting index for `A` +* @returns {number} maximum absolute norm +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* +* var out = maxAbsNorm( 'row-major', 2, 2, A, 2, 1, 0 ); +* // returns 4.0 +*/ +function maxAbsNorm( order, M, N, A, strideA1, strideA2, offsetA ) { + var value; + var tmp; + var sa; + var i; + var j; + + // Find max( abs( A[ i, j ] ) ) + value = 0.0; + if ( order === 'column-major' ) { + for ( j = 0; j < N; j++ ) { + sa = offsetA + ( j * strideA1 ); + for ( i = 0; i < M; i++ ) { + tmp = abs( A[ sa + ( i * strideA2 ) ] ); + if ( value <= tmp || isnan( tmp ) ) { + value = tmp; + } + } + } + return value; + } + // order === 'row-major' + for ( j = 0; j < N; j++ ) { + sa = offsetA + ( j * strideA2 ); + for ( i = 0; i < M; i++ ) { + tmp = abs( A[ sa + ( i * strideA1 ) ] ); + if ( value <= tmp || isnan( tmp ) ) { + value = tmp; + } + } + } + return value; +} + +/** +* Computes one norm for a given matrix `A`. +* +* @private +* @param {NonNegativeInteger} M - number of rows of `A` +* @param {NonNegativeInteger} N - number of columns of `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 {PositiveInteger} offsetA - starting index for `A` +* @returns {number} one norm +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* +* var out = oneNorm( 2, 2, A, 2, 1, 0 ); +* // returns 6.0 +*/ +function oneNorm( M, N, A, strideA1, strideA2, offsetA ) { + var value; + var sum; + var sa; + var i; + var j; + + // Find norm1( A ) + value = 0.0; + for ( j = 0; j < N; j++ ) { + sum = 0.0; + sa = offsetA + ( j * strideA2 ); + for ( i = 0; i < M; i++ ) { + sum += abs( A[ sa + ( i * strideA1 ) ] ); + } + if ( value < sum || isnan( sum ) ) { + value = sum; + } + } + return value; +} + +/** +* Computes infinity norm for a given matrix `A`. +* +* @private +* @param {NonNegativeInteger} M - number of rows of `A` +* @param {NonNegativeInteger} N - number of columns of `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 {PositiveInteger} offsetA - starting index for `A` +* @param {Float64Array} work - workspace array +* @param {integer} strideW - stride length for `work` +* @param {PositiveInteger} offsetW - starting index for `work` +* @returns {number} one norm +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); +* +* var out = infNorm( 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // returns 7.0 +*/ +function infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { + var value; + var tmp; + var sa; + var i; + var j; + + // Find normI( A ) + value = 0.0; + for ( i = 0; i < M; i++ ) { + work[ offsetW + ( i * strideW ) ] = 0.0; + } + for ( j = 0; j < N; j++ ) { + sa = offsetA + ( j * strideA2 ); + for ( i = 0; i < M; i++ ) { + work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA1 ) ] ); + } + } + for ( i = 0; i < M; i++ ) { + tmp = work[ offsetW + ( i * strideW ) ]; + if ( value < tmp || isnan( tmp ) ) { + value = tmp; + } + } + return value; +} + +/** +* Computes Frobenius norm for a given matrix `A`. +* +* @private +* @param {NonNegativeInteger} M - number of rows of `A` +* @param {NonNegativeInteger} N - number of columns of `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 {PositiveInteger} offsetA - starting index for `A` +* @returns {number} Frobenius norm +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* +* var out = frobeniusNorm( 2, 2, A, 2, 1, 0 ); +* // returns 5.477225575051661 +*/ +function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { + var value; + var out; + var j; + + // Find normF( A ) + out = new Float64Array( [ 0.0, 1.0 ] ); + for ( j = 0; j < N; j++ ) { + out = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), out[ 0 ], out[ 1 ], out, 1, 0 ); + } + value = out[ 0 ] * sqrt( out[ 1 ] ); + return value; +} + + // MAIN // /** @@ -62,138 +247,27 @@ var isnan = require( '@stdlib/assert/is-nan' ); function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { var order; var value; - var sum; - var tmp; - var out; - var sa0; - var sa1; - var sa; - var i; - var j; norm = lowercase( norm ); - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { - // For row-major matrices, the last dimension has the fastest changing index... order = 'row-major'; - sa0 = strideA2; // stride for innermost loop - sa1 = strideA1; // stride for outermost loop } else { // order == 'column-major' - // For column-major matrices, the first dimension has the fastest changing index... order = 'column-major'; - sa0 = strideA1; - sa1 = strideA2; } if ( min( M, N ) === 0.0 ) { value = 0.0; } else if ( norm === 'm' ) { - // Find max( abs( A[ i, j ] ) ) - value = 0.0; - if ( order === 'column-major' ) { - for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * sa0 ); - for ( i = 0; i < M; i++ ) { - tmp = abs( A[ sa + ( i * sa1 ) ] ); - if ( value <= tmp || isnan( tmp ) ) { - value = tmp; - } - } - } - return value; - } - // order === 'row-major' - for ( j = 0; j < M; j++ ) { - sa = offsetA + ( j * sa1 ); - for ( i = 0; i < N; i++ ) { - tmp = abs( A[ sa + ( i * sa0 ) ] ); - if ( value <= tmp || isnan( tmp ) ) { - value = tmp; - } - } - } - return value; + return maxAbsNorm( order, M, N, A, strideA1, strideA2, offsetA ); } if ( norm === 'o' || norm === '1' ) { - // Find norm1( A ) - value = 0.0; - if ( order === 'column-major' ) { - for ( j = 0; j < N; j++ ) { - sum = 0.0; - sa = offsetA + ( j * sa1 ); - for ( i = 0; i < M; i++ ) { - sum += abs( A[ sa + ( i * sa0 ) ] ); - } - if ( value < sum || isnan( sum ) ) { - value = sum; - } - } - return value; - } - // order === 'row-major' - // For computing one norm, first dimension has the fastest changing index... - sa0 = strideA1; - sa1 = strideA2; - for ( j = 0; j < N; j++ ) { - sum = 0.0; - sa = offsetA + ( j * sa1 ); - for ( i = 0; i < M; i++ ) { - sum += abs( A[ sa + ( i * sa0 ) ] ); - } - if ( value < sum || isnan( sum ) ) { - value = sum; - } - } - return value; + return oneNorm( M, N, A, strideA1, strideA2, offsetA ); } if ( norm === 'i' ) { - // Find normI( A ) - for ( i = 0; i < M; i++ ) { - work[ offsetW + ( i * strideW ) ] = 0.0; - } - if ( order === 'column-major' ) { - for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * sa1 ); - for ( i = 0; i < M; i++ ) { - work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * sa0 ) ] ); - } - } - } else { // order === 'row-major' - // For computing infinity norm, first dimension has the fastest changing index... - sa0 = strideA1; - sa1 = strideA2; - for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * sa1 ); - for ( i = 0; i < M; i++ ) { - work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * sa0 ) ] ); - } - } - } - value = 0.0; - for ( i = 0; i < M; i++ ) { - tmp = work[ offsetW + ( i * strideW ) ]; - if ( value < tmp || isnan( tmp ) ) { - value = tmp; - } - } - return value; + return infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); } if ( norm === 'f' ) { - // Find normF( A ) - out = new Float64Array( [ 0.0, 1.0 ] ); - if ( order === 'column-major' ) { - for ( j = 0; j < N; j++ ) { - out = dlassq( M, A, sa0, offsetA + ( j * sa1 ), out[ 0 ], out[ 1 ], out, 1, 0 ); - } - value = out[ 0 ] * sqrt( out[ 1 ] ); - return value; - } - // order === 'row-major' - for ( j = 0; j < N; j++ ) { - out = dlassq( M, A, sa1, offsetA + ( j * sa0 ), out[ 0 ], out[ 1 ], out, 1, 0 ); - } - value = out[ 0 ] * sqrt( out[ 1 ] ); - return value; + return frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ); } return value; } From b0742ba3ad3f0528d5fdb0f245b795b41612e26e Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 1 Aug 2024 21:06:03 +0530 Subject: [PATCH 14/16] refactor: forbenius norm implementation and tests --- .../@stdlib/lapack/base/dlange/lib/base.js | 30 +++++++++------- .../lapack/base/dlange/test/test.dlange.js | 34 ++----------------- 2 files changed, 21 insertions(+), 43 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 c4eac7a8c01..793b644d265 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -25,8 +25,8 @@ var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); var dlassq = require( '@stdlib/lapack/base/dlassq' ).ndarray; var lowercase = require( '@stdlib/string/base/lowercase' ); +var dnrm2 = require( '@stdlib/blas/base/dnrm2' ).ndarray; var sqrt = require( '@stdlib/math/base/special/sqrt' ); -var Float64Array = require( '@stdlib/array/float64' ); var abs = require( '@stdlib/math/base/special/abs' ); var min = require( '@stdlib/math/base/special/min' ); var isnan = require( '@stdlib/assert/is-nan' ); @@ -192,27 +192,34 @@ function infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {PositiveInteger} offsetA - starting index for `A` +* @param {Float64Array} work - workspace array +* @param {integer} strideW - stride length for `work` +* @param {PositiveInteger} offsetW - starting index for `work` * @returns {number} Frobenius norm * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var work = new Float64Array( 2 ); * -* var out = frobeniusNorm( 2, 2, A, 2, 1, 0 ); +* var out = frobeniusNorm( 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 5.477225575051661 */ -function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { +function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { var value; - var out; var j; // Find normF( A ) - out = new Float64Array( [ 0.0, 1.0 ] ); + if ( M === 1 ) { + return dnrm2( N, A, strideA2, offsetA, strideA1 ); + } + work[ offsetW ] = 0.0; + work[ offsetW + strideW ] = 1.0; for ( j = 0; j < N; j++ ) { - out = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), out[ 0 ], out[ 1 ], out, 1, 0 ); + work = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), work[ offsetW ], work[ offsetW + strideW ], work, strideW, offsetW ); } - value = out[ 0 ] * sqrt( out[ 1 ] ); + value = work[ offsetW ] * sqrt( work[ offsetW + strideW ] ); return value; } @@ -246,7 +253,6 @@ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ) { */ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { var order; - var value; norm = lowercase( norm ); if ( isRowMajor( [ strideA1, strideA2 ] ) ) { @@ -256,8 +262,9 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offs } if ( min( M, N ) === 0.0 ) { - value = 0.0; - } else if ( norm === 'm' ) { + return 0.0; + } + if ( norm === 'm' ) { return maxAbsNorm( order, M, N, A, strideA1, strideA2, offsetA ); } if ( norm === 'o' || norm === '1' ) { @@ -267,9 +274,8 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offs return infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); } if ( norm === 'f' ) { - return frobeniusNorm( M, N, A, strideA1, strideA2, offsetA ); + return frobeniusNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); } - return value; } 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 9385859ae60..dc2750f267d 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 @@ -77,7 +77,6 @@ tape( 'the function returns maximum absolute value of elements of a square real out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); expected = 4.0; - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -93,7 +92,6 @@ tape( 'the function returns maximum absolute value of elements of a real matrix out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); expected = 6.0; - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -109,7 +107,6 @@ tape( 'the function returns maximum absolute value of elements of a square real out = dlange( 'column-major', 'M', 2, 2, A, 2, work ); expected = 4.0; - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -125,7 +122,6 @@ tape( 'the function returns maximum absolute value of elements of a real matrix out = dlange( 'column-major', 'M', 3, 2, A, 2, work ); expected = 6.0; - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -141,15 +137,12 @@ tape( 'the function returns the one norm of a square real matrix ( row-major )', out = dlange( 'row-major', '1', 2, 2, A, 2, work ); expected = 6.0; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'row-major', 'O', 2, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'row-major', 'o', 2, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -165,15 +158,12 @@ tape( 'the function returns the one norm of a real matrix ( row-major )', functi out = dlange( 'row-major', '1', 2, 3, A, 3, work ); expected = 9.0; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'row-major', 'O', 2, 3, A, 3, work ); - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'row-major', 'o', 2, 3, A, 3, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -189,15 +179,12 @@ tape( 'the function returns the one norm of a square real matrix ( column-major out = dlange( 'column-major', '1', 2, 2, A, 2, work ); expected = 6.0; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'column-major', 'O', 2, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'column-major', 'o', 2, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -213,15 +200,12 @@ tape( 'the function returns the one norm of a real matrix ( column-major )', fun out = dlange( 'column-major', '1', 3, 2, A, 2, work ); expected = 10.0; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'column-major', 'O', 3, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'column-major', 'o', 3, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -237,11 +221,9 @@ tape( 'the function returns the infinity norm of a square real matrix ( row-majo out = dlange( 'row-major', 'I', 2, 2, A, 2, work ); expected = 7.0; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'row-major', 'i', 2, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -257,11 +239,9 @@ tape( 'the function returns the infinity norm of a real matrix ( row-major )', f out = dlange( 'row-major', 'I', 2, 3, A, 3, work ); expected = 15.0; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'row-major', 'i', 2, 3, A, 3, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -277,11 +257,9 @@ tape( 'the function returns the infinity norm of a square real matrix ( column-m out = dlange( 'column-major', 'I', 2, 2, A, 2, work ); expected = 7.0; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'column-major', 'i', 2, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -297,11 +275,9 @@ tape( 'the function returns the infinity norm of a real matrix ( column-major )' out = dlange( 'column-major', 'I', 3, 2, A, 2, work ); expected = 9.0; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'column-major', 'i', 3, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -317,11 +293,13 @@ tape( 'the function returns the Frobenius norm of a square real matrix ( row-maj out = dlange( 'row-major', 'F', 2, 2, A, 2, work ); expected = 5.477225575051661; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'row-major', 'f', 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + work = new Float64Array( 1 ); + out = dlange( 'row-major', 'F', 1, 4, A, 4, work ); t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -337,11 +315,9 @@ tape( 'the function returns the Frobenius norm of a real matrix ( row-major )', out = dlange( 'row-major', 'F', 2, 3, A, 3, work ); expected = 9.539392014169456; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'row-major', 'f', 2, 3, A, 3, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -357,11 +333,9 @@ tape( 'the function returns the Frobenius norm of a square real matrix ( column- out = dlange( 'column-major', 'F', 2, 2, A, 2, work ); expected = 5.477225575051661; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'column-major', 'f', 2, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -377,11 +351,9 @@ tape( 'the function returns the Frobenius norm of a real matrix ( column-major ) out = dlange( 'column-major', 'F', 3, 2, A, 2, work ); expected = 7.681145747868608; - t.strictEqual( out, expected, 'returns expected value' ); out = dlange( 'column-major', 'f', 3, 2, A, 2, work ); - t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); From b114224051b4da71f371cf1953b6065a87eae70c Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Thu, 1 Aug 2024 21:08:07 +0530 Subject: [PATCH 15/16] chore: apply suggestion from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dlange/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/package.json b/lib/node_modules/@stdlib/lapack/base/dlange/package.json index 34b6595a3e4..7f5948513c5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlange/package.json @@ -57,6 +57,7 @@ "dlange", "norm", "absolute", + "frobenius", "subroutines", "array", "ndarray", From 24f69980eb0f9ee6c4be8e274c1d5b3ec75aa865 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 3 Aug 2024 16:13:45 +0530 Subject: [PATCH 16/16] feat: support axis attribute in base implementation --- .../@stdlib/lapack/base/dlange/README.md | 18 +- .../lapack/base/dlange/benchmark/benchmark.js | 2 +- .../dlange/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/lapack/base/dlange/docs/repl.txt | 14 +- .../lapack/base/dlange/docs/types/index.d.ts | 23 +- .../lapack/base/dlange/docs/types/test.ts | 362 ++++++++++-------- .../lapack/base/dlange/examples/index.js | 2 +- .../@stdlib/lapack/base/dlange/lib/base.js | 95 +++-- .../@stdlib/lapack/base/dlange/lib/dlange.js | 7 +- .../@stdlib/lapack/base/dlange/lib/index.js | 4 +- .../@stdlib/lapack/base/dlange/lib/ndarray.js | 9 +- .../lapack/base/dlange/test/test.dlange.js | 126 ++++-- .../@stdlib/lapack/base/dlange/test/test.js | 1 + .../lapack/base/dlange/test/test.ndarray.js | 36 +- 14 files changed, 425 insertions(+), 276 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/README.md b/lib/node_modules/@stdlib/lapack/base/dlange/README.md index ec6d3fd14f8..55d61f49a1b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlange/README.md @@ -30,7 +30,7 @@ limitations under the License. var dlange = require( '@stdlib/lapack/base/dlange' ); ``` -#### dlange( order, norm, M, N, A, LDA, work ) +#### dlange( order, norm, axis, M, N, A, LDA, work ) Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. @@ -40,7 +40,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var work = new Float64Array( 2 ); -var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); +var out = dlange( 'row-major', 'M', 1, 2, 3, A, 3, work ); // returns 6.0 ``` @@ -48,6 +48,7 @@ The function has the following parameters: - **order**: storage layout. - **norm**: specifies the value to be returned. +- **axis**: axis along which to compute the norm. - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input [`Float64Array`][mdn-float64array]. @@ -69,11 +70,11 @@ var WORK0 = new Float64Array( 4 ); var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var WORK1 = new Float64Array( WORK0.buffer, WORK0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var out = dlange( 'row-major', 'M', 2, 3, A1, 3, WORK1 ); +var out = dlange( 'row-major', 'M', 1, 2, 3, A1, 3, WORK1 ); // returns 6.0 ``` -#### dlange.ndarray( norm, M, N, A, sa1, sa2, oa, work, sw, ow ) +#### dlange.ndarray( norm, axis, M, N, A, sa1, sa2, oa, work, sw, ow ) Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A` using alternative indexing semantics. @@ -83,13 +84,14 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var work = new Float64Array( 2 ); -var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +var out = dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // returns 4.0 ``` The function has the following parameters: - **norm**: specifies the value to be returned. +- **axis**: axis along which to compute the norm. - **M**: number of rows in `A`. - **N**: number of columns in `A`. - **A**: input [`Float64Array`][mdn-float64array]. @@ -108,7 +110,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); var work = new Float64Array( 2 ); -var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 2, work, 1, 0 ); +var out = dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 2, work, 1, 0 ); // returns 4.0 ``` @@ -120,6 +122,8 @@ var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 2, work, 1, 0 ); ## Notes +- The `axis` parameter specifies the axis along which to compute the norm. When `axis` is `1`, the function computes the norm along columns which is default behavior. +- When `axis` is `0`, the function computes the norm along rows. - `dlange()` corresponds to the [LAPACK][lapack] routine [`dlange`][lapack-dlange].
@@ -139,7 +143,7 @@ var dlange = require( '@stdlib/lapack/base/dlange' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var work = new Float64Array( 2 ); -var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); +var out = dlange( 'row-major', 'M', 1, 2, 3, A, 3, work ); // returns 6.0 ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js index a742679f774..ebd4448d7df 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.js @@ -66,7 +66,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlange( 'column-major', values[ i%values.length ], N, N, A, N, work ); + z = dlange( 'column-major', values[ i%values.length ], 1, N, N, A, N, work ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } 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 index 2a8415ff147..dbca1ab34b7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/benchmark/benchmark.ndarray.js @@ -66,7 +66,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlange( values[ i%values.length ], N, N, A, 1, N, 0, work, 1, 0 ); + z = dlange( values[ i%values.length ], 1, N, N, A, 1, N, 0, work, 1, 0 ); if ( isnan( z ) ) { b.fail( 'should not return NaN' ); } 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 3c8826d1d66..86f0d056335 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( order, norm, M, N, A, LDA, work ) +{{alias}}( order, norm, axis, M, N, A, LDA, work ) Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. @@ -15,6 +15,9 @@ norm: string Specifies the value to be returned. + axis: string + Axis along which to compute the norm. + M: integer Number of rows in `A`. @@ -40,11 +43,11 @@ -------- > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); > var work = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); - > {{alias}}( 'row-major', 'M', 2, 2, A, 2, work ) + > {{alias}}( 'row-major', 'M', 1, 2, 2, A, 2, work ) 4.0 -{{alias}}.ndarray( norm, M, N, A, sa1, sa2, oa, work, sw, ow ) +{{alias}}.ndarray( norm, axis, M, N, A, sa1, sa2, oa, work, sw, ow ) Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A` using alternative indexing semantics. @@ -58,6 +61,9 @@ norm: string Specifies the value to be returned. + axis: string + Axis along which to compute the norm. + M: integer Number of rows in `A`. @@ -94,7 +100,7 @@ -------- > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); > var work = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0 ] ); - > {{alias}}.ndarray( 'M', 2, 2, A, 2, 1, 1, work, 1, 1 ) + > {{alias}}.ndarray( 'M', 1, 2, 2, A, 2, 1, 1, work, 1, 1 ) 4.0 See Also 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 4875aa352aa..d2e52a6b387 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 @@ -27,10 +27,11 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. + * Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. * * @param order - storage layout * @param norm - specifies the value to be returned + * @param axis - specifies the axis along which to compute the norm * @param M - number of rows of `A` * @param N - number of columns of `A` * @param A - input array @@ -44,15 +45,16 @@ interface Routine { * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * - * var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); - * // out => 4.0 + * var out = dlange( 'row-major', 'M', 1, 2, 2, A, 2, work ); + * // returns 4.0 */ - ( order: Layout, norm: string, M: number, N: number, A: Float64Array, LDA: number, work: Float64Array ): number; + ( order: Layout, norm: string, axis: number, M: number, N: number, A: Float64Array, LDA: number, work: Float64Array ): number; /** * Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A` using alternative indexing semantics. * * @param norm - specifies the value to be returned + * @param axis - specifies the axis along which to compute the norm * @param M - number of rows of `A` * @param N - number of columns of `A` * @param A - input array @@ -70,17 +72,18 @@ interface Routine { * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * - * var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); + * var out = dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ - ndarray( norm: string, M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, work: Float64Array, strideW: number, offsetW: number ): number; + ndarray( norm: string, axis: number, M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, work: Float64Array, strideW: number, offsetW: number ): number; } /** -* Returns the value of one norm, or the Forbenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. +* Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A`. * * @param order - storage layout * @param norm - specifies the value to be returned +* @param axis - specifies the axis along which to compute the norm * @param M - number of rows of `A` * @param N - number of columns of `A` * @param A - input array @@ -94,8 +97,8 @@ interface Routine { * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); -* // out => 4.0 +* var out = dlange( 'row-major', 'M', 1, 2, 2, A, 2, work ); +* // returns 4.0 * * @example * var Float64Array = require( '@stdlib/array/float64' ); @@ -103,7 +106,7 @@ interface Routine { * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ declare var dlange: Routine; 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 index 247e47dff8b..26ec6448e23 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts @@ -26,7 +26,7 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange( 'row-major', 'M', 2, 2, A, 2, work ); // $ExpectType number + dlange( 'row-major', 'M', 1, 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... @@ -34,14 +34,14 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange( 5, 'M', 2, 2, A, 2, work ); // $ExpectError - dlange( true, 'M', 2, 2, A, 2, work ); // $ExpectError - dlange( false, 'M', 2, 2, A, 2, work ); // $ExpectError - dlange( null, 'M', 2, 2, A, 2, work ); // $ExpectError - dlange( void 0, 'M', 2, 2, A, 2, work ); // $ExpectError - dlange( [], 'M', 2, 2, A, 2, work ); // $ExpectError - dlange( {}, 'M', 2, 2, A, 2, work ); // $ExpectError - dlange( ( x: number ): number => x, 'M', 2, 2, A, 2, work ); // $ExpectError + dlange( 5, 'M', 1, 2, 2, A, 2, work ); // $ExpectError + dlange( true, 'M', 1, 2, 2, A, 2, work ); // $ExpectError + dlange( false, 'M', 1, 2, 2, A, 2, work ); // $ExpectError + dlange( null, 'M', 1, 2, 2, A, 2, work ); // $ExpectError + dlange( void 0, 'M', 1, 2, 2, A, 2, work ); // $ExpectError + dlange( [], 'M', 1, 2, 2, A, 2, work ); // $ExpectError + dlange( {}, 'M', 1, 2, 2, A, 2, work ); // $ExpectError + dlange( ( x: number ): number => x, 'M', 1, 2, 2, A, 2, work ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a string... @@ -49,14 +49,14 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - 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 + dlange( 'row-major', 5, 1, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', true, 1, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', false, 1, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', null, 1, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', void 0, 1, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', [], 1, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', {}, 1, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', ( x: number ): number => x, 1, 2, 2, A, 2, work ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -64,14 +64,14 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange( 'row-major', 'M', '5', 2, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', true, 2, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', false, 2, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', null, 2, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', void 0, 2, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', [], 2, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', {}, 2, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', ( x: number ): number => x, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', '5', 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', true, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', false, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', null, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', void 0, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', [], 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', {}, 2, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', ( x: number ): number => x, 2, 2, A, 2, work ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -79,59 +79,74 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange( 'row-major', 'M', 2, '5', A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, true, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, false, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, null, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, void 0, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, [], A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, {}, A, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, ( x: number ): number => x, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, '5', 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, true, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, false, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, null, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, void 0, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, [], 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, {}, 2, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, ( x: number ): number => x, 2, A, 2, work ); // $ExpectError } -// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +// The compiler throws an error if the function is provided a fifth argument which is not a number... { const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange( 'row-major', 'M', 2, 2, '5', 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, 5, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, true, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, false, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, null, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, void 0, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, [], 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, {}, 2, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, ( x: number ): number => x, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, '5', A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, true, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, false, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, null, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, void 0, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, [], A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, {}, A, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, ( x: number ): number => x, A, 2, work ); // $ExpectError } -// The compiler throws an error if the function is provided a sixth argument which is not a number... +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dlange( 'row-major', 'M', 1, 2, 2, '5', 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, 5, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, true, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, false, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, null, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, void 0, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, [], 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, {}, 2, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, ( x: number ): number => x, 2, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... { const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange( 'row-major', 'M', 2, 2, A, '5', work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, true, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, false, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, null, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, void 0, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, [], work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, {}, work ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, ( x: number ): number => x, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, '5', work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, true, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, false, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, null, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, void 0, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, [], work ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, {}, work ); // $ExpectError + dlange( 'row-major', 'M', 1, 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... +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... { const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange( 'row-major', 'M', 2, 2, A, 2, '5' ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, 5 ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, true ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, false ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, null ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, void 0 ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, [] ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, {} ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, ( x: number ): number => x ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, '5' ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, 5 ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, true ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, false ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, null ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, void 0 ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, [] ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, {} ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -142,11 +157,12 @@ import dlange = require( './index' ); dlange(); // $ExpectError dlange( 'row-major' ); // $ExpectError dlange( 'row-major', 'M' ); // $ExpectError - dlange( 'row-major', 'M', 2 ); // $ExpectError - dlange( 'row-major', 'M', 2, 2 ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2 ); // $ExpectError - dlange( 'row-major', 'M', 2, 2, A, 2, work, 10 ); // $ExpectError + dlange( 'row-major', 'M', 1 ); // $ExpectError + dlange( 'row-major', 'M', 1, 2 ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2 ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2 ); // $ExpectError + dlange( 'row-major', 'M', 1, 2, 2, A, 2, work, 10 ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a Float64Array... @@ -154,7 +170,7 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectType number + dlange.ndarray( 'M', 1, 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... @@ -162,14 +178,14 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 5, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( true, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( false, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( null, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( void 0, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( [], 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( {}, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( ( x: number ): number => x, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 5, 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( true, 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( false, 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( null, 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( void 0, 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( [], 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( {}, 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( ( x: number ): number => x, 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -177,14 +193,14 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', '5', 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', true, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', false, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', null, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', void 0, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', [], 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', {}, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', ( x: number ): number => x, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', '5', 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', true, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', false, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', null, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', void 0, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', [], 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', {}, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', ( x: number ): number => x, 2, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... @@ -192,44 +208,44 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, '5', A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, true, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, false, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, null, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, void 0, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, [], A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, {}, A, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, ( x: number ): number => x, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, '5', 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, true, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, false, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, null, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, void 0, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, [], 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, {}, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, ( x: number ): number => x, 2, A, 2, 1, 0, work, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +// The compiler throws an error if the function is provided a fourth argument which is not a number... { const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, 2, '5', 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, 5, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, true, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, false, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, null, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, void 0, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, [], 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, {}, 2, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, ( x: number ): number => x, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, '5', A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, true, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, false, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, null, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, void 0, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, [], A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, {}, A, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, ( x: number ): number => x, A, 2, 1, 0, work, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fifth argument which is not a number... +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... { const work = new Float64Array( [ 0.0, 0.0 ] ); - const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, 2, A, '5', 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, true, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, false, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, null, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, void 0, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, [], 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, {}, 1, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, ( x: number ): number => x, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, '5', 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, 5, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, true, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, false, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, null, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, void 0, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, [], 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, {}, 2, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, ( x: number ): number => x, 2, 1, 0, work, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not a number... @@ -237,14 +253,14 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, 2, A, 2, '5', 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, true, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, false, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, null, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, void 0, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, [], 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, {}, 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, ( x: number ): number => x, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, '5', 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, true, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, false, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, null, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, void 0, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, [], 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, {}, 1, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, ( x: number ): number => x, 1, 0, work, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not a number... @@ -252,44 +268,44 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, 2, A, 2, 1, '5', work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, true, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, false, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, null, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, void 0, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, [], work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, {}, work, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, ( x: number ): number => x, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, '5', 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, true, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, false, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, null, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, void 0, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, [], 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, {}, 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, ( x: number ): number => x, 0, work, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +// The compiler throws an error if the function is provided an eighth argument which is not a number... { + const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, '5', 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, 5, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, true, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, false, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, null, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, void 0, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, [], 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, {}, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, '5', work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, true, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, false, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, null, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, void 0, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, [], work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, {}, work, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, ( x: number ): number => x, work, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a ninth argument which is not a number... +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... { - const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, '5', 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, true, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, false, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, null, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, void 0, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, [], 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, {}, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, ( x: number ): number => x, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, '5', 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, 5, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, true, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, false, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, null, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, void 0, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, [], 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, {}, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a tenth argument which is not a number... @@ -297,14 +313,29 @@ import dlange = require( './index' ); const work = new Float64Array( [ 0.0, 0.0 ] ); const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, '5' ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, true ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, false ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, null ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, void 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, [] ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, {} ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, ( x: number ): number => x ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, '5', 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, true, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, false, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, null, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, void 0, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, [], 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, {}, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, '5' ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, true ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, false ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, null ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, void 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, [] ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, {} ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -314,13 +345,14 @@ import dlange = require( './index' ); dlange.ndarray(); // $ExpectError dlange.ndarray( 'M' ); // $ExpectError - dlange.ndarray( 'M', 2 ); // $ExpectError - dlange.ndarray( 'M', 2, 2 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1 ); // $ExpectError - dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0, 10 ); // $ExpectError + dlange.ndarray( 'M', 1 ); // $ExpectError + dlange.ndarray( 'M', 1, 2 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1 ); // $ExpectError + dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0, 10 ); // $ExpectError } 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 79a2b8c4998..5b1dd8e47c5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js @@ -24,5 +24,5 @@ var dlange = require( './../lib' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var work = new Float64Array( 2 ); -var out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); +var out = dlange( 'row-major', 'M', 1, 2, 3, A, 3, work ); console.log( out ); 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 793b644d265..3f093e42517 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -16,7 +16,7 @@ * limitations under the License. */ -/* eslint-disable max-len */ +/* eslint-disable max-len, max-params */ 'use strict'; @@ -93,6 +93,7 @@ function maxAbsNorm( order, M, N, A, strideA1, strideA2, offsetA ) { * Computes one norm for a given matrix `A`. * * @private +* @param {NonNegativeInteger} axis - axis along which to compute the norm * @param {NonNegativeInteger} M - number of rows of `A` * @param {NonNegativeInteger} N - number of columns of `A` * @param {Float64Array} A - input array @@ -106,10 +107,10 @@ function maxAbsNorm( order, M, N, A, strideA1, strideA2, offsetA ) { * * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * -* var out = oneNorm( 2, 2, A, 2, 1, 0 ); +* var out = oneNorm( 1, 2, 2, A, 2, 1, 0 ); * // returns 6.0 */ -function oneNorm( M, N, A, strideA1, strideA2, offsetA ) { +function oneNorm( axis, M, N, A, strideA1, strideA2, offsetA ) { var value; var sum; var sa; @@ -118,11 +119,25 @@ function oneNorm( M, N, A, strideA1, strideA2, offsetA ) { // Find norm1( A ) value = 0.0; - for ( j = 0; j < N; j++ ) { + if ( axis === 1 ) { + for ( j = 0; j < N; j++ ) { + sum = 0.0; + sa = offsetA + ( j * strideA2 ); + for ( i = 0; i < M; i++ ) { + sum += abs( A[ sa + ( i * strideA1 ) ] ); + } + if ( value < sum || isnan( sum ) ) { + value = sum; + } + } + return value; + } + // axis === 0 + for ( i = 0; i < M; i++ ) { sum = 0.0; - sa = offsetA + ( j * strideA2 ); - for ( i = 0; i < M; i++ ) { - sum += abs( A[ sa + ( i * strideA1 ) ] ); + sa = offsetA + ( i * strideA1 ); + for ( j = 0; j < N; j++ ) { + sum += abs( A[ sa + ( j * strideA2 ) ] ); } if ( value < sum || isnan( sum ) ) { value = sum; @@ -135,6 +150,7 @@ function oneNorm( M, N, A, strideA1, strideA2, offsetA ) { * Computes infinity norm for a given matrix `A`. * * @private +* @param {NonNegativeInteger} axis - axis along which to compute the norm * @param {NonNegativeInteger} M - number of rows of `A` * @param {NonNegativeInteger} N - number of columns of `A` * @param {Float64Array} A - input array @@ -152,10 +168,10 @@ function oneNorm( M, N, A, strideA1, strideA2, offsetA ) { * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = infNorm( 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = infNorm( 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 7.0 */ -function infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { +function infNorm( axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { var value; var tmp; var sa; @@ -164,17 +180,36 @@ function infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) // Find normI( A ) value = 0.0; - for ( i = 0; i < M; i++ ) { - work[ offsetW + ( i * strideW ) ] = 0.0; - } - for ( j = 0; j < N; j++ ) { - sa = offsetA + ( j * strideA2 ); + if ( axis === 1) { + for ( i = 0; i < M; i++ ) { + work[ offsetW + ( i * strideW ) ] = 0.0; + } + for ( j = 0; j < N; j++ ) { + sa = offsetA + ( j * strideA2 ); + for ( i = 0; i < M; i++ ) { + work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA1 ) ] ); + } + } for ( i = 0; i < M; i++ ) { - work[ offsetW + ( i * strideW ) ] += abs( A[ sa + ( i * strideA1 ) ] ); + tmp = work[ offsetW + ( i * strideW ) ]; + if ( value < tmp || isnan( tmp ) ) { + value = tmp; + } } + return value; + } + // axis === 0 + for ( j = 0; j < N; j++ ) { + work[ offsetW + ( j * strideW ) ] = 0.0; } for ( i = 0; i < M; i++ ) { - tmp = work[ offsetW + ( i * strideW ) ]; + sa = offsetA + ( i * strideA1 ); + for ( j = 0; j < N; j++ ) { + work[ offsetW + ( j * strideW ) ] += abs( A[ sa + ( j * strideA2 ) ] ); + } + } + for ( j = 0; j < N; j++ ) { + tmp = work[ offsetW + ( j * strideW ) ]; if ( value < tmp || isnan( tmp ) ) { value = tmp; } @@ -186,6 +221,7 @@ function infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) * Computes Frobenius norm for a given matrix `A`. * * @private +* @param {NonNegativeInteger} axis - axis along which to compute the norm * @param {NonNegativeInteger} M - number of rows of `A` * @param {NonNegativeInteger} N - number of columns of `A` * @param {Float64Array} A - input array @@ -203,10 +239,10 @@ function infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = frobeniusNorm( 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = frobeniusNorm( 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 5.477225575051661 */ -function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { +function frobeniusNorm( axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { var value; var j; @@ -216,8 +252,16 @@ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, off } work[ offsetW ] = 0.0; work[ offsetW + strideW ] = 1.0; - for ( j = 0; j < N; j++ ) { - work = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), work[ offsetW ], work[ offsetW + strideW ], work, strideW, offsetW ); + if ( axis === 1 ) { + for ( j = 0; j < N; j++ ) { + work = dlassq( M, A, strideA1, offsetA + ( j * strideA2 ), work[ offsetW ], work[ offsetW + strideW ], work, strideW, offsetW ); + } + value = work[ offsetW ] * sqrt( work[ offsetW + strideW ] ); + return value; + } + // axis === 0 + for ( j = 0; j < M; j++ ) { + work = dlassq( N, A, strideA2, offsetA + ( j * strideA1 ), work[ offsetW ], work[ offsetW + strideW ], work, strideW, offsetW ); } value = work[ offsetW ] * sqrt( work[ offsetW + strideW ] ); return value; @@ -231,6 +275,7 @@ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, off * * @private * @param {string} norm - specifies the value to be returned +* @param {NonNegativeInteger} axis - axis along which to compute the norm * @param {NonNegativeInteger} M - number of rows of `A` * @param {NonNegativeInteger} N - number of columns of `A` * @param {Float64Array} A - input array @@ -248,10 +293,10 @@ function frobeniusNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, off * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = dlange( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ -function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { +function dlange( norm, axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { var order; norm = lowercase( norm ); @@ -268,13 +313,13 @@ function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offs return maxAbsNorm( order, M, N, A, strideA1, strideA2, offsetA ); } if ( norm === 'o' || norm === '1' ) { - return oneNorm( M, N, A, strideA1, strideA2, offsetA ); + return oneNorm( axis, M, N, A, strideA1, strideA2, offsetA ); } if ( norm === 'i' ) { - return infNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); + return infNorm( axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); } if ( norm === 'f' ) { - return frobeniusNorm( M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); + return frobeniusNorm( axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); } } 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 7269dcae141..7840a3af8de 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -32,6 +32,7 @@ var base = require( './base.js' ); * * @param {string} order - storage layout * @param {string} norm - specifies the value to be returned +* @param {NonNegativeInteger} axis - specifies the axis along which to compute the norm * @param {NonNegativeInteger} M - number of rows of `A` * @param {NonNegativeInteger} N - number of columns of `A` * @param {Float64Array} A - input array @@ -46,10 +47,10 @@ var base = require( './base.js' ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); +* var out = dlange( 'row-major', 'M', 1, 2, 2, A, 2, work ); * // returns 4.0 */ -function dlange( order, norm, M, N, A, LDA, work ) { +function dlange( order, norm, axis, M, N, A, LDA, work ) { var sa1; var sa2; @@ -63,7 +64,7 @@ function dlange( order, norm, M, N, A, LDA, work ) { sa1 = LDA; sa2 = 1; } - return base( norm, M, N, A, sa1, sa2, 0, work, 1, 0 ); + return base( norm, axis, M, N, A, sa1, sa2, 0, work, 1, 0 ); } 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 c35cce798a4..7d401fd7d92 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js @@ -30,7 +30,7 @@ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); +* var out = dlange( 'row-major', 'M', 1, 2, 2, A, 2, work ); * // out => 4.0 * * @example @@ -40,7 +40,7 @@ * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange.ndarray( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = dlange.ndarray( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ 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 138a9385bcc..90cd886b049 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -16,7 +16,7 @@ * limitations under the License. */ -/* eslint-disable max-len */ +/* eslint-disable max-len, max-params */ 'use strict'; @@ -31,6 +31,7 @@ var base = require( './base.js' ); * Returns the value of one norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real matrix `A` using alternative indexing semantics. * * @param {string} norm - specifies the value to be returned +* @param {NonNegativeInteger} axis - specifies the axis along which to compute the norm * @param {NonNegativeInteger} M - number of rows of `A` * @param {NonNegativeInteger} N - number of columns of `A` * @param {Float64Array} A - input array @@ -48,11 +49,11 @@ var base = require( './base.js' ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); * var work = new Float64Array( 2 ); * -* var out = dlange( 'M', 2, 2, A, 2, 1, 0, work, 1, 0 ); +* var out = dlange( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); * // returns 4.0 */ -function dlange( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { - return base( norm, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); +function dlange( norm, axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { + return base( norm, axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); } 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 dc2750f267d..81ba7dc1672 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 @@ -33,8 +33,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 7', function test( t ) { - t.strictEqual( dlange.length, 7, 'returns expected value' ); +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dlange.length, 8, 'returns expected value' ); t.end(); }); @@ -75,9 +75,12 @@ tape( 'the function returns maximum absolute value of elements of a square real A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'row-major', 'M', 2, 2, A, 2, work ); + out = dlange( 'row-major', 'M', 1, 2, 2, A, 2, work ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'M', 0, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -90,9 +93,12 @@ tape( 'the function returns maximum absolute value of elements of a real matrix A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'row-major', 'M', 2, 3, A, 3, work ); + out = dlange( 'row-major', 'M', 1, 2, 3, A, 3, work ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'M', 0, 3, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -105,9 +111,12 @@ tape( 'the function returns maximum absolute value of elements of a square real A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'column-major', 'M', 2, 2, A, 2, work ); + out = dlange( 'column-major', 'M', 1, 2, 2, A, 2, work ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'M', 0, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -120,9 +129,12 @@ tape( 'the function returns maximum absolute value of elements of a real matrix A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'column-major', 'M', 3, 2, A, 2, work ); + out = dlange( 'column-major', 'M', 1, 3, 2, A, 2, work ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'M', 0, 2, 3, A, 3, work ); + t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -135,14 +147,18 @@ tape( 'the function returns the one norm of a square real matrix ( row-major )', A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'row-major', '1', 2, 2, A, 2, work ); + out = dlange( 'row-major', '1', 1, 2, 2, A, 2, work ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'O', 2, 2, A, 2, work ); + out = dlange( 'row-major', 'O', 1, 2, 2, A, 2, work ); t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'o', 2, 2, A, 2, work ); + out = dlange( 'row-major', 'o', 1, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', '1', 0, 2, 2, A, 2, work ); + expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -156,14 +172,18 @@ tape( 'the function returns the one norm of a real matrix ( row-major )', functi A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'row-major', '1', 2, 3, A, 3, work ); + out = dlange( 'row-major', '1', 1, 2, 3, A, 3, work ); expected = 9.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'O', 2, 3, A, 3, work ); + out = dlange( 'row-major', 'O', 1, 2, 3, A, 3, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'o', 1, 2, 3, A, 3, work ); t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'o', 2, 3, A, 3, work ); + out = dlange( 'row-major', '1', 0, 3, 2, A, 2, work ); + expected = 11.0; t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -177,14 +197,18 @@ tape( 'the function returns the one norm of a square real matrix ( column-major A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'column-major', '1', 2, 2, A, 2, work ); + out = dlange( 'column-major', '1', 1, 2, 2, A, 2, work ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'column-major', 'O', 2, 2, A, 2, work ); + out = dlange( 'column-major', 'O', 1, 2, 2, A, 2, work ); t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'column-major', 'o', 2, 2, A, 2, work ); + out = dlange( 'column-major', 'o', 1, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', '1', 0, 2, 2, A, 2, work ); + expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -198,14 +222,18 @@ tape( 'the function returns the one norm of a real matrix ( column-major )', fun A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'column-major', '1', 3, 2, A, 2, work ); + out = dlange( 'column-major', '1', 1, 3, 2, A, 2, work ); expected = 10.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'column-major', 'O', 3, 2, A, 2, work ); + out = dlange( 'column-major', 'O', 1, 3, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'o', 1, 3, 2, A, 2, work ); t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'column-major', 'o', 3, 2, A, 2, work ); + out = dlange( 'column-major', '1', 0, 3, 2, A, 2, work ); + expected = 9.0; t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -219,11 +247,15 @@ tape( 'the function returns the infinity norm of a square real matrix ( row-majo A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'row-major', 'I', 2, 2, A, 2, work ); + out = dlange( 'row-major', 'I', 1, 2, 2, A, 2, work ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'i', 2, 2, A, 2, work ); + out = dlange( 'row-major', 'i', 1, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'I', 0, 2, 2, A, 2, work ); + expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -237,11 +269,15 @@ tape( 'the function returns the infinity norm of a real matrix ( row-major )', f A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); work = new Float64Array( 3 ); - out = dlange( 'row-major', 'I', 2, 3, A, 3, work ); + out = dlange( 'row-major', 'I', 1, 2, 3, A, 3, work ); expected = 15.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'i', 2, 3, A, 3, work ); + out = dlange( 'row-major', 'i', 1, 2, 3, A, 3, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'I', 0, 3, 2, A, 2, work ); + expected = 12.0; t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -255,11 +291,15 @@ tape( 'the function returns the infinity norm of a square real matrix ( column-m A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'column-major', 'I', 2, 2, A, 2, work ); + out = dlange( 'column-major', 'I', 1, 2, 2, A, 2, work ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'column-major', 'i', 2, 2, A, 2, work ); + out = dlange( 'column-major', 'i', 1, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'I', 0, 2, 2, A, 2, work ); + expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -273,11 +313,15 @@ tape( 'the function returns the infinity norm of a real matrix ( column-major )' A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); work = new Float64Array( 3 ); - out = dlange( 'column-major', 'I', 3, 2, A, 2, work ); + out = dlange( 'column-major', 'I', 1, 3, 2, A, 2, work ); expected = 9.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'column-major', 'i', 3, 2, A, 2, work ); + out = dlange( 'column-major', 'i', 1, 3, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'I', 0, 3, 2, A, 2, work ); + expected = 10.0; t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -291,15 +335,18 @@ tape( 'the function returns the Frobenius norm of a square real matrix ( row-maj A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'row-major', 'F', 2, 2, A, 2, work ); + out = dlange( 'row-major', 'F', 1, 2, 2, A, 2, work ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'f', 2, 2, A, 2, work ); + out = dlange( 'row-major', 'f', 1, 2, 2, A, 2, work ); t.strictEqual( out, expected, 'returns expected value' ); work = new Float64Array( 1 ); - out = dlange( 'row-major', 'F', 1, 4, A, 4, work ); + out = dlange( 'row-major', 'F', 1, 1, 4, A, 4, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'f', 0, 1, 4, A, 4, work ); t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -313,11 +360,14 @@ tape( 'the function returns the Frobenius norm of a real matrix ( row-major )', A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); work = new Float64Array( 3 ); - out = dlange( 'row-major', 'F', 2, 3, A, 3, work ); + out = dlange( 'row-major', 'F', 1, 2, 3, A, 3, work ); expected = 9.539392014169456; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'row-major', 'f', 2, 3, A, 3, work ); + out = dlange( 'row-major', 'f', 1, 2, 3, A, 3, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'F', 0, 3, 2, A, 2, work ); t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -331,11 +381,14 @@ tape( 'the function returns the Frobenius norm of a square real matrix ( column- A = new Float64Array( [ 1.0, 3.0, 2.0, 4.0 ] ); work = new Float64Array( 2 ); - out = dlange( 'column-major', 'F', 2, 2, A, 2, work ); + out = dlange( 'column-major', 'F', 1, 2, 2, A, 2, work ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'column-major', 'f', 2, 2, A, 2, work ); + out = dlange( 'column-major', 'f', 1, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'F', 0, 2, 2, A, 2, work ); t.strictEqual( out, expected, 'returns expected value' ); t.end(); }); @@ -349,11 +402,14 @@ tape( 'the function returns the Frobenius norm of a real matrix ( column-major ) A = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); work = new Float64Array( 3 ); - out = dlange( 'column-major', 'F', 3, 2, A, 2, work ); + out = dlange( 'column-major', 'F', 1, 3, 2, A, 2, work ); expected = 7.681145747868608; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'column-major', 'f', 3, 2, A, 2, work ); + out = dlange( 'column-major', 'f', 1, 3, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'F', 0, 3, 2, A, 2, work ); t.strictEqual( out, 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 index 56b6b40d299..f9d9beab3ae 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js @@ -1,3 +1,4 @@ + /** * @license Apache-2.0 * 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 b0bd4343880..6db7b5ed3f2 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 @@ -33,8 +33,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 10', function test( t ) { - t.strictEqual( dlange.length, 10, 'returns expected value' ); +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( dlange.length, 11, 'returns expected value' ); t.end(); }); @@ -47,19 +47,19 @@ tape( 'the function allows specifying offset for computation of norms ( offsetA A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] ); work = new Float64Array( [ 0.0, 0.0, 999.9, 999.9 ] ); - out = dlange( 'M', 2, 2, A, 2, 1, 4, work, 1, 2 ); + out = dlange( 'M', 1, 2, 2, A, 2, 1, 4, work, 1, 2 ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( '1', 2, 2, A, 2, 1, 4, work, 1, 2 ); + out = dlange( '1', 1, 2, 2, A, 2, 1, 4, work, 1, 2 ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'I', 2, 2, A, 2, 1, 4, work, 1, 2 ); + out = dlange( 'I', 1, 2, 2, A, 2, 1, 4, work, 1, 2 ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'F', 2, 2, A, 2, 1, 4, work, 1, 2 ); + out = dlange( 'F', 1, 2, 2, A, 2, 1, 4, work, 1, 2 ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); @@ -75,19 +75,19 @@ tape( 'the function allows accessing elements from an input array which do not h A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 999.9, 2.0, 3.0, 999.9, 4.0 ] ); work = new Float64Array( [ 0.0, 0.0, 999.9, 999.9 ] ); - out = dlange( 'M', 2, 2, A, 3, 2, 4, work, 1, 2 ); + out = dlange( 'M', 1, 2, 2, A, 3, 2, 4, work, 1, 2 ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( '1', 2, 2, A, 3, 2, 4, work, 1, 2 ); + out = dlange( '1', 1, 2, 2, A, 3, 2, 4, work, 1, 2 ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'I', 2, 2, A, 3, 2, 4, work, 1, 2 ); + out = dlange( 'I', 1, 2, 2, A, 3, 2, 4, work, 1, 2 ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'F', 2, 2, A, 3, 2, 4, work, 1, 2 ); + out = dlange( 'F', 1, 2, 2, A, 3, 2, 4, work, 1, 2 ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); t.end(); @@ -102,19 +102,19 @@ tape( 'the function allows accessing elements from an input array which do not h A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 999.9, 2.0, 999.9, 999.9, 999.9, 3.0, 999.9, 4.0 ] ); work = new Float64Array( [ 0.0, 999.9, 0.0, 999.9 ] ); - out = dlange( 'M', 2, 2, A, 6, 2, 4, work, 2, 1 ); + out = dlange( 'M', 1, 2, 2, A, 6, 2, 4, work, 2, 1 ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( '1', 2, 2, A, 6, 2, 4, work, 2, 1 ); + out = dlange( '1', 1, 2, 2, A, 6, 2, 4, work, 2, 1 ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'I', 2, 2, A, 6, 2, 4, work, 2, 1 ); + out = dlange( 'I', 1, 2, 2, A, 6, 2, 4, work, 2, 1 ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'F', 2, 2, A, 6, 2, 4, work, 2, 1 ); + out = dlange( 'F', 1, 2, 2, A, 6, 2, 4, work, 2, 1 ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); t.end(); @@ -129,19 +129,19 @@ tape( 'the function supports accessing elements in reverse order', function test A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 4.0, 999.9, 3.0, 999.9, 999.9, 999.9, 2.0, 999.9, 1.0 ] ); work = new Float64Array( [ 0.0, 999.9, 0.0, 999.9 ] ); - out = dlange( 'M', 2, 2, A, -6, -2, 12, work, -1, 3 ); + out = dlange( 'M', 1, 2, 2, A, -6, -2, 12, work, -1, 3 ); expected = 4.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( '1', 2, 2, A, -6, -2, 12, work, -1, 3 ); + out = dlange( '1', 1, 2, 2, A, -6, -2, 12, work, -1, 3 ); expected = 6.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'I', 2, 2, A, -6, -2, 12, work, -1, 3 ); + out = dlange( 'I', 1, 2, 2, A, -6, -2, 12, work, -1, 3 ); expected = 7.0; t.strictEqual( out, expected, 'returns expected value' ); - out = dlange( 'F', 2, 2, A, -6, -2, 12, work, -1, 3 ); + out = dlange( 'F', 1, 2, 2, A, -6, -2, 12, work, -1, 3 ); expected = 5.477225575051661; t.strictEqual( out, expected, 'returns expected value' ); t.end();