diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/README.md b/lib/node_modules/@stdlib/lapack/base/dlange/README.md new file mode 100644 index 000000000000..55d61f49a1b9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/README.md @@ -0,0 +1,246 @@ + + +# 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`. + +
+ +## Usage + +```javascript +var dlange = require( '@stdlib/lapack/base/dlange' ); +``` + +#### 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`. + +```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', 1, 2, 3, A, 3, work ); +// returns 6.0 +``` + +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]. +- **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', 1, 2, 3, A1, 3, WORK1 ); +// returns 6.0 +``` + +#### 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. + +```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( '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]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **work**: workspace array. +- **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( 'M', 1, 2, 2, A, 2, 1, 2, work, 1, 0 ); +// returns 4.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]. + +
+ + + +
+ +## 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', 1, 2, 3, A, 3, work ); +// returns 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 000000000000..ebd4448d7df3 --- /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 ], 1, 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 000000000000..dbca1ab34b78 --- /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( values[ i%values.length ], 1, 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/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt new file mode 100644 index 000000000000..86f0d056335c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/repl.txt @@ -0,0 +1,107 @@ + +{{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`. + + 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. + + axis: string + Axis along which to compute the norm. + + 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', 1, 2, 2, A, 2, work ) + 4.0 + + +{{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. + + 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. + + axis: string + Axis along which to compute the norm. + + 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', 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 new file mode 100644 index 000000000000..d2e52a6b3872 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/index.d.ts @@ -0,0 +1,117 @@ +/** +* @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 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 + * @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', 1, 2, 2, A, 2, work ); + * // returns 4.0 + */ + ( 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 + * @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( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); + * // returns 4.0 + */ + 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 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 +* @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', 1, 2, 2, A, 2, work ); +* // returns 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( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // returns 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 000000000000..26ec6448e235 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/docs/types/test.ts @@ -0,0 +1,358 @@ +/* +* @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', 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... +{ + 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', 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... +{ + 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, 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... +{ + 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, 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... +{ + 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', 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 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', 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 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', 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 an eighth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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... +{ + 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', 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... +{ + 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, 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, 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... +{ + 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, 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... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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 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, '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 Float64Array... +{ + const work = new Float64Array( [ 0.0, 0.0 ] ); + + 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... +{ + 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, '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... +{ + 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, '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 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, '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 Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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... +{ + 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, '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... +{ + 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( 'M' ); // $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 new file mode 100644 index 000000000000..5b1dd8e47c51 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/examples/index.js @@ -0,0 +1,28 @@ +/** +* @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', 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 new file mode 100644 index 000000000000..3f093e42517a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/base.js @@ -0,0 +1,329 @@ +/** +* @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, max-params */ + +'use strict'; + +// 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 dnrm2 = require( '@stdlib/blas/base/dnrm2' ).ndarray; +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var abs = require( '@stdlib/math/base/special/abs' ); +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} 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 +* @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( 1, 2, 2, A, 2, 1, 0 ); +* // returns 6.0 +*/ +function oneNorm( axis, M, N, A, strideA1, strideA2, offsetA ) { + var value; + var sum; + var sa; + var i; + var j; + + // Find norm1( A ) + value = 0.0; + 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 + ( i * strideA1 ); + for ( j = 0; j < N; j++ ) { + sum += abs( A[ sa + ( j * strideA2 ) ] ); + } + if ( value < sum || isnan( sum ) ) { + value = sum; + } + } + return value; +} + +/** +* 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 +* @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( 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // returns 7.0 +*/ +function infNorm( axis, 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; + 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++ ) { + 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++ ) { + 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; + } + } + return value; +} + +/** +* 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 +* @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( 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // returns 5.477225575051661 +*/ +function frobeniusNorm( axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { + var value; + var j; + + // Find normF( A ) + if ( M === 1 ) { + return dnrm2( N, A, strideA2, offsetA, strideA1 ); + } + work[ offsetW ] = 0.0; + work[ offsetW + strideW ] = 1.0; + 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; +} + + +// 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`. +* +* @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 +* @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( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // returns 4.0 +*/ +function dlange( norm, axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ) { + var order; + + norm = lowercase( norm ); + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + order = 'row-major'; + } else { // order == 'column-major' + order = 'column-major'; + } + + if ( min( M, N ) === 0.0 ) { + return 0.0; + } + if ( norm === 'm' ) { + return maxAbsNorm( order, M, N, A, strideA1, strideA2, offsetA ); + } + if ( norm === 'o' || norm === '1' ) { + return oneNorm( axis, M, N, A, strideA1, strideA2, offsetA ); + } + if ( norm === 'i' ) { + return infNorm( axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); + } + if ( norm === 'f' ) { + return frobeniusNorm( axis, M, N, A, strideA1, strideA2, offsetA, work, strideW, offsetW ); + } +} + + +// 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 000000000000..7840a3af8de1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/dlange.js @@ -0,0 +1,73 @@ +/** +* @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 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 +* @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 +* @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', 1, 2, 2, A, 2, work ); +* // returns 4.0 +*/ +function dlange( order, norm, axis, 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( norm, axis, M, N, A, sa1, sa2, 0, work, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dlange; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/index.js new file mode 100644 index 000000000000..7d401fd7d926 --- /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', 1, 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( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // returns 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/main.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js new file mode 100644 index 000000000000..9b733faf588f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlange = require( './dlange.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlange, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlange; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js new file mode 100644 index 000000000000..90cd886b0494 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/lib/ndarray.js @@ -0,0 +1,62 @@ +/** +* @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, max-params */ + +'use strict'; + +// MODULES // + +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. +* +* @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 +* @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( 'M', 1, 2, 2, A, 2, 1, 0, work, 1, 0 ); +* // returns 4.0 +*/ +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 ); +} + + +// EXPORTS // + +module.exports = dlange; diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/package.json b/lib/node_modules/@stdlib/lapack/base/dlange/package.json new file mode 100644 index 000000000000..7f5948513c55 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/package.json @@ -0,0 +1,69 @@ +{ + "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`.", + "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", + "frobenius", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js new file mode 100644 index 000000000000..81ba7dc1672b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.dlange.js @@ -0,0 +1,415 @@ +/** +* @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 8', function test( t ) { + t.strictEqual( dlange.length, 8, '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', 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(); +}); + +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', 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(); +}); + +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', 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(); +}); + +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', 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(); +}); + +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', 1, 2, 2, A, 2, work ); + expected = 6.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', 'O', 1, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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', 1, 2, 3, A, 3, work ); + expected = 9.0; + 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', 1, 2, 3, A, 3, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'row-major', '1', 0, 3, 2, A, 2, work ); + expected = 11.0; + 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', 1, 2, 2, A, 2, work ); + expected = 6.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', 'O', 1, 2, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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', 1, 3, 2, A, 2, work ); + expected = 10.0; + 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', 1, 3, 2, A, 2, work ); + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'column-major', '1', 0, 3, 2, A, 2, work ); + expected = 9.0; + 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', 1, 2, 2, A, 2, work ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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', 1, 2, 3, A, 3, work ); + expected = 15.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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', 1, 2, 2, A, 2, work ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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', 1, 3, 2, A, 2, work ); + expected = 9.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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', 1, 2, 2, A, 2, work ); + expected = 5.477225575051661; + t.strictEqual( out, expected, 'returns expected value' ); + + 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, 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(); +}); + +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', 1, 2, 3, A, 3, work ); + expected = 9.539392014169456; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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', 1, 2, 2, A, 2, work ); + expected = 5.477225575051661; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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', 1, 3, 2, A, 2, work ); + expected = 7.681145747868608; + t.strictEqual( out, expected, 'returns expected value' ); + + 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 new file mode 100644 index 000000000000..f9d9beab3ae6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.js @@ -0,0 +1,83 @@ + +/** +* @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' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js new file mode 100644 index 000000000000..6db7b5ed3f29 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlange/test/test.ndarray.js @@ -0,0 +1,148 @@ +/** +* @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/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(); +}); + +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( 'M', 1, 2, 2, A, 2, 1, 4, work, 1, 2 ); + expected = 4.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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', 1, 2, 2, A, 2, 1, 4, work, 1, 2 ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + out = dlange( 'F', 1, 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( 'M', 1, 2, 2, A, 3, 2, 4, work, 1, 2 ); + expected = 4.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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', 1, 2, 2, A, 3, 2, 4, work, 1, 2 ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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( 'M', 1, 2, 2, A, 6, 2, 4, work, 2, 1 ); + expected = 4.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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', 1, 2, 2, A, 6, 2, 4, work, 2, 1 ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +}); + +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( 'M', 1, 2, 2, A, -6, -2, 12, work, -1, 3 ); + expected = 4.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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', 1, 2, 2, A, -6, -2, 12, work, -1, 3 ); + expected = 7.0; + t.strictEqual( out, expected, 'returns expected value' ); + + 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(); +});