diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/README.md b/lib/node_modules/@stdlib/lapack/base/dgebal/README.md new file mode 100644 index 000000000000..1fef3ab203d8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/README.md @@ -0,0 +1,314 @@ + + +# dgebal + +> Balances a general real matrix `A`. + +
+ +## Usage + +```javascript +var dgebal = require( '@stdlib/lapack/base/dgebal' ); +``` + +#### dgebal( order, job, N, A, LDA, out, scale ) + +Balances a general real matrix `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +var out = new Int32Array( 2 ); +var scale = new Float64Array( 3 ); + +/* + A = [ + [ 1.0, 100.0, 0.0 ], + [ 2.0, 200.0, 0.0 ], + [ 0.0, 0.0, 3.0 ], + ] +*/ + +dgebal( 'row-major', 'both', 3, A, 3, out, scale ); +// A => [ 1.0, 12.5, 0.0, 16.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] +// out => [ 0, 1 ] +// scale => [ 8.0, 1.0, 2.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **job**: indicates the operations to be performed. The `job` parameter can be one of the following. `none` (do nothing), `permute` (permute only), `scale` (scale only) and `both` (both permute and scale). +- **N**: number of row/columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **out**: stores the first and last row/column of the balanced submatrix as a [`Int32Array`][mdn-int32array]. +- **scale**: scale factors are stored in the `scale` array as a [`Float64Array`][mdn-float64array]. Where the indices `0` to `out[ 0 ] - 1` and `out[ 1 ] + 1` to `N-1` contain the index of the interchanged row/column (zero based), and the indices `out[ 0 ]` to `out[ 1 ]` contains the scaling factor applied. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +// Initial arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +var out0 = new Int32Array( 3 ); +var scale0 = new Float64Array( 4 ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var out1 = new Int32Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var scale1 = new Float64Array( scale0.buffer, scale0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +/* + A = [ + [ 1.0, 100.0, 0.0 ], + [ 2.0, 200.0, 0.0 ], + [ 0.0, 0.0, 3.0 ], + ] +*/ + +dgebal( 'row-major', 'both', 3, A1, 3, out1, scale1 ); +// A0 => [ 0.0, 1.0, 12.5, 0.0, 16.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] +// out0 => [ 0, 0, 1 ] +// scale0 => [ 0.0, 8.0, 1.0, 2.0 ] +``` + +#### dgebal.ndarray( uplo, M, N, A, sa1, sa2, oa, B, sb1, sb2, ob ) + +Balances a general real matrix `A` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +var out = new Int32Array( 2 ); +var scale = new Float64Array( 3 ); + +/* + A = [ + [ 1.0, 100.0, 0.0 ], + [ 2.0, 200.0, 0.0 ], + [ 0.0, 0.0, 3.0 ], + ] +*/ + +dgebal.ndarray( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); +// A => [ 1.0, 12.5, 0.0, 16.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] +// out => [ 0, 1 ] +// scale => [ 8.0, 1.0, 2.0 ] +``` + +The function has the following parameters: + +- **job**: indicates the operations to be performed. The `job` parameter can be one of the following. `none` (do nothing), `permute` (permute only), `scale` (scale only) and `both` (both permute and scale). +- **N**: number of row/columns in `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **strideA1**: stride of the first dimension of `A`. +- **strideA2**: stride of the second dimension of `A`. +- **offsetA**: starting index for `A`. +- **out**: stores the first and last row/column of the balanced submatrix as a [`Int32Array`][mdn-int32array]. +- **strideOut**: stride length of `out`. +- **offsetOut**: starting index for `out`. +- **scale**: scale factors are stored in the `scale` array as a [`Float64Array`][mdn-float64array]. Where the indices `0` to `out[ 0 ] - 1` and `out[ 1 ] + 1` to `N-1` contain the index of the interchanged row/column (zero based), and the indices `out[ 0 ]` to `out[ 1 ]` contains the scaling factor applied. +- **strideScale**: stride length for `scale`. +- **offsetScale**: starting index for `scale`. + +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 Int32Array = require( '@stdlib/array/int32' ); + +var A = new Float64Array( [ 0.0, 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +var out = new Int32Array( 3 ); +var scale = new Float64Array( 4 ); + +/* + A = [ + [ 1.0, 100.0, 0.0 ], + [ 2.0, 200.0, 0.0 ], + [ 0.0, 0.0, 3.0 ], + ] +*/ + +dgebal.ndarray( 'both', 3, A, 3, 1, 1, out, 1, 1, scale, 1, 1 ); +// A => [ 0.0, 1.0, 12.5, 0.0, 16.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] +// out => [ 0, 0, 1 ] +// scale => [ 0.0, 8.0, 1.0, 2.0 ] +``` + +
+ + + +
+ +## Notes + +- `dgebal()` corresponds to the [LAPACK][lapack] routine [`dgebal`][lapack-dgebal]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgebal = require( '@stdlib/lapack/base/dgebal' ); + +// Specify matrix meta data: +var shape = [ 3, 3 ]; +var strides = [ 3, 1 ]; +var offset = 0; +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +// Define arrays to store the scaling factors +var out = new Int32Array( 2 ); +var scale = new Float64Array( 3 ); + +// Permute and scale the matrix: +dgebal( order, 'both', shape[ 0 ], A, strides[ 0 ], out, scale ); + +console.log( ndarray2array( A, shape, strides, offset, order ) ); +console.log( out ); +console.log( scale ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgebal/benchmark/benchmark.js new file mode 100644 index 000000000000..914cfa68602b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/benchmark/benchmark.js @@ -0,0 +1,133 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var Int32Array = require( '@stdlib/array/int32' ); +var pkg = require( './../package.json' ).name; +var dgebal = require( './../lib/dgebal.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var JOBS = [ + 'permute', + 'scale', + 'both', + 'none' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @param {string} job - indicates the operations to be performed +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N, job ) { + var scale; + var out; + var A; + + scale = new Float64Array( N ); + out = new Int32Array( 2 ); + + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + 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 = dgebal( order, job, N, A, N, out, scale ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var job; + var N; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + for ( j = 0; j < JOBS.length; j++ ) { + job = JOBS[ j ]; + f = createBenchmark( ord, N, job ); + bench( pkg+'::square_matrix:order='+ord+',job='+job+',size='+(N*N), f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgebal/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..da36207604c9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/benchmark/benchmark.ndarray.js @@ -0,0 +1,145 @@ +/** +* @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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var Int32Array = require( '@stdlib/array/int32' ); +var pkg = require( './../package.json' ).name; +var dgebal = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var JOBS = [ + 'permute', + 'scale', + 'both', + 'none' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @param {string} job - indicates the operations to be performed +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N, job ) { + var scale; + var out; + var sa1; + var sa2; + var A; + + scale = new Float64Array( N ); + out = new Int32Array( 2 ); + + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { + sa1 = N; + sa2 = 1; + } + + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dgebal( job, N, A, sa1, sa2, 0, out, 1, 0, scale, 1, 0 ); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var job; + var N; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + for ( j = 0; j < JOBS.length; j++ ) { + job = JOBS[ j ]; + f = createBenchmark( ord, N, job ); + bench( pkg+'::square_matrix:order='+ord+',job='+job+',size='+(N*N), f ); + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgebal/docs/repl.txt new file mode 100644 index 000000000000..13eca4ba865a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/docs/repl.txt @@ -0,0 +1,135 @@ + +{{alias}}( order, job, N, A, LDA, out, scale ) + Balances a general real matrix `A`. + + The matrix `A` is overwritten by the balanced matrix. Scale factors are + stored in the `scale` array. Where the indices `0` to `out[ 0 ] - 1` and + `out[ 1 ] + 1` to `N-1` contain the index of the interchanged row/column + (zero based), and the indices `out[ 0 ]` to `out[ 1 ]` contains the + scaling factor applied. + + 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'. + + job: string + Indicates the operations to be performed. The `job` parameter can be + one of the following. 'none' (do nothing), 'permute' (permute only), + 'scale' (scale only) and 'both' (both permute and scale). + + N: integer + Number of row/columns in `A`. + + A: Float64Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + out: Int32Array + Output matrix `out`. Stores the first and last row/column of the + balanced submatrix. + + scale: Float64Array + Array containing permutation and scaling information. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var out = new {{alias:@stdlib/array/int32}}( 2 ); + > var scale = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}( 'row-major', 'both', 2, A, 2, out, scale ) + 0 + > A + [ 1.0, 2.0, 3.0, 4.0 ] + > out + [ 0, 1 ] + > scale + [ 1.0, 1.0 ] + + +{{alias}}.ndarray( job, N, A, sa1, sa2, oa, out, so, oo, scale, ss, os ) + Balances a general real matrix `A` using alternative indexing semantics. + + The matrix `A` is overwritten by the balanced matrix. Scale factors are + stored in the `scale` array. Where the indices `0` to `out[ 0 ] - 1` and + `out[ 1 ] + 1` to `N-1` contain the index of the interchanged row/column + (zero based), and the indices `out[ 0 ]` to `out[ 1 ]` contains the + scaling factor applied. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + job: string + Indicates the operations to be performed. The `job` parameter can be + one of the following. 'none' (do nothing), 'permute' (permute only), + 'scale' (scale only) and 'both' (both permute and scale). + + N: integer + Number of row/columns in `A`. + + A: Float64Array + Input matrix `A`. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + out: Int32Array + Output matrix `out`. + + so: integer + Stride length of `out`. + + oo: integer + Starting index of `out`. + + scale: Float64Array + Array containing permutation and scaling information. + + ss: integer + Stride length for `scale`. + + os: integer + Starting index for `scale`. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var out = new {{alias:@stdlib/array/int32}}( 2 ); + > var scale = new {{alias:@stdlib/array/float64}}( 2 ); + > {{alias}}.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ) + 0 + > A + [ 1.0, 2.0, 3.0, 4.0 ] + > out + [ 0, 1 ] + > scale + [ 1.0, 1.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgebal/docs/types/index.d.ts new file mode 100644 index 000000000000..2857c648f422 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/docs/types/index.d.ts @@ -0,0 +1,208 @@ +/** +* @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, then the factorization was successful. +*/ +type StatusCode = number; + +/** +* Job parameter. +* +* ## Notes +* +* The job parameter can be one of the following: +* +* - 'none': none, return immediately +* - 'permute': permute only +* - 'scale': scale only +* - 'both': both permute and scale +*/ +type Job = 'none' | 'permute' | 'scale' | 'both'; + +/** +* Interface describing `dgebal`. +*/ +interface Routine { + /** + * Balances a general real matrix `A`. + * + * ## Notes + * + * The job parameter can be one of the following: + * + * - 'none': none, return immediately + * - 'permute': permute only + * - 'scale': scale only + * - 'both': both permute and scale + * + * The matrix `A` is overwritten by the balanced matrix. Scale factors are stored in the `scale` array. If `P[ j ]` is the index of the row and column interchanged with row and column j (zero-based) and `D[ j ]` is the scaling factor applied to row and column j, then: + * + * - `scale[ j ]` = `P[ j ]` for j = `0`,...,`out[ 0 ]-1` + * - `scale[ j ]` = `D[ j ]` for j = `out[ 0 ]`,...,`out[ 1 ]` + * - `scale[ j ]` = `P[ j ]` for j = `out[ 1 ]+1`,...,`N-1`. + * + * The order in which the interchanges are made is `N-1` to `out[ 1 ]+1`, then `0` to `out[ 0 ]-1`. + * + * @param order - storage layout of `A` + * @param job - indicates the operations to be performed + * @param N - number of rows/columns in matrix `A` + * @param A - input matrix to be balanced + * @param LDA - leading dimension of `A` + * @param out - stores the first and last row/column of the balanced submatrix + * @param scale - array containing permutation and scaling information + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * + * var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); + * var out = new Int32Array( 2 ); + * var scale = new Float64Array( 3 ); + * + * dgebal( 'row-major', 'both', 3, A, 3, out, scale ); + * // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] + * // out => [ 0, 1 ] + * // scale => [ 8, 1, 2 ] + */ + ( order: Layout, job: Job, N: number, A: Float64Array, LDA: number, out: Int32Array, scale: Float64Array ): StatusCode; + + /** + * Balances a general real matrix `A` using alternative indexing semantics. + * + * ## Notes + * + * The job parameter can be one of the following: + * + * - 'none': none, return immediately + * - 'permute': permute only + * - 'scale': scale only + * - 'both': both permute and scale + * + * The matrix `A` is overwritten by the balanced matrix. Scale factors are stored in the `scale` array. If `P[ j ]` is the index of the row and column interchanged with row and column j (zero-based) and `D[ j ]` is the scaling factor applied to row and column j, then: + * + * - `scale[ j ]` = `P[ j ]` for j = `0`,...,`out[ 0 ]-1` + * - `scale[ j ]` = `D[ j ]` for j = `out[ 0 ]`,...,`out[ 1 ]` + * - `scale[ j ]` = `P[ j ]` for j = `out[ 1 ]+1`,...,`N-1`. + * + * The order in which the interchanges are made is `N-1` to `out[ 1 ]+1`, then `0` to `out[ 0 ]-1`. + * + * @param job - indicates the operations to be performed + * @param N - number of rows/columns in matrix `A` + * @param A - input matrix to be balanced + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @param out - stores the first and last row/column of the balanced submatrix + * @param strideOut - stride of `out` + * @param offsetOut - starting index for `out` + * @param scale - array containing permutation and scaling information + * @param strideScale - stride of `scale` + * @param offsetScale - starting index for `scale` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * + * var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); + * var out = new Int32Array( 2 ); + * var scale = new Float64Array( 3 ); + * + * dgebal.ndarray( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + * // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] + * // out => [ 0, 1 ] + * // scale => [ 8, 1, 2 ] + */ + ndarray( job: Job, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, out: Int32Array, strideOut: number, offsetOut: number, scale: Float64Array, strideScale: number, offsetScale: number ): StatusCode; +} + +/** +* Balances a general real matrix `A`. +* +* ## Notes +* +* The job parameter can be one of the following: +* +* - 'none': none, return immediately +* - 'permute': permute only +* - 'scale': scale only +* - 'both': both permute and scale +* +* The matrix `A` is overwritten by the balanced matrix. Scale factors are stored in the `scale` array. If `P[ j ]` is the index of the row and column interchanged with row and column j (zero-based) and `D[ j ]` is the scaling factor applied to row and column j, then: +* +* - `scale[ j ]` = `P[ j ]` for j = `0`,...,`out[ 0 ]-1` +* - `scale[ j ]` = `D[ j ]` for j = `out[ 0 ]`,...,`out[ 1 ]` +* - `scale[ j ]` = `P[ j ]` for j = `out[ 1 ]+1`,...,`N-1`. +* +* The order in which the interchanges are made is `N-1` to `out[ 1 ]+1`, then `0` to `out[ 0 ]-1`. +* +* @param order - storage layout of `A` +* @param job - indicates the operations to be performed +* @param N - number of rows/columns in matrix `A` +* @param A - input matrix to be balanced +* @param LDA - leading dimension of `A` +* @param out - stores the first and last row/column of the balanced submatrix +* @param scale - array containing permutation and scaling information +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var out = new Int32Array( 2 ); +* var scale = new Float64Array( 3 ); +* +* dgebal( 'row-major', 'both', 3, A, 3, out, scale ); +* // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] +* // out => [ 0, 1 ] +* // scale => [ 8, 1, 2 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var out = new Int32Array( 2 ); +* var scale = new Float64Array( 3 ); +* +* dgebal.ndarray( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); +* // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] +* // out => [ 0, 1 ] +* // scale => [ 8, 1, 2 ] +*/ +declare var dgebal: Routine; + + +// EXPORTS // + +export = dgebal; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dgebal/docs/types/test.ts new file mode 100644 index 000000000000..2acfedbd413e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/docs/types/test.ts @@ -0,0 +1,379 @@ +/* +* @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 dgebal = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal( 'row-major', 'both', 2, A, 2, out, scale ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal( 5, 'both', 2, A, 2, out, scale ); // $ExpectError + dgebal( true, 'both', 2, A, 2, out, scale ); // $ExpectError + dgebal( false, 'both', 2, A, 2, out, scale ); // $ExpectError + dgebal( null, 'both', 2, A, 2, out, scale ); // $ExpectError + dgebal( void 0, 'both', 2, A, 2, out, scale ); // $ExpectError + dgebal( [], 'both', 2, A, 2, out, scale ); // $ExpectError + dgebal( {}, 'both', 2, A, 2, out, scale ); // $ExpectError + dgebal( ( x: number ): number => x, 'both', 2, A, 2, out, scale ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal( 'row-major', 5, 2, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', true, 2, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', false, 2, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', null, 2, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', void 0, 2, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', [], 2, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', {}, 2, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', ( x: number ): number => x, 2, A, 2, out, scale ); // $ExpectError +} + + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal( 'row-major', 'both', '5', A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', true, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', false, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', null, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', void 0, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', [], A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', {}, A, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', ( x: number ): number => x, A, 2, out, scale ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal( 'row-major', 'both', 2, '5', 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, 5, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, true, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, false, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, null, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, void 0, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, [], 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, {}, 2, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, ( x: number ): number => x, 2, out, scale ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + dgebal( 'row-major', 'both', 2, A, '5', out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, true, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, false, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, null, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, void 0, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, [], out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, {}, out, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, ( x: number ): number => x, out, scale ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Int32Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const scale = new Float64Array( 2 ); + + dgebal( 'row-major', 'both', 2, A, 2, '5', scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, true, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, false, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, null, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, void 0, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, [], scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, {}, scale ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, ( x: number ): number => x, scale ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + + dgebal( 'row-major', 'both', 2, A, 2, out, '5' ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out, true ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out, false ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out, null ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out, void 0 ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out, [] ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out, {} ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal(); // $ExpectError + dgebal( 'row-major' ); // $ExpectError + dgebal( 'row-major', 'both' ); // $ExpectError + dgebal( 'row-major', 'both', 2 ); // $ExpectError + dgebal( 'row-major', 'both', 2, A ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2 ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out ); // $ExpectError + dgebal( 'row-major', 'both', 2, A, 2, out, scale, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 5, 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( true, 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( false, 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( null, 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( void 0, 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( [], 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( {}, 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( ( x: number ): number => x, 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', '5', A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', true, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', false, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', null, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', void 0, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', [], A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', {}, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', ( x: number ): number => x, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, '5', 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, true, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, false, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, null, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, void 0, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, [], 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, {}, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, ( x: number ): number => x, 2, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, '5', 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, true, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, false, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, null, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, void 0, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, [], 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, {}, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, ( x: number ): number => x, 1, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, '5', 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, true, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, false, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, null, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, void 0, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, [], 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, {}, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, ( x: number ): number => x, 0, out, 1, 0, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, 1, '5', out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, true, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, false, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, null, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, void 0, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, [], out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, {}, out, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, ( x: number ): number => x, out, 1, 0, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Int32Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, 1, 0, '5', 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, 5, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, true, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, false, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, null, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, void 0, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, [], 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, {}, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Int32Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, 1, 0, '5', 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, 5, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, true, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, false, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, null, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, void 0, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, [], 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, {}, 1, 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, ( x: number ): number => x, 1, 0, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, '5', scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, true, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, false, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, null, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, void 0, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, [], scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, {}, scale, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, ( x: number ): number => x, scale, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, '5', 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, 5, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, true, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, false, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, null, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, void 0, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, [], 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, {}, 1, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 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 A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, '5', 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, true, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, false, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, null, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, void 0, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, [], 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, {}, 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, ( 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 A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, '5' ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, true ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, false ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, null ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, void 0 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, [] ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, {} ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const out = new Int32Array( 2 ); + const scale = new Float64Array( 2 ); + + dgebal.ndarray(); // $ExpectError + dgebal.ndarray( 'none' ); // $ExpectError + dgebal.ndarray( 'permute', 2 ); // $ExpectError + dgebal.ndarray( 'scale', 2, A ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2 ); // $ExpectError + dgebal.ndarray( 'none', 2, A, 2, 1 ); // $ExpectError + dgebal.ndarray( 'permute', 2, A, 2, 1, 0 ); // $ExpectError + dgebal.ndarray( 'scale', 2, A, 2, 1, 0, out ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1 ); // $ExpectError + dgebal.ndarray( 'none', 2, A, 2, 1, 0, out, 1, 0 ); // $ExpectError + dgebal.ndarray( 'permute', 2, A, 2, 1, 0, out, 1, 0, scale ); // $ExpectError + dgebal.ndarray( 'scale', 2, A, 2, 1, 0, out, 1, 0, scale, 1 ); // $ExpectError + dgebal.ndarray( 'both', 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dgebal/examples/index.js new file mode 100644 index 000000000000..30eeefb8a3c6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/examples/index.js @@ -0,0 +1,45 @@ +/** +* @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 Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgebal = require( './../lib' ); + +// Specify matrix meta data: +var shape = [ 3, 3 ]; +var strides = [ 3, 1 ]; +var offset = 0; +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +// Define arrays to store the scaling factors +var out = new Int32Array( 2 ); +var scale = new Float64Array( 3 ); + +// Permute and scale the matrix: +dgebal( order, 'both', shape[ 0 ], A, strides[ 0 ], out, scale ); + +console.log( ndarray2array( A, shape, strides, offset, order ) ); +console.log( out ); +console.log( scale ); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/base.js new file mode 100644 index 000000000000..b213282f54d4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/base.js @@ -0,0 +1,351 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params, max-statements, max-lines-per-function */ + +'use strict'; + +// MODULES // + +var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; +var dlamch = require( '@stdlib/lapack/base/dlamch' ); +var dnrm2 = require( '@stdlib/blas/base/dnrm2' ).ndarray; +var idamax = require( '@stdlib/blas/base/idamax' ).ndarray; +var abs = require( '@stdlib/math/base/special/abs' ); +var isnan = require( '@stdlib/assert/is-nan' ); +var max = require( '@stdlib/math/base/special/maxn' ); +var min = require( '@stdlib/math/base/special/minn' ); +var dscal = require( '@stdlib/blas/base/dscal' ).ndarray; + + +// VARIABLES // + +var sclfac = 2.0; +var factor = 0.95; + + +// MAIN // + +/** +* Balances a general real matrix `A`. +* +* ## Notes +* +* The job parameter can be one of the following: +* +* - 'none': none, return immediately +* - 'permute': permute only +* - 'scale': scale only +* - 'both': both permute and scale +* +* The matrix `A` is overwritten by the balanced matrix. Scale factors are stored in the `scale` array. If `P[ j ]` is the index of the row and column interchanged with row and column j (zero-based) and `D[ j ]` is the scaling factor applied to row and column j, then: +* +* - `scale[ j ]` = `P[ j ]` for j = `0`,...,`out[ 0 ]-1` +* - `scale[ j ]` = `D[ j ]` for j = `out[ 0 ]`,...,`out[ 1 ]` +* - `scale[ j ]` = `P[ j ]` for j = `out[ 1 ]+1`,...,`N-1`. +* +* The order in which the interchanges are made is `N-1` to `out[ 1 ]+1`, then `0` to `out[ 0 ]-1`. +* +* @private +* @param {string} job - indicates the operations to be performed +* @param {NonNegativeInteger} N - number of rows/columns in matrix `A` +* @param {Float64Array} A - input matrix to be balanced +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Int32Array} out - stores the first and last row/column of the balanced submatrix +* @param {integer} strideOut - stride of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @param {Float64Array} scale - array containing permutation and scaling information +* @param {integer} strideScale - stride of `scale` +* @param {NonNegativeInteger} offsetScale - starting index for `scale` +* @throws {RangeError} should not return NaN +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var out = new Int32Array( 2 ); +* var scale = new Float64Array( 3 ); +* +* dgebal( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); +* // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] +* // out => [ 0, 1 ] +* // scale => [ 8, 1, 2 ] +*/ +function dgebal( job, N, A, strideA1, strideA2, offsetA, out, strideOut, offsetOut, scale, strideScale, offsetScale ) { + var canSwap; + var noconv; + var sfmin1; + var sfmin2; + var sfmax1; + var sfmax2; + var ica; + var ira; + var ia1; + var ia2; + var ia3; + var ia4; + var ca; + var ra; + var is; + var c; + var r; + var k; + var l; + var i; + var j; + var g; + var f; + var s; + + // Quick return if possible + if ( N === 0 ) { + out[ offsetOut ] = 0.0; // ilo + out[ offsetOut + strideOut ] = -1.0; // ihi (invalid) + return 0; + } + + if ( job === 'none' ) { + is = offsetScale; + for ( i = 0; i < N; i++ ) { + scale[ is ] = 1.0; + is += strideScale; + } + + out[ offsetOut ] = 0.0; // ilo + out[ offsetOut + strideOut ] = N - 1; // ihi + return 0; + } + + // Permutation to isolate eigenvalues if possible + k = 0; + l = N - 1; + + if ( job !== 'scale' ) { + // Row and column exchange + noconv = true; + while ( noconv ) { + // Search for rows isolating an eigenvalue and push them down + noconv = false; + + is = offsetScale + ( l * strideScale ); // Follows scale + ia1 = offsetA + ( l * strideA2 ); // Follows `i`th column of A + ia2 = offsetA + ( l * strideA2 ); // Follows `l`th column of A + ia3 = offsetA + (l*strideA1) + (k*strideA2); // Follows `i`th row of A + ia4 = offsetA + (l*strideA1) + (k*strideA2); // Follows `l`th row of A + + for ( i = l; i >= 0; i-- ) { + canSwap = true; + for ( j = 0; j <= l; j++ ) { + if ( i !== j && A[ offsetA + (i*strideA1) + (j*strideA2) ] !== 0.0 ) { + canSwap = false; + break; + } + } + + if ( canSwap ) { + scale[ is ] = i; + if ( i !== l ) { + dswap( l+1, A, strideA1, ia1, A, strideA1, ia2 ); + dswap( N - k, A, strideA2, ia3, A, strideA2, ia4 ); + } + noconv = true; + + // Check if remaining submatrix is empty and return + if ( l === 0.0 ) { + out[ offsetOut ] = 0.0; // ilo + out[ offsetOut + strideOut ] = 0.0; // ihi + return 0; + } + l -= 1; + + is -= strideScale; + ia2 -= strideA2; + ia4 -= strideA1; + } + + ia1 -= strideA2; + ia3 -= strideA1; + } + } + + noconv = true; + while ( noconv ) { + // Search for columns isolating an eigenvalue and push them left + noconv = false; + is = offsetScale + ( k * strideScale ); // Follows scale + ia1 = offsetA + ( k * strideA2 ); // Follows `j`th column of A + ia2 = offsetA + ( k * strideA2 ); // Follows `k`th column of A + ia3 = offsetA + ( k * strideA1 ); // Follows `j`th row of A + ia4 = offsetA + ( k * strideA1 ); // Follows `k`th row of A + + for ( j = k; j <= l; j++ ) { + canSwap = true; + for ( i = k; i <= l; i++ ) { + if ( i !== j && A[ offsetA + (i*strideA1) + (j*strideA2) ] !== 0.0 ) { + canSwap = false; + break; + } + } + + if ( canSwap ) { + scale[ is ] = j; + if ( j !== k ) { + dswap( l+1, A, strideA1, ia1, A, strideA1, ia2 ); + dswap( N-k, A, strideA2, ia3, A, strideA2, ia4 ); + } + noconv = true; + k += 1; + + is += strideScale; + ia2 += strideA2; + ia4 += strideA1; + } + + ia1 += strideA2; + ia3 += strideA1; + } + } + } + + // Initialize scale for non-permuted submatrix + is = offsetScale + ( k * strideScale ); + for ( i = k; i <= l; i++ ) { + scale[ is ] = 1.0; + is += strideScale; + } + + if ( job === 'permute' ) { + out[ offsetOut ] = k; // ilo + out[ offsetOut + strideOut ] = l; // ihi + return 0; + } + + // Balance the submatrix in rows K to L, iterative loop for norm reduction (job = 'B') + sfmin1 = dlamch( 'S' ) / dlamch( 'P' ); + sfmax1 = 1.0 / sfmin1; + sfmin2 = sfmin1 * sclfac; + sfmax2 = 1.0 / sfmin2; + + noconv = true; + while ( noconv ) { + is = offsetScale + ( k * strideScale ); // Follows scale + ia1 = offsetA + ( k * strideA1 ) + ( k * strideA2 ); // Follows A[ k, i ] + ia2 = offsetA + ( k * strideA1 ) + ( k * strideA2 ); // Follows A[ i, k ] + ia3 = offsetA + ( k * strideA2 ); // follows `i`th column of A + + noconv = false; + for ( i = k; i <= l; i++ ) { + c = dnrm2( l-k+1, A, strideA1, ia1 ); + r = dnrm2( l-k+1, A, strideA2, ia2 ); + ica = idamax( l+1, A, strideA1, ia3 ); + ca = abs( A[ offsetA + (ica*strideA1) + (i*strideA2) ] ); + ira = idamax( N-k+1, A, strideA2, ia2 ); + ra = abs( A[ offsetA + (i*strideA1) + ((ira+k)*strideA2) ] ); + + if ( c === 0.0 || r === 0.0 ) { + ia1 += strideA2; + ia2 += strideA1; + is += strideScale; + ia3 += strideA2; + continue; + } + + if ( isnan( c ) || isnan( r ) || isnan( ca ) || isnan( ra ) ) { + throw new RangeError( 'should not return NaN' ); + } + + g = r / sclfac; + f = 1.0; + s = c + r; + + while ( c < g && max( f, c, ca ) < sfmax2 && min( r, g, ra ) > sfmin2 ) { + f *= sclfac; + c *= sclfac; + ca *= sclfac; + r /= sclfac; + g /= sclfac; + ra /= sclfac; + } + + g = c / sclfac; + + while ( g >= r && max( r, ra ) < sfmax2 && min( f, c, g, ca ) > sfmin2 ) { + f /= sclfac; + c /= sclfac; + g /= sclfac; + ca /= sclfac; + r *= sclfac; + ra *= sclfac; + } + + // Now balance + if ( ( c + r ) >= factor * s ) { + ia1 += strideA2; + ia2 += strideA1; + is += strideScale; + ia3 += strideA2; + continue; + } + + if ( f < 1.0 && scale[ is ] < 1.0 ) { + if ( f * scale[ is ] <= sfmin1 ) { + ia1 += strideA2; + ia2 += strideA1; + is += strideScale; + ia3 += strideA2; + continue; + } + } + + if ( f > 1.0 && scale[ is ] > 1.0 ) { + if ( scale[ is ] >= sfmax1 / f ) { + ia1 += strideA2; + ia2 += strideA1; + is += strideScale; + ia3 += strideA2; + continue; + } + } + + g = 1.0 / f; + scale[ is ] *= f; + noconv = true; + + dscal( N-k, g, A, strideA2, ia2 ); + dscal( l+1, f, A, strideA1, ia3 ); + + ia1 += strideA2; + ia2 += strideA1; + is += strideScale; + ia3 += strideA2; + } + } + + out[ offsetOut ] = k; // ilo + out[ offsetOut + strideOut ] = l; // ihi + return 0; +} + + +// EXPORTS // + +module.exports = dgebal; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/lib/dgebal.js b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/dgebal.js new file mode 100644 index 000000000000..db716fd51dc2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/dgebal.js @@ -0,0 +1,105 @@ +/** +* @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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var format = require( '@stdlib/string/format' ); +var isJob = require( './isjob.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Balances a general real matrix `A`. +* +* ## Notes +* +* The job parameter can be one of the following: +* +* - 'none': none, return immediately +* - 'permute': permute only +* - 'scale': scale only +* - 'both': both permute and scale +* +* The matrix `A` is overwritten by the balanced matrix. Scale factors are stored in the `scale` array. If `P[ j ]` is the index of the row and column interchanged with row and column j (zero-based) and `D[ j ]` is the scaling factor applied to row and column j, then: +* +* - `scale[ j ]` = `P[ j ]` for j = `0`,...,`out[ 0 ]-1` +* - `scale[ j ]` = `D[ j ]` for j = `out[ 0 ]`,...,`out[ 1 ]` +* - `scale[ j ]` = `P[ j ]` for j = `out[ 1 ]+1`,...,`N-1`. +* +* The order in which the interchanges are made is `N-1` to `out[ 1 ]+1`, then `0` to `out[ 0 ]-1`. +* +* @private +* @param {string} order - storage layout of `A` +* @param {string} job - indicates the operations to be performed +* @param {NonNegativeInteger} N - number of rows/columns in matrix `A` +* @param {Float64Array} A - input matrix to be balanced +* @param {NonNegativeInteger} LDA - leading dimension of `A` +* @param {Int32Array} out - stores the first and last row/column of the balanced submatrix +* @param {Float64Array} scale - array containing permutation and scaling information +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be a valid job +* @throws {RangeError} fifth argument must be greater than or equal to `N` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var out = new Int32Array( 2 ); +* var scale = new Float64Array( 3 ); +* +* dgebal( 'row-major', 'both', 3, A, 3, out, scale ); +* // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] +* // out => [ 0, 1 ] +* // scale => [ 8, 1, 2 ] +*/ +function dgebal( order, job, N, A, LDA, out, scale ) { + var sa1; + var sa2; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isJob( job ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be one of the following: `both`, `scale`, `permute`, or `none`. Value: `%s`.', job ) ); + } + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + if ( LDA < N ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to %d. Value: `%d`.', N, LDA ) ); + } + sa1 = LDA; + sa2 = 1; + } + + return base( job, N, A, sa1, sa2, 0, out, 1, 0, scale, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dgebal; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/index.js new file mode 100644 index 000000000000..313d8d886867 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/index.js @@ -0,0 +1,78 @@ +/** +* @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 balance a general real matrix `A`. +* +* @module @stdlib/lapack/base/dgebal +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgebal = require( '@stdlib/lapack/base/dgebal' ); +* +* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var out = new Int32Array( 2 ); +* var scale = new Float64Array( 3 ); +* +* dgebal( 'row-major', 'both', 3, A, 3, out, scale ); +* // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] +* // out => [ 0, 1 ] +* // scale => [ 8, 1, 2 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dgebal = require( '@stdlib/lapack/base/dgebal' ); +* +* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var out = new Int32Array( 2 ); +* var scale = new Float64Array( 3 ); +* +* dgebal.ndarray( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); +* // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] +* // out => [ 0, 1 ] +* // scale => [ 8, 1, 2 ] +*/ + +// 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 dgebal; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dgebal = main; +} else { + dgebal = tmp; +} + + +// EXPORTS // + +module.exports = dgebal; + +// exports: { "ndarray": "dgebal.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/lib/isjob.js b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/isjob.js new file mode 100644 index 000000000000..fd4ffa0500d3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/isjob.js @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var contains = require( '@stdlib/array/base/assert/contains' ).factory; + + +// VARIABLES // + +var JOBS = [ 'none', 'permute', 'scale', 'both' ]; + + +// MAIN // + +/** +* Tests whether an input value is a supported job. +* +* @name isJob +* @type {Function} +* @param {*} v - value to test +* @returns {boolean} boolean indicating whether an input value is a supported job +* +* @example +* var bool = isJob( 'both' ); +* // returns true +* +* bool = isJob( 'none' ); +* // returns true +* +* bool = isJob( 'permute' ); +* // returns true +* +* bool = isJob( 'scale' ); +* // returns true +* +* bool = isJob( 'foo' ); +* // returns false +*/ +var isJob = contains( JOBS ); + + +// EXPORTS // + +module.exports = isJob; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/main.js new file mode 100644 index 000000000000..b9c15110c92a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/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 dgebal = require( './dgebal.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dgebal, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgebal; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/ndarray.js new file mode 100644 index 000000000000..b6916760c151 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/lib/ndarray.js @@ -0,0 +1,89 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var isJob = require( './isjob.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Balances a general real matrix `A` using alternative indexing semantics. +* +* ## Notes +* +* The job parameter can be one of the following: +* +* - 'none': none, return immediately +* - 'permute': permute only +* - 'scale': scale only +* - 'both': both permute and scale +* +* The matrix `A` is overwritten by the balanced matrix. Scale factors are stored in the `scale` array. If `P[ j ]` is the index of the row and column interchanged with row and column j (zero-based) and `D[ j ]` is the scaling factor applied to row and column j, then: +* +* - `scale[ j ]` = `P[ j ]` for j = `0`,...,`out[ 0 ]-1` +* - `scale[ j ]` = `D[ j ]` for j = `out[ 0 ]`,...,`out[ 1 ]` +* - `scale[ j ]` = `P[ j ]` for j = `out[ 1 ]+1`,...,`N-1`. +* +* The order in which the interchanges are made is `N-1` to `out[ 1 ]+1`, then `0` to `out[ 0 ]-1`. +* +* @private +* @param {string} job - indicates the operations to be performed +* @param {NonNegativeInteger} N - number of rows/columns in matrix `A` +* @param {Float64Array} A - input matrix to be balanced +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Int32Array} out - stores the first and last row/column of the balanced submatrix +* @param {integer} strideOut - stride of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @param {Float64Array} scale - array containing permutation and scaling information +* @param {integer} strideScale - stride of `scale` +* @param {NonNegativeInteger} offsetScale - starting index for `scale` +* @throws {TypeError} second argument must be a valid job +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var A = new Float64Array( [ 1.0, 100.0, 0.0, 2.0, 200.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var out = new Int32Array( 2 ); +* var scale = new Float64Array( 3 ); +* +* dgebal( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); +* // A => [ 1, 12.5, 0, 16, 200, 0, 0, 0, 3 ] +* // out => [ 0, 1 ] +* // scale => [ 8, 1, 2 ] +*/ +function dgebal( job, N, A, strideA1, strideA2, offsetA, out, strideOut, offsetOut, scale, strideScale, offsetScale ) { // eslint-disable-line max-len, max-params + if ( !isJob( job ) ) { + throw new TypeError( format( 'invalid argument. First argument must be one of the following: `both`, `scale`, `permute`, or `none`. Value: `%s`.', job ) ); + } + return base( job, N, A, strideA1, strideA2, offsetA, out, strideOut, offsetOut, scale, strideScale, offsetScale ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dgebal; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/package.json b/lib/node_modules/@stdlib/lapack/base/dgebal/package.json new file mode 100644 index 000000000000..2287d2b86653 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/lapack/base/dgebal", + "version": "0.0.0", + "description": "LAPACK routine to balance a general real matrix `A`.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "lapack", + "dgebal", + "balance", + "scale", + "permute", + "permutedims", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/test/test.dgebal.js b/lib/node_modules/@stdlib/lapack/base/dgebal/test/test.dgebal.js new file mode 100644 index 000000000000..1da6a69f0938 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/test/test.dgebal.js @@ -0,0 +1,748 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable array-element-newline */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgebal = require( './../lib/dgebal.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgebal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dgebal.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var scale; + var out; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = new Int32Array( 2 ); + scale = 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() { + dgebal( value, 'both', 2, A, 2, out, scale ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var scale; + var out; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = new Int32Array( 2 ); + scale = 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() { + dgebal( 'row-major', value, 2, A, 2, out, scale ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var scale; + var out; + var A; + var i; + + values = [ + 0, + 1 + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = new Int32Array( 2 ); + scale = 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() { + dgebal( 'row-major', 'both', 2, A, value, out, scale ); + }; + } +}); + +tape( 'the function returns invalid indices and leaves the input array unchanged for N = 0', function test( t ) { + var expectedOut; + var scale; + var info; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = new Int32Array( 2 ); + scale = new Float64Array( 2 ); + + info = dgebal( 'row-major', 'both', 0, A, 2, out, scale ); + + expectedOut = new Int32Array( [ 0, -1 ] ); + + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + ]); + + info = dgebal( 'row-major', 'none', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 4.0, 7.0, + 2.0, 5.0, 8.0, + 3.0, 6.0, 9.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 4.0, 7.0, + 2.0, 5.0, 8.0, + 3.0, 6.0, 9.0 + ]); + + info = dgebal( 'column-major', 'none', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 2.0, + 0.0, 5.0, 0.0, + 3.0, 0.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 2.0, 0.0, + 3.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'row-major', 'permute', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 3.0, + 0.0, 5.0, 0.0, + 2.0, 0.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 3.0, 0.0, + 2.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'column-major', 'permute', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 16.0, 16.0, 16.0, + 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.125, 0.125 ] ); + expectedA = new Float64Array([ + 16.0, 2.0, 2.0, + 2.0, 0.25, 0.25, + 2.0, 0.25, 0.25 + ]); + + info = dgebal( 'row-major', 'scale', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 16.0, 0.25, 0.25, + 16.0, 0.25, 0.25, + 16.0, 0.25, 0.25 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.125, 0.125 ] ); + expectedA = new Float64Array([ + 16.0, 2.0, 2.0, + 2.0, 0.25, 0.25, + 2.0, 0.25, 0.25 + ]); + + info = dgebal( 'column-major', 'scale', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 2.0, + 0.0, 5.0, 0.0, + 100.0, 0.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 0.125, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 16.0, 0.0, + 12.5, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'row-major', 'both', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 100.0, + 0.0, 5.0, 0.0, + 2.0, 0.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 0.125, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 12.5, 0.0, + 16.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'column-major', 'both', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 1.0, 0.0, + 0.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 0.0, 1.0, 2.0 ] ); + expectedA = new Float64Array([ + 1.0, 1.0, 0.0, + 0.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + + info = dgebal( 'row-major', 'both', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 0.0, + 1.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 0.0, 1.0, 2.0 ] ); + expectedA = new Float64Array([ + 1.0, 0.0, 0.0, + 1.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + + info = dgebal( 'column-major', 'both', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 2.0, + 3.0, 4.0, 5.0, + 6.0, 0.0, 7.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 4.0, 1.5, 5.0, + 0.0, 1.0, 4.0, + 0.0, 3.0, 7.0 + ]); + + info = dgebal( 'row-major', 'both', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 3.0, 6.0, + 0.0, 4.0, 0.0, + 2.0, 5.0, 7.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 4.0, 0.0, 0.0, + 1.5, 1.0, 3.0, + 5.0, 4.0, 7.0 + ]); + + info = dgebal( 'column-major', 'both', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 4.0, + 2.0, 0.0, 5.0, + 3.0, 0.0, 6.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 0.0, 4.0, + 2.0, 0.0, 5.0, + 3.0, 0.0, 6.0 + ]); + + info = dgebal( 'row-major', 'scale', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 2.0, 3.0, + 0.0, 0.0, 0.0, + 4.0, 5.0, 6.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 2.0, 3.0, + 0.0, 0.0, 0.0, + 4.0, 5.0, 6.0 + ]); + + info = dgebal( 'column-major', 'scale', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with small values (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0e-4, 1.0, 2.0, 1.0e4, + 2.0e-4, 1.0, 2.0, 2.0e4, + 3.0e-4, 1.0, 2.0, 3.0e4, + 4.0e-4, 1.0, 2.0, 4.0e4 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 4 ); + + expectedOut = new Int32Array( [ 0.0, 3.0 ] ); + expectedScale = new Float64Array( [ 4096.0, 128.0, 128.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0e-4, 3.125e-2, 6.25e-2, 2.44140625, + 6.4e-3, 1.0, 2.0, 1.5625e2, + 9.6e-3, 1.0, 2.0, 2.34375e2, + 1.6384, 1.28e2, 2.56e2, 4.0e4 + ]); + + info = dgebal( 'row-major', 'scale', 4, A, 4, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with small values (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0e-4, 2.0e-4, 3.0e-4, 4.0e-4, + 1.0, 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0, 2.0, + 1.0e4, 2.0e4, 3.0e4, 4.0e4 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 4 ); + + expectedOut = new Int32Array( [ 0.0, 3.0 ] ); + expectedScale = new Float64Array( [ 4096.0, 128.0, 128.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0e-4, 6.4e-3, 9.6e-3, 1.6384, + 3.125e-2, 1.0, 1.0, 1.28e2, + 6.25e-2, 2.0, 2.0, 2.56e2, + 2.44140625, 1.5625e2, 2.34375e2, 4.0e4 + ]); + + info = dgebal( 'column-major', 'scale', 4, A, 4, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with large values (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0e30, 1.0, 1.0e-30, + 1.0e30, 1.0, 1.0e-30, + 1.0e30, 1.0, 1.0e-30 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1125899906842624.0, 1.2676506002282294e30 ] ); // eslint-disable-line max-len + expectedA = new Float64Array([ + 1.0e30, 1.1258999068426240e15, 1.2676506002282295, + 8.8817841970012525e14, 1.0, 1.1258999068426241e-15, + 7.8886090522101182e-1, 8.8817841970012523e-16, 1.0e-30 + ]); + + info = dgebal( 'row-major', 'both', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with large values (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0e30, 1.0e30, 1.0e30, + 1.0, 1.0, 1.0, + 1.0e-30, 1.0e-30, 1.0e-30 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1125899906842624.0, 1.2676506002282294e30 ] ); // eslint-disable-line max-len + expectedA = new Float64Array([ + 1.0e30, 8.8817841970012525e14, 7.8886090522101182e-1, + 1.1258999068426240e15, 1.0, 8.8817841970012523e-16, + 1.2676506002282295, 1.1258999068426241e-15, 1.0e-30 + ]); + + info = dgebal( 'column-major', 'both', 3, A, 3, out, scale ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgebal/test/test.js new file mode 100644 index 000000000000..f22291acb9fc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/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 dgebal = 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 dgebal, '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 dgebal.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 dgebal = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgebal, 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 dgebal; + var main; + + main = require( './../lib/dgebal.js' ); + + dgebal = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgebal, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebal/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgebal/test/test.ndarray.js new file mode 100644 index 000000000000..86e20a5b6ed9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebal/test/test.ndarray.js @@ -0,0 +1,2748 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable array-element-newline, max-lines */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgebal = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgebal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( dgebal.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var scale; + var out; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = new Int32Array( 2 ); + scale = 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() { + dgebal( value, 2, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); + }; + } +}); + +tape( 'the function returns invalid indices and leaves the input array unchanged for N = 0', function test( t ) { + var expectedOut; + var scale; + var info; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = new Int32Array( 2 ); + scale = new Float64Array( 2 ); + + info = dgebal( 'both', 0, A, 2, 1, 0, out, 1, 0, scale, 1, 0 ); + + expectedOut = new Int32Array( [ 0, -1 ] ); + + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + ]); + + info = dgebal( 'none', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 4.0, 7.0, + 2.0, 5.0, 8.0, + 3.0, 6.0, 9.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 4.0, 7.0, + 2.0, 5.0, 8.0, + 3.0, 6.0, 9.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 2.0, + 0.0, 5.0, 0.0, + 3.0, 0.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 2.0, 0.0, + 3.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'permute', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 3.0, + 0.0, 5.0, 0.0, + 2.0, 0.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 3.0, 0.0, + 2.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 16.0, 16.0, 16.0, + 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.125, 0.125 ] ); + expectedA = new Float64Array([ + 16.0, 2.0, 2.0, + 2.0, 0.25, 0.25, + 2.0, 0.25, 0.25 + ]); + + info = dgebal( 'scale', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 16.0, 0.25, 0.25, + 16.0, 0.25, 0.25, + 16.0, 0.25, 0.25 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.125, 0.125 ] ); + expectedA = new Float64Array([ + 16.0, 2.0, 2.0, + 2.0, 0.25, 0.25, + 2.0, 0.25, 0.25 + ]); + + info = dgebal( 'scale', 3, A, 1, 3, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 2.0, + 0.0, 5.0, 0.0, + 100.0, 0.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 0.125, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 16.0, 0.0, + 12.5, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 100.0, + 0.0, 5.0, 0.0, + 2.0, 0.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 0.125, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 12.5, 0.0, + 16.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 0, out, 1, 0, scale, 1, 0 ); + + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 1.0, 0.0, + 0.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 0.0, 1.0, 2.0 ] ); + expectedA = new Float64Array([ + 1.0, 1.0, 0.0, + 0.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + + info = dgebal( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 0.0, + 1.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 0.0, 1.0, 2.0 ] ); + expectedA = new Float64Array([ + 1.0, 0.0, 0.0, + 1.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 2.0, + 3.0, 4.0, 5.0, + 6.0, 0.0, 7.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 4.0, 1.5, 5.0, + 0.0, 1.0, 4.0, + 0.0, 3.0, 7.0 + ]); + + info = dgebal( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 3.0, 6.0, + 0.0, 4.0, 0.0, + 2.0, 5.0, 7.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 4.0, 0.0, 0.0, + 1.5, 1.0, 3.0, + 5.0, 4.0, 7.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 0.0, 4.0, + 2.0, 0.0, 5.0, + 3.0, 0.0, 6.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 0.0, 4.0, + 2.0, 0.0, 5.0, + 3.0, 0.0, 6.0 + ]); + + info = dgebal( 'scale', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 2.0, 3.0, + 0.0, 0.0, 0.0, + 4.0, 5.0, 6.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 2.0, 3.0, + 0.0, 0.0, 0.0, + 4.0, 5.0, 6.0 + ]); + + info = dgebal( 'scale', 3, A, 1, 3, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with small values (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0e-4, 1.0, 2.0, 1.0e4, + 2.0e-4, 1.0, 2.0, 2.0e4, + 3.0e-4, 1.0, 2.0, 3.0e4, + 4.0e-4, 1.0, 2.0, 4.0e4 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 4 ); + + expectedOut = new Int32Array( [ 0, 3 ] ); + expectedScale = new Float64Array( [ 4096.0, 128.0, 128.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0e-4, 3.125e-2, 6.25e-2, 2.44140625, + 6.4e-3, 1.0, 2.0, 1.5625e2, + 9.6e-3, 1.0, 2.0, 2.34375e2, + 1.6384, 1.28e2, 2.56e2, 4.0e4 + ]); + + info = dgebal( 'scale', 4, A, 4, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with small values (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0e-4, 2.0e-4, 3.0e-4, 4.0e-4, + 1.0, 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0, 2.0, + 1.0e4, 2.0e4, 3.0e4, 4.0e4 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 4 ); + + expectedOut = new Int32Array( [ 0, 3 ] ); + expectedScale = new Float64Array( [ 4096.0, 128.0, 128.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0e-4, 6.4e-3, 9.6e-3, 1.6384, + 3.125e-2, 1.0, 1.0, 1.28e2, + 6.25e-2, 2.0, 2.0, 2.56e2, + 2.44140625, 1.5625e2, 2.34375e2, 4.0e4 + ]); + + info = dgebal( 'scale', 4, A, 1, 4, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with large values (row-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0e30, 1.0, 1.0e-30, + 1.0e30, 1.0, 1.0e-30, + 1.0e30, 1.0, 1.0e-30 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1125899906842624.0, 1.2676506002282294e30 ] ); // eslint-disable-line max-len + expectedA = new Float64Array([ + 1.0e30, 1.1258999068426240e15, 1.2676506002282295, + 8.8817841970012525e14, 1.0, 1.1258999068426241e-15, + 7.8886090522101182e-1, 8.8817841970012523e-16, 1.0e-30 + ]); + + info = dgebal( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with large values (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0e30, 1.0e30, 1.0e30, + 1.0, 1.0, 1.0, + 1.0e-30, 1.0e-30, 1.0e-30 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1125899906842624.0, 1.2676506002282294e30 ] ); // eslint-disable-line max-len + expectedA = new Float64Array([ + 1.0e30, 8.8817841970012525e14, 7.8886090522101182e-1, + 1.1258999068426240e15, 1.0, 8.8817841970012523e-16, + 1.2676506002282295, 1.1258999068426241e-15, 1.0e-30 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (row-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 9.0, 8.0, 7.0, + 6.0, 5.0, 4.0, + 3.0, 2.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 2, 0 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 9.0, 8.0, 7.0, + 6.0, 5.0, 4.0, + 3.0, 2.0, 1.0 + ]); + + info = dgebal( 'none', 3, A, -3, -1, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (column-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 9.0, 6.0, 3.0, + 8.0, 5.0, 2.0, + 7.0, 4.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 2, 0 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 9.0, 6.0, 3.0, + 8.0, 5.0, 2.0, + 7.0, 4.0, 1.0 + ]); + + info = dgebal( 'both', 3, A, -1, -3, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (row-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 4.0, 0.0, 3.0, + 0.0, 5.0, 0.0, + 2.0, 0.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + expectedA = new Float64Array([ + 5.0, 0.0, 0.0, + 0.0, 4.0, 3.0, + 0.0, 2.0, 1.0 + ]); + + info = dgebal( 'permute', 3, A, -3, -1, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (column-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 4.0, 0.0, 2.0, + 0.0, 5.0, 0.0, + 3.0, 0.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 5.0, 0.0, 0.0, + 0.0, 4.0, 2.0, + 0.0, 3.0, 1.0 + ]); + + info = dgebal( 'permute', 3, A, -1, -3, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (row-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 16.0, 16.0, 16.0, + 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25 + ]); + + A = new Float64Array([ + 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25, + 16.0, 16.0, 16.0 + ]); + + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 2, 0 ] ); + expectedScale = new Float64Array( [ 0.125, 0.125, 1.0 ] ); + expectedA = new Float64Array([ + 16.0, 2.0, 2.0, + 2.0, 0.25, 0.25, + 2.0, 0.25, 0.25 + ]); + + expectedA = new Float64Array([ + 0.25, 0.25, 2.0, + 0.25, 0.25, 2.0, + 2.0, 2.0, 16.0 + ]); + + info = dgebal( 'scale', 3, A, -3, -1, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (column-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.25, 0.25, 16.0, + 0.25, 0.25, 16.0, + 0.25, 0.25, 16.0 + ]); + + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 2, 0 ] ); + expectedScale = new Float64Array( [ 0.125, 0.125, 1.0 ] ); + expectedA = new Float64Array([ + 0.25, 0.25, 2.0, + 0.25, 0.25, 2.0, + 2.0, 2.0, 16.0 + ]); + + info = dgebal( 'scale', 3, A, -1, -3, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (row-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 4.0, 0.0, 100.0, + 0.0, 5.0, 0.0, + 2.0, 0.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 0.125 ] ); + + expectedA = new Float64Array([ + 5.0, 0.0, 0.0, + 0.0, 4.0, 12.5, + 0.0, 16.0, 1.0 + ]); + + info = dgebal( 'both', 3, A, -3, -1, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (column-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 4.0, 0.0, 2.0, + 0.0, 5.0, 0.0, + 100.0, 0.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 0.125 ] ); + expectedA = new Float64Array([ + 5.0, 0.0, 0.0, + 0.0, 4.0, 16.0, + 0.0, 12.5, 1.0 + ]); + + info = dgebal( 'both', 3, A, -1, -3, 8, out, -1, 1, scale, -1, 2 ); + + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 3.0, 0.0, 0.0, + 0.0, 2.0, 0.0, + 0.0, 1.0, 1.0 + ]); + + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 2.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 3.0, 0.0, 0.0, + 0.0, 2.0, 0.0, + 0.0, 1.0, 1.0 + ]); + + info = dgebal( 'both', 3, A, -3, -1, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 3.0, 0.0, 0.0, + 0.0, 2.0, 1.0, + 0.0, 0.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 2.0, 1.0, 0.0 ] ); + + expectedA = new Float64Array([ + 3.0, 0.0, 0.0, + 0.0, 2.0, 1.0, + 0.0, 0.0, 1.0 + ]); + + info = dgebal( 'both', 3, A, -1, -3, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 7.0, 0.0, 6.0, + 5.0, 4.0, 3.0, + 2.0, 0.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 2.0, 1.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 7.0, 3.0, 0.0, + 4.0, 1.0, 0.0, + 5.0, 1.5, 4.0 + ]); + info = dgebal( 'both', 3, A, -3, -1, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 7.0, 5.0, 2.0, + 0.0, 4.0, 0.0, + 6.0, 3.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 2.0, 1.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.5, 1.0 ] ); + + expectedA = new Float64Array([ + 7.0, 4.0, 5.0, + 3.0, 1.0, 1.5, + 0.0, 0.0, 4.0 + ]); + + info = dgebal( 'both', 3, A, -1, -3, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (row-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 6.0, 0.0, 3.0, + 5.0, 0.0, 2.0, + 4.0, 0.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 2, 0 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 6.0, 0.0, 3.0, + 5.0, 0.0, 2.0, + 4.0, 0.0, 1.0 + ]); + + info = dgebal( 'scale', 3, A, -3, -1, 8, out, -1, 1, scale, -1, 2 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (column-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 2.0, 3.0, + 0.0, 0.0, 0.0, + 4.0, 5.0, 6.0 + ]); + A = new Float64Array([ + 6.0, 5.0, 4.0, + 0.0, 0.0, 0.0, + 3.0, 2.0, 1.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 2, 0 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 1.0, 2.0, 3.0, + 0.0, 0.0, 0.0, + 4.0, 5.0, 6.0 + ]); + expectedA = new Float64Array([ + 6.0, 5.0, 4.0, + 0.0, 0.0, 0.0, + 3.0, 2.0, 1.0 + ]); + + info = dgebal( 'scale', 3, A, -1, -3, 8, out, -1, 1, scale, -1, 2 ); + + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with small values (row-major) (negative strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 4.0e4, 2.0, 1.0, 4.0e-4, + 3.0e4, 2.0, 1.0, 3.0e-4, + 2.0e4, 2.0, 1.0, 2.0e-4, + 1.0e4, 2.0, 1.0, 1.0e-4 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 4 ); + + expectedOut = new Int32Array( [ 3.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 128.0, 128.0, 4096.0 ] ); + expectedA = new Float64Array([ + 4.0e4, 2.56e2, 1.28e2, 1.6384, + 2.34375e2, 2.0, 1.0, 9.6e-3, + 1.5625e2, 2.0, 1.0, 6.4e-3, + 2.44140625, 6.25e-2, 3.125e-2, 1.0e-4 + ]); + + info = dgebal( 'scale', 4, A, -4, -1, 15, out, -1, 1, scale, -1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with small values (column-major)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 4.0e4, 3.0e4, 2.0e4, 1.0e4, + 2.0, 2.0, 2.0, 2.0, + 1.0, 1.0, 1.0, 1.0, + 4.0e-4, 3.0e-4, 2.0e-4, 1.0e-4 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 4 ); + + expectedOut = new Int32Array( [ 3.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 128.0, 128.0, 4096.0 ] ); + expectedA = new Float64Array([ + 4.0e4, 2.34375e2, 1.5625e2, 2.44140625, + 2.56e2, 2.0, 2.0, 6.25e-2, + 1.28e2, 1.0, 1.0, 3.125e-2, + 1.6384, 9.6e-3, 6.4e-3, 1.0e-4 + ]); + info = dgebal( 'scale', 4, A, -1, -4, 15, out, -1, 1, scale, -1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (row-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 2.0, 3.0, + 4.0, 5.0, 6.0, + 7.0, 8.0, 9.0 + ]); + + info = dgebal( 'none', 3, A, 3, 1, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (column-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 4.0, 7.0, + 2.0, 5.0, 8.0, + 3.0, 6.0, 9.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 4.0, 7.0, + 2.0, 5.0, 8.0, + 3.0, 6.0, 9.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (row-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 2.0, + 0.0, 5.0, 0.0, + 3.0, 0.0, 4.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 1.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 2.0, 0.0, + 3.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'permute', 3, A, 3, 1, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (column-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 3.0, + 0.0, 5.0, 0.0, + 2.0, 0.0, 4.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 1.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 3.0, 0.0, + 2.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (row-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 16.0, 16.0, 16.0, + 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.125, 0.125 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 16.0, 2.0, 2.0, + 2.0, 0.25, 0.25, + 2.0, 0.25, 0.25 + ]); + + info = dgebal( 'scale', 3, A, 3, 1, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (column-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 16.0, 0.25, 0.25, + 16.0, 0.25, 0.25, + 16.0, 0.25, 0.25 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.125, 0.125 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 16.0, 2.0, 2.0, + 2.0, 0.25, 0.25, + 2.0, 0.25, 0.25 + ]); + + info = dgebal( 'scale', 3, A, 1, 3, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (row-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 2.0, + 0.0, 5.0, 0.0, + 100.0, 0.0, 4.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 1.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 0.125, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 16.0, 0.0, + 12.5, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'both', 3, A, 3, 1, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (column-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 100.0, + 0.0, 5.0, 0.0, + 2.0, 0.0, 4.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 1.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 0.125, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 12.5, 0.0, + 16.0, 4.0, 0.0, + 0.0, 0.0, 5.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 2, out, 1, 1, scale, 1, 3 ); + + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 1.0, 0.0, + 0.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 0.0, 1.0, 2.0 ] ); + expectedA = new Float64Array([ + 1.0, 1.0, 0.0, + 0.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + + info = dgebal( 'both', 3, A, 3, 1, 0, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 0.0, + 1.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 0.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 0.0, + 1.0, 2.0, 0.0, + 0.0, 0.0, 3.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 2.0, + 3.0, 4.0, 5.0, + 6.0, 0.0, 7.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 1.0, 2.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 4.0, 1.5, 5.0, + 0.0, 1.0, 4.0, + 0.0, 3.0, 7.0 + ]); + + info = dgebal( 'both', 3, A, 3, 1, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 3.0, 6.0, + 0.0, 4.0, 0.0, + 2.0, 5.0, 7.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 1.0, 2.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 4.0, 0.0, 0.0, + 1.5, 1.0, 3.0, + 5.0, 4.0, 7.0 + ]); + + info = dgebal( 'both', 3, A, 1, 3, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (row-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 4.0, + 2.0, 0.0, 5.0, + 3.0, 0.0, 6.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 0.0, 4.0, + 2.0, 0.0, 5.0, + 3.0, 0.0, 6.0 + ]); + + info = dgebal( 'scale', 3, A, 3, 1, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (column-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0, 2.0, 3.0, + 0.0, 0.0, 0.0, + 4.0, 5.0, 6.0 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0, 2.0, 3.0, + 0.0, 0.0, 0.0, + 4.0, 5.0, 6.0 + ]); + + info = dgebal( 'scale', 3, A, 1, 3, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with small values (row-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0e-4, 1.0, 2.0, 1.0e4, + 2.0e-4, 1.0, 2.0, 2.0e4, + 3.0e-4, 1.0, 2.0, 3.0e4, + 4.0e-4, 1.0, 2.0, 4.0e4 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 7 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 3.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 4096.0, 128.0, 128.0, 1.0 ] ); // eslint-disable-line max-len + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0e-4, 3.125e-2, 6.25e-2, 2.44140625, + 6.4e-3, 1.0, 2.0, 1.5625e2, + 9.6e-3, 1.0, 2.0, 2.34375e2, + 1.6384, 1.28e2, 2.56e2, 4.0e4 + ]); + + info = dgebal( 'scale', 4, A, 4, 1, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with small values (column-major) (offsets)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, + 1.0e-4, 2.0e-4, 3.0e-4, 4.0e-4, + 1.0, 1.0, 1.0, 1.0, + 2.0, 2.0, 2.0, 2.0, + 1.0e4, 2.0e4, 3.0e4, 4.0e4 + ]); + out = new Int32Array( 3 ); + scale = new Float64Array( 7 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 3.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 0.0, 4096.0, 128.0, 128.0, 1.0 ] ); // eslint-disable-line max-len + expectedA = new Float64Array([ + 0.0, 0.0, + 1.0e-4, 6.4e-3, 9.6e-3, 1.6384, + 3.125e-2, 1.0, 1.0, 1.28e2, + 6.25e-2, 2.0, 2.0, 2.56e2, + 2.44140625, 1.5625e2, 2.34375e2, 4.0e4 + ]); + + info = dgebal( 'scale', 4, A, 1, 4, 2, out, 1, 1, scale, 1, 3 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (row-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 3.0, 2.0, 1.0, + 6.0, 5.0, 4.0, + 9.0, 8.0, 7.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + + expectedA = new Float64Array([ + 3.0, 2.0, 1.0, + 6.0, 5.0, 4.0, + 9.0, 8.0, 7.0 + ]); + + info = dgebal( 'none', 3, A, 3, -1, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (column-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 4.0, 7.0, + 2.0, 5.0, 8.0, + 3.0, 6.0, 9.0 + ]); + + A = new Float64Array([ + 7.0, 4.0, 1.0, + 8.0, 5.0, 2.0, + 9.0, 6.0, 3.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 7.0, 4.0, 1.0, + 8.0, 5.0, 2.0, + 9.0, 6.0, 3.0 + ]); + + info = dgebal( 'both', 3, A, -1, 3, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (row-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 2.0, 0.0, 1.0, + 0.0, 5.0, 0.0, + 4.0, 0.0, 3.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 2.0, 1.0, + 0.0, 4.0, 3.0, + 5.0, 0.0, 0.0 + ]); + + info = dgebal( 'permute', 3, A, 3, -1, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (column-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 3.0, 0.0, 1.0, + 0.0, 5.0, 0.0, + 4.0, 0.0, 2.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 3.0, 1.0, + 0.0, 4.0, 2.0, + 5.0, 0.0, 0.0 + ]); + info = dgebal( 'both', 3, A, -1, 3, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (row-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 16.0, 16.0, 16.0, + 0.25, 0.25, 0.25, + 0.25, 0.25, 0.25 + ]); + + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.125, 0.125 ] ); + expectedA = new Float64Array([ + 2.0, 2.0, 16.0, + 0.25, 0.25, 2.0, + 0.25, 0.25, 2.0 + ]); + + info = dgebal( 'scale', 3, A, 3, -1, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (column-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.25, 0.25, 16.0, + 0.25, 0.25, 16.0, + 0.25, 0.25, 16.0 + ]); + + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.125, 0.125 ] ); + expectedA = new Float64Array([ + 2.0, 2.0, 16.0, + 0.25, 0.25, 2.0, + 0.25, 0.25, 2.0 + ]); + + info = dgebal( 'scale', 3, A, -1, 3, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (row-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 2.0, 0.0, 1.0, + 0.0, 5.0, 0.0, + 4.0, 0.0, 100.0 + ]); + + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 0.125, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 16.0, 1.0, + 0.0, 4.0, 12.5, + 5.0, 0.0, 0.0 + ]); + + info = dgebal( 'both', 3, A, 3, -1, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (column-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 100.0, 0.0, 1.0, + 0.0, 5.0, 0.0, + 4.0, 0.0, 2.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 1 ] ); + expectedScale = new Float64Array( [ 0.125, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 12.5, 1.0, + 0.0, 4.0, 16.0, + 5.0, 0.0, 0.0 + ]); + info = dgebal( 'both', 3, A, -1, 3, 2, out, 1, 0, scale, 1, 0 ); + + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 1.0, 1.0, + 0.0, 2.0, 0.0, + 3.0, 0.0, 0.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 0.0, 1.0, 2.0 ] ); + expectedA = new Float64Array([ + 0.0, 1.0, 1.0, + 0.0, 2.0, 0.0, + 3.0, 0.0, 0.0 + ]); + + info = dgebal( 'both', 3, A, 3, -1, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 0.0, 0.0, 1.0, + 0.0, 2.0, 1.0, + 3.0, 0.0, 0.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 0 ] ); + expectedScale = new Float64Array( [ 0.0, 1.0, 2.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, 1.0, + 0.0, 2.0, 1.0, + 3.0, 0.0, 0.0 + ]); + + info = dgebal( 'both', 3, A, -1, 3, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 2.0, 0.0, 1.0, + 5.0, 4.0, 3.0, + 7.0, 0.0, 6.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 5.0, 1.5, 4.0, + 4.0, 1.0, 0.0, + 7.0, 3.0, 0.0 + ]); + + info = dgebal( 'both', 3, A, 3, -1, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 6.0, 3.0, 1.0, + 0.0, 4.0, 0.0, + 7.0, 5.0, 2.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 1, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 0.5, 1.0 ] ); + expectedA = new Float64Array([ + 0.0, 0.0, 4.0, + 3.0, 1.0, 1.5, + 7.0, 4.0, 5.0 + ]); + info = dgebal( 'both', 3, A, -1, 3, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (row-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 4.0, 0.0, 1.0, + 5.0, 0.0, 2.0, + 6.0, 0.0, 3.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 4.0, 0.0, 1.0, + 5.0, 0.0, 2.0, + 6.0, 0.0, 3.0 + ]); + + info = dgebal( 'scale', 3, A, 3, -1, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (column-major) (mixed strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 3.0, 2.0, 1.0, + 0.0, 0.0, 0.0, + 6.0, 5.0, 4.0 + ]); + out = new Int32Array( 2 ); + scale = new Float64Array( 3 ); + + expectedOut = new Int32Array( [ 0, 2 ] ); + expectedScale = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + expectedA = new Float64Array([ + 3.0, 2.0, 1.0, + 0.0, 0.0, 0.0, + 6.0, 5.0, 4.0 + ]); + + info = dgebal( 'scale', 3, A, -1, 3, 2, out, 1, 0, scale, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (row-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 2.0, 9999.0, 3.0, 9999.0, + 4.0, 9999.0, 5.0, 9999.0, 6.0, 9999.0, + 7.0, 9999.0, 8.0, 9999.0, 9.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 2.0, 9999.0, 3.0, 9999.0, + 4.0, 9999.0, 5.0, 9999.0, 6.0, 9999.0, + 7.0, 9999.0, 8.0, 9999.0, 9.0, 9999.0 + ]); + + info = dgebal( 'none', 3, A, 6, 2, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = none (column-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 4.0, 9999.0, 7.0, 9999.0, + 2.0, 9999.0, 5.0, 9999.0, 8.0, 9999.0, + 3.0, 9999.0, 6.0, 9999.0, 9.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 4.0, 9999.0, 7.0, 9999.0, + 2.0, 9999.0, 5.0, 9999.0, 8.0, 9999.0, + 3.0, 9999.0, 6.0, 9999.0, 9.0, 9999.0 + ]); + + info = dgebal( 'both', 3, A, 2, 6, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (row-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 2.0, 9999.0, + 0.0, 9999.0, 5.0, 9999.0, 0.0, 9999.0, + 3.0, 9999.0, 0.0, 9999.0, 4.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 1.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 2.0, 9999.0, 0.0, 9999.0, + 3.0, 9999.0, 4.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 5.0, 9999.0 + ]); + + info = dgebal( 'permute', 3, A, 6, 2, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = permute (column-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 3.0, 9999.0, + 0.0, 9999.0, 5.0, 9999.0, 0.0, 9999.0, + 2.0, 9999.0, 0.0, 9999.0, 4.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 1.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 3.0, 9999.0, 0.0, 9999.0, + 2.0, 9999.0, 4.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 5.0, 9999.0 + ]); + + info = dgebal( 'permute', 3, A, 6, 2, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (row-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 16.0, 9999.0, 16.0, 9999.0, 16.0, 9999.0, + 0.25, 9999.0, 0.25, 9999.0, 0.25, 9999.0, + 0.25, 9999.0, 0.25, 9999.0, 0.25, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 0.125, 0.0, 0.125, 0.0 ] ); + expectedA = new Float64Array([ + 16.0, 9999.0, 2.0, 9999.0, 2.0, 9999.0, + 2.0, 9999.0, 0.25, 9999.0, 0.25, 9999.0, + 2.0, 9999.0, 0.25, 9999.0, 0.25, 9999.0 + ]); + + info = dgebal( 'scale', 3, A, 6, 2, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale (column-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 16.0, 9999.0, 0.25, 9999.0, 0.25, 9999.0, + 16.0, 9999.0, 0.25, 9999.0, 0.25, 9999.0, + 16.0, 9999.0, 0.25, 9999.0, 0.25, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 0.125, 0.0, 0.125, 0.0 ] ); + expectedA = new Float64Array([ + 16.0, 9999.0, 2.0, 9999.0, 2.0, 9999.0, + 2.0, 9999.0, 0.25, 9999.0, 0.25, 9999.0, + 2.0, 9999.0, 0.25, 9999.0, 0.25, 9999.0 + ]); + + info = dgebal( 'scale', 3, A, 2, 6, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (row-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 2.0, 9999.0, + 0.0, 9999.0, 5.0, 9999.0, 0.0, 9999.0, + 100.0, 9999.0, 0.0, 9999.0, 4.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 1.0, 0.0 ] ); + expectedScale = new Float64Array( [ 0.125, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 16.0, 9999.0, 0.0, 9999.0, + 12.5, 9999.0, 4.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 5.0, 9999.0 + ]); + + info = dgebal( 'both', 3, A, 6, 2, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both (column-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 100.0, 9999.0, + 0.0, 9999.0, 5.0, 9999.0, 0.0, 9999.0, + 2.0, 9999.0, 0.0, 9999.0, 4.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 1.0, 0.0 ] ); + expectedScale = new Float64Array( [ 0.125, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 12.5, 9999.0, 0.0, 9999.0, + 16.0, 9999.0, 4.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 5.0, 9999.0 + ]); + + info = dgebal( 'both', 3, A, 2, 6, 0, out, 2, 0, scale, 2, 0 ); + + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 1.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 2.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 3.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 1.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 2.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 3.0, 9999.0 + ]); + + info = dgebal( 'both', 3, A, 6, 2, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 0.0, 9999.0, + 1.0, 9999.0, 2.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 3.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + expectedScale = new Float64Array( [ 0.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 0.0, 9999.0, + 1.0, 9999.0, 2.0, 9999.0, 0.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 3.0, 9999.0 + ]); + + info = dgebal( 'both', 3, A, 2, 6, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (row-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 2.0, 9999.0, + 3.0, 9999.0, 4.0, 9999.0, 5.0, 9999.0, + 6.0, 9999.0, 0.0, 9999.0, 7.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 0.5, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 4.0, 9999.0, 1.5, 9999.0, 5.0, 9999.0, + 0.0, 9999.0, 1.0, 9999.0, 4.0, 9999.0, + 0.0, 9999.0, 3.0, 9999.0, 7.0, 9999.0 + ]); + + info = dgebal( 'both', 3, A, 6, 2, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = both with complex input (column-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 3.0, 9999.0, 6.0, 9999.0, + 0.0, 9999.0, 4.0, 9999.0, 0.0, 9999.0, + 2.0, 9999.0, 5.0, 9999.0, 7.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 1.0, 0.0, 2.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 0.5, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 4.0, 9999.0, 0.0, 9999.0, 0.0, 9999.0, + 1.5, 9999.0, 1.0, 9999.0, 3.0, 9999.0, + 5.0, 9999.0, 4.0, 9999.0, 7.0, 9999.0 + ]); + + info = dgebal( 'both', 3, A, 2, 6, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (row-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 4.0, 9999.0, + 2.0, 9999.0, 0.0, 9999.0, 5.0, 9999.0, + 3.0, 9999.0, 0.0, 9999.0, 6.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 0.0, 9999.0, 4.0, 9999.0, + 2.0, 9999.0, 0.0, 9999.0, 5.0, 9999.0, + 3.0, 9999.0, 0.0, 9999.0, 6.0, 9999.0 + ]); + + info = dgebal( 'scale', 3, A, 6, 2, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values for job = scale with zero norm (column-major) (large strides)', function test( t ) { + var expectedScale; + var expectedOut; + var expectedA; + var scale; + var info; + var out; + var A; + + A = new Float64Array([ + 1.0, 9999.0, 2.0, 9999.0, 3.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 0.0, 9999.0, + 4.0, 9999.0, 5.0, 9999.0, 6.0, 9999.0 + ]); + out = new Int32Array( 4 ); + scale = new Float64Array( 6 ); + + expectedOut = new Int32Array( [ 0.0, 0.0, 2.0, 0.0 ] ); + expectedScale = new Float64Array( [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ] ); + expectedA = new Float64Array([ + 1.0, 9999.0, 2.0, 9999.0, 3.0, 9999.0, + 0.0, 9999.0, 0.0, 9999.0, 0.0, 9999.0, + 4.0, 9999.0, 5.0, 9999.0, 6.0, 9999.0 + ]); + + info = dgebal( 'scale', 3, A, 2, 6, 0, out, 2, 0, scale, 2, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( out, expectedOut, 'returns expected value' ); + t.deepEqual( A, expectedA, 'returns expected value' ); + t.deepEqual( scale, expectedScale, 'returns expected value' ); + t.end(); +});