diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/README.md b/lib/node_modules/@stdlib/lapack/base/dppequ/README.md new file mode 100644 index 000000000000..cfb7e5e8d06e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/README.md @@ -0,0 +1,280 @@ + + +# dppequ + +> LAPACK routine to compute the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm). + +
+ +## Usage + +```javascript +var dppequ = require( '@stdlib/lapack/base/dppequ' ); +``` + +#### dppequ( order, uplo, N, AP, S, out ) + +Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm). + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +var S = new Float64Array( 3 ); +var out = new Float64Array( 2 ); + +dppequ( 'row-major', 'lower', 3, AP, S, out ); +// S => [ 1.0, ~0.58, ~0.33 ] +// out => [ ~0.33, 9.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ). +- **AP**: array containing the upper or lower triangle of `A` in packed form stored in linear memory as a [`Float64Array`][mdn-float64array], expects `N * ( N + 1 ) / 2` indexed elements +- **S**: array to store the scale factors of `A` in linear memory as a [`Float64Array`][mdn-float64array], expects `N` indexed elements. +- **out**: the first element of `out` represents `scond`, the second element of out represents `amax`. if `scond` >= 0.1 and `amax` is not close to overflow/underflow it isn't worth scaling the matrix by `S`, if `amax` is close to underflow/overflow the matrix shoud be scaled. expects a [`Float64Array`][mdn-float64array] with 2 indexed elements. + +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, 5.0, 6.0, 9.0 ] ); +var S0 = new Float64Array( 4 ); +var out0 = new Float64Array( 3 ); + +// 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 out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dppequ( 'row-major', 'lower', 3, AP1, S1, out1 ); +// S0 => [ 0.0, 1.0, ~0.58, ~0.33 ] +// out => [ ~0.33, 9.0 ] +``` + +#### dppequ.ndarray( order, uplo, N, AP, sap, oap, S, ss, os, out, so, oo ) + +Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm) using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +var S = new Float64Array( 3 ); +var out = new Float64Array( 2 ); + +dppequ.ndarray( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); +// S => [ 1.0, ~0.58, ~0.33 ] +// out => [ ~0.33, 9.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ). +- **AP**: array containing the upper or lower triangle of `A` in packed form stored in linear memory as a [`Float64Array`][mdn-float64array], expects `N * ( N + 1 ) / 2` indexed elements. +- **sap**: index increment for `AP`. +- **oap**: starting index of `AP`. +- **S**: array to store the scale factors of `A` in linear memory as a [`Float64Array`][mdn-float64array], expects `N` indexed elements. +- **ss**: index increment for `S`. +- **os**: starting index of `S`. +- **out**: the first element of `out` represents `scond`, the second element of out represents `amax`. if `scond` >= 0.1 and `amax` is not close to overflow/underflow it isn't worth scaling the matrix by `S`, if `amax` is close to underflow/overflow the matrix shoud be scaled. expects a [`Float64Array`][mdn-float64array] with 2 indexed elements. +- **so**: index increment for `out`. +- **oo**: starting index of `out`. + +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( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +var S = new Float64Array( 4 ); +var out = new Float64Array( 3 ); + +dppequ.ndarray( 'row-major', 'lower', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); +// S => [ 0.0, 1.0, ~0.58, ~0.33 ] +// out => [ 0.0, ~0.33, 9.0 ] +``` + +
+ + + +
+ +## Notes + +- `dppequ()` corresponds to the [LAPACK][LAPACK] function [`dppequ`][lapack-dppequ]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dppequ = require( '@stdlib/lapack/base/dppequ' ); + +var i; +var j; + +// Specify matrix meta data: +var shape = [ 3, 3 ]; +var order = 'row-major'; +var uplo = 'upper'; +var strides = shape2strides( shape, order ); +var offset = 0; + +// Define a symmetric positive definite matrix: +var A = new Float64Array( [ 4.0, 1.0, 1.0, 1.0, 3.0, 0.0, 1.0, 0.0, 2.0 ] ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +// Convert the matrix to packed storage (upper triangle): +var buf = []; +for ( i = 0; i < shape[ 0 ]; i++ ) { + for ( j = i; j < shape[ 1 ]; j++ ) { + buf.push( A[ (i*strides[ 0 ]) + (j*strides[ 1 ]) + offset ] ); + } +} +console.log( buf ); + +var AP = new Float64Array( buf ); +var out = new Float64Array( 2 ); +var S = new Float64Array( shape[ 0 ] ); +var info = dppequ( order, uplo, shape[ 0 ], AP, S, out ); + +console.log( 'info:', info ); +console.log( 'S:', S ); +console.log( 'out:', out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dppequ/benchmark/benchmark.js new file mode 100644 index 000000000000..18b24aa13fa4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/benchmark/benchmark.js @@ -0,0 +1,131 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dppequ = require( './../lib/dppequ.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var UPLO = [ + 'upper', + 'lower' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @param {string} uplo - specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ) +* @param {string} order - storage layout +* @returns {Function} benchmark function +*/ +function createBenchmark( N, uplo, order ) { + var opts; + var out; + var AP; + var S; + + opts = { + 'dtype': 'float64' + }; + + AP = uniform( N * ( N + 1 ) / 2, -10.0, 10.0, opts ); + S = new Float64Array( N ); + out = new Float64Array( 2 ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dppequ( order, uplo, N, AP, S, out ); + if ( z < 0 ) { + b.fail( 'should not return an integer lesser than zero' ); + } + } + b.toc(); + if ( z < 0 ) { + b.fail( 'should not return an integer lesser than zero' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var order; + var uplo; + var min; + var max; + var N; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + for ( j = 0; j < LAYOUTS.length; j++ ) { + order = LAYOUTS[ j ]; + for ( k = 0; k < UPLO.length; k++ ) { + uplo = UPLO[ k ]; + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N, uplo, order ); + bench( pkg+'::square_matrix:order='+order+',uplo='+uplo+',size='+(N*N), f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dppequ/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..91b4d16eef81 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/benchmark/benchmark.ndarray.js @@ -0,0 +1,131 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dppequ = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var UPLO = [ + 'upper', + 'lower' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @param {string} uplo - specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ) +* @param {string} order - storage layout +* @returns {Function} benchmark function +*/ +function createBenchmark( N, uplo, order ) { + var opts; + var out; + var AP; + var S; + + opts = { + 'dtype': 'float64' + }; + + AP = uniform( N * ( N + 1 ) / 2, -10.0, 10.0, opts ); + S = new Float64Array( N ); + out = new Float64Array( 2 ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dppequ( order, uplo, N, AP, 1, 0, S, 1, 0, out, 1, 0 ); + if ( z < 0 ) { + b.fail( 'should not return an integer lesser than zero' ); + } + } + b.toc(); + if ( z < 0 ) { + b.fail( 'should not return an integer lesser than zero' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var order; + var uplo; + var min; + var max; + var N; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + for ( j = 0; j < LAYOUTS.length; j++ ) { + order = LAYOUTS[ j ]; + for ( k = 0; k < UPLO.length; k++ ) { + uplo = UPLO[ k ]; + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N, uplo, order ); + bench( pkg+'::square_matrix:order='+order+',uplo='+uplo+',size='+(N*N), f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dppequ/docs/repl.txt new file mode 100644 index 000000000000..38fbb7d1e14e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/docs/repl.txt @@ -0,0 +1,141 @@ + +{{alias}}( order, uplo, N, AP, S, out ) + Computes the row and column scaling factors intended to equilibrate a + symmetric positive definite matrix `A` in packed storage and reduce + it's condition number (with respect to the two-norm). + + The function returns a status code. If the status code is equal to zero then + it shows a sucessful exit. If the status code it a positive integer `I` then + it means that the `I`th diagonal element had a non positive value. + + The first element of `out` represents `scond` and the second element of + `out` represents `amax`. if `scond` >= 0.1 and `amax` is not too close to + overflow/underflow then it is not worth scaling by `S`. if `amax` is close + to overflow/underflow the matrix should be scaled. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether upper or lower triangle of `A` is stored. + + N: integer + Number of rows/columns in `A`. + + AP: Float64Array + Array containing the upper or lower triangle of `A` in packed form, + expects `N * ( N + 1 ) / 2` indexed elements. + + S: Float64Array + Array to store the scale factors of `A`, expects `N` indexed + elements. + + out: Float64Array + Array to store `scond` and `amax`, expects 2 indexed elements. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var AP = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + > var S = new {{alias:@stdlib/array/float64}}( 3 ); + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > var ord = 'row-major'; + > var uplo = 'lower'; + > {{alias}}( 'row-major', 'lower', 3, AP, S, out ) + 0 + > S + [ 1, ~0.58, ~0.33 ] + > out + [ ~0.33, 9 ] + + +{{alias}}.ndarray( order, uplo, N, AP, sap, oap, S, ss, os, out, so, oo ) + Computes the row and column scaling factors intended to equilibrate a + symmetric positive definite matrix `A` in packed storage and reduce + it's condition number (with respect to the two-norm). + + The function returns a status code. If the status code is equal to zero then + it shows a sucessful exit. If the status code it a positive integer `I` then + it means that the `I`th diagonal element had a non positive value. + + The first element of `out` represents `scond` and the second element of + `out` represents `amax`. if `scond` >= 0.1 and `amax` is not too close to + overflow/underflow then it is not worth scaling by `S`. if `amax` is close + to overflow/underflow the matrix should be scaled. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + 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 upper or lower triangle of `A` is stored. + + N: integer + Number of rows/columns in `A`. + + AP: Float64Array + Array containing the upper or lower triangle of `A` in packed form, + expects `N * ( N + 1 ) / 2` indexed elements. + + sap: integer + Stride length for `AP`. + + oap: integer + Starting index for `AP`. + + S: Float64Array + Array to store the scale factors of `A`, expects `N` indexed + elements. + + ss: integer + Stride length for `S`. + + os: integer + Starting index for `S`. + + out: Float64Array + Array to store `scond` and `amax`, expects 2 indexed elements. + + so: integer + Stride length for `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var AP = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + > var S = new {{alias:@stdlib/array/float64}}( 3 ); + > var out = new {{alias:@stdlib/array/float64}}( 2 ); + > var ord = 'row-major'; + > var uplo = 'lower'; + > {{alias}}.ndarray( ord, uplo, 3, AP, 1, 0, S, 1, 0, out, 1, 0 ) + 0 + > S + [ 1, ~0.58, ~0.33 ] + > out + [ ~0.33, 9 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dppequ/docs/types/index.d.ts new file mode 100644 index 000000000000..5c4b8374a055 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/docs/types/index.d.ts @@ -0,0 +1,155 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Status code. +* +* ## Notes +* +* The status code indicates the following conditions: +* +* - if equal to zero, successful exit. +* - if greater than zero, then the `i`th diagonal element was non positive. +*/ +type StatusCode = number; + +/** +* Interface describing `dppequ`. +*/ +interface Routine { + /** + * Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm). + * + * ## Notes + * + * - the function returns `0` if it sucessfully exits. + * - if the function returns an integer `i` greater then zero then the `i`th diagonal element was non positive. + * - the first indexed element of `out` represents `scond` and the second indexed elements represents `amax`, if it `scond` >= 0.1 and `amax` is not close to overflow/underflow then it is not worth scaling by `S`. + * - if `amax` is too close to overflow/underflow, the matrix should be scaled. + * + * @param order - storage layout + * @param uplo - specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ) + * @param N - number of rows/columns in `A` + * @param AP - array containing the upper or lower triangle of `A` in packed form, expects `N * ( N + 1 ) / 2` indexed elements + * @param S - array to store the scale factors of `A`, expects `N` indexed elements + * @param out - array to store the output + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + * var S = new Float64Array( 3 ); + * var out = new Float64Array( 2 ); + * + * dppequ( 'row-major', 'lower', 3, AP, S, out ); + * // S => [ 1, ~0.58, ~0.33 ] + * // out => [ ~0.33, 9 ] + */ + ( order: Layout, uplo: string, N: number, AP: Float64Array, S: Float64Array, out: Float64Array ): StatusCode; + + /** + * Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm) using alternative indexing semantics. + * + * ## Notes + * + * - the function returns `0` if it sucessfully exits. + * - if the function returns an integer `i` greater then zero then the `i`th diagonal element was non positive. + * - the first indexed element of `out` represents `scond` and the second indexed elements represents `amax`, if it `scond` >= 0.1 and `amax` is not close to overflow/underflow then it is not worth scaling by `S`. + * - if `amax` is too close to overflow/underflow, the matrix should be scaled. + * + * @param order - storage layout + * @param uplo - specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ) + * @param N - number of rows/columns in `A` + * @param AP - array containing the upper or lower triangle of `A` in packed form, expects `N * ( N + 1 ) / 2` indexed elements + * @param strideAP - stride length for `AP` + * @param offsetAP - starting index for `AP` + * @param S - array to store the scale factors of `A`, expects `N` indexed elements + * @param strideS - stride length for `S` + * @param offsetS - starting index for `S` + * @param out - array to store the output + * @param strideOut - stride length for `out` + * @param offsetOut - starting index for `out` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + * var S = new Float64Array( 3 ); + * var out = new Float64Array( 2 ); + * + * dppequ.ndarray( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + * // S => [ 1, ~0.58, ~0.33 ] + * // out => [ ~0.33, 9 ] + */ + ndarray( order: Layout, uplo: string, N: number, AP: Float64Array, strideAP: number, offsetAP: number, S: Float64Array, strideS: number, offsetS: number, out: Float64Array, strideOut: number, offsetOut: number ): StatusCode; +} + +/** +* Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm). +* +* ## Notes +* +* - the function returns `0` if it sucessfully exits. +* - if the function returns an integer `i` greater then zero then the `i`th diagonal element was non positive. +* - the first indexed element of `out` represents `scond` and the second indexed elements represents `amax`, if it `scond` >= 0.1 and `amax` is not close to overflow/underflow then it is not worth scaling by `S`. +* - if `amax` is too close to overflow/underflow, the matrix should be scaled. +* +* @param order - storage layout +* @param uplo - specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ) +* @param N - number of rows/columns in `A` +* @param AP - array containing the upper or lower triangle of `A` in packed form, expects `N * ( N + 1 ) / 2` indexed elements +* @param S - array to store the scale factors of `A`, expects `N` indexed elements +* @param out - array to store the output +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +* var S = new Float64Array( 3 ); +* var out = new Float64Array( 2 ); +* +* dppequ( 'row-major', 'lower', 3, AP, S, out ); +* // S => [ 1, ~0.58, ~0.33 ] +* // out => [ ~0.33, 9 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +* var S = new Float64Array( 3 ); +* var out = new Float64Array( 2 ); +* +* dppequ.ndarray( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); +* // S => [ 1, ~0.58, ~0.33 ] +* // out => [ ~0.33, 9 ] +*/ +declare var dppequ: Routine; + + +// EXPORTS // + +export = dppequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dppequ/docs/types/test.ts new file mode 100644 index 000000000000..3703547e1745 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/docs/types/test.ts @@ -0,0 +1,359 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dppequ = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( 3 ); + const out = new Float64Array( 2 ); + + dppequ( 'row-major', 'upper', 3, AP, S, out ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const AP = new Float64Array( 6 ); + const S = new Float64Array( 3 ); + const out = new Float64Array( 2 ); + + dppequ( 5, 'upper', 3, AP, S, out ); // $ExpectError + dppequ( true, 'upper', 3, AP, S, out ); // $ExpectError + dppequ( false, 'upper', 3, AP, S, out ); // $ExpectError + dppequ( null, 'upper', 3, AP, S, out ); // $ExpectError + dppequ( void 0, 'upper', 3, AP, S, out ); // $ExpectError + dppequ( [], 'upper', 3, AP, S, out ); // $ExpectError + dppequ( {}, 'upper', 3, AP, S, out ); // $ExpectError + dppequ( ( x: number ): number => x, 'upper', 3, AP, S, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const AP = new Float64Array( 6 ); + const S = new Float64Array( 3 ); + const out = new Float64Array( 2 ); + + dppequ( 'row-major', 5, 3, AP, S, out ); // $ExpectError + dppequ( 'row-major', true, 3, AP, S, out ); // $ExpectError + dppequ( 'row-major', false, 3, AP, S, out ); // $ExpectError + dppequ( 'row-major', null, 3, AP, S, out ); // $ExpectError + dppequ( 'row-major', void 0, 3, AP, S, out ); // $ExpectError + dppequ( 'row-major', [], 3, AP, S, out ); // $ExpectError + dppequ( 'row-major', {}, 3, AP, S, out ); // $ExpectError + dppequ( 'row-major', ( x: number ): number => x, 3, AP, S, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const AP = new Float64Array( 6 ); + const S = new Float64Array( 3 ); + const out = new Float64Array( 2 ); + + dppequ( 'row-major', 'upper', '3', AP, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', true, AP, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', false, AP, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', null, AP, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', void 0, AP, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', [], AP, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', {}, AP, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', ( x: number ): number => x, AP, S, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const S = new Float64Array( 3 ); + const out = new Float64Array( 2 ); + + dppequ( 'row-major', 'upper', 3, [], S, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, 'abc', S, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, 123, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, null, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, void 0, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, {}, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, true, S, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, ( x: number ): number => x, S, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const AP = new Float64Array( 6 ); + const out = new Float64Array( 2 ); + + dppequ( 'row-major', 'upper', 3, AP, [], out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, 'abc', out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, 123, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, null, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, void 0, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, {}, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, true, out ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, ( x: number ): number => x, out ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const AP = new Float64Array( 6 ); + const S = new Float64Array( 3 ); + + dppequ( 'row-major', 'upper', 3, AP, S, [] ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S, 'abc' ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S, 123 ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S, null ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S, void 0 ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S, {} ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S, true ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S, ( 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ(); // $ExpectError + dppequ( 'row-major' ); // $ExpectError + dppequ( 'row-major', 'upper' ); // $ExpectError + dppequ( 'row-major', 'upper', 3 ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S ); // $ExpectError + dppequ( 'row-major', 'upper', 3, AP, S, out, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectType number +} + +// 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 5, 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( true, 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( false, 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( null, 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( void 0, 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( [], 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( {}, 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( ( x: number ): number => x, 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 5, 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', true, 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', false, 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', null, 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', void 0, 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', [], 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', {}, 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', ( x: number ): number => x, 3, AP, 1, 0, S, 1, 0, out, 1, 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', '5', AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', true, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', false, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', null, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', void 0, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', [], AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', {}, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', ( x: number ): number => x, AP, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const S = new Float64Array( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, 5, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, true, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, false, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, null, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, void 0, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, [], 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, {}, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, ( x: number ): number => x, 1, 0, S, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, '5', 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, true, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, false, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, null, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, void 0, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, [], 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, {}, 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, ( x: number ): number => x, 0, S, 1, 0, out, 1, 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, '5', S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, true, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, false, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, null, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, void 0, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, [], S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, {}, S, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, ( x: number ): number => x, S, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function 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 ] ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, 5, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, true, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, false, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, null, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, void 0, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, [], 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, {}, 1, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, ( x: number ): number => x, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, '5', 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, true, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, false, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, null, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, void 0, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, [], 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, {}, 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, ( x: number ): number => x, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, '5', out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, true, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, false, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, null, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, void 0, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, [], out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, {}, out, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float64Array... +{ + const AP = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const S = new Float64Array( 3 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, 5, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, true, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, false, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, null, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, void 0, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, [], 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, {}, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, '5', 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, true, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, false, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, null, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, void 0, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, [], 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, {}, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, '5' ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, true ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, false ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, null ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, void 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, [] ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, {} ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, ( 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( 3 ); + const out = new Float64Array( 2 ); + + dppequ.ndarray(); // $ExpectError + dppequ.ndarray( 'row-major' ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper' ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1 ); // $ExpectError + dppequ.ndarray( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0, 10 ); // $ExpectError +} + diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dppequ/examples/index.js new file mode 100644 index 000000000000..61bd86767f14 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/examples/index.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dppequ = require( './../lib' ); + +var i; +var j; + +// Specify matrix meta data: +var shape = [ 3, 3 ]; +var order = 'row-major'; +var uplo = 'upper'; +var strides = shape2strides( shape, order ); +var offset = 0; + +// Define a symmetric positive definite matrix: +var A = new Float64Array( [ 4.0, 1.0, 1.0, 1.0, 3.0, 0.0, 1.0, 0.0, 2.0 ] ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +// Convert the matrix to packed storage (upper triangle): +var buf = []; +for ( i = 0; i < shape[ 0 ]; i++ ) { + for ( j = i; j < shape[ 1 ]; j++ ) { + buf.push( A[ (i*strides[ 0 ]) + (j*strides[ 1 ]) + offset ] ); + } +} +console.log( buf ); + +var AP = new Float64Array( buf ); +var out = new Float64Array( 2 ); +var S = new Float64Array( shape[ 0 ] ); +var info = dppequ( order, uplo, shape[ 0 ], AP, S, out ); + +console.log( 'info:', info ); +console.log( 'S:', S ); +console.log( 'out:', out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js new file mode 100644 index 000000000000..a0a6191df04f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/base.js @@ -0,0 +1,139 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); + + +// MAIN // + +/** +* Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm). +* +* ## Notes +* +* - the function returns `0` if it sucessfully exits. +* - if the function returns an integer `i` greater then zero then the `i`th diagonal element was non positive. +* - the first indexed element of `out` represents `scond` and the second indexed elements represents `amax`, if it `scond` >= 0.1 and `amax` is not close to overflow/underflow then it is not worth scaling by `S`. +* - if `amax` is too close to overflow/underflow, the matrix should be scaled. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ) +* @param {NonNegativeInteger} N - number of rows/columns in `A` +* @param {Float64Array} AP - array containing the upper or lower triangle of `A` in packed form, expects `N * ( N + 1 ) / 2` indexed elements +* @param {integer} strideAP - stride length for `AP` +* @param {NonNegativeInteger} offsetAP - starting index for `AP` +* @param {Float64Array} S - array to store the scale factors of `A`, expects `N` indexed elements +* @param {integer} strideS - stride length for `S` +* @param {NonNegativeInteger} offsetS - starting index for `S` +* @param {Float64Array} out - array to store the output +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +* var S = new Float64Array( 3 ); +* var out = new Float64Array( 2 ); +* +* dppequ( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); +* // S => [ 1, ~0.58, ~0.33 ] +* // out => [ ~0.33, 9 ] +*/ +function dppequ( order, uplo, N, AP, strideAP, offsetAP, S, strideS, offsetS, out, strideOut, offsetOut ) { // eslint-disable-line max-len, max-params + var info; + var smin; + var amax; + var iap; + var is; + var i; + + if ( N === 0 ) { + out[ offsetOut ] = 1.0; // scond + out[ offsetOut + strideOut ] = 0.0; // amax + return 0; // info + } + + is = offsetS; + S[ is ] = AP[ offsetAP ]; + smin = S[ is ]; + amax = S[ is ]; + + is = offsetS + strideS; + iap = offsetAP; + if ( uplo === 'upper' ) { + for ( i = 1; i < N; i++ ) { + if ( order === 'row-major' ) { + iap += ( N - i + 1 ) * strideAP; + } else { // order === 'column-major' + iap += ( i + 1 ) * strideAP; + } + S[ is ] = AP[ iap ]; + smin = min( smin, S[ is ] ); + amax = max( amax, S[ is ] ); + is += strideS; + } + } else { // uplo === 'lower' + for ( i = 1; i < N; i++ ) { + if ( order === 'row-major' ) { + iap += ( i + 1 ) * strideAP; + } else { // order === 'column-major' + iap += ( N - i + 1 ) * strideAP; + } + S[ is ] = AP[ iap ]; + smin = min( smin, S[ is ] ); + amax = max( amax, S[ is ] ); + is += strideS; + } + } + + is = offsetS; + if ( smin <= 0.0 ) { + for ( i = 0; i < N; i++ ) { + if ( S[ is ] <= 0.0 ) { + // Leave first element of `out` unchanged + out[ offsetOut + strideOut ] = amax; // amax + info = i; + return info; + } + is += strideS; + } + } else { + for ( i = 0; i < N; i++ ) { + S[ is ] = 1.0 / sqrt( S[ is ] ); + is += strideS; + } + } + + out[ offsetOut ] = sqrt( smin ) / sqrt( amax ); // scond + out[ offsetOut + strideOut ] = amax; // amax + info = 0; + return info; +} + + +// EXPORTS // + +module.exports = dppequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/lib/dppequ.js b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/dppequ.js new file mode 100644 index 000000000000..06160dacdd0e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/dppequ.js @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var format = require( '@stdlib/string/format' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm). +* +* ## Notes +* +* - the function returns `0` if it sucessfully exits. +* - if the function returns an integer `i` greater then zero then the `i`th diagonal element was non positive. +* - the first indexed element of `out` represents `scond` and the second indexed elements represents `amax`, if it `scond` >= 0.1 and `amax` is not close to overflow/underflow then it is not worth scaling by `S`. +* - if `amax` is too close to overflow/underflow, the matrix should be scaled. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ) +* @param {NonNegativeInteger} N - number of rows/columns in `A` +* @param {Float64Array} AP - array containing the upper or lower triangle of `A` in packed form, expects `N * ( N + 1 ) / 2` indexed elements +* @param {Float64Array} S - array to store the scale factors of `A`, expects `N` indexed elements +* @param {Float64Array} out - array to store the output +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be a valid side +* @throws {RangeError} third argument must be a nonnegative integer +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +* var S = new Float64Array( 3 ); +* var out = new Float64Array( 2 ); +* +* dppequ( 'row-major', 'lower', 3, AP, S, out ); +* // S => [ 1, ~0.58, ~0.33 ] +* // out => [ ~0.33, 9 ] +*/ +function dppequ( order, uplo, N, AP, S, out ) { + 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 be a valid side. Value: `%s`.', order ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + return base( order, uplo, N, AP, 1, 0, S, 1, 0, out, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dppequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/index.js new file mode 100644 index 000000000000..9828bb32ee86 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm). +* +* @module @stdlib/lapack/base/dppequ +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dppequ = require( '@stdlib/lapack/base/dppequ' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +* var S = new Float64Array( 3 ); +* var out = new Float64Array( 2 ); +* +* dppequ( 'row-major', 'lower', 3, AP, S, out ); +* // S => [ 1, ~0.58, ~0.33 ] +* // out => [ ~0.33, 9 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dppequ = require( '@stdlib/lapack/base/dppequ' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +* var S = new Float64Array( 3 ); +* var out = new Float64Array( 2 ); +* +* dppequ.ndarray( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); +* // S => [ 1, ~0.58, ~0.33 ] +* // out => [ ~0.33, 9 ] +*/ + +// 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 dppequ; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dppequ = main; +} else { + dppequ = tmp; +} + + +// EXPORTS // + +module.exports = dppequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/main.js new file mode 100644 index 000000000000..7b6ee1e50424 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dppequ = require( './dppequ.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dppequ, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dppequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/ndarray.js new file mode 100644 index 000000000000..9e1ca3dd12bd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/lib/ndarray.js @@ -0,0 +1,85 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var format = require( '@stdlib/string/format' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm) using alternative indexing semantics. +* +* ## Notes +* +* - the function returns `0` if it sucessfully exits. +* - if the function returns an integer `i` greater then zero then the `i`th diagonal element was non positive. +* - the first indexed element of `out` represents `scond` and the second indexed elements represents `amax`, if it `scond` >= 0.1 and `amax` is not close to overflow/underflow then it is not worth scaling by `S`. +* - if `amax` is too close to overflow/underflow, the matrix should be scaled. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether upper or lower triangle of `A` is stored ( `upper` or `lower` ) +* @param {NonNegativeInteger} N - number of rows/columns in `A` +* @param {Float64Array} AP - array containing the upper or lower triangle of `A` in packed form, expects `N * ( N + 1 ) / 2` indexed elements +* @param {integer} strideAP - stride length for `AP` +* @param {NonNegativeInteger} offsetAP - starting index for `AP` +* @param {Float64Array} S - array to store the scale factors of `A`, expects `N` indexed elements +* @param {integer} strideS - stride length for `S` +* @param {NonNegativeInteger} offsetS - starting index for `S` +* @param {Float64Array} out - array to store the output +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} first argument must be a valid side +* @throws {RangeError} third argument must be a nonnegative integer +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); +* var S = new Float64Array( 3 ); +* var out = new Float64Array( 2 ); +* +* dppequ( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); +* // S => [ 1, ~0.58, ~0.33 ] +* // out => [ ~0.33, 9 ] +*/ +function dppequ( order, uplo, N, AP, strideAP, offsetAP, S, strideS, offsetS, out, strideOut, offsetOut ) { // eslint-disable-line max-len, max-params + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a valid side. Value: `%s`.', order ) ); + } + return base( order, uplo, N, AP, strideAP, offsetAP, S, strideS, offsetS, out, strideOut, offsetOut ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dppequ; diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/package.json b/lib/node_modules/@stdlib/lapack/base/dppequ/package.json new file mode 100644 index 000000000000..7ec8d78a8012 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dppequ", + "version": "0.0.0", + "description": "LAPACK routine to compute the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage and reduce it's condition number (with respect to the two-norm).", + "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", + "dppequ", + "copy", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.dppequ.js b/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.dppequ.js new file mode 100644 index 000000000000..86212cf206bd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.dppequ.js @@ -0,0 +1,357 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/* eslint-disable max-len */ + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dppequ = require( './../lib/dppequ.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dppequ, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dppequ.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var out; + var AP; + var S; + var i; + + values = [ + -1, + -2, + -3, + -4, + -5 + ]; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + 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() { + dppequ( 'row-major', 'lower', value, AP, S, out ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var out; + var AP; + var S; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + 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() { + dppequ( value, 'lower', 3, AP, S, out ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a valid side', function test( t ) { + var values; + var out; + var AP; + var S; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + 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() { + dppequ( 'row-major', value, 3, AP, S, out ); + }; + } +}); + +tape( 'the function leaves the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage unchanged if N is equal to 0', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 0, AP, S, out ); + + expectedOut = new Float64Array( [ 1.0, 0.0 ] ); + expectedS = new Float64Array( 3 ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 3, AP, S, out ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.57735026918962584, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 5.0, 3.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'lower', 3, AP, S, out ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.57735026918962584, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'upper', 3, AP, S, out ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.44721359549995793, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 5.0, 3.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'upper', 3, AP, S, out ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.44721359549995793, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'upper', 3, AP, S, out ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'upper', 3, AP, S, out ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'lower', 3, AP, S, out ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 3, AP, S, out ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.js b/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.js new file mode 100644 index 000000000000..96853273fab0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dppequ = 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 dppequ, '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 dppequ.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 dppequ = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dppequ, 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 dppequ; + var main; + + main = require( './../lib/dppequ.js' ); + + dppequ = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dppequ, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.ndarray.js new file mode 100644 index 000000000000..7ba194f9d756 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dppequ/test/test.ndarray.js @@ -0,0 +1,1094 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/* eslint-disable max-len */ + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dppequ = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dppequ, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( dppequ.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var out; + var AP; + var S; + var i; + + values = [ + -1, + -2, + -3, + -4, + -5 + ]; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + 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() { + dppequ( 'row-major', 'lower', value, AP, 1, 0, S, 1, 0, out, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var out; + var AP; + var S; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + 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() { + dppequ( value, 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a valid side', function test( t ) { + var values; + var out; + var AP; + var S; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + 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() { + dppequ( 'row-major', value, 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + }; + } +}); + +tape( 'the function leaves the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage unchanged if N is equal to 0', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 0, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 1.0, 0.0 ] ); + expectedS = new Float64Array( 3 ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.57735026918962584, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 5.0, 3.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.57735026918962584, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.44721359549995793, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 2.0, 5.0, 3.0, 6.0, 9.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.44721359549995793, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with negative strides (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 9.0, 6.0, 5.0, 3.0, 2.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 3, AP, -1, 5, S, -1, 2, out, -1, 1 ); + + expectedOut = new Float64Array( [ 9.0, 0.33333333333333331 ] ); + expectedS = new Float64Array( [ 0.33333333333333331, 0.57735026918962584, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with negative strides (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 9.0, 6.0, 3.0, 5.0, 2.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'lower', 3, AP, -1, 5, S, -1, 2, out, -1, 1 ); + + expectedOut = new Float64Array( [ 9.0, 0.33333333333333331 ] ); + expectedS = new Float64Array( [ 0.33333333333333331, 0.57735026918962584, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with negative strides (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 9.0, 6.0, 5.0, 3.0, 2.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'upper', 3, AP, -1, 5, S, -1, 2, out, -1, 1 ); + + expectedOut = new Float64Array( [ 9.0, 0.33333333333333331 ] ); + expectedS = new Float64Array( [ 0.33333333333333331, 0.44721359549995793, 1.0 ] ); + + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with negative strides (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 9.0, 6.0, 3.0, 5.0, 2.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'upper', 3, AP, -1, 5, S, -1, 2, out, -1, 1 ); + + expectedOut = new Float64Array( [ 9.0, 0.33333333333333331 ] ); + expectedS = new Float64Array( [ 0.33333333333333331, 0.44721359549995793, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with negative strides and returns (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'upper', 3, AP, 1, 0, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with negative strides and returns (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'upper', 3, AP, -1, 5, S, -1, 2, out, -1, 1 ); + + expectedOut = new Float64Array( [ 1.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with negative strides and returns (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'lower', 3, AP, -1, 5, S, -1, 2, out, -1, 1 ); + + expectedOut = new Float64Array( [ 1.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with negative strides and returns (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 3, AP, -1, 5, S, -1, 2, out, -1, 1 ); + + expectedOut = new Float64Array( [ 1.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with offsets (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 4 ); + out = new Float64Array( 3 ); + + info = dppequ( 'row-major', 'lower', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); + + expectedOut = new Float64Array( [ 0.0, 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 0.0, 1.0, 0.57735026918962584, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with offsets (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 0.0, 1.0, 2.0, 5.0, 3.0, 6.0, 9.0 ] ); + S = new Float64Array( 4 ); + out = new Float64Array( 3 ); + + info = dppequ( 'column-major', 'lower', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); + + expectedOut = new Float64Array( [ 0.0, 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 0.0, 1.0, 0.57735026918962584, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with offsets (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 9.0 ] ); + S = new Float64Array( 4 ); + out = new Float64Array( 3 ); + + info = dppequ( 'row-major', 'upper', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); + + expectedOut = new Float64Array( [ 0.0, 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 0.0, 1.0, 0.44721359549995793, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with offsets (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 0.0, 1.0, 2.0, 5.0, 3.0, 6.0, 9.0 ] ); + S = new Float64Array( 4 ); + out = new Float64Array( 3 ); + + info = dppequ( 'column-major', 'upper', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); + + expectedOut = new Float64Array( [ 0.0, 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 0.0, 1.0, 0.44721359549995793, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with offsets and returns (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 4 ); + out = new Float64Array( 3 ); + + info = dppequ( 'column-major', 'upper', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); + + expectedOut = new Float64Array( [ 0.0, 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 0.0, 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with offsets and returns (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 4 ); + out = new Float64Array( 3 ); + + info = dppequ( 'row-major', 'upper', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); + + expectedOut = new Float64Array( [ 0.0, 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 0.0, 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with offsets and returns (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 0.0, 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 4 ); + out = new Float64Array( 3 ); + + info = dppequ( 'column-major', 'lower', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); + + expectedOut = new Float64Array( [ 0.0, 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 0.0, 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with offsets and returns (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 4 ); + out = new Float64Array( 3 ); + + info = dppequ( 'row-major', 'lower', 3, AP, 1, 1, S, 1, 1, out, 1, 1 ); + + expectedOut = new Float64Array( [ 0.0, 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 0.0, 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with large strides (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 6.0, 0.0, 9.0, 0.0 ] ); + S = new Float64Array( 6 ); + out = new Float64Array( 4 ); + + info = dppequ( 'row-major', 'lower', 3, AP, 2, 0, S, 2, 0, out, 2, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 0.0, 9.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 0.57735026918962584, 0.0, 0.33333333333333331, 0.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with large strides (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 5.0, 0.0, 3.0, 0.0, 6.0, 0.0, 9.0, 0.0 ] ); + S = new Float64Array( 6 ); + out = new Float64Array( 4 ); + + info = dppequ( 'column-major', 'lower', 3, AP, 2, 0, S, 2, 0, out, 2, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 0.0, 9.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 0.57735026918962584, 0.0, 0.33333333333333331, 0.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with large strides (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 6.0, 0.0, 9.0, 0.0 ] ); + S = new Float64Array( 6 ); + out = new Float64Array( 4 ); + + info = dppequ( 'row-major', 'upper', 3, AP, 2, 0, S, 2, 0, out, 2, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 0.0, 9.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 0.44721359549995793, 0.0, 0.33333333333333331, 0.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with large strides (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 5.0, 0.0, 3.0, 0.0, 6.0, 0.0, 9.0, 0.0 ] ); + S = new Float64Array( 6 ); + out = new Float64Array( 4 ); + + info = dppequ( 'column-major', 'upper', 3, AP, 2, 0, S, 2, 0, out, 2, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 0.0, 9.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 0.44721359549995793, 0.0, 0.33333333333333331, 0.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with large strides and returns (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] ); + S = new Float64Array( 6 ); + out = new Float64Array( 4 ); + + info = dppequ( 'column-major', 'upper', 3, AP, 2, 0, S, 2, 0, out, 2, 0 ); + + expectedOut = new Float64Array( [ 0.0, 0.0, 1.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 1.0, 0.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with large strides and returns (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] ); + S = new Float64Array( 6 ); + out = new Float64Array( 4 ); + + info = dppequ( 'row-major', 'upper', 3, AP, 2, 0, S, 2, 0, out, 2, 0 ); + + expectedOut = new Float64Array( [ 0.0, 0.0, 1.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 1.0, 0.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with large strides and returns (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] ); + S = new Float64Array( 6 ); + out = new Float64Array( 4 ); + + info = dppequ( 'column-major', 'lower', 3, AP, 2, 0, S, 2, 0, out, 2, 0 ); + + expectedOut = new Float64Array( [ 0.0, 0.0, 1.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with large strides and returns (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] ); + S = new Float64Array( 6 ); + out = new Float64Array( 4 ); + + info = dppequ( 'row-major', 'lower', 3, AP, 2, 0, S, 2, 0, out, 2, 0 ); + + expectedOut = new Float64Array( [ 0.0, 0.0, 1.0, 0.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with mixed strides (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 9.0, 6.0, 5.0, 3.0, 2.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 3, AP, -1, 5, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.57735026918962584, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with mixed strides (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 9.0, 6.0, 3.0, 5.0, 2.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'lower', 3, AP, -1, 5, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.57735026918962584, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with mixed strides (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 9.0, 6.0, 5.0, 3.0, 2.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'upper', 3, AP, -1, 5, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.44721359549995793, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the row and column scaling factors intended to equilibrate a symmetric positive definite matrix `A` in packed storage with mixed strides (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 9.0, 6.0, 3.0, 5.0, 2.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'upper', 3, AP, -1, 5, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.33333333333333331, 9.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.44721359549995793, 0.33333333333333331 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with mixed strides and returns (upper-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'upper', 3, AP, -1, 5, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with mixed strides and returns (upper-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'upper', 3, AP, -1, 5, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, -1.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element with mixed strides and returns (lower-triangular) (column-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'column-major', 'lower', 3, AP, -1, 5, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function finds the first non-positive diagonal element and returns (lower-triangular) (row-major)', function test( t ) { + var expectedOut; + var expectedS; + var info; + var out; + var AP; + var S; + + AP = new Float64Array( [ 1.0, 0.0, -1.0, 0.0, 0.0, 1.0 ] ); + S = new Float64Array( 3 ); + out = new Float64Array( 2 ); + + info = dppequ( 'row-major', 'lower', 3, AP, -1, 5, S, 1, 0, out, 1, 0 ); + + expectedOut = new Float64Array( [ 0.0, 1.0 ] ); + expectedS = new Float64Array( [ 1.0, 0.0, 1.0 ] ); + t.deepEqual( S, expectedS, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( info, 1, 'returns expected value' ); + + t.end(); +});