diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/README.md b/lib/node_modules/@stdlib/lapack/base/dlascl/README.md new file mode 100644 index 000000000000..f791296b575e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/README.md @@ -0,0 +1,249 @@ + + +# dlascl + +> LAPACK routine to multiply a real M by N matrix `A` by a real scalar `CTO/CFROM`. + +
+ +## Usage + +```javascript +var dlascl = require( '@stdlib/lapack/base/dlascl' ); +``` + +#### dlascl( order, type, KL, KU, CFROM, CTO, M, N, A, LDA ) + +Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] + +dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); +// A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **type**: specifies the type of matrix `A` ( should be one of these: `general`, `upper`, `lower`, `upper-hessenberg`, `symmetric-banded-lower`, `symmetric-banded-upper` or `banded` ). +- **KL**: lower band width of `A`. Referenced only if type is `symmetric-banded-lower` or `banded`. +- **KU**: upper band width of `A`. Referenced only if type is `symmetric-banded-upper` or `banded`. +- **CFROM**: the matrix `A` is multiplied by `CTO / CFROM`. +- **CTO**: the matrix `A` is multiplied by `CTO / CFROM`. +- **M**: number of rows in matrix `A`. +- **N**: number of columns in matrix `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +If `type` is `banded`, `symmetric-banded-lower` or `symmetric-banded-upper` the matrix should be stored in the [`Band storage`][lapack-band-storage] format. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A1, 2 ); +// A0 => [ 0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +``` + +#### dlascl.ndarray( type, KL, KU, CFROM, CTO, M, N, A, strideA1, strideA2, offsetA ) + +Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] + +dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2, 1, 0 ); +// A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +``` + +The function has the following additional parameters: + +- **type**: specifies the type of matrix `A` ( should be one of these: `general`, `upper`, `lower`, `upper-hessenberg`, `symmetric-banded-lower`, `symmetric-banded-upper` or `banded` ). +- **KL**: lower band width of `A`. Referenced only if type is `symmetric-banded-lower` or `banded`. +- **KU**: upper band width of `A`. Referenced only if type is `symmetric-banded-upper` or `banded`. +- **CFROM**: the matrix `A` is multiplied by `CTO / CFROM`. +- **CTO**: the matrix `A` is multiplied by `CTO / CFROM`. +- **M**: number of rows in matrix `A`. +- **N**: number of columns in matrix `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **strideA1**: stride of the first dimension of `A`. +- **strideA2**: stride of the second dimension of `A`. +- **offsetA**: starting index for `A`. + +If `type` is `banded`, `symmetric-banded-lower` or `symmetric-banded-upper` the matrix should be stored in the [`Band storage`][lapack-band-storage] format. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2, 1, 1 ); +// A => [ 0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +``` + +
+ + + +
+ +## Notes + +- `dlascl()` corresponds to the [LAPACK][lapack] routine [`dlascl`][lapack-dlascl]. +- If `type` is `banded`, `symmetric-banded-lower` or `symmetric-banded-upper` the matrix should be stored in the [`Band storage`][lapack-band-storage] format. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlascl = require( '@stdlib/lapack/base/dlascl' ); + +// Define a matrix A (3x2 in row-major order): +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +console.log( 'Initial A (row-major): ', A ); + +dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); +console.log( 'Scaled A (row-major): ', A ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlascl/benchmark/benchmark.js new file mode 100644 index 000000000000..83204efdac05 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/benchmark/benchmark.js @@ -0,0 +1,117 @@ +/** +* @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 dlascl = require( './../lib/dlascl.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of rows/columns +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var LDA; + var A; + + LDA = N; + + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dlascl( order, 'general', 0, 0, 1.0, 2.0, N, N, A, LDA ); + 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 min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( pkg+'::square_matrix:order='+ord+',size='+(N*N), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlascl/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..c73ffd067621 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/benchmark/benchmark.ndarray.js @@ -0,0 +1,124 @@ +/** +* @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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dlascl = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of rows/columns +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var sa1; + var sa2; + var A; + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dlascl( 'general', 0, 0, 1.0, 2.0, N, N, A, sa1, sa2, 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 min; + var max; + var ord; + var N; + var f; + var i; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( ord, N ); + bench( pkg+'::square_matrix:ndarray:order='+ord+',size='+(N*N), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlascl/docs/repl.txt new file mode 100644 index 000000000000..3d3cf98d8244 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/docs/repl.txt @@ -0,0 +1,112 @@ +{{alias}}( order, type, KL, KU, CFROM, CTO, M, N, A, LDA ) + Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM`. + + 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'. + + type: string + Specifies the type of matrix `A`. + + KL: nonNegativeInteger + Lower band width of `A`. Referenced only if type is + `symmetric-banded-lower` or `banded`. + + KU: nonNegativeInteger + Upper band width of `A`. Referenced only if type is + `symmetric-banded-upper` or `banded`. + + CFROM: number + The matrix `A` are multiplied by `CTO / CFROM`. + + CTO: number + The matrix `A` are multiplied by `CTO / CFROM`. + + M: nonNegativeInteger + Number of rows in matrix `A`. + + N: nonNegativeInteger + Number of columns in matrix `A`. + + A: Float64Array + Input matrix `A`. + + LDA: positiveInteger + Stride of the first dimension of `A` (a.k.a., leading dimension of + the matrix `A`). + + Returns + ------- + A: Float64Array + Scaled matrix `A`. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ) + [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + + +{{alias}}.ndarray( type, KL, KU, CFROM, CTO, M, N, A, sa1, sa2, oa ) + Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM` 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 + ---------- + type: string + Specifies the type of matrix `A`. + + KL: nonNegativeInteger + Lower band width of `A`. Referenced only if type is + `symmetric-banded-lower` or `banded`. + + KU: nonNegativeInteger + Upper band width of `A`. Referenced only if type is + `symmetric-banded-upper` or `banded`. + + CFROM: number + The matrix `A` are multiplied by `CTO / CFROM`. + + CTO: number + The matrix `A` are multiplied by `CTO / CFROM`. + + M: nonNegativeInteger + Number of rows in matrix `A`. + + N: nonNegativeInteger + Number of columns in matrix `A`. + + A: Float64Array + Input matrix `A`. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: nonNegativeInteger + Starting index for `A`. + + Returns + ------- + A: Float64Array + Scaled matrix `A`. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2, 1, 0 ) + [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlascl/docs/types/index.d.ts new file mode 100644 index 000000000000..2da272ea1bcc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/docs/types/index.d.ts @@ -0,0 +1,117 @@ +/* +* @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'; + +/** +* Interface describing `dlascl`. +*/ +interface Routine { + /** + * Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM`. + * + * @param order - storage layout + * @param type - specifies the type of matrix `A` + * @param KL - lower band width of `A`. Referenced only if type is `symmetric-banded-lower` or `banded`. + * @param KU - upper band width of `A`. Referenced only if type is `symmetric-banded-upper` or `banded`. + * @param CFROM - the matrix `A` is multiplied by `CTO / CFROM` + * @param CTO - the matrix `A` is multiplied by `CTO / CFROM` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @returns scaled matrix `A` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] + * + * dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); + * // A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + */ + ( order: Layout, type: string, KL: number, KU: number, CFROM: number, CTO: number, M: number, N: number, A: Float64Array, LDA: number ): Float64Array; + + /** + * Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM` using alternative indexing semantics. + * + * @param type - specifies the type of matrix `A` + * @param KL - lower band width of `A`. Referenced only if type is `symmetric-banded-lower` or `banded`. + * @param KU - upper band width of `A`. Referenced only if type is `symmetric-banded-upper` or `banded`. + * @param CFROM - the matrix `A` is multiplied by `CTO / CFROM` + * @param CTO - the matrix `A` is multiplied by `CTO / CFROM` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @returns scaled matrix `A` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] + * + * dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2, 1, 0 ); + * // A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] + */ + ndarray( type: string, KL: number, KU: number, CFROM: number, CTO: number, M: number, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; +} + +/** +* Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM`. +* +* @param order - storage layout +* @param type - specifies the type of matrix `A` +* @param KL - lower band width of `A`. Referenced only if type is `symmetric-banded-lower` or `banded`. +* @param KU - upper band width of `A`. Referenced only if type is `symmetric-banded-upper` or `banded`. +* @param CFROM - the matrix `A` is multiplied by `CTO / CFROM` +* @param CTO - the matrix `A` is multiplied by `CTO / CFROM` +* @param M - number of rows in matrix `A` +* @param N - number of columns in matrix `A` +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @returns scaled matrix `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); +* // A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2, 1, 0 ); +* // A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +declare var dlascl: Routine; + + +// EXPORTS // + +export = dlascl; diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlascl/docs/types/test.ts new file mode 100644 index 000000000000..87d4bc1d597c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/docs/types/test.ts @@ -0,0 +1,363 @@ +/* +* @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 dlascl = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( 6 ); + + dlascl( 5, 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( true, 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( false, 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( null, 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( void 0, 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( [], 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( {}, 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( ( x: number ): number => x, 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 5, 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', true, 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', false, 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', null, 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', void 0, 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', [], 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', {}, 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', ( x: number ): number => x, 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 'general', '5', 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', true, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', false, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', null, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', void 0, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', [], 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', {}, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', ( x: number ): number => x, 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 'general', 0, '5', 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, true, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, false, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, null, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, void 0, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, [], 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, {}, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, ( x: number ): number => x, 1.0, 2.0, 3, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 'general', 0, 0, '5', 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, true, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, false, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, null, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, void 0, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, [], 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, {}, 2.0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, ( x: number ): number => x, 2.0, 3, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 'general', 0, 0, 1.0, '5', 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, true, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, false, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, null, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, void 0, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, [], 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, {}, 3, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, ( x: number ): number => x, 3, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, '3', 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, true, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, false, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, null, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, void 0, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, [], 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, {}, 2, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, ( x: number ): number => x, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, '2', A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, true, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, false, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, null, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, void 0, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, [], A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, {}, A, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, ( x: number ): number => x, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, 'A', 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, 5, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, true, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, false, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, null, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, void 0, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, [], 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, {}, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, '2' ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, true ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, false ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, null ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, void 0 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, [] ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, {} ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( 6 ); + + dlascl(); // $ExpectError + dlascl( 'row-major' ); // $ExpectError + dlascl( 'row-major', 'general' ); // $ExpectError + dlascl( 'row-major', 'general', 0 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2 ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A ); // $ExpectError + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a string... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 5, 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( true, 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( false, 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( null, 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( void 0, 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( [], 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( {}, 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( ( x: number ): number => x, 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', '0', 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', true, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', false, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', null, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', void 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', [], 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', {}, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', ( x: number ): number => x, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, '0', 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, true, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, false, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, null, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, void 0, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, [], 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, {}, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, ( x: number ): number => x, 1.0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, 0, '1.0', 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, true, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, false, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, null, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, void 0, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, [], 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, {}, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, ( x: number ): number => x, 2.0, 3, 2, A, 1, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, 0, 1.0, '2.0', 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, true, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, false, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, null, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, void 0, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, [], 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, {}, 3, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, ( x: number ): number => x, 3, 2, A, 1, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, '3', 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, true, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, false, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, null, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, void 0, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, [], 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, {}, 2, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, ( x: number ): number => x, 2, A, 1, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, '2', A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, true, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, false, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, null, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, void 0, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, [], A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, {}, A, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, ( x: number ): number => x, A, 1, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a Float64Array... +{ + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, 'A', 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, 5, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, true, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, false, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, null, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, void 0, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, [], 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, {}, 1, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, ( x: number ): number => x, 1, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, '1', 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, true, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, false, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, null, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, void 0, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, [], 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, {}, 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, ( x: number ): number => x, 0, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, '0', 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, true, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, false, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, null, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, void 0, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, [], 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, {}, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, '2' ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, true ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, false ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, null ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, void 0 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, [] ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, {} ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Float64Array( 6 ); + + dlascl.ndarray(); // $ExpectError + dlascl.ndarray( 'general' ); // $ExpectError + dlascl.ndarray( 'general', 0 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0 ); // $ExpectError + dlascl.ndarray( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 1, 0, 2, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlascl/examples/index.js new file mode 100644 index 000000000000..418b447a1e8f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/examples/index.js @@ -0,0 +1,29 @@ +/** +* @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 dlascl = require( './../lib' ); + +// Define a matrix A (3x2 in row-major order): +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +console.log( 'Initial A (row-major): ', A ); + +dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); +console.log( 'Scaled A (row-major): ', A ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/base.js new file mode 100644 index 000000000000..e231741a119a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/base.js @@ -0,0 +1,277 @@ +/** +* @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-statements, max-len */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlamch = require( '@stdlib/lapack/base/dlamch' ); +var loopOrder = require( '@stdlib/ndarray/base/nullary-loop-interchange-order' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var min = require( '@stdlib/math/base/special/fast/min' ); + + +// VARIABLES // + +var smlnum = dlamch( 'safe minimum' ); +var bignum = 1.0 / smlnum; + + +// MAIN // + +/** +* Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM`. +* +* @private +* @param {string} type - specifies the type of matrix `A` +* @param {NonNegativeInteger} KL - lower band width of `A`. Referenced only if type is `symmetric-banded-lower` or `banded`. +* @param {NonNegativeInteger} KU - upper band width of `A`. Referenced only if type is `symmetric-banded-upper` or `banded`. +* @param {number} CFROM - the matrix `A` is multiplied by `CTO / CFROM` +* @param {number} CTO - the matrix `A` is multiplied by `CTO / CFROM` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @returns {Float64Array} scaled matrix `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* dlascl( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2, 1, 0 ); +* // A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +function dlascl( type, KL, KU, CFROM, CTO, M, N, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-params + var cfromc; + var cfrom1; + var ctoc; + var cto1; + var done; + var mul; + var da1; + var da0; + var S1; + var S0; + var ia; + var i0; + var i1; + var k3; + var k4; + var k1; + var k2; + var sh; + var sa; + var o; + + if ( N === 0 || M === 0 ) { + return A; + } + + done = false; + + cfromc = CFROM; + ctoc = CTO; + + while ( !done ) { + cfrom1 = CTO * smlnum; + if ( cfrom1 === cfromc ) { + // cfromc is Infinity, multiply by a correctly signed zero for finite ctoc or NaN + mul = ctoc / cfromc; + done = true; + cto1 = ctoc; + } else { + cto1 = ctoc / bignum; + if ( cto1 === ctoc ) { + // ctoc is either zero or Infinity, thus ctoc itself is a correct multiplication factor + mul = ctoc; + done = true; + cfromc = 1.0; + } else if ( abs( cfrom1 ) > abs( ctoc ) && ctoc !== 0.0 ) { + mul = smlnum; + done = false; + ctoc = cto1; + } else if ( abs( cto1 ) > abs( cfromc ) ) { + mul = bignum; + done = false; + ctoc = cto1; + } else { + mul = ctoc / cfromc; + done = true; + } + } + + if ( type === 'general' ) { + // Full matrix + + // Resolve the loop interchange order: + o = loopOrder( [ M, N ], [ strideA1, strideA2 ] ); + sh = o.sh; + sa = o.sx; + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0*sa[0] ); + + // Set the pointers to the first indexed elements in the respective matrices... + ia = offsetA; + + // Iterate over the matrix dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + A[ ia ] *= mul; + ia += da0; + } + ia += da1; + } + } + + if ( type === 'upper' ) { + // Upper triangular matrix + ia = offsetA; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = i1; i0 < N; i0++ ) { + A[ ia+(i0*strideA2) ] *= mul; + } + ia += strideA1; + } + } else { + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = 0; i0 <= min( i1, M-1 ); i0++ ) { + A[ ia+(i0*strideA1) ] *= mul; + } + ia += strideA2; + } + } + } + + if ( type === 'lower' ) { + // Lower triangular matrix + ia = offsetA; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = 0; i0 <= min( i1, N-1 ); i0++ ) { + A[ ia+(i0*strideA2) ] *= mul; + } + ia += strideA1; + } + } else { + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = i1; i0 < M; i0++ ) { + A[ ia+(i0*strideA1) ] *= mul; + } + ia += strideA2; + } + } + } + + if ( type === 'upper-hessenberg' ) { + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ia = offsetA; + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = 0; i0 <= min( i1+1, N-1 ); i0++ ) { + A[ ia+(i0*strideA2) ] *= mul; + } + ia += strideA1; + } + } else { + ia = offsetA; + for ( i0 = 0; i0 < N; i0++ ) { + for ( i1 = 0; i1 <= min( i0+1, M-1 ); i1++ ) { + A[ ia+(i1*strideA1) ] *= mul; + } + ia += strideA2; + } + } + } + + if ( type === 'symmetric-banded-lower' ) { + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ia = offsetA; + k3 = KL + 1; + k4 = N; + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = max( 0, i1 - KL ); i0 < min( k4, i1 + 1 ); i0++ ) { + A[ ia+( ( i1-i0 ) * strideA2) ] *= mul; + } + ia += strideA1; + } + } else { + ia = offsetA; + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = 0; i0 < min( k3, k4 - i1 ); i0++ ) { + A[ ia+(i0*strideA1) ] *= mul; + } + ia += strideA2; + } + } + } + + if ( type === 'symmetric-banded-upper' ) { + k1 = KU + 1; + ia = offsetA; + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = i1; i0 < min( N, i1 + k1 ); i0++ ) { + A[ ia + ( (i0-i1) * strideA2) ] *= mul; + } + ia += strideA1; + } + } else { + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = max( k1 - i1, 0 ); i0 < k1; i0++ ) { + A[ ia+(i0*strideA1) ] *= mul; + } + ia += strideA2; + } + } + } + + if ( type === 'banded' ) { + k1 = KL + KU; + k2 = KL; + k3 = ( 2 * KL ) + KU; + k4 = KL + KU + M - 1; + ia = offsetA; + + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = max( k1 - i1, k2 ); i0 <= min( k3, k4-i1 ); i0++ ) { + A[ ia+(i0*strideA1) ] *= mul; + } + ia += strideA2; + } + } + } + + return A; +} + + +// EXPORTS // + +module.exports = dlascl; diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/lib/dlascl.js b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/dlascl.js new file mode 100644 index 000000000000..4a1154a3440e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/dlascl.js @@ -0,0 +1,101 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major-string' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM`. +* +* @param {string} order - storage layout +* @param {string} type - specifies the type of matrix `A` +* @param {NonNegativeInteger} KL - lower band width of `A`. Referenced only if type is `symmetric-banded-lower` or `banded`. +* @param {NonNegativeInteger} KU - upper band width of `A`. Referenced only if type is `symmetric-banded-upper` or `banded`. +* @param {number} CFROM - the matrix `A` is multiplied by `CTO / CFROM` +* @param {number} CTO - the matrix `A` is multiplied by `CTO / CFROM` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fourth argument must be greater than or equal to max(1,N) +* @returns {Float64Array} scaled matrix `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); +* // A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +function dlascl( order, type, KL, KU, CFROM, CTO, M, N, A, LDA ) { + var sa1; + var sa2; + var s; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + + if ( type !== 'general' && type !== 'upper' && type !== 'lower' && type !== 'upper-hessenberg' && type !== 'symmetric-banded-lower' && type !== 'symmetric-banded-upper' && type !== 'banded' ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid matrix type. Value: `%s`.', type ) ); + } + + if ( isRowMajor( order ) ) { + s = N; + } else if ( type === 'general' || type === 'upper' || type === 'lower' || type === 'upper-hessenberg' ) { + s = M; + } else if ( type === 'symmetric-banded-lower' ) { + s = KL + 1; + } else if ( type === 'symmetric-banded-upper' ) { + s = KU + 1; + } else { + s = (2*KL) + KU + 1; + } + + if ( LDA < max( 1, s ) ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.', s, LDA ) ); + } + + if ( isColumnMajor( order ) ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + + return base( type, KL, KU, CFROM, CTO, M, N, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = dlascl; diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/index.js new file mode 100644 index 000000000000..c1efddb9eef0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/index.js @@ -0,0 +1,59 @@ +/** +* @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 multiply a real M by N matrix `A` by a real scalar `CTO/CFROM`. +* +* @module @stdlib/lapack/base/dlascl +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlascl = require( '@stdlib/lapack/base/dlascl' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2 ); +* // A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var dlascl; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlascl = main; +} else { + dlascl = tmp; +} + + +// EXPORTS // + +module.exports = dlascl; + +// exports: { "ndarray": "dlascl.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/main.js new file mode 100644 index 000000000000..76e9fd4d9586 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/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 dlascl = require( './dlascl.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlascl, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlascl; diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/ndarray.js new file mode 100644 index 000000000000..63fe7f1b73c7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/lib/ndarray.js @@ -0,0 +1,65 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Multiplies a real M by N matrix `A` by a real scalar `CTO/CFROM` using alternative indexing semantics. +* +* @param {string} type - specifies the type of matrix `A` +* @param {NonNegativeInteger} KL - lower band width of `A`. Referenced only if type is `symmetric-banded-lower` or `banded`. +* @param {NonNegativeInteger} KU - upper band width of `A`. Referenced only if type is `symmetric-banded-upper` or `banded`. +* @param {number} CFROM - the matrix `A` is multiplied by `CTO / CFROM` +* @param {number} CTO - the matrix `A` is multiplied by `CTO / CFROM` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fourth argument must be greater than or equal to max(1,N) +* @returns {Float64Array} scaled matrix `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* dlascl( 'general', 0, 0, 1.0, 2.0, 3, 2, A, 2, 1, 0 ); +* // A => [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ] +*/ +function dlascl( type, KL, KU, CFROM, CTO, M, N, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params + if ( type !== 'general' && type !== 'upper' && type !== 'lower' && type !== 'upper-hessenberg' && type !== 'symmetric-banded-lower' && type !== 'symmetric-banded-upper' && type !== 'banded' ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid matrix type. Value: `%s`.', type ) ); + } + return base( type, KL, KU, CFROM, CTO, M, N, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dlascl; diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/package.json b/lib/node_modules/@stdlib/lapack/base/dlascl/package.json new file mode 100644 index 000000000000..c69c98163e7c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dlascl", + "version": "0.0.0", + "description": "LAPACK routine to multiply a real M by N matrix `A` by a real scalar `CTO/CFROM`.", + "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", + "dlascl", + "scale", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/banded_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/banded_column_major.json new file mode 100644 index 000000000000..9fcd8f4d79a7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/banded_column_major.json @@ -0,0 +1,42 @@ +{ + "order": "column-major", + "type": "banded", + "M": 5, + "N": 5, + "KL": 2, + "KU": 1, + "CFROM": 1.0, + "CTO": 10.0, + "A": [ + 0.0, 0.0, 0.0, 1.1, 2.1, 3.1, + 0.0, 0.0, 1.2, 2.2, 3.2, 4.2, + 0.0, 0.0, 2.3, 3.3, 4.3, 5.3, + 0.0, 0.0, 3.4, 4.4, 5.4, 0.0, + 0.0, 0.0, 4.5, 5.5, 0.0, 0.0 + ], + "A_mat": [ + [ 1.1, 1.2, 0.0, 0.0, 0.0 ], + [ 2.1, 2.2, 2.3, 0.0, 0.0 ], + [ 3.1, 3.2, 3.3, 3.4, 0.0 ], + [ 0.0, 4.2, 4.3, 4.4, 4.5 ], + [ 0.0, 0.0, 5.3, 5.4, 5.5 ] + ], + "LDA": 6, + "strideA1": 1, + "strideA2": 6, + "offsetA": 0, + "A_out": [ + 0.0, 0.0, 0.0, 11.0, 21.0, 31.0, + 0.0, 0.0, 12.0, 22.0, 32.0, 42.0, + 0.0, 0.0, 23.0, 33.0, 43.0, 53.0, + 0.0, 0.0, 34.0, 44.0, 54.0, 0.0, + 0.0, 0.0, 45.0, 55.0, 0.0, 0.0 + ], + "A_out_mat": [ + [ 11.0, 12.0, 0.0, 0.0, 0.0 ], + [ 21.0, 22.0, 23.0, 0.0, 0.0 ], + [ 31.0, 32.0, 33.0, 34.0, 0.0 ], + [ 0.0, 42.0, 43.0, 44.0, 45.0 ], + [ 0.0, 0.0, 53.0, 54.0, 55.0 ] + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/banded_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/banded_row_major.json new file mode 100644 index 000000000000..c166ace4cf04 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/banded_row_major.json @@ -0,0 +1,44 @@ +{ + "order": "row-major", + "type": "banded", + "M": 5, + "N": 5, + "KL": 2, + "KU": 1, + "CFROM": 1.0, + "CTO": 10.0, + "A": [ + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 1.2, 2.3, 3.4, 4.5, + 1.1, 2.2, 3.3, 4.4, 5.5, + 2.1, 3.2, 4.3, 5.4, 0.0, + 3.1, 4.2, 5.3, 0.0, 0.0 + ], + "A_mat": [ + [ 1.1, 1.2, 0.0, 0.0, 0.0 ], + [ 2.1, 2.2, 2.3, 0.0, 0.0 ], + [ 3.1, 3.2, 3.3, 3.4, 0.0 ], + [ 0.0, 4.2, 4.3, 4.4, 4.5 ], + [ 0.0, 0.0, 5.3, 5.4, 5.5 ] + ], + "LDA": 5, + "strideA1": 5, + "strideA2": 1, + "offsetA": 0, + "A_out": [ + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 12.0, 23.0, 34.0, 45.0, + 11.0, 22.0, 33.0, 44.0, 55.0, + 21.0, 32.0, 43.0, 54.0, 0.0, + 31.0, 42.0, 53.0, 0.0, 0.0 + ], + "A_out_mat": [ + [ 11.0, 12.0, 0.0, 0.0, 0.0 ], + [ 21.0, 22.0, 23.0, 0.0, 0.0 ], + [ 31.0, 32.0, 33.0, 34.0, 0.0 ], + [ 0.0, 42.0, 43.0, 44.0, 45.0 ], + [ 0.0, 0.0, 53.0, 54.0, 55.0 ] + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/general_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/general_column_major.json new file mode 100644 index 000000000000..3f9682f399de --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/general_column_major.json @@ -0,0 +1,26 @@ +{ + "order": "column-major", + "type": "general", + "M": 3, + "N": 2, + "KL": 0, + "KU": 0, + "CFROM": 1.0, + "CTO": 2.0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 2.0, 4.0, 6.0, 8.0, 10.0, 12.0 ], + "A_out_mat": [ + [ 2.0, 4.0 ], + [ 6.0, 8.0 ], + [ 10.0, 12.0 ] + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/general_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/general_row_major.json new file mode 100644 index 000000000000..ac970e7f1811 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/general_row_major.json @@ -0,0 +1,26 @@ +{ + "order": "row-major", + "type": "general", + "M": 3, + "N": 2, + "KL": 0, + "KU": 0, + "CFROM": 1.0, + "CTO": 2.0, + "A": [ 1.0, 4.0, 2.0, 5.0, 3.0, 6.0 ], + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 8.0, 4.0, 10.0, 6.0, 12.0 ], + "A_out_mat": [ + [ 2.0, 8.0 ], + [ 4.0, 10.0 ], + [ 6.0, 12.0 ] + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/lower_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/lower_column_major.json new file mode 100644 index 000000000000..babf42ed9e86 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/lower_column_major.json @@ -0,0 +1,26 @@ +{ + "order": "column-major", + "type": "lower", + "M": 3, + "N": 3, + "KL": 0, + "KU": 0, + "CFROM": 1.0, + "CTO": 2.0, + "A": [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ], + "A_mat": [ + [ 1.0, 0.0, 0.0 ], + [ 2.0, 4.0, 0.0 ], + [ 3.0, 5.0, 6.0 ] + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 2.0, 4.0, 6.0, 0.0, 8.0, 10.0, 0.0, 0.0, 12.0 ], + "A_out_mat": [ + [ 2.0, 0.0, 0.0 ], + [ 4.0, 8.0, 0.0 ], + [ 6.0, 10.0, 12.0 ] + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/lower_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/lower_row_major.json new file mode 100644 index 000000000000..e2f0b9837d5f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/lower_row_major.json @@ -0,0 +1,26 @@ +{ + "order": "row-major", + "type": "lower", + "M": 3, + "N": 3, + "KL": 0, + "KU": 0, + "CFROM": 1.0, + "CTO": 2.0, + "A": [ 1.0, 0.0, 0.0, 2.0, 4.0, 0.0, 3.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 0.0, 0.0 ], + [ 2.0, 4.0, 0.0 ], + [ 3.0, 5.0, 6.0 ] + ], + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 0.0, 0.0, 4.0, 8.0, 0.0, 6.0, 10.0, 12.0 ], + "A_out_mat": [ + [ 2.0, 0.0, 0.0 ], + [ 4.0, 8.0, 0.0 ], + [ 6.0, 10.0, 12.0 ] + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/upper_column_major.json b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/upper_column_major.json new file mode 100644 index 000000000000..dc639a094b76 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/upper_column_major.json @@ -0,0 +1,26 @@ +{ + "order": "column-major", + "type": "upper", + "M": 3, + "N": 3, + "KL": 0, + "KU": 0, + "CFROM": 1.0, + "CTO": 2.0, + "A": [ 1.0, 0.0, 0.0, 2.0, 3.0, 0.0, 4.0, 5.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 4.0 ], + [ 0.0, 3.0, 5.0 ], + [ 0.0, 0.0, 6.0 ] + ], + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 2.0, 0.0, 0.0, 4.0, 6.0, 0.0, 8.0, 10.0, 12.0 ], + "A_out_mat": [ + [ 2.0, 4.0, 8.0 ], + [ 0.0, 6.0, 10.0 ], + [ 0.0, 0.0, 12.0 ] + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/upper_row_major.json b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/upper_row_major.json new file mode 100644 index 000000000000..3cf311d545e3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/fixtures/upper_row_major.json @@ -0,0 +1,26 @@ +{ + "order": "row-major", + "type": "upper", + "M": 3, + "N": 3, + "KL": 0, + "KU": 0, + "CFROM": 1.0, + "CTO": 2.0, + "A": [ 1.0, 2.0, 4.0, 0.0, 3.0, 5.0, 0.0, 0.0, 6.0 ], + "A_mat": [ + [ 1.0, 2.0, 4.0 ], + [ 0.0, 3.0, 5.0 ], + [ 0.0, 0.0, 6.0 ] + ], + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 2.0, 4.0, 8.0, 0.0, 6.0, 10.0, 0.0, 0.0, 12.0 ], + "A_out_mat": [ + [ 2.0, 4.0, 8.0 ], + [ 0.0, 6.0, 10.0 ], + [ 0.0, 0.0, 12.0 ] + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/test.dlascl.js b/lib/node_modules/@stdlib/lapack/base/dlascl/test/test.dlascl.js new file mode 100644 index 000000000000..ca8628cd4253 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/test.dlascl.js @@ -0,0 +1,460 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlascl = require( './../lib/dlascl.js' ); + + +// FIXTURES // + +var GENERAL_COL_MAJOR = require( './fixtures/general_column_major.json' ); +var GENERAL_ROW_MAJOR = require( './fixtures/general_row_major.json' ); +var UPPER_COL_MAJOR = require( './fixtures/upper_column_major.json' ); +var UPPER_ROW_MAJOR = require( './fixtures/upper_row_major.json' ); +var LOWER_COL_MAJOR = require( './fixtures/lower_row_major.json' ); +var LOWER_ROW_MAJOR = require( './fixtures/lower_row_major.json' ); +var BANDED_COL_MAJOR = require( './fixtures/banded_column_major.json' ); +var BANDED_ROW_MAJOR = require( './fixtures/banded_row_major.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlascl, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dlascl.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 i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + 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() { + dlascl( value, 'general', 0, 0, 1, 1, 0, 0, new Float64Array(), 1 ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a valid matrix type', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + 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() { + dlascl( 'row-major', value, 0, 0, 1, 1, 0, 0, new Float64Array(), 1 ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (general, row-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'row-major', 'general', 0, 0, 1.0, 2.0, 2, 2, new Float64Array( 4 ), value ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (general, column-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'column-major', 'general', 0, 0, 1.0, 2.0, 2, 2, new Float64Array( 4 ), value ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (upper, row-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'row-major', 'upper', 0, 0, 1.0, 2.0, 2, 2, new Float64Array( 4 ), value ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (upper, column-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'column-major', 'upper', 0, 0, 1.0, 2.0, 2, 2, new Float64Array( 4 ), value ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (lower, row-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'row-major', 'lower', 0, 0, 1.0, 2.0, 2, 2, new Float64Array( 4 ), value ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (lower, column-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'column-major', 'lower', 0, 0, 1.0, 2.0, 2, 2, new Float64Array( 4 ), value ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (symmetric-banded-lower, column-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'column-major', 'symmetric-banded-lower', 1, 0, 1.0, 2.0, 5, 5, new Float64Array( 10 ), value ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (symmetric-banded-upper, column-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'column-major', 'symmetric-banded-upper', 0, 1, 1.0, 2.0, 5, 5, new Float64Array( 10 ), value ); + }; + } +}); + +tape( 'the function throws a range error if `LDA` is invalid (banded, column-major)', function test( t ) { + var values; + var i; + + values = [ + 0, + 1, + 2, + 3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws a range error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlascl( 'column-major', 'banded', 1, 1, 1.0, 2.0, 5, 5, new Float64Array( 20 ), value ); + }; + } +}); + +tape( 'the function scales a general matrix (column-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = GENERAL_COL_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales a general matrix (row-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = GENERAL_ROW_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales an upper triangular matrix (column-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = UPPER_COL_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales an upper triangular matrix (row-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = UPPER_ROW_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales a lower triangular matrix (column-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = LOWER_COL_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales a lower triangular matrix (row-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = LOWER_ROW_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales a banded matrix (column-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = BANDED_COL_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales a banded matrix (row-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = BANDED_ROW_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.order, data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.LDA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlascl/test/test.js new file mode 100644 index 000000000000..15d459bc01e3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/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 dlascl = 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 dlascl, '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 dlascl.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 dlascl = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlascl, 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 dlascl; + var main; + + main = require( './../lib/dlascl.js' ); + + dlascl = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlascl, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlascl/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlascl/test/test.ndarray.js new file mode 100644 index 000000000000..631d90008013 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlascl/test/test.ndarray.js @@ -0,0 +1,197 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dlascl = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var GENERAL_COL_MAJOR = require( './fixtures/general_column_major.json' ); +var GENERAL_ROW_MAJOR = require( './fixtures/general_row_major.json' ); +var UPPER_COL_MAJOR = require( './fixtures/upper_column_major.json' ); +var UPPER_ROW_MAJOR = require( './fixtures/upper_row_major.json' ); +var LOWER_COL_MAJOR = require( './fixtures/lower_row_major.json' ); +var LOWER_ROW_MAJOR = require( './fixtures/lower_row_major.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlascl, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( dlascl.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid matrix type', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + 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() { + dlascl( value, 0, 0, 1, 1, 0, 0, new Float64Array(), 1, 1, 0 ); + }; + } +}); + +tape( 'the function scales a general matrix (column-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = GENERAL_COL_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales a general matrix (row-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = GENERAL_ROW_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales an upper triangular matrix (column-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = UPPER_COL_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales an upper triangular matrix (row-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = UPPER_ROW_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales a lower triangular matrix (column-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = LOWER_COL_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function scales a lower triangular matrix (row-major)', function test( t ) { + var expected; + var data; + var out; + var A; + + data = LOWER_ROW_MAJOR; + + A = new Float64Array( data.A ); + + expected = new Float64Array( data.A_out ); + + out = dlascl( data.type, data.KL, data.KU, data.CFROM, data.CTO, data.M, data.N, A, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +});