diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaqsp/README.md new file mode 100644 index 000000000000..df8fca12a790 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/README.md @@ -0,0 +1,245 @@ + + +# dlaqsp + +> Equilibrate a real symmetric matrix stored in packed format. + +
+ +Given a vector of scaling factors `S`, the routine equilibrates a real symmetric matrix `A` stored in packed format such that + + + +```math +A = \text{diag}(S) \times A \times \text{diag}(S) +``` + + + +
+ + + +
+ +## Usage + +```javascript +var dlaqsp = require( '@stdlib/lapack/base/dlaqsp' ); +``` + +#### dlaqsp( order, uplo, N, AP, S, scond, amax ) + +Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + +var out = dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ); +// AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] +// out => 'Y' +``` + +The function has the following parameters: + +- **order**: storage layout (either `'row-major'` or `'column-major'`). +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied (either `'upper'` or `'lower'`). +- **N**: order of matrix `A`. +- **AP**: packed form of symmetric matrix `A` as a [`Float64Array`][mdn-float64array]. +- **S**: scale factors vector for `A` as a [`Float64Array`][mdn-float64array]. +- **scond**: ratio of the smallest `S[i]` to the largest `S[i]`. +- **amax**: absolute value of the largest matrix entry. + +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 AP0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var S0 = new Float64Array( [ 0.0, 0.05, 2.0, 4.0 ] ); + +// Create offset views: +var AP1 = new Float64Array( AP0.buffer, AP0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var S1 = new Float64Array( S0.buffer, S0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out = dlaqsp( 'column-major', 'upper', 3, AP1, S1, 0.0125, 6.0 ); +// AP1 => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] +// out => 'Y' +``` + + + +#### dlaqsp.ndarray( order, uplo, N, AP, strideAP, offsetAP, S, strideS, offsetS, scond, amax ) + + + +Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S` and alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + +var out = dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); +// AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] +// out => 'Y' +``` + +The function has the following additional parameters: + +- **strideAP**: stride length for `AP`. +- **offsetAP**: starting index for `AP`. +- **strideS**: stride length for `S`. +- **offsetS**: starting index for `S`. + +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 AP = new Float64Array( [ 9999.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var S = new Float64Array( [ 9999.0, 0.05, 2.0, 4.0 ] ); + +var out = dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 1, S, 1, 1, 0.0125, 6.0 ); +// AP => [ 9999.0, ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] +// out => 'Y' +``` + +
+ + + +
+ +## Notes + +- `AP` should contain `N*(N+1)/2` elements. +- If `scond` is greater than or equal to `0.1` and `amax` is neither too small nor too large (i.e., the matrix is close to neither underflow nor overflow), the matrix is considered to be sufficiently well-scaled, `AP` is left unchanged, and the function returns `'N'`. Otherwise, the function mutates `AP` in-place, replacing `A` by `diag(S)*A*diag(S)`, and returns `'Y'`. +- `dlaqsp()` corresponds to the [LAPACK][LAPACK] routine [`dlaqsp`][lapack-dlaqsp]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlaqsp = require( '@stdlib/lapack/base/dlaqsp' ); + +// Define a symmetric matrix in packed format and a vector of scale factors: +var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + +// Equilibrate the matrix, whose upper triangle is stored: +var out = dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ); +console.log( out ); +console.log( AP ); + +AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + +// Equilibrate the matrix, whose lower triangle is stored: +out = dlaqsp.ndarray( 'column-major', 'lower', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); +console.log( out ); +console.log( AP ); +``` + +
+ + + +* * * + +
+ +## C APIs + +
+ +
+ + + +
+ +### Usage + +```c +// TODO +``` + +
+ + + +
+ +
+ + + +
+ +### Examples + +```c +// TODO +``` + +
+ + + +
+ + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/benchmark/benchmark.js new file mode 100644 index 000000000000..4ec9dfbbb38a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/benchmark/benchmark.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isString = require( '@stdlib/assert/is-string' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dlaqsp = require( './../lib/dlaqsp.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - matrix order +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var AP; + var S; + + AP = uniform( N * ( N + 1 ) / 2, -10.0, 10.0, options ); + S = uniform( N, 0.5, 2.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var equed; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + equed = dlaqsp( 'column-major', 'upper', N, AP, S, 0.01, 10.0 ); + if ( !isString( equed ) ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( equed ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( format( '%s:size=%d', pkg, len * ( len + 1 ) / 2 ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..3e1464c77088 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/benchmark/benchmark.ndarray.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isString = require( '@stdlib/assert/is-string' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ndarray = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - matrix order +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var AP; + var S; + + AP = uniform( N * ( N + 1 ) / 2, -10.0, 10.0, options ); + S = uniform( N, 0.5, 2.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var equed; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + equed = ndarray( 'column-major', 'upper', N, AP, 1, 0, S, 1, 0, 0.01, 10.0 ); + if ( !isString( equed ) ) { + b.fail( 'should return a string' ); + } + } + b.toc(); + if ( !isString( equed ) ) { + b.fail( 'should return a string' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( format( '%s:ndarray:size=%d', pkg, len * ( len + 1 ) / 2 ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/repl.txt new file mode 100644 index 000000000000..a890a6ad70d3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/repl.txt @@ -0,0 +1,123 @@ + +{{alias}}( order, uplo, N, AP, S, scond, amax ) + Equilibrates a real symmetric matrix `A` stored in packed format using + scaling factors `S`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `scond` is greater than or equal to `0.1` and `amax` is neither too small + nor too large, the matrix is considered to be sufficiently well-scaled, `AP` + is left unchanged, and the function returns 'N'. Otherwise, the function + mutates `AP` in-place, replacing `A` by diag(S)*A*diag(S), and returns 'Y'. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether the upper or lower triangular part of the symmetric + matrix `A` is stored. Must be either 'upper' or 'lower'. + + N: integer + Order of matrix `A`. + + AP: Float64Array + Packed symmetric matrix `A`. + + S: Float64Array + Scale factors vector. + + scond: number + Ratio of smallest `S[i]` to largest `S[i]`. + + amax: number + Absolute value of largest matrix entry. + + Returns + ------- + equed: string + Character flag indicating whether the matrix was equilibrated ('Y') or + not ('N'). + + Examples + -------- + > var AP = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var S = new {{alias:@stdlib/array/float64}}( [ 0.05, 2.0, 4.0 ] ); + > {{alias}}( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ) + 'Y' + > AP + [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] + + +{{alias}}.ndarray( order, uplo, N, AP, sap, oap, S, ss, os, scond, amax ) + Equilibrates a real symmetric matrix `A` stored in packed format using + scaling factors `S` and alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + If `scond` is greater than or equal to `0.1` and `amax` is neither too small + nor too large, the matrix is considered to be sufficiently well-scaled, `AP` + is left unchanged, and the function returns 'N'. Otherwise, the function + mutates `AP` in-place, replacing `A` by diag(S)*A*diag(S), and returns 'Y'. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether the upper or lower triangular part of the symmetric + matrix `A` is stored. Must be either 'upper' or 'lower'. + + N: integer + Order of matrix `A`. + + AP: Float64Array + Packed symmetric matrix `A`. + + sap: integer + Stride of `AP`. + + oap: integer + Index offset for `AP`. + + S: Float64Array + Scale factors vector. + + ss: integer + Stride of `S`. + + os: integer + Index offset for `S`. + + scond: number + Ratio of smallest `S[i]` to largest `S[i]`. + + amax: number + Absolute value of largest matrix entry. + + Returns + ------- + equed: string + Character flag indicating whether the matrix was equilibrated ('Y') or + not ('N'). + + Examples + -------- + > var AP = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var S = new {{alias:@stdlib/array/float64}}( [ 0.05, 2.0, 4.0 ] ); + > var order = 'column-major'; + > var uplo = 'upper'; + > {{alias}}.ndarray( order, uplo, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ) + 'Y' + > AP + [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/types/index.d.ts new file mode 100644 index 000000000000..2b6026591f8b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/types/index.d.ts @@ -0,0 +1,129 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout, MatrixTriangle } from '@stdlib/types/blas'; + +/** +* Interface describing `dlaqsp`. +*/ +interface Routine { + /** + * Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S`. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is stored + * @param N - order of matrix `A` + * @param AP - packed symmetric matrix `A` + * @param S - scale factors vector + * @param scond - ratio of smallest `S[i]` to largest `S[i]` + * @param amax - absolute value of largest matrix entry + * @returns character flag indicating whether the matrix was equilibrated ('Y') or not ('N') + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + * + * var out = dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ); + * // AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] + * // returns 'Y' + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + * + * var out = dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); + * // AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] + * // returns 'Y' + */ + ( order: Layout, uplo: MatrixTriangle, N: number, AP: Float64Array, S: Float64Array, scond: number, amax: number ): string; + + /** + * Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S` and alternative indexing semantics. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is stored + * @param N - order of matrix `A` + * @param AP - packed symmetric matrix `A` + * @param strideAP - `AP` stride length + * @param offsetAP - starting index of `AP` + * @param S - scale factors vector + * @param strideS - `S` stride length + * @param offsetS - starting index of `S` + * @param scond - ratio of smallest `S[i]` to largest `S[i]` + * @param amax - absolute value of largest matrix entry + * @returns character flag indicating whether the matrix was equilibrated ('Y') or not ('N') + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + * + * var out = dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); + * // AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] + * // returns 'Y' + */ + ndarray( order: Layout, uplo: MatrixTriangle, N: number, AP: Float64Array, strideAP: number, offsetAP: number, S: Float64Array, strideS: number, offsetS: number, scond: number, amax: number ): string; +} + +/** +* Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S`. +* +* @param order - storage layout +* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is stored +* @param N - order of matrix `A` +* @param AP - packed symmetric matrix `A` +* @param S - scale factors vector +* @param scond - ratio of smallest `S[i]` to largest `S[i]` +* @param amax - absolute value of largest matrix entry +* @returns character flag indicating whether the matrix was equilibrated ('Y') or not ('N') +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); +* +* var out = dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ); +* // AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] +* // returns 'Y' +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); +* +* var out = dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); +* // AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] +* // returns 'Y' +*/ +declare var dlaqsp: Routine; + + +// EXPORTS // + +export = dlaqsp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/types/test.ts new file mode 100644 index 000000000000..a4448b5cc470 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/docs/types/test.ts @@ -0,0 +1,342 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dlaqsp = require( './index' ); + + +// TESTS // + +// The function returns a string... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectType string +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp( 5, 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( true, 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( false, 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( null, 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( void 0, 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( [], 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( {}, 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( ( x: number ): number => x, 'upper', 3, AP, S, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp( 'column-major', 5, 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', true, 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', false, 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', null, 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', void 0, 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', [], 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', {}, 3, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', ( x: number ): number => x, 3, AP, S, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp( 'column-major', 'upper', '5', AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', true, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', false, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', null, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', void 0, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', [], AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', {}, AP, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', ( x: number ): number => x, AP, S, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp( 'column-major', 'upper', 3, '5', S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, 5, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, true, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, false, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, null, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, void 0, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, [], S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, {}, S, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, ( x: number ): number => x, S, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dlaqsp( 'column-major', 'upper', 3, AP, '5', 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, 5, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, true, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, false, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, null, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, void 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, [], 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, {}, 0.0125, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, ( x: number ): number => x, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp( 'column-major', 'upper', 3, AP, S, '5', 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, true, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, false, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, null, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, void 0, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, [], 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, {}, 6.0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, ( x: number ): number => x, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, '6.0' ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, true ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, false ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, null ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, void 0 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, [] ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, {} ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp(); // $ExpectError + dlaqsp( 'column-major' ); // $ExpectError + dlaqsp( 'column-major', 'upper' ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125 ); // $ExpectError + dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a string... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectType string +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a string... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 5, 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( true, 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( false, 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( null, 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( void 0, 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( [], 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( {}, 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( ( x: number ): number => x, 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a string... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 5, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', true, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', false, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', null, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', void 0, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', [], 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', {}, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', ( x: number ): number => x, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', '5', AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', true, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', false, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', null, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', void 0, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', [], AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', {}, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', ( x: number ): number => x, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a Float64Array... +{ + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, '5', 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, 5, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, true, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, false, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, null, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, void 0, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, [], 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, {}, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, ( x: number ): number => x, 1, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, '5', 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, true, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, false, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, null, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, void 0, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, [], 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, {}, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, ( x: number ): number => x, 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, '5', S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, true, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, false, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, null, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, void 0, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, [], S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, {}, S, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, ( x: number ): number => x, S, 1, 0, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a Float64Array... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, '5', 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, 5, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, true, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, false, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, null, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, void 0, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, [], 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, {}, 1, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, ( x: number ): number => x, 1, 0, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, '5', 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, true, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, false, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, null, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, void 0, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, [], 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, {}, 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, ( x: number ): number => x, 0, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, '5', 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, true, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, false, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, null, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, void 0, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, [], 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, {}, 0.0125, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, ( x: number ): number => x, 0.0125, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, '5', 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, true, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, false, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, null, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, void 0, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, [], 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, {}, 6.0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, ( x: number ): number => x, 6.0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, '6.0' ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, true ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, false ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, null ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, void 0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, [] ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, {} ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + + dlaqsp.ndarray(); // $ExpectError + dlaqsp.ndarray( 'column-major' ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper' ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125 ); // $ExpectError + dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/examples/index.js new file mode 100644 index 000000000000..50f59ae40752 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/examples/index.js @@ -0,0 +1,39 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var dlaqsp = require( './../lib' ); + +// Define a symmetric matrix in packed format and a vector of scale factors: +var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + +// Equilibrate the matrix, whose upper triangle is stored: +var out = dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ); +console.log( out ); +console.log( AP ); + +AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); + +// Equilibrate the matrix, whose lower triangle is stored: +out = dlaqsp.ndarray( 'column-major', 'lower', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); +console.log( out ); +console.log( AP ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/base.js new file mode 100644 index 000000000000..5501143f4678 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/base.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dlamch = require( '@stdlib/lapack/base/dlamch' ); + + +// MAIN // + +/** +* Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S`. +* +* @private +* @param {boolean} isUpper - boolean indicating whether `AP` contains the upper triangular part of `A` stored in column-major order +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} AP - packed symmetric matrix `A` +* @param {integer} strideAP - `AP` stride length +* @param {NonNegativeInteger} offsetAP - starting index of `AP` +* @param {Float64Array} S - scale factors vector +* @param {integer} strideS - `S` stride length +* @param {NonNegativeInteger} offsetS - starting index of `S` +* @param {number} scond - ratio of smallest `S[i]` to largest `S[i]` +* @param {number} amax - absolute value of largest matrix entry +* @returns {string} character flag indicating whether the matrix was equilibrated ('Y') or not ('N') +*/ +function dlaqsp( isUpper, N, AP, strideAP, offsetAP, S, strideS, offsetS, scond, amax ) { // eslint-disable-line max-len + var thresh; + var small; + var large; + var iap; + var cj; + var jc; + var is; + var js; + var i; + var j; + + if ( N <= 0 ) { + return 'N'; + } + + thresh = 0.1; + small = dlamch( 'Safe minimum' ) / dlamch( 'Precision' ); + large = 1.0 / small; + + // If the matrix is already well-conditioned (`scond` above threshold) and its largest entry is within safe bounds, no equilibration is needed... + if ( scond >= thresh && amax >= small && amax <= large ) { + return 'N'; + } + // Replace A by diag(S) * A * diag(S): + if ( isUpper ) { + // Upper triangle of A is stored: + jc = 0; + js = offsetS; + for ( j = 0; j < N; j++ ) { + cj = S[ js ]; + iap = offsetAP + ( jc * strideAP ); + is = offsetS; + for ( i = 0; i <= j; i++ ) { + AP[ iap ] *= cj * S[ is ]; + iap += strideAP; + is += strideS; + } + jc += j + 1; + js += strideS; + } + } else { + // Lower triangle of A is stored: + jc = 0; + js = offsetS; + for ( j = 0; j < N; j++ ) { + cj = S[ js ]; + iap = offsetAP + ( jc * strideAP ); + is = js; + for ( i = j; i < N; i++ ) { + AP[ iap ] *= cj * S[ is ]; + iap += strideAP; + is += strideS; + } + jc += N - j; + js += strideS; + } + } + return 'Y'; +} + + +// EXPORTS // + +module.exports = dlaqsp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/dlaqsp.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/dlaqsp.js new file mode 100644 index 000000000000..1d558d3baf6c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/dlaqsp.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S`. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is stored +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} AP - packed symmetric matrix `A` +* @param {Float64Array} S - scale factors vector +* @param {number} scond - ratio of smallest `S[i]` to largest `S[i]` +* @param {number} amax - absolute value of largest matrix entry +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @throws {RangeError} third argument must be a nonnegative integer +* @returns {string} character flag indicating whether the matrix was equilibrated ('Y') or not ('N') +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaqsp = require( '@stdlib/lapack/base/dlaqsp' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); +* +* var out = dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ); +* // returns 'Y' +*/ +function dlaqsp( order, uplo, N, AP, S, scond, amax ) { + return ndarray( order, uplo, N, AP, 1, 0, S, 1, 0, scond, amax ); +} + + +// EXPORTS // + +module.exports = dlaqsp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/index.js new file mode 100644 index 000000000000..7d0ea0a2a3a1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to equilibrate a real symmetric matrix stored in packed format. +* +* @module @stdlib/lapack/base/dlaqsp +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaqsp = require( '@stdlib/lapack/base/dlaqsp' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); +* +* var out = dlaqsp( 'column-major', 'upper', 3, AP, S, 0.0125, 6.0 ); +* // AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] +* // returns 'Y' +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaqsp = require( '@stdlib/lapack/base/dlaqsp' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); +* +* var out = dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); +* // AP => [ ~0.0025, 0.2, 12.0, 0.8, 40.0, 96.0 ] +* // returns 'Y' +*/ + +// 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 dlaqsp; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlaqsp = main; +} else { + dlaqsp = tmp; +} + + +// EXPORTS // + +module.exports = dlaqsp; + +// exports: { "ndarray": "dlaqsp.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/main.js new file mode 100644 index 000000000000..a6864d940801 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlaqsp = require( './dlaqsp.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlaqsp, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlaqsp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/ndarray.js new file mode 100644 index 000000000000..ef75c8edd77c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/lib/ndarray.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Equilibrates a real symmetric matrix `A` stored in packed format using scaling factors `S` and alternative indexing semantics. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is stored +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} AP - packed symmetric matrix `A` +* @param {integer} strideAP - `AP` stride length +* @param {NonNegativeInteger} offsetAP - starting index of `AP` +* @param {Float64Array} S - scale factors vector +* @param {integer} strideS - `S` stride length +* @param {NonNegativeInteger} offsetS - starting index of `S` +* @param {number} scond - ratio of smallest `S[i]` to largest `S[i]` +* @param {number} amax - absolute value of largest matrix entry +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be non-zero +* @throws {RangeError} eighth argument must be non-zero +* @returns {string} character flag indicating whether the matrix was equilibrated ('Y') or not ('N') +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaqsp = require( '@stdlib/lapack/base/dlaqsp' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var S = new Float64Array( [ 0.05, 2.0, 4.0 ] ); +* +* var out = dlaqsp.ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); +* // returns 'Y' +*/ +function ndarray( order, uplo, N, AP, strideAP, offsetAP, S, strideS, offsetS, scond, amax ) { + var isUpper; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideAP === 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideAP ) ); + } + if ( strideS === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideS ) ); + } + + isUpper = ( ( isColumnMajor( order ) && uplo === 'upper' ) || ( !isColumnMajor( order ) && uplo === 'lower' ) ); + + return base( isUpper, N, AP, strideAP, offsetAP, S, strideS, offsetS, scond, amax ); +} + + +// EXPORTS // + +module.exports = ndarray; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/package.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/package.json new file mode 100644 index 000000000000..bacc5e0ac2dd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/lapack/base/dlaqsp", + "version": "0.0.0", + "description": "Equilibrate a real symmetric matrix stored in packed format.", + "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", + "dlaqsp", + "equilibration", + "matrix", + "symmetric", + "packed", + "scaling", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower.json new file mode 100644 index 000000000000..4028b47be9b9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower.json @@ -0,0 +1,33 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "AP": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "strideAP": 1, + "offsetAP": 0, + "S": [ + 0.05, + 2, + 4 + ], + "strideS": 1, + "offsetS": 0, + "scond": 0.0125, + "amax": 6, + "AP_out": [ + 0.0025000000000000005, + 0.2, + 0.6000000000000001, + 16, + 40, + 96 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_large_strides.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_large_strides.json new file mode 100644 index 000000000000..5a851bc2941c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_large_strides.json @@ -0,0 +1,48 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "AP": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999 + ], + "strideAP": 2, + "offsetAP": 0, + "S": [ + 0.05, + 9999, + 2, + 9999, + 4, + 9999 + ], + "strideS": 2, + "offsetS": 0, + "scond": 0.0125, + "amax": 6, + "AP_out": [ + 0.0025000000000000005, + 9999, + 0.2, + 9999, + 0.6000000000000001, + 9999, + 16, + 9999, + 40, + 9999, + 96, + 9999 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_n1.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_n1.json new file mode 100644 index 000000000000..f8508c5d29c4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_n1.json @@ -0,0 +1,21 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 1, + "AP": [ + 4 + ], + "strideAP": 1, + "offsetAP": 0, + "S": [ + 0.25 + ], + "strideS": 1, + "offsetS": 0, + "scond": 0.05, + "amax": 4, + "AP_out": [ + 0.25 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_n5.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_n5.json new file mode 100644 index 000000000000..7a2c35f120da --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_n5.json @@ -0,0 +1,53 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 5, + "AP": [ + 1.5, + -2.25, + 3.75, + 4, + -5.5, + 6.25, + 7, + -8.5, + 9.75, + 10, + -11.25, + 12.5, + 13.75, + -14, + 15.5 + ], + "strideAP": 1, + "offsetAP": 0, + "S": [ + 0.03125, + 0.5, + 2, + 16, + 0.125 + ], + "strideS": 1, + "offsetS": 0, + "scond": 0.001953125, + "amax": 15.5, + "AP_out": [ + 0.00146484375, + -0.03515625, + 0.234375, + 2, + -0.021484375, + 1.5625, + 7, + -68, + 0.609375, + 40, + -360, + 3.125, + 3520, + -28, + 0.2421875 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_negative_strides.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_negative_strides.json new file mode 100644 index 000000000000..fc3f7cf068ab --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_negative_strides.json @@ -0,0 +1,33 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "AP": [ + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideAP": -1, + "offsetAP": 5, + "S": [ + 4, + 2, + 0.05 + ], + "strideS": -1, + "offsetS": 2, + "scond": 0.0125, + "amax": 6, + "AP_out": [ + 96, + 40, + 16, + 0.6000000000000001, + 0.2, + 0.0025000000000000005 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_offsets.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_offsets.json new file mode 100644 index 000000000000..a5901fc3d06d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_offsets.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "AP": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "strideAP": 1, + "offsetAP": 1, + "S": [ + 9999, + 0.05, + 2, + 4 + ], + "strideS": 1, + "offsetS": 1, + "scond": 0.0125, + "amax": 6, + "AP_out": [ + 9999, + 0.0025000000000000005, + 0.2, + 0.6000000000000001, + 16, + 40, + 96 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_rounding.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_rounding.json new file mode 100644 index 000000000000..68750ef6ff70 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_lower_rounding.json @@ -0,0 +1,33 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "AP": [ + -9.732141494626244, + -5.954675151014084, + 9.754648217817138, + 7.822198876096959, + 0.03678322305752957, + 2.2467899379538316 + ], + "strideAP": 1, + "offsetAP": 0, + "S": [ + 0.022770366669991226, + 1.8288016916852452, + 2.68750989492401 + ], + "strideS": 1, + "offsetS": 0, + "scond": 0.00847266337995569, + "amax": 9.754648217817138, + "AP_out": [ + -0.005046014134009787, + -0.24796747117030152, + 0.596941411344282, + 26.16146638260381, + 0.18078669586067367, + 16.227910884028738 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper.json new file mode 100644 index 000000000000..1833db596fd2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper.json @@ -0,0 +1,33 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "AP": [ + 1, + 2, + 3, + 4, + 5, + 6 + ], + "strideAP": 1, + "offsetAP": 0, + "S": [ + 0.05, + 2, + 4 + ], + "strideS": 1, + "offsetS": 0, + "scond": 0.0125, + "amax": 6, + "AP_out": [ + 0.0025000000000000005, + 0.2, + 12, + 0.8, + 40, + 96 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_large_strides.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_large_strides.json new file mode 100644 index 000000000000..e4deda25ceb3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_large_strides.json @@ -0,0 +1,48 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "AP": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999 + ], + "strideAP": 2, + "offsetAP": 0, + "S": [ + 0.05, + 9999, + 2, + 9999, + 4, + 9999 + ], + "strideS": 2, + "offsetS": 0, + "scond": 0.0125, + "amax": 6, + "AP_out": [ + 0.0025000000000000005, + 9999, + 0.2, + 9999, + 12, + 9999, + 0.8, + 9999, + 40, + 9999, + 96, + 9999 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_n1.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_n1.json new file mode 100644 index 000000000000..759f6a80e7b8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_n1.json @@ -0,0 +1,21 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 1, + "AP": [ + 4 + ], + "strideAP": 1, + "offsetAP": 0, + "S": [ + 0.25 + ], + "strideS": 1, + "offsetS": 0, + "scond": 0.05, + "amax": 4, + "AP_out": [ + 0.25 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_n5.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_n5.json new file mode 100644 index 000000000000..789a71832e76 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_n5.json @@ -0,0 +1,53 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 5, + "AP": [ + 1.5, + -2.25, + 3.75, + 4, + -5.5, + 6.25, + 7, + -8.5, + 9.75, + 10, + -11.25, + 12.5, + 13.75, + -14, + 15.5 + ], + "strideAP": 1, + "offsetAP": 0, + "S": [ + 0.03125, + 0.5, + 2, + 16, + 0.125 + ], + "strideS": 1, + "offsetS": 0, + "scond": 0.001953125, + "amax": 15.5, + "AP_out": [ + 0.00146484375, + -0.03515625, + 0.9375, + 0.25, + -5.5, + 25, + 3.5, + -68, + 312, + 2560, + -0.0439453125, + 0.78125, + 3.4375, + -28, + 0.2421875 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_negative_strides.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_negative_strides.json new file mode 100644 index 000000000000..4b227da20b53 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_negative_strides.json @@ -0,0 +1,33 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "AP": [ + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideAP": -1, + "offsetAP": 5, + "S": [ + 4, + 2, + 0.05 + ], + "strideS": -1, + "offsetS": 2, + "scond": 0.0125, + "amax": 6, + "AP_out": [ + 96, + 40, + 0.8, + 12, + 0.2, + 0.0025000000000000005 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_offsets.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_offsets.json new file mode 100644 index 000000000000..fe858a491c32 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_offsets.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "AP": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "strideAP": 1, + "offsetAP": 1, + "S": [ + 9999, + 0.05, + 2, + 4 + ], + "strideS": 1, + "offsetS": 1, + "scond": 0.0125, + "amax": 6, + "AP_out": [ + 9999, + 0.0025000000000000005, + 0.2, + 12, + 0.8, + 40, + 96 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_rounding.json b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_rounding.json new file mode 100644 index 000000000000..4554de3ee200 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/fixtures/column_major_upper_rounding.json @@ -0,0 +1,33 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "AP": [ + -9.732141494626244, + -5.954675151014084, + 9.754648217817138, + 7.822198876096959, + 0.03678322305752957, + 2.2467899379538316 + ], + "strideAP": 1, + "offsetAP": 0, + "S": [ + 0.022770366669991226, + 1.8288016916852452, + 2.68750989492401 + ], + "strideS": 1, + "offsetS": 0, + "scond": 0.00847266337995569, + "amax": 9.754648217817138, + "AP_out": [ + -0.005046014134009787, + -0.24796747117030152, + 32.62457340535994, + 0.47868404197131326, + 0.18078669586067367, + 16.227910884028738 + ], + "equed_out": "Y" +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.dlaqsp.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.dlaqsp.js new file mode 100644 index 000000000000..74a7f168ffa9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.dlaqsp.js @@ -0,0 +1,472 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlamch = require( '@stdlib/lapack/base/dlamch' ); +var dlaqsp = require( './../lib/dlaqsp.js' ); + + +// FIXTURES // + +var fixtureU = require( './fixtures/column_major_upper.json' ); +var fixtureL = require( './fixtures/column_major_lower.json' ); +var fixtureU1 = require( './fixtures/column_major_upper_n1.json' ); +var fixtureL1 = require( './fixtures/column_major_lower_n1.json' ); +var fixtureU5 = require( './fixtures/column_major_upper_n5.json' ); +var fixtureL5 = require( './fixtures/column_major_lower_n5.json' ); +var roundingU = require( './fixtures/column_major_upper_rounding.json' ); +var roundingL = require( './fixtures/column_major_lower_rounding.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlaqsp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dlaqsp.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 AP; + var S; + var i; + + values = [ + 'foo', + 'bar', + 'row-major-invalid', + 123, + true, + null, + void 0, + {} + ]; + + AP = new Float64Array( 6 ); + S = new Float64Array( 3 ); + + 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() { + dlaqsp( value, 'upper', 3, AP, S, 0.0125, 6.0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var AP; + var S; + var i; + + values = [ + 'foo', + 'bar', + 'upper-invalid', + 123, + true, + null, + void 0, + {} + ]; + + AP = new Float64Array( 6 ); + S = new Float64Array( 3 ); + + 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() { + dlaqsp( 'column-major', value, 3, AP, S, 0.0125, 6.0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var AP; + var S; + var i; + + values = [ + -1, + -2, + -3, + -100 + ]; + + AP = new Float64Array( 6 ); + S = new Float64Array( 3 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlaqsp( 'column-major', 'upper', value, AP, S, 0.0125, 6.0 ); + }; + } +}); + +tape( 'the function equilibrates a real symmetric matrix stored in packed format (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = fixtureU.N; + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + equed = dlaqsp( 'column-major', 'upper', N, AP, S, fixtureU.scond, fixtureU.amax ); + t.strictEqual( equed, fixtureU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a real symmetric matrix stored in packed format (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = fixtureL.N; + AP = new Float64Array( fixtureL.AP ); + S = new Float64Array( fixtureL.S ); + + expectedAP = new Float64Array( fixtureL.AP_out ); + + equed = dlaqsp( 'column-major', 'lower', N, AP, S, fixtureL.scond, fixtureL.amax ); + t.strictEqual( equed, fixtureL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a matrix of order one (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU1.AP ); + S = new Float64Array( fixtureU1.S ); + + expectedAP = new Float64Array( fixtureU1.AP_out ); + + equed = dlaqsp( 'column-major', 'upper', fixtureU1.N, AP, S, fixtureU1.scond, fixtureU1.amax ); + t.strictEqual( equed, fixtureU1.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a matrix of order one (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureL1.AP ); + S = new Float64Array( fixtureL1.S ); + + expectedAP = new Float64Array( fixtureL1.AP_out ); + + equed = dlaqsp( 'column-major', 'lower', fixtureL1.N, AP, S, fixtureL1.scond, fixtureL1.amax ); + t.strictEqual( equed, fixtureL1.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a higher-order matrix (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU5.AP ); + S = new Float64Array( fixtureU5.S ); + + expectedAP = new Float64Array( fixtureU5.AP_out ); + + equed = dlaqsp( 'column-major', 'upper', fixtureU5.N, AP, S, fixtureU5.scond, fixtureU5.amax ); + t.strictEqual( equed, fixtureU5.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a higher-order matrix (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureL5.AP ); + S = new Float64Array( fixtureL5.S ); + + expectedAP = new Float64Array( fixtureL5.AP_out ); + + equed = dlaqsp( 'column-major', 'lower', fixtureL5.N, AP, S, fixtureL5.scond, fixtureL5.amax ); + t.strictEqual( equed, fixtureL5.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function preserves the reference evaluation order when scaling (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( roundingU.AP ); + S = new Float64Array( roundingU.S ); + + expectedAP = new Float64Array( roundingU.AP_out ); + + // Note: every entry of this fixture distinguishes the LAPACK evaluation order `AP*(CJ*S(I))` from `(CJ*AP)*S(I)`, which differ by one ULP... + equed = dlaqsp( 'column-major', 'upper', roundingU.N, AP, S, roundingU.scond, roundingU.amax ); + t.strictEqual( equed, roundingU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function preserves the reference evaluation order when scaling (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( roundingL.AP ); + S = new Float64Array( roundingL.S ); + + expectedAP = new Float64Array( roundingL.AP_out ); + + equed = dlaqsp( 'column-major', 'lower', roundingL.N, AP, S, roundingL.scond, roundingL.amax ); + t.strictEqual( equed, roundingL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function does not modify the vector of scale factors', function test( t ) { + var expectedS; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedS = new Float64Array( fixtureU.S ); + + dlaqsp( 'column-major', 'upper', fixtureU.N, AP, S, fixtureU.scond, fixtureU.amax ); + t.strictEqual( isSameFloat64Array( S, expectedS ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports row-major layout (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = fixtureL.N; + AP = new Float64Array( fixtureL.AP ); + S = new Float64Array( fixtureL.S ); + + expectedAP = new Float64Array( fixtureL.AP_out ); + + // Note: row-major upper uses lower triangle column-major values/logic: + equed = dlaqsp( 'row-major', 'upper', N, AP, S, fixtureL.scond, fixtureL.amax ); + t.strictEqual( equed, fixtureL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports row-major layout (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = fixtureU.N; + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + // Note: row-major lower uses upper triangle column-major values/logic: + equed = dlaqsp( 'row-major', 'lower', N, AP, S, fixtureU.scond, fixtureU.amax ); + t.strictEqual( equed, fixtureU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns \'N\' when N is 0', function test( t ) { + var equed; + var AP; + var S; + + AP = new Float64Array( 0 ); + S = new Float64Array( 0 ); + + equed = dlaqsp( 'column-major', 'upper', 0, AP, S, 0.0125, 6.0 ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns \'N\' and does not modify the matrix when equilibration is not needed', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + S = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + expectedAP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + equed = dlaqsp( 'column-major', 'upper', 3, AP, S, 0.5, 6.0 ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns \'N\' and does not modify the matrix when `scond` equals the scaling threshold', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP ); + + // Note: the LAPACK reference implementation only scales when `scond` is strictly less than `0.1`... + equed = dlaqsp( 'column-major', 'upper', fixtureU.N, AP, S, 0.1, fixtureU.amax ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates the matrix when `scond` is less than the scaling threshold', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + equed = dlaqsp( 'column-major', 'upper', fixtureU.N, AP, S, 0.09999999999999999, fixtureU.amax ); + t.strictEqual( equed, 'Y', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates the matrix when `amax` is too small, even if `scond` is greater than or equal to the scaling threshold', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + // Note: `1.0e-300` is less than `dlamch( 'Safe minimum' ) / dlamch( 'Precision' )`, meaning that the matrix is close to underflow... + equed = dlaqsp( 'column-major', 'upper', fixtureU.N, AP, S, 0.5, 1.0e-300 ); + t.strictEqual( equed, 'Y', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates the matrix when `amax` is too large, even if `scond` is greater than or equal to the scaling threshold', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + // Note: `1.0e300` is greater than `dlamch( 'Precision' ) / dlamch( 'Safe minimum' )`, meaning that the matrix is close to overflow... + equed = dlaqsp( 'column-major', 'upper', fixtureU.N, AP, S, 0.5, 1.0e300 ); + t.strictEqual( equed, 'Y', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns \'N\' when `amax` equals the underflow and overflow thresholds', function test( t ) { + var expectedAP; + var large; + var small; + var equed; + var AP; + var S; + + small = dlamch( 'Safe minimum' ) / dlamch( 'Precision' ); + large = 1.0 / small; + + expectedAP = new Float64Array( fixtureU.AP ); + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + equed = dlaqsp( 'column-major', 'upper', fixtureU.N, AP, S, 0.5, small ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + equed = dlaqsp( 'column-major', 'upper', fixtureU.N, AP, S, 0.5, large ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.js new file mode 100644 index 000000000000..772997c8c7f0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.js @@ -0,0 +1,84 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dlaqsp = 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 dlaqsp, '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 dlaqsp.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 dlaqsp; + + dlaqsp = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaqsp, 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 dlaqsp; + var main; + + main = require( './../lib/dlaqsp.js' ); + + dlaqsp = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaqsp, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.ndarray.js new file mode 100644 index 000000000000..3c50e05b341f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaqsp/test/test.ndarray.js @@ -0,0 +1,652 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameFloat64Array = require( '@stdlib/assert/is-same-float64array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlamch = require( '@stdlib/lapack/base/dlamch' ); +var ndarray = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var fixtureU = require( './fixtures/column_major_upper.json' ); +var fixtureL = require( './fixtures/column_major_lower.json' ); +var offsetsU = require( './fixtures/column_major_upper_offsets.json' ); +var offsetsL = require( './fixtures/column_major_lower_offsets.json' ); +var negativeStridesU = require( './fixtures/column_major_upper_negative_strides.json' ); +var negativeStridesL = require( './fixtures/column_major_lower_negative_strides.json' ); +var largeStridesU = require( './fixtures/column_major_upper_large_strides.json' ); +var largeStridesL = require( './fixtures/column_major_lower_large_strides.json' ); +var fixtureU1 = require( './fixtures/column_major_upper_n1.json' ); +var fixtureL1 = require( './fixtures/column_major_lower_n1.json' ); +var fixtureU5 = require( './fixtures/column_major_upper_n5.json' ); +var fixtureL5 = require( './fixtures/column_major_lower_n5.json' ); +var roundingU = require( './fixtures/column_major_upper_rounding.json' ); +var roundingL = require( './fixtures/column_major_lower_rounding.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ndarray, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( ndarray.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 AP; + var S; + var i; + + values = [ + 'foo', + 'bar', + 'row-major-invalid', + 123, + true, + null, + void 0, + {} + ]; + + AP = new Float64Array( 6 ); + S = new Float64Array( 3 ); + + 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() { + ndarray( value, 'upper', 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var AP; + var S; + var i; + + values = [ + 'foo', + 'bar', + 'upper-invalid', + 123, + true, + null, + void 0, + {} + ]; + + AP = new Float64Array( 6 ); + S = new Float64Array( 3 ); + + 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() { + ndarray( 'column-major', value, 3, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var AP; + var S; + var i; + + values = [ + -1, + -2, + -3, + -100 + ]; + + AP = new Float64Array( 6 ); + S = new Float64Array( 3 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ndarray( 'column-major', 'upper', value, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument (strideAP === 0)', function test( t ) { + var AP; + var S; + + AP = new Float64Array( 6 ); + S = new Float64Array( 3 ); + + t.throws( function badValue() { + ndarray( 'column-major', 'upper', 3, AP, 0, 0, S, 1, 0, 0.0125, 6.0 ); + }, RangeError ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid eighth argument (strideS === 0)', function test( t ) { + var AP; + var S; + + AP = new Float64Array( 6 ); + S = new Float64Array( 3 ); + + t.throws( function badValue() { + ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 0, 0, 0.0125, 6.0 ); + }, RangeError ); + t.end(); +}); + +tape( 'the function equilibrates a real symmetric matrix stored in packed format (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = fixtureU.N; + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + equed = ndarray( 'column-major', 'upper', N, AP, fixtureU.strideAP, fixtureU.offsetAP, S, fixtureU.strideS, fixtureU.offsetS, fixtureU.scond, fixtureU.amax ); + t.strictEqual( equed, fixtureU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a real symmetric matrix stored in packed format (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = fixtureL.N; + AP = new Float64Array( fixtureL.AP ); + S = new Float64Array( fixtureL.S ); + + expectedAP = new Float64Array( fixtureL.AP_out ); + + equed = ndarray( 'column-major', 'lower', N, AP, fixtureL.strideAP, fixtureL.offsetAP, S, fixtureL.strideS, fixtureL.offsetS, fixtureL.scond, fixtureL.amax ); + t.strictEqual( equed, fixtureL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a matrix of order one (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU1.AP ); + S = new Float64Array( fixtureU1.S ); + + expectedAP = new Float64Array( fixtureU1.AP_out ); + + equed = ndarray( 'column-major', 'upper', fixtureU1.N, AP, fixtureU1.strideAP, fixtureU1.offsetAP, S, fixtureU1.strideS, fixtureU1.offsetS, fixtureU1.scond, fixtureU1.amax ); + t.strictEqual( equed, fixtureU1.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a matrix of order one (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureL1.AP ); + S = new Float64Array( fixtureL1.S ); + + expectedAP = new Float64Array( fixtureL1.AP_out ); + + equed = ndarray( 'column-major', 'lower', fixtureL1.N, AP, fixtureL1.strideAP, fixtureL1.offsetAP, S, fixtureL1.strideS, fixtureL1.offsetS, fixtureL1.scond, fixtureL1.amax ); + t.strictEqual( equed, fixtureL1.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a higher-order matrix (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU5.AP ); + S = new Float64Array( fixtureU5.S ); + + expectedAP = new Float64Array( fixtureU5.AP_out ); + + equed = ndarray( 'column-major', 'upper', fixtureU5.N, AP, fixtureU5.strideAP, fixtureU5.offsetAP, S, fixtureU5.strideS, fixtureU5.offsetS, fixtureU5.scond, fixtureU5.amax ); + t.strictEqual( equed, fixtureU5.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates a higher-order matrix (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureL5.AP ); + S = new Float64Array( fixtureL5.S ); + + expectedAP = new Float64Array( fixtureL5.AP_out ); + + equed = ndarray( 'column-major', 'lower', fixtureL5.N, AP, fixtureL5.strideAP, fixtureL5.offsetAP, S, fixtureL5.strideS, fixtureL5.offsetS, fixtureL5.scond, fixtureL5.amax ); + t.strictEqual( equed, fixtureL5.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function preserves the reference evaluation order when scaling (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( roundingU.AP ); + S = new Float64Array( roundingU.S ); + + expectedAP = new Float64Array( roundingU.AP_out ); + + // Note: every entry of this fixture distinguishes the LAPACK evaluation order `AP*(CJ*S(I))` from `(CJ*AP)*S(I)`, which differ by one ULP... + equed = ndarray( 'column-major', 'upper', roundingU.N, AP, roundingU.strideAP, roundingU.offsetAP, S, roundingU.strideS, roundingU.offsetS, roundingU.scond, roundingU.amax ); + t.strictEqual( equed, roundingU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function preserves the reference evaluation order when scaling (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( roundingL.AP ); + S = new Float64Array( roundingL.S ); + + expectedAP = new Float64Array( roundingL.AP_out ); + + equed = ndarray( 'column-major', 'lower', roundingL.N, AP, roundingL.strideAP, roundingL.offsetAP, S, roundingL.strideS, roundingL.offsetS, roundingL.scond, roundingL.amax ); + t.strictEqual( equed, roundingL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function does not modify the vector of scale factors', function test( t ) { + var expectedS; + var AP; + var S; + + AP = new Float64Array( largeStridesU.AP ); + S = new Float64Array( largeStridesU.S ); + + expectedS = new Float64Array( largeStridesU.S ); + + ndarray( 'column-major', 'upper', largeStridesU.N, AP, largeStridesU.strideAP, largeStridesU.offsetAP, S, largeStridesU.strideS, largeStridesU.offsetS, largeStridesU.scond, largeStridesU.amax ); + t.strictEqual( isSameFloat64Array( S, expectedS ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing offsets (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = offsetsU.N; + AP = new Float64Array( offsetsU.AP ); + S = new Float64Array( offsetsU.S ); + + expectedAP = new Float64Array( offsetsU.AP_out ); + + equed = ndarray( 'column-major', 'upper', N, AP, offsetsU.strideAP, offsetsU.offsetAP, S, offsetsU.strideS, offsetsU.offsetS, offsetsU.scond, offsetsU.amax ); + t.strictEqual( equed, offsetsU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports providing offsets (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = offsetsL.N; + AP = new Float64Array( offsetsL.AP ); + S = new Float64Array( offsetsL.S ); + + expectedAP = new Float64Array( offsetsL.AP_out ); + + equed = ndarray( 'column-major', 'lower', N, AP, offsetsL.strideAP, offsetsL.offsetAP, S, offsetsL.strideS, offsetsL.offsetS, offsetsL.scond, offsetsL.amax ); + t.strictEqual( equed, offsetsL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports positive strides (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = largeStridesU.N; + AP = new Float64Array( largeStridesU.AP ); + S = new Float64Array( largeStridesU.S ); + + expectedAP = new Float64Array( largeStridesU.AP_out ); + + equed = ndarray( 'column-major', 'upper', N, AP, largeStridesU.strideAP, largeStridesU.offsetAP, S, largeStridesU.strideS, largeStridesU.offsetS, largeStridesU.scond, largeStridesU.amax ); + t.strictEqual( equed, largeStridesU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports positive strides (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = largeStridesL.N; + AP = new Float64Array( largeStridesL.AP ); + S = new Float64Array( largeStridesL.S ); + + expectedAP = new Float64Array( largeStridesL.AP_out ); + + equed = ndarray( 'column-major', 'lower', N, AP, largeStridesL.strideAP, largeStridesL.offsetAP, S, largeStridesL.strideS, largeStridesL.offsetS, largeStridesL.scond, largeStridesL.amax ); + t.strictEqual( equed, largeStridesL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = negativeStridesU.N; + AP = new Float64Array( negativeStridesU.AP ); + S = new Float64Array( negativeStridesU.S ); + + expectedAP = new Float64Array( negativeStridesU.AP_out ); + + equed = ndarray( 'column-major', 'upper', N, AP, negativeStridesU.strideAP, negativeStridesU.offsetAP, S, negativeStridesU.strideS, negativeStridesU.offsetS, negativeStridesU.scond, negativeStridesU.amax ); + t.strictEqual( equed, negativeStridesU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = negativeStridesL.N; + AP = new Float64Array( negativeStridesL.AP ); + S = new Float64Array( negativeStridesL.S ); + + expectedAP = new Float64Array( negativeStridesL.AP_out ); + + equed = ndarray( 'column-major', 'lower', N, AP, negativeStridesL.strideAP, negativeStridesL.offsetAP, S, negativeStridesL.strideS, negativeStridesL.offsetS, negativeStridesL.scond, negativeStridesL.amax ); + t.strictEqual( equed, negativeStridesL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports row-major layout (upper triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = fixtureL.N; + AP = new Float64Array( fixtureL.AP ); + S = new Float64Array( fixtureL.S ); + + expectedAP = new Float64Array( fixtureL.AP_out ); + + equed = ndarray( 'row-major', 'upper', N, AP, 1, 0, S, 1, 0, fixtureL.scond, fixtureL.amax ); + t.strictEqual( equed, fixtureL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports row-major layout (lower triangle)', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + var N; + + N = fixtureU.N; + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + equed = ndarray( 'row-major', 'lower', N, AP, 1, 0, S, 1, 0, fixtureU.scond, fixtureU.amax ); + t.strictEqual( equed, fixtureU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports row-major layout when provided offsets', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( offsetsL.AP ); + S = new Float64Array( offsetsL.S ); + + expectedAP = new Float64Array( offsetsL.AP_out ); + + // Note: row-major upper uses lower triangle column-major values/logic: + equed = ndarray( 'row-major', 'upper', offsetsL.N, AP, offsetsL.strideAP, offsetsL.offsetAP, S, offsetsL.strideS, offsetsL.offsetS, offsetsL.scond, offsetsL.amax ); + t.strictEqual( equed, offsetsL.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports row-major layout when provided negative strides', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( negativeStridesU.AP ); + S = new Float64Array( negativeStridesU.S ); + + expectedAP = new Float64Array( negativeStridesU.AP_out ); + + // Note: row-major lower uses upper triangle column-major values/logic: + equed = ndarray( 'row-major', 'lower', negativeStridesU.N, AP, negativeStridesU.strideAP, negativeStridesU.offsetAP, S, negativeStridesU.strideS, negativeStridesU.offsetS, negativeStridesU.scond, negativeStridesU.amax ); + t.strictEqual( equed, negativeStridesU.equed_out, 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns \'N\' when N is 0', function test( t ) { + var equed; + var AP; + var S; + + AP = new Float64Array( 0 ); + S = new Float64Array( 0 ); + + equed = ndarray( 'column-major', 'upper', 0, AP, 1, 0, S, 1, 0, 0.0125, 6.0 ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns \'N\' and does not modify the matrix when equilibration is not needed', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + S = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + expectedAP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + equed = ndarray( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, 0.5, 6.0 ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns \'N\' and does not modify the matrix when `scond` equals the scaling threshold', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP ); + + // Note: the LAPACK reference implementation only scales when `scond` is strictly less than `0.1`... + equed = ndarray( 'column-major', 'upper', fixtureU.N, AP, 1, 0, S, 1, 0, 0.1, fixtureU.amax ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates the matrix when `scond` is less than the scaling threshold', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + equed = ndarray( 'column-major', 'upper', fixtureU.N, AP, 1, 0, S, 1, 0, 0.09999999999999999, fixtureU.amax ); + t.strictEqual( equed, 'Y', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates the matrix when `amax` is too small, even if `scond` is greater than or equal to the scaling threshold', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + // Note: `1.0e-300` is less than `dlamch( 'Safe minimum' ) / dlamch( 'Precision' )`, meaning that the matrix is close to underflow... + equed = ndarray( 'column-major', 'upper', fixtureU.N, AP, 1, 0, S, 1, 0, 0.5, 1.0e-300 ); + t.strictEqual( equed, 'Y', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function equilibrates the matrix when `amax` is too large, even if `scond` is greater than or equal to the scaling threshold', function test( t ) { + var expectedAP; + var equed; + var AP; + var S; + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + expectedAP = new Float64Array( fixtureU.AP_out ); + + // Note: `1.0e300` is greater than `dlamch( 'Precision' ) / dlamch( 'Safe minimum' )`, meaning that the matrix is close to overflow... + equed = ndarray( 'column-major', 'upper', fixtureU.N, AP, 1, 0, S, 1, 0, 0.5, 1.0e300 ); + t.strictEqual( equed, 'Y', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns \'N\' when `amax` equals the underflow and overflow thresholds', function test( t ) { + var expectedAP; + var large; + var small; + var equed; + var AP; + var S; + + small = dlamch( 'Safe minimum' ) / dlamch( 'Precision' ); + large = 1.0 / small; + + expectedAP = new Float64Array( fixtureU.AP ); + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + equed = ndarray( 'column-major', 'upper', fixtureU.N, AP, 1, 0, S, 1, 0, 0.5, small ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + + AP = new Float64Array( fixtureU.AP ); + S = new Float64Array( fixtureU.S ); + + equed = ndarray( 'column-major', 'upper', fixtureU.N, AP, 1, 0, S, 1, 0, 0.5, large ); + t.strictEqual( equed, 'N', 'returns expected value' ); + t.strictEqual( isSameFloat64Array( AP, expectedAP ), true, 'returns expected value' ); + + t.end(); +});