diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/README.md b/lib/node_modules/@stdlib/lapack/base/dgebak/README.md new file mode 100644 index 000000000000..1ba9037d8a82 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/README.md @@ -0,0 +1,284 @@ + + +# dgebak + +> LAPACK routine to form the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`. + +
+ +## Usage + +```javascript +var dgebak = require( '@stdlib/lapack/base/dgebak' ); +``` + +#### dgebak( order, job, side, N, M, ilo, ihi, scale, V, LDC ) + +Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); +var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + +/* + V = [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ] +*/ + +var out = dgebak( 'row-major', 'scale', 'right', 3, 2, 0, 2, scale, V, 2 ); +// returns [ 0.5, 2.0, 4.0, 10.0, 3.0, 6.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). +- **side**: specifies the side of the eigenvectors in `V` (`right` or `left`). +- **N**: number of rows in `V`. +- **M**: number of columns in `V`. +- **ilo**: index of the leftmost element in the submatrix computed by `dgebal` (zero-based). +- **ihi**: index of the rightmost element in the submatrix computed by `dgebal` (zero-based). +- **scale**: contains the details of the permutations and scaling factors applied when balancing `V`, computed by `dgebal` as a [`Float64Array`][mdn-float64array]. +- **V**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **LDV**: stride of the first dimension of `V` (a.k.a., leading dimension of the matrix `V`). + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var scale0 = new Float64Array( [ 0.0, 0.5, 2.0, 1.0 ] ); +var V0 = new Float64Array( [ 0.0, 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + +// Create offset views... +var scale1 = new Float64Array( scale0.buffer, scale0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var V1 = new Float64Array( V0.buffer, V0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +/* + V = [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ] +*/ + +var out = dgebak( 'row-major', 'scale', 'right', 3, 2, 0, 2, scale1, V1, 2 ); +// V0 => [ 0.0, 0.5, 2.0, 4.0, 10.0, 3.0, 6.0 ] +``` + +#### dgebak.ndarray( job, side, N, M, ilo, ihi, scale, ss, os, V, sv1, sv2, ov ) + +Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); +var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + +/* + V = [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ] +*/ + +var out = dgebak.ndarray( 'scale', 'right', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); +// returns [ 0.5, 2.0, 4.0, 10.0, 3.0, 6.0 ] +``` + +The function has the following additional parameters: + +- **ss**: stride of `scale`. +- **os**: starting index of `scale`. +- **sv1**: stride of the first dimension of `V`. +- **sv2**: stride of the second dimension of `V`. +- **ov**: starting index of `V`. + +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 scale = new Float64Array( [ 0.0, 0.5, 2.0, 1.0 ] ); +var V = new Float64Array( [ 0.0, 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + +/* + V = [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ] +*/ + +var out = dgebak.ndarray( 'scale', 'right', 3, 2, 0, 2, scale, 1, 1, V, 2, 1, 1 ); +// returns [ 0.0, 0.5, 2.0, 4.0, 10.0, 3.0, 6.0 ] +``` + +
+ + + +
+ +## Notes + +- `dgebak()` corresponds to the [LAPACK][LAPACK] function [`dgebak`][lapack-dgebak]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgebak = require( '@stdlib/lapack/base/dgebak' ); + +// Specify matrix meta data: +var shape = [ 3, 2 ]; +var strides = [ 2, 1 ]; +var offset = 0; +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +console.log( ndarray2array( V, shape, strides, offset, order ) ); + +var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); + +var out = dgebak( order, 'scale', 'right', shape[ 0 ], shape[ 1 ], 0, 2, scale, V, strides[ 0 ] ); +console.log( ndarray2array( out, shape, strides, offset, order ) ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dgebak/benchmark/benchmark.js new file mode 100644 index 000000000000..52b79c360b2e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/benchmark/benchmark.js @@ -0,0 +1,141 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dgebak = require( './../lib/dgebak.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var JOBS = [ + 'permute', + 'scale', + 'both', + 'none' +]; +var SIDE = [ + 'left', + 'right' +]; + + +// 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 +* @param {string} side - indicates the specifies the side of the eigenvectors in `V` (`right` or `left`). +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N, job, side ) { + var scale; + var V; + + scale = uniform( N, -10.0, 10.0, { + 'dtype': 'float64' + }); + + V = 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 = dgebak( order, job, side, N, N, 0, N-1, scale, V, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var side; + var min; + var max; + var ord; + var job; + var N; + var f; + var i; + var j; + var k; + var l; + + 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 ]; + for ( l = 0; l < SIDE.length; l++ ) { + side = SIDE[ l ]; + f = createBenchmark( ord, N, job, side ); + bench( pkg+'::square_matrix:order='+ord+',job='+job+',side='+side+',size='+(N*N), f ); + } + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgebak/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..56ca3d9ddf79 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/benchmark/benchmark.ndarray.js @@ -0,0 +1,153 @@ +/** +* @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 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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var pkg = require( './../package.json' ).name; +var dgebak = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; +var JOBS = [ + 'permute', + 'scale', + 'both', + 'none' +]; +var SIDE = [ + 'left', + 'right' +]; + + +// 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 +* @param {string} side - indicates the specifies the side of the eigenvectors in `V` (`right` or `left`). +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N, job, side ) { + var scale; + var sv1; + var sv2; + var V; + + scale = uniform( N, -10.0, 10.0, { + 'dtype': 'float64' + }); + + V = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + + if ( isColumnMajor( order ) ) { + sv1 = 1; + sv2 = N; + } else { + sv1 = N; + sv2 = 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 = dgebak( job, side, N, N, 0, N-1, scale, 1, 0, V, sv1, sv2, 0 ); + if ( isnan( z[ i%z.length ] )) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var side; + var min; + var max; + var ord; + var job; + var N; + var f; + var i; + var j; + var k; + var l; + + 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 ]; + for ( l = 0; l < SIDE.length; l++ ) { + side = SIDE[ l ]; + f = createBenchmark( ord, N, job, side ); + bench( pkg+'::square_matrix:order='+ord+',job='+job+',side='+side+',size='+(N*N), f ); + } + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dgebak/docs/repl.txt new file mode 100644 index 000000000000..81170b3057d7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/docs/repl.txt @@ -0,0 +1,133 @@ + +{{alias}}( order, job, side, N, M, ilo, ihi, scale, V, LDV ) + Forms the right or left eigenvectors of a real general matrix by backward + transformation on the computed eigenvectors of the balanced matrix output + by `dgebal`. + + 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). + + side: string + Specifies the side of the eigenvectors in `V` (`right` or `left`). + + N: integer + Number of rows in `V`. + + M: integer + Number of columns in `V`. + + ilo: integer + Index of leftmost column of the submatrix computed by `dgebal` + (zero-based). + + ihi: integer + Index of rightmost column of the submatrix computed by `dgebal` + (zero-based). + + scale: Float64Array + Contains the details of the permutations and scaling factors applied + when balancing `V`, computed by `dgebal`. + + V: Float64Array + Input matrix. + + LDV: integer + Stride of the first dimension of `V` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + V: Float64Array + Mutated input matrix. + + Examples + -------- + > var V = new {{alias:@stdlib/array/float64}}( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + > var scale = new {{alias:@stdlib/array/float64}}( [ 0.5, 2.0, 1.0 ] ); + > var ord = 'row-major'; + > var out = {{alias}}( ord, 'scale', 'right', 3, 2, 0, 2, scale, V, 2 ) + [ 0.5, 2.0, 4.0, 10.0, 3.0, 6.0 ] + + +{{alias}}.ndarray( job, side, N, M, ilo, ihi, scale, ss, os, V, sv1, sv2, ov ) + Forms the right or left eigenvectors of a real general matrix by backward + transformation on the computed eigenvectors of the balanced matrix output + by `dgebal` using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + 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). + + side: string + Specifies the side of the eigenvectors in `V` (`right` or `left`). + + N: integer + Number of rows in `V`. + + M: integer + Number of columns in `V`. + + ilo: integer + Index of leftmost column of the submatrix computed by `dgebal` + (zero-based). + + ihi: integer + Index of rightmost column of the submatrix computed by `dgebal` + (zero-based). + + scale: Float64Array + Contains the details of the permutations and scaling factors applied + when balancing `V`, computed by `dgebal`. + + ss: integer + Stride length of `scale`. + + os: integer + Starting index of `scale`. + + V: Float64Array + Input matrix. + + sv1: integer + Stride of the first dimension of `V`. + + sv2: integer + Stride of the second dimension of `V`. + + ov: integer + Starting index of `V`. + + Returns + ------- + V: Float64Array + Mutated input matrix. + + Examples + -------- + > var V = new {{alias:@stdlib/array/float64}}( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + > var scale = new {{alias:@stdlib/array/float64}}( [ 0.5, 2.0, 1.0 ] ); + > var job = 'both'; + > var side = 'right'; + > var out = {{alias}}.ndarray( job,side, 3,2, 0,2, scale,1,0, V,2,1,0 ) + [ 0.5, 2.0, 4.0, 10.0, 3.0, 6.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dgebak/docs/types/index.d.ts new file mode 100644 index 000000000000..4ca12c06ea84 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/docs/types/index.d.ts @@ -0,0 +1,176 @@ +/* +* @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'; + +/** +* 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'; + +/** +* Side parameter. +*s +* ## Notes +* +* The `side` parameter can be one of the following: +* +* - 'right' +* - 'left' +*/ +type Side = 'left' | 'right'; + +/** +* Interface describing `dgebak`. +*/ +interface Routine { + /** + * Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`. + * + * ## 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 + * + * @param order - storage layout + * @param job - type of transformation. + * @param side - specifies the side of the eigenvectors in `V` (`right` or `left`). + * @param N - number of rows in matrix `V` + * @param M - number of columns in matrix `V` + * @param ilo - index of leftmost column of the submatrix computed by `dgebal` (zero-based) + * @param ihi - index of rightmost column of the submatrix computed by `dgebal` (zero-based) + * @param scale - contains the details of the permutations and scaling factors applied when balancing `V`, computed by `dgebal` + * @param V - input matrix + * @param LDV - leading dimension of `V` + * @returns `V` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); + * var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + * + * var out = dgebak( 'row-major', 'scale', 'right', 3, 2, 0, 2, scale, V, 2 ); + * // returns [ 0.5, 2, 4, 10, 3, 6 ] + */ + ( order: Layout, job: Job, side: Side, N: number, M: number, ilo: number, ihi: number, scale: Float64Array, V: Float64Array, LDV: number ): Float64Array; + + /** + * Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`. + * + * ## 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 + * + * @param job - type of transformation. + * @param side - specifies the side of the eigenvectors in `V` (`right` or `left`). + * @param N - number of rows in matrix `V` + * @param M - number of columns in matrix `V` + * @param ilo - index of leftmost column of the submatrix computed by `dgebal` (zero-based) + * @param ihi - index of rightmost column of the submatrix computed by `dgebal` (zero-based) + * @param scale - contains the details of the permutations and scaling factors applied when balancing `V`, computed by `dgebal` + * @param strideScale - stride of `scale` + * @param offsetScale - starting index for `scale` + * @param V - input matrix + * @param strideV1 - stride of the first dimension of `V` + * @param strideV2 - stride of the second dimension of `V` + * @param offsetV - starting index for `V` + * @returns `V` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); + * var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); + * + * var out = dgebak.ndarray( 'scale', 'right', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); + * // returns [ 0.5, 2, 4, 10, 3, 6 ] + */ + ndarray( job: Job, side: Side, N: number, M: number, ilo: number, ihi: number, scale: Float64Array, strideScale: number, offsetScale: number, V: Float64Array, strideV1: number, strideV2: number, offsetV: number ): Float64Array; +} + +/** +* Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`. +* +* ## 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 +* +* @param order - storage layout +* @param job - type of transformation. +* @param side - specifies the side of the eigenvectors in `V` (`right` or `left`). +* @param N - number of rows in matrix `V` +* @param M - number of columns in matrix `V` +* @param ilo - index of leftmost column of the submatrix computed by `dgebal` (zero-based) +* @param ihi - index of rightmost column of the submatrix computed by `dgebal` (zero-based) +* @param scale - contains the details of the permutations and scaling factors applied when balancing `V`, computed by `dgebal` +* @param V - input matrix +* @param LDV - leading dimension of `V` +* @returns `V` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); +* var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* +* var out = dgebak( 'row-major', 'scale', 'right', 3, 2, 0, 2, scale, V, 2 ); +* // returns [ 0.5, 2, 4, 10, 3, 6 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); +* var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* +* var out = dgebak.ndarray( 'scale', 'right', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); +* // returns [ 0.5, 2, 4, 10, 3, 6 ] +*/ +declare var dgebak: Routine; + + +// EXPORTS // + +export = dgebak; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dgebak/docs/types/test.ts new file mode 100644 index 000000000000..e878fb48a03b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/docs/types/test.ts @@ -0,0 +1,422 @@ +/* +* @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 dgebak = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 5, 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( true, 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( false, 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( null, 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( void 0, 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( [], 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( {}, 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( ( x: number ): number => x, 'both', 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 5, 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', true, 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', false, 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', null, 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', void 0, 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', [], 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', {}, 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', ( x: number ): number => x, 'left', 3, 2, 0, 2, scale, V, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a string... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 'both', 5, 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', true, 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', false, 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', null, 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', void 0, 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', [], 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', {}, 3, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', ( x: number ): number => x, 3, 2, 0, 2, scale, V, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 'both', 'left', '5', 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', true, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', false, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', null, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', void 0, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', [], 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', {}, 2, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', ( x: number ): number => x, 2, 0, 2, scale, V, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 'both', 'left', 3, '5', 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, true, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, false, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, null, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, void 0, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, [], 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, {}, 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, ( x: number ): number => x, 0, 2, scale, V, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 'both', 'left', 3, 2, '5', 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, true, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, false, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, null, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, void 0, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, [], 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, {}, 2, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, ( x: number ): number => x, 2, scale, V, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 'both', 'left', 3, 2, 0, '5', scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, true, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, false, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, null, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, void 0, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, [], scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, {}, scale, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, ( x: number ): number => x, scale, V, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, '5', V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, 5, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, true, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, false, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, null, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, void 0, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, [], V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, {}, V, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, ( x: number ): number => x, V, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, '5', 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, 5, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, true, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, false, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, null, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, void 0, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, [], 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, {}, 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, ( x: number ): number => x, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, '5' ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, true ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, false ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, null ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, void 0 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, [] ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, {} ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak(); // $ExpectError + dgebak( 'column-major' ); // $ExpectError + dgebak( 'column-major', 'both' ); // $ExpectError + dgebak( 'column-major', 'both', 'left' ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2 ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V ); // $ExpectError + dgebak( 'column-major', 'both', 'left', 3, 2, 0, 2, scale, V, 3, 1 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 5, 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( true, 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( false, 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( null, 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( void 0, 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( [], 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( {}, 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( ( x: number ): number => x, 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 5, 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', true, 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', false, 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', null, 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', void 0, 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', [], 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', {}, 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', ( x: number ): number => x, 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', '5', 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', true, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', false, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', null, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', void 0, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', [], 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', {}, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', ( x: number ): number => x, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, '5', 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, true, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, false, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, null, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, void 0, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, [], 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, {}, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, ( x: number ): number => x, 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, '5', 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, true, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, false, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, null, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, void 0, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, [], 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, {}, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, ( x: number ): number => x, 2, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, '5', scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, true, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, false, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, null, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, void 0, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, [], scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, {}, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, ( x: number ): number => x, scale, 1, 0, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, '5', 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, 5, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, true, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, false, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, null, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, void 0, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, [], 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, {}, 1, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, ( x: number ): number => x, 1, 0, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, '5', 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, true, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, false, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, null, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, void 0, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, [], 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, {}, 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, ( x: number ): number => x, 0, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, '5', V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, true, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, false, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, null, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, void 0, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, [], V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, {}, V, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, ( x: number ): number => x, V, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float64Array... +{ + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, '5', 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, 5, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, true, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, false, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, null, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, void 0, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, [], 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, {}, 2, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, '5', 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, true, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, false, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, null, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, void 0, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, [], 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, {}, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, '5', 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, true, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, false, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, null, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, void 0, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, [], 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, {}, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, '5' ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, true ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, false ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, null ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, void 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, [] ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, {} ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + const scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + dgebak.ndarray(); // $ExpectError + dgebak.ndarray( 'both' ); // $ExpectError + dgebak.ndarray( 'both', 'left' ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1 ); // $ExpectError + dgebak.ndarray( 'both', 'left', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0, 1 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dgebak/examples/index.js new file mode 100644 index 000000000000..f796d29d3fb7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/examples/index.js @@ -0,0 +1,38 @@ +/** +* @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 ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgebak = require( './../lib' ); + +// Specify matrix meta data: +var shape = [ 3, 2 ]; +var strides = [ 2, 1 ]; +var offset = 0; +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +console.log( ndarray2array( V, shape, strides, offset, order ) ); + +var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); + +var out = dgebak( order, 'scale', 'right', shape[ 0 ], shape[ 1 ], 0, 2, scale, V, strides[ 0 ] ); +console.log( ndarray2array( out, shape, strides, offset, order ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/base.js new file mode 100644 index 000000000000..f45b5e448d8c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/base.js @@ -0,0 +1,107 @@ +/** +* @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 dscal = require( '@stdlib/blas/base/dscal' ).ndarray; +var swaps = require( './swaps.js' ); + + +// MAIN // + +/** +* Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`. +* +* ## 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 +* +* @private +* @param {string} job - type of transformation. +* @param {string} side - specifies the side of the eigenvectors in `V` (`right` or `left`). +* @param {NonNegativeInteger} N - number of rows in matrix `V` +* @param {NonNegativeInteger} M - number of columns in matrix `V` +* @param {NonNegativeInteger} ilo - index of leftmost column of the submatrix computed by `dgebal` (zero-based) +* @param {NonNegativeInteger} ihi - index of rightmost column of the submatrix computed by `dgebal` (zero-based) +* @param {Float64Array} scale - contains the details of the permutations and scaling factors applied when balancing `V`, computed by `dgebal` +* @param {integer} strideScale - stride of `scale` +* @param {NonNegativeInteger} offsetScale - starting index for `scale` +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of `V` +* @param {integer} strideV2 - stride of the second dimension of `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @returns {Float64Array} `V` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); +* var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* +* var out = dgebak( 'scale', 'right', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); +* // returns [ 0.5, 2, 4, 10, 3, 6 ] +*/ +function dgebak( job, side, N, M, ilo, ihi, scale, strideScale, offsetScale, V, strideV1, strideV2, offsetV ) { // eslint-disable-line max-len, max-params + var is; + var iv; + var i; + var s; + + if ( N === 0 || M === 0 || job === 'none' ) { + return V; + } + + if ( ilo === ihi ) { + if ( job === 'permute' || job === 'both' ) { + swaps( N, M, ilo, ihi, scale, strideScale, offsetScale, V, strideV1, strideV2, offsetV ); // eslint-disable-line max-len + } + return V; + } + + if ( job === 'scale' || job === 'both' ) { + is = offsetScale + ( ilo * strideScale ); + iv = offsetV + ( ilo * strideV1 ); + for ( i = ilo; i <= ihi; i++ ) { + if ( side === 'right' ) { + s = scale[ is ]; + } else { + s = 1.0 / scale[ is ]; + } + dscal( M, s, V, strideV2, iv ); + is += strideScale; + iv += strideV1; + } + } + + if ( job === 'permute' || job === 'both' ) { + swaps( N, M, ilo, ihi, scale, strideScale, offsetScale, V, strideV1, strideV2, offsetV ); // eslint-disable-line max-len + } + return V; +} + + +// EXPORTS // + +module.exports = dgebak; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/lib/dgebak.js b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/dgebak.js new file mode 100644 index 000000000000..c61e883d16de --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/dgebak.js @@ -0,0 +1,100 @@ +/** +* @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 max = require( '@stdlib/math/base/special/max' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var format = require( '@stdlib/string/format' ); +var isOperationSide = require( '@stdlib/blas/base/assert/is-operation-side' ); +var isJob = require( './isjob.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`. +* +* ## 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 +* +* @param {string} order - storage layout +* @param {string} job - type of transformation. +* @param {string} side - specifies the side of the eigenvectors in `V` (`right` or `left`) +* @param {NonNegativeInteger} N - number of rows in matrix `V` +* @param {NonNegativeInteger} M - number of columns in matrix `V` +* @param {NonNegativeInteger} ilo - index of leftmost column of the submatrix computed by `dgebal` (zero-based) +* @param {NonNegativeInteger} ihi - index of rightmost column of the submatrix computed by `dgebal` (zero-based) +* @param {Float64Array} scale - contains the details of the permutations and scaling factors applied when balancing `V`, computed by `dgebal` +* @param {Float64Array} V - input matrix +* @param {integer} LDV - leading dimension of `V` +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be a valid job +* @throws {TypeError} third argument must be a valid side +* @throws {RangeError} fourth argument must be greater than or equal to max(1,M) +* @returns {Float64Array} `V` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); +* var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* +* var out = dgebak( 'row-major', 'scale', 'right', 3, 2, 0, 2, scale, V, 2 ); +* // returns [ 0.5, 2, 4, 10, 3, 6 ] +*/ +function dgebak( order, job, side, N, M, ilo, ihi, scale, V, LDV ) { + 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 a valid job. Value: `%s`.', job ) ); + } + if ( !isOperationSide( side ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a valid side. Value: `%s`.', side ) ); + } + if ( isRowMajor( order ) && LDV < max( 1, M ) ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.', M, LDV ) ); + } + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = LDV; + } else { // order === 'row-major' + sa1 = LDV; + sa2 = 1; + } + return base( job, side, N, M, ilo, ihi, scale, 1, 0, V, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = dgebak; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/index.js new file mode 100644 index 000000000000..1c376ce22fb8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/index.js @@ -0,0 +1,58 @@ +/** +* @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 form the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`. +* +* @module @stdlib/lapack/base/dgebak +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dgebak = require( '@stdlib/lapack/base/dgebak' ); +* +* var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); +* var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* +* var out = dgebak( 'row-major', 'scale', 'right', 3, 0, 2, scale, 2, V, 2 ); +* // returns [ 0.5, 2, 4, 10, 3, 6 ] +*/ + +// 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 dgebak; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dgebak = main; +} else { + dgebak = tmp; +} + + +// EXPORTS // + +module.exports = dgebak; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/lib/isjob.js b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/isjob.js new file mode 100644 index 000000000000..fd4ffa0500d3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/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/dgebak/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/main.js new file mode 100644 index 000000000000..243e6a164c9b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/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 dgebak = require( './dgebak.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dgebak, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dgebak; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/ndarray.js new file mode 100644 index 000000000000..6c09f7390f24 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/ndarray.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 format = require( '@stdlib/string/format' ); +var isOperationSide = require( '@stdlib/blas/base/assert/is-operation-side' ); +var isJob = require( './isjob.js' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal` 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 +* +* @param {string} job - type of transformation. +* @param {string} side - specifies the side of the eigenvectors in `V` (`right` or `left`). +* @param {NonNegativeInteger} N - number of rows in matrix `V` +* @param {NonNegativeInteger} M - number of columns in matrix `V` +* @param {NonNegativeInteger} ilo - index of leftmost column of the submatrix computed by `dgebal` (zero-based) +* @param {NonNegativeInteger} ihi - index of rightmost column of the submatrix computed by `dgebal` (zero-based) +* @param {Float64Array} scale - contains the details of the permutations and scaling factors applied when balancing `V`, computed by `dgebal` +* @param {integer} strideScale - stride of `scale` +* @param {NonNegativeInteger} offsetScale - starting index for `scale` +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of `V` +* @param {integer} strideV2 - stride of the second dimension of `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @throws {TypeError} first argument must be a valid job +* @throws {TypeError} third argument must be a valid side +* @returns {Float64Array} `V` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var scale = new Float64Array( [ 0.5, 2.0, 1.0 ] ); +* var V = new Float64Array( [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ] ); +* +* var out = dgebak( 'scale', 'right', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); +* // returns [ 0.5, 2, 4, 10, 3, 6 ] +*/ +function dgebak( job, side, N, M, ilo, ihi, scale, strideScale, offsetScale, V, strideV1, strideV2, offsetV ) { // eslint-disable-line max-len, max-params + if ( !isJob( job ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a valid job. Value: `%s`.', job ) ); + } + if ( !isOperationSide( side ) ) { + throw new TypeError( format( 'invalid argument. Third argument must be a valid side. Value: `%s`.', side ) ); + } + return base( job, side, N, M, ilo, ihi, scale, strideScale, offsetScale, V, strideV1, strideV2, offsetV ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dgebak; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/lib/swaps.js b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/swaps.js new file mode 100644 index 000000000000..47aa6429b587 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/lib/swaps.js @@ -0,0 +1,79 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; +var trunc = require( '@stdlib/math/base/special/trunc' ); + + +// MAIN // + +/** +* Swaps the rows of a matrix `V` according to the permutation specified by the `scale` array. +* +* @private +* @param {NonNegativeInteger} N - number of rows in matrix `V` +* @param {NonNegativeInteger} M - number of columns in matrix `V` +* @param {NonNegativeInteger} ilo - index of leftmost column of the submatrix computed by `dgebal` (zero-based) +* @param {NonNegativeInteger} ihi - index of rightmost column of the submatrix computed by `dgebal` (zero-based) +* @param {Float64Array} scale - contains the details of the permutations and scaling factors applied when balancing `V`, computed by `dgebal` +* @param {integer} strideScale - stride of `scale` +* @param {NonNegativeInteger} offsetScale - starting index for `scale` +* @param {Float64Array} V - input matrix +* @param {integer} strideV1 - stride of the first dimension of `V` +* @param {integer} strideV2 - stride of the second dimension of `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @returns {void} manipulates `V` in place +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var scale = new Float64Array( [ 2.0, 1.0, 0.0 ] ); +* var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* swaps( 3, 2, 0, 1, scale, 1, 0, V, 2, 1, 0 ); +* // V => [ 5, 6, 3, 4, 1, 2 ] +*/ +function swaps( N, M, ilo, ihi, scale, strideScale, offsetScale, V, strideV1, strideV2, offsetV ) { // eslint-disable-line max-len, max-params + var ii; + var k; + var i; + + for ( ii = 0; ii < N; ii++ ) { + i = ii; + if ( i >= ilo && i <= ihi ) { + continue; + } + if ( i < ilo ) { + i = ilo - ( ii + 1 ); // Use ii + 1 here to match fortran's 1 based implementation + } + k = trunc( scale[ offsetScale + (i * strideScale) ] ); // K = int ( scale[ i ] ) + if ( k === i ) { + continue; + } + dswap( M, V, strideV2, offsetV + (i * strideV1), V, strideV2, offsetV + (k * strideV1) ); // eslint-disable-line max-len + } +} + + +// EXPORTS // + +module.exports = swaps; diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/package.json b/lib/node_modules/@stdlib/lapack/base/dgebak/package.json new file mode 100644 index 000000000000..059c891b7249 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/lapack/base/dgebak", + "version": "0.0.0", + "description": "Forms the right or left eigenvectors of a real general matrix by backward transformation on the computed eigenvectors of the balanced matrix output by `dgebal`.", + "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", + "dgebak", + "dgebal", + "balance", + "eigenvectors", + "permute", + "permutedims", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/test/test.dgebak.js b/lib/node_modules/@stdlib/lapack/base/dgebak/test/test.dgebak.js new file mode 100644 index 000000000000..6f4fdb967fbb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/test/test.dgebak.js @@ -0,0 +1,804 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var dgebak = require( './../lib/dgebak.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgebak, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dgebak.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var scale; + var i; + var V; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + 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() { + dgebak( value, 'scale', 'right', 3, 2, 0, 2, scale, V, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a valid job', function test( t ) { + var values; + var scale; + var i; + var V; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + 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() { + dgebak( 'row-major', value, 'right', 3, 2, 0, 2, scale, V, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a third argument which is not a valid side', function test( t ) { + var values; + var scale; + var i; + var V; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + 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() { + dgebak( 'row-major', 'scale', value, 3, 2, 0, 2, scale, V, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a fourth argument which is not a valid `LDV` value (row-major)', function test( t ) { + var values; + var scale; + var V; + var i; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + values = [ + 0, + 1 + ]; + + 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() { + dgebak( 'row-major', 'scale', 'right', 0, 2, 0, 2, scale, V, value ); + }; + } +}); + +tape( 'the function returns the array unchanged when N = 0', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'row-major', 'scale', 'right', 0, 2, 0, 2, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when M = 0', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'column-major', 'both', 'right', 3, 0, 0, 2, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when job = none (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'row-major', 'none', 'right', 3, 2, 0, 2, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when job = none (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'column-major', 'none', 'right', 3, 2, 0, 2, scale, V, 3 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'row-major', 'permute', 'right', 4, 2, 2, 2, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 5.0, 3.0, 7.0, 2.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'column-major', 'permute', 'right', 4, 2, 2, 2, scale, V, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'row-major', 'both', 'right', 4, 2, 2, 2, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 5.0, 3.0, 7.0, 2.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'column-major', 'both', 'right', 4, 2, 2, 2, scale, V, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.1 ] ); + V = new Float64Array( [ 10.0, 20.0, 3.0, 4.0, 0.5, 0.6, 0.04, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 100.0, 200.0, 3.0, 4.0, 0.05, 0.06, 0.004, 0.008 ] ); // eslint-disable-line max-len + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'row-major', 'scale', 'right', 4, 2, 0, 3, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.1 ] ); + V = new Float64Array( [ 10.0, 3.0, 0.5, 0.04, 20.0, 4.0, 0.6, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 100.0, 3.0, 0.05, 0.004, 200.0, 4.0, 0.06, 0.008 ] ); // eslint-disable-line max-len + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'column-major', 'scale', 'right', 4, 2, 0, 3, scale, V, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.01 ] ); + V = new Float64Array( [ 10.0, 20.0, 3.0, 4.0, 0.5, 0.6, 0.04, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'row-major', 'scale', 'left', 4, 2, 0, 3, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.01 ] ); + V = new Float64Array( [ 10.0, 3.0, 0.5, 0.04, 20.0, 4.0, 0.6, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 4.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'column-major', 'scale', 'left', 4, 2, 0, 3, scale, V, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'row-major', 'permute', 'right', 4, 2, 0, 1, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0, 8.0, 6.0, 4.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'column-major', 'permute', 'right', 4, 2, 0, 1, scale, V, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'row-major', 'permute', 'left', 4, 2, 0, 1, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0, 8.0, 6.0, 4.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'column-major', 'permute', 'left', 4, 2, 0, 1, scale, V, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 7.0, 8.0, 3.0, 4.0, 0.5, 0.6, 1.0, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 30.0, 40.0, 0.05, 0.06, 1.0, 2.0 ] ); // eslint-disable-line max-len + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'row-major', 'both', 'right', 4, 2, 1, 2, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 7.0, 3.0, 0.5, 1.0, 8.0, 4.0, 0.6, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 30.0, 0.05, 1.0, 8.0, 40.0, 0.06, 2.0 ] ); // eslint-disable-line max-len + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'column-major', 'both', 'right', 4, 2, 1, 2, scale, V, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 7.0, 8.0, 8.0, 4.0, 0.5, 0.6, 1.0, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 0.8, 0.4, 5.0, 6.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'row-major', 'both', 'left', 4, 2, 1, 2, scale, V, 2 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 7.0, 8.0, 0.5, 1.0, 8.0, 4.0, 0.6, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.8, 5.0, 1.0, 8.0, 0.4, 6.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'column-major', 'both', 'left', 4, 2, 1, 2, scale, V, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/test/test.js b/lib/node_modules/@stdlib/lapack/base/dgebak/test/test.js new file mode 100644 index 000000000000..53b523a8adff --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/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 dgebak = 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 dgebak, '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 dgebak.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 dgebak = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgebak, 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 dgebak; + var main; + + main = require( './../lib/dgebak.js' ); + + dgebak = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dgebak, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dgebak/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dgebak/test/test.ndarray.js new file mode 100644 index 000000000000..463bcd8d46b3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dgebak/test/test.ndarray.js @@ -0,0 +1,3089 @@ +/** +* @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-lines, max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dgebak = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dgebak, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( dgebak.length, 13, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var scale; + var i; + var V; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + 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() { + dgebak( value, 'scale', 'right', 3, 2, 0, 2, scale, V, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a valid job', function test( t ) { + var values; + var scale; + var i; + var V; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + 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() { + dgebak( value, 'right', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided a third argument which is not a valid side', function test( t ) { + var values; + var scale; + var i; + var V; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + 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() { + dgebak( 'scale', value, 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); + }; + } +}); + +tape( 'the function returns the array unchanged when N = 0', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'scale', 'right', 0, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when M = 0', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'both', 'right', 3, 0, 0, 2, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when job = none (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'none', 'right', 3, 2, 0, 2, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when job = none (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'none', 'right', 3, 2, 0, 2, scale, 1, 0, V, 1, 3, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 5.0, 3.0, 7.0, 2.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, 1, 0, V, 1, 4, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 5.0, 3.0, 7.0, 2.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, 1, 0, V, 1, 4, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.1 ] ); + V = new Float64Array( [ 10.0, 20.0, 3.0, 4.0, 0.5, 0.6, 0.04, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 100.0, 200.0, 3.0, 4.0, 0.05, 0.06, 0.004, 0.008 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.1 ] ); + V = new Float64Array( [ 10.0, 3.0, 0.5, 0.04, 20.0, 4.0, 0.6, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 100.0, 3.0, 0.05, 0.004, 200.0, 4.0, 0.06, 0.008 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, 1, 0, V, 1, 4, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.01 ] ); + V = new Float64Array( [ 10.0, 20.0, 3.0, 4.0, 0.5, 0.6, 0.04, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.01 ] ); + V = new Float64Array( [ 10.0, 3.0, 0.5, 0.04, 20.0, 4.0, 0.6, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 4.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, 1, 0, V, 1, 4, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0, 8.0, 6.0, 4.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 1, 0, V, 1, 4, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 5.0, 3.0, 1.0, 8.0, 6.0, 4.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, 1, 0, V, 1, 4, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 7.0, 8.0, 3.0, 4.0, 0.5, 0.6, 1.0, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 30.0, 40.0, 0.05, 0.06, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 7.0, 3.0, 0.5, 1.0, 8.0, 4.0, 0.6, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 30.0, 0.05, 1.0, 8.0, 40.0, 0.06, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, 1, 0, V, 1, 4, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 7.0, 8.0, 8.0, 4.0, 0.5, 0.6, 1.0, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 0.8, 0.4, 5.0, 6.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (column-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 7.0, 8.0, 0.5, 1.0, 8.0, 4.0, 0.6, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.8, 5.0, 1.0, 8.0, 0.4, 6.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, 1, 0, V, 1, 4, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when job = none (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'none', 'right', 3, 2, 0, 2, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when job = none (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'none', 'right', 3, 2, 0, 2, scale, 1, 2, V, 1, 3, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 1.0, 5.0, 3.0, 7.0, 2.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, 1, 2, V, 1, 4, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 1.0, 2.0, 5.0, 6.0, 3.0, 4.0, 7.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 1.0, 5.0, 3.0, 7.0, 2.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, 1, 2, V, 1, 4, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 10.0, 1.0, 0.1, 0.1 ] ); + V = new Float64Array( [ 0.0, 10.0, 20.0, 3.0, 4.0, 0.5, 0.6, 0.04, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 0.0, 100.0, 200.0, 3.0, 4.0, 0.05, 0.06, 0.004, 0.008 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 10.0, 1.0, 0.1, 0.1, 0.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 10.0, 3.0, 0.5, 0.04, 20.0, 4.0, 0.6, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 0.0, 100.0, 3.0, 0.05, 0.004, 200.0, 4.0, 0.06, 0.008 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, 1, 2, V, 1, 4, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 10.0, 1.0, 0.1, 0.01, 0.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 10.0, 20.0, 3.0, 4.0, 0.5, 0.6, 0.04, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 4.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 10.0, 1.0, 0.1, 0.01, 0.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 10.0, 3.0, 0.5, 0.04, 20.0, 4.0, 0.6, 0.08 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 0.0, 1.0, 3.0, 5.0, 4.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, 1, 2, V, 1, 4, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 2.0, 1.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 2.0, 1.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 7.0, 5.0, 3.0, 1.0, 8.0, 6.0, 4.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 1, 2, V, 1, 4, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 2.0, 1.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 0.0, 1.0, 3.0, 5.0, 7.0, 2.0, 4.0, 6.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 7.0, 5.0, 3.0, 1.0, 8.0, 6.0, 4.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, 1, 2, V, 1, 4, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 0.0, 7.0, 8.0, 3.0, 4.0, 0.5, 0.6, 1.0, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 7.0, 8.0, 30.0, 40.0, 0.05, 0.06, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 0.0, 7.0, 3.0, 0.5, 1.0, 8.0, 4.0, 0.6, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 7.0, 30.0, 0.05, 1.0, 8.0, 40.0, 0.06, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, 1, 2, V, 1, 4, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (row-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 0.0, 7.0, 8.0, 8.0, 4.0, 0.5, 0.6, 1.0, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 7.0, 8.0, 0.8, 0.4, 5.0, 6.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, 1, 2, V, 2, 1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (column-major) (offsets)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.0, 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 0.0, 7.0, 8.0, 0.5, 1.0, 8.0, 4.0, 0.6, 2.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 0.0, 7.0, 0.8, 5.0, 1.0, 8.0, 0.4, 6.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, 1, 2, V, 1, 4, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when job = none (row-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + V = new Float64Array( [ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'none', 'right', 3, 2, 0, 2, scale, -1, 2, V, -2, -1, 5 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the array unchanged when job = none (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + V = new Float64Array( [ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + expected = new Float64Array( V ); + + actual = dgebak( 'none', 'right', 3, 2, 0, 2, scale, -1, 2, V, -1, -3, 5 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (row-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 2.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 7.0, 4.0, 3.0, 6.0, 5.0, 2.0, 1.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, -1, 3, V, -2, -1, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 2.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 8.0, 6.0, 4.0, 2.0, 7.0, 5.0, 3.0, 1.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 4.0, 6.0, 2.0, 7.0, 3.0, 5.0, 1.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, -1, 3, V, -1, -4, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (row-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 2.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 7.0, 4.0, 3.0, 6.0, 5.0, 2.0, 1.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, -1, 3, V, -2, -1, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 2.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 8.0, 6.0, 4.0, 2.0, 7.0, 5.0, 3.0, 1.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 4.0, 6.0, 2.0, 7.0, 3.0, 5.0, 1.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, -1, 3, V, -1, -4, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (row-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.1, 0.1, 1.0, 10.0 ] ); + V = new Float64Array( [ 0.04, 0.08, 0.5, 0.6, 3.0, 4.0, 10.0, 20.0 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 0.004, 0.008, 0.05, 0.06, 3.0, 4.0, 100.0, 200.0 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, -1, 3, V, -2, -1, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.1, 0.1, 1.0, 10.0 ] ); + V = new Float64Array( [ 0.04, 0.5, 3.0, 10.0, 0.08, 0.6, 4.0, 20.0 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 0.004, 0.05, 3.0, 100.0, 0.008, 0.06, 4.0, 200.0 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, -1, 3, V, -1, -4, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (row-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.01, 0.1, 1.0, 10.0 ] ); + V = new Float64Array( [ 0.08, 0.04, 0.6, 0.5, 4.0, 3.0, 20.0, 10.0 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 8.0, 4.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, -1, 3, V, -2, -1, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.01, 0.1, 1.0, 10.0 ] ); + V = new Float64Array( [ 10.0, 3.0, 0.5, 0.04, 20.0, 4.0, 0.6, 0.08 ] ); + V = new Float64Array( [ 0.08, 0.6, 4.0, 20.0, 0.04, 0.5, 3.0, 10.0 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 8.0, 6.0, 4.0, 2.0, 4.0, 5.0, 3.0, 1.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, -1, 3, V, -1, -4, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (row-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 1, 0, V, 2, 1, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 8.0, 6.0, 4.0, 2.0, 7.0, 5.0, 3.0, 1.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 1.0, 3.0, 5.0, 7.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, -1, 3, V, -1, -4, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (row-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 1.0, 4.0, 3.0, 6.0, 5.0, 8.0, 7.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, -1, 3, V, -2, -1, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + V = new Float64Array( [ 8.0, 6.0, 4.0, 2.0, 7.0, 5.0, 3.0, 1.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 1.0, 3.0, 5.0, 7.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, -1, 3, V, -1, -4, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (row-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.1, 10.0, 3.0 ] ); + V = new Float64Array( [ 2.0, 1.0, 0.6, 0.5, 4.0, 3.0, 8.0, 7.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 1.0, 0.06, 0.05, 40.0, 30.0, 8.0, 7.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, -1, 3, V, -2, -1, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.1, 10.0, 3.0 ] ); + V = new Float64Array( [ 2.0, 0.6, 4.0, 8.0, 1.0, 0.5, 3.0, 7.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 0.06, 40.0, 8.0, 1.0, 0.05, 30.0, 7.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, -1, 3, V, -1, -4, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (row-major)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.1, 10.0, 3.0 ] ); + V = new Float64Array( [ 2.0, 1.0, 0.6, 0.5, 4.0, 8.0, 8.0, 7.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 1.0, 6.0, 5.0, 0.4, 0.8, 8.0, 7.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, -1, 3, V, -2, -1, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (column-major) (negative strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 0.0, 0.1, 10.0, 3.0 ] ); + V = new Float64Array( [ 2.0, 0.6, 4.0, 8.0, 1.0, 0.5, 8.0, 7.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 6.0, 0.4, 8.0, 1.0, 5.0, 0.8, 7.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, -1, 3, V, -1, -4, 7 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 2.0, 1.0, 4.0, 3.0, 6.0, 5.0, 8.0, 7.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 1.0, 6.0, 5.0, 4.0, 3.0, 8.0, 7.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, 1, 0, V, 2, -1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (column-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 1.0, 3.0, 5.0, 7.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 6.0, 4.0, 8.0, 1.0, 5.0, 3.0, 7.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, 1, 0, V, 1, -4, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 2.0, 1.0, 4.0, 3.0, 6.0, 5.0, 8.0, 7.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 1.0, 6.0, 5.0, 4.0, 3.0, 8.0, 7.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, 1, 0, V, 2, -1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (column-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 2.0, 0.0 ] ); + V = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 1.0, 3.0, 5.0, 7.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 2.0, 6.0, 4.0, 8.0, 1.0, 5.0, 3.0, 7.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, 1, 0, V, 1, -4, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.1 ] ); + V = new Float64Array( [ 20.0, 10.0, 4.0, 3.0, 0.6, 0.5, 0.08, 0.04 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 200.0, 100.0, 4.0, 3.0, 0.06, 0.05, 0.008, 0.004 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, 1, 0, V, 2, -1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (column-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.1 ] ); + V = new Float64Array( [ 20.0, 4.0, 0.6, 0.08, 10.0, 3.0, 0.5, 0.04 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 200.0, 4.0, 0.06, 0.008, 100.0, 3.0, 0.05, 0.004 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, 1, 0, V, 1, -4, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.01 ] ); + V = new Float64Array( [ 20.0, 10.0, 4.0, 3.0, 0.6, 0.5, 0.08, 0.04 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 2.0, 1.0, 4.0, 3.0, 6.0, 5.0, 8.0, 4.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, 1, 0, V, 2, -1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (column-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 1.0, 0.1, 0.01 ] ); + V = new Float64Array( [ 20.0, 4.0, 0.6, 0.08, 10.0, 3.0, 0.5, 0.04 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 1.0, 3.0, 5.0, 4.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, 1, 0, V, 1, -4, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 2.0, 1.0, 4.0, 3.0, 6.0, 5.0, 8.0, 7.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 1, 0, V, 2, -1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (column-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 1.0, 3.0, 5.0, 7.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 6.0, 4.0, 2.0, 7.0, 5.0, 3.0, 1.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 1, 0, V, 1, -4, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 2.0, 1.0, 4.0, 3.0, 6.0, 5.0, 8.0, 7.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 7.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, 1, 0, V, 2, -1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (column-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 2.0, 1.0, 0.0 ] ); + V = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 1.0, 3.0, 5.0, 7.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 6.0, 4.0, 2.0, 7.0, 5.0, 3.0, 1.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, 1, 0, V, 1, -4, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 8.0, 7.0, 4.0, 3.0, 0.6, 0.5, 2.0, 1.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 7.0, 40.0, 30.0, 0.06, 0.05, 2.0, 1.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, 1, 0, V, 2, -1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (column-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 8.0, 4.0, 0.6, 2.0, 7.0, 3.0, 0.5, 1.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 40.0, 0.06, 2.0, 7.0, 30.0, 0.05, 1.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, 1, 0, V, 1, -4, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 8.0, 7.0, 4.0, 8.0, 0.6, 0.5, 2.0, 1.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 7.0, 0.4, 0.8, 6.0, 5.0, 2.0, 1.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, 1, 0, V, 2, -1, 1 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (column-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 10.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 8.0, 4.0, 0.6, 2.0, 7.0, 8.0, 0.5, 1.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 8.0, 0.4, 6.0, 2.0, 7.0, 0.8, 5.0, 1.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, 1, 0, V, 1, -4, 4 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (row-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 2.0, 0.0, 2.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0, 0.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 5.0, 0.0, 6.0, 0.0, 3.0, 0.0, 4.0, 0.0, 7.0, 0.0, 8.0, 0.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, 2, 0, V, 4, 2, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = permute (column-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 2.0, 0.0, 2.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 0.0, 5.0, 0.0, 3.0, 0.0, 7.0, 0.0, 2.0, 0.0, 6.0, 0.0, 4.0, 0.0, 8.0, 0.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 2, 2, scale, 2, 0, V, 2, 8, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (row-major) (mixed strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 2.0, 0.0, 2.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0, 0.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 5.0, 0.0, 6.0, 0.0, 3.0, 0.0, 4.0, 0.0, 7.0, 0.0, 8.0, 0.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, 2, 0, V, 4, 2, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output when ilo = ihi and job = both (column-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 2.0, 0.0, 2.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 1.0, 0.0, 5.0, 0.0, 3.0, 0.0, 7.0, 0.0, 2.0, 0.0, 6.0, 0.0, 4.0, 0.0, 8.0, 0.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 7.0, 8.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 2, 2, scale, 2, 0, V, 2, 8, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (row-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 0.0, 1.0, 0.0, 0.1, 0.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 10.0, 0.0, 20.0, 0.0, 3.0, 0.0, 4.0, 0.0, 0.5, 0.0, 0.6, 0.0, 0.04, 0.0, 0.08, 0.0 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 100.0, 0.0, 200.0, 0.0, 3.0, 0.0, 4.0, 0.0, 0.05, 0.0, 0.06, 0.0, 0.004, 0.0, 0.008, 0.0 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, 2, 0, V, 4, 2, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (right side) (column-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 0.0, 1.0, 0.0, 0.1, 0.0, 0.1, 0.0 ] ); + V = new Float64Array( [ 10.0, 0.0, 3.0, 0.0, 0.5, 0.0, 0.04, 0.0, 20.0, 0.0, 4.0, 0.0, 0.6, 0.0, 0.08, 0.0 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 100.0, 0.0, 3.0, 0.0, 0.05, 0.0, 0.004, 0.0, 200.0, 0.0, 4.0, 0.0, 0.06, 0.0, 0.008, 0.0 ] ); + + /* + expected = [ + [ 100.0, 200.0 ], + [ 3.0, 4.0 ], + [ 0.05, 0.06 ], + [ 0.004, 0.008 ] + ] + */ + + actual = dgebak( 'scale', 'right', 4, 2, 0, 3, scale, 2, 0, V, 2, 8, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (row-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 0.0, 1.0, 0.0, 0.1, 0.0, 0.01, 0.0 ] ); + V = new Float64Array( [ 10.0, 0.0, 20.0, 0.0, 3.0, 0.0, 4.0, 0.0, 0.5, 0.0, 0.6, 0.0, 0.04, 0.0, 0.08, 0.0 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 4.0, 0.0, 8.0, 0.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, 2, 0, V, 4, 2, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = scale (left side) (column-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 10.0, 0.0, 1.0, 0.0, 0.1, 0.0, 0.01, 0.0 ] ); + V = new Float64Array( [ 10.0, 0.0, 3.0, 0.0, 0.5, 0.0, 0.04, 0.0, 20.0, 0.0, 4.0, 0.0, 0.6, 0.0, 0.08, 0.0 ] ); + + /* + V = [ + [ 10.0, 20.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 0.04, 0.08 ] + ] + */ + + expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 5.0, 0.0, 4.0, 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); + + /* + expected = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 4.0, 8.0 ] + ] + */ + + actual = dgebak( 'scale', 'left', 4, 2, 0, 3, scale, 2, 0, V, 2, 8, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (row-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0, 0.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.0, 8.0, 0.0, 5.0, 0.0, 6.0, 0.0, 3.0, 0.0, 4.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 2, 0, V, 4, 2, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (right side) (column-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.0, 5.0, 0.0, 3.0, 0.0, 1.0, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'right', 4, 2, 0, 1, scale, 2, 0, V, 2, 8, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (row-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0, 0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0, 0.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.0, 8.0, 0.0, 5.0, 0.0, 6.0, 0.0, 3.0, 0.0, 4.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, 2, 0, V, 4, 2, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = permute (left side) (column-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 2.0, 0.0, 1.0, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 8.0, 0.0 ] ); + + /* + V = [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.0, 5.0, 0.0, 3.0, 0.0, 1.0, 0.0, 8.0, 0.0, 6.0, 0.0, 4.0, 0.0, 2.0, 0.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'permute', 'left', 4, 2, 0, 1, scale, 2, 0, V, 2, 8, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (row-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 10.0, 0.0, 0.1, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 7.0, 0.0, 8.0, 0.0, 3.0, 0.0, 4.0, 0.0, 0.5, 0.0, 0.6, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.0, 8.0, 0.0, 30.0, 0.0, 40.0, 0.0, 0.05, 0.0, 0.06, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, 2, 0, V, 4, 2, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (right side) (column-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 10.0, 0.0, 0.1, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 7.0, 0.0, 3.0, 0.0, 0.5, 0.0, 1.0, 0.0, 8.0, 0.0, 4.0, 0.0, 0.6, 0.0, 2.0, 0.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 3.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.0, 30.0, 0.0, 0.05, 0.0, 1.0, 0.0, 8.0, 0.0, 40.0, 0.0, 0.06, 0.0, 2.0, 0.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 30.0, 40.0 ], + [ 0.05, 0.06 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'right', 4, 2, 1, 2, scale, 2, 0, V, 2, 8, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (row-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 10.0, 0.0, 0.1, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 7.0, 0.0, 8.0, 0.0, 8.0, 0.0, 4.0, 0.0, 0.5, 0.0, 0.6, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.0, 8.0, 0.0, 0.8, 0.0, 0.4, 0.0, 5.0, 0.0, 6.0, 0.0, 1.0, 0.0, 2.0, 0.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, 2, 0, V, 4, 2, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected output for job = both (left side) (column-major) (large strides)', function test( t ) { + var expected; + var actual; + var scale; + var V; + + scale = new Float64Array( [ 3.0, 0.0, 10.0, 0.0, 0.1, 0.0, 0.0, 0.0 ] ); + V = new Float64Array( [ 7.0, 0.0, 8.0, 0.0, 0.5, 0.0, 1.0, 0.0, 8.0, 0.0, 4.0, 0.0, 0.6, 0.0, 2.0, 0.0 ] ); + + /* + V = [ + [ 7.0, 8.0 ], + [ 8.0, 4.0 ], + [ 0.5, 0.6 ], + [ 1.0, 2.0 ] + ] + */ + + expected = new Float64Array( [ 7.0, 0.0, 0.8, 0.0, 5.0, 0.0, 1.0, 0.0, 8.0, 0.0, 0.4, 0.0, 6.0, 0.0, 2.0, 0.0 ] ); + + /* + expected = [ + [ 7.0, 8.0 ], + [ 0.8, 0.4 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ] + */ + + actual = dgebak( 'both', 'left', 4, 2, 1, 2, scale, 2, 0, V, 2, 8, 0 ); + + t.deepEqual( actual, expected, 'returns expected value' ); + t.end(); +});