diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/README.md b/lib/node_modules/@stdlib/blas/base/dtrsm/README.md new file mode 100644 index 000000000000..9e9e046e48a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/README.md @@ -0,0 +1,250 @@ + + +# dtrsm + +> Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. + +
+ +## Usage + +```javascript +var dtrsm = require( '@stdlib/blas/base/dtrsm' ); +``` + +#### dtrsm( order, side, uplo, transa, diag, m, n, alpha, A, LDA, B, LDB ) + +Solves matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); +B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + +dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); +// B => [ 30.0, 6.0, 0.0, 12.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout of `A` and `B`. +- **side**: specifies whether `op( A )` appears on the left or right side of `X`. +- **uplo**: specifies whether the upper or lower triangular part of the matrix `A` is supplied. +- **transa**: specifies the form of `op( A )` to be used in the matrix multiplication. +- **diag**: specifies whether or not `A` is unit triangular. +- **m**: number of rows in `B`. +- **n**: number of columns in `B`. +- **alpha**: scalar constant. +- **A**: input matrix `A`. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **B**: input matrix `B`. +- **LDB**: stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). + +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, 3.0, 0.0, 4.0 ] ); +var B0 = new Float64Array( [ 0.0, 5.0, 7.0, 0.0, 8.0 ] ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var B1 = new Float64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A1, 2, B1, 2 ); +// B0 => [ 0.0, 30.0, 6.0, 0.0, 12.0 ] +``` + +#### dtrsm.ndarray( s, ul, t, d, m, n, α, A, sa1, sa2, oa, B, sb1, sb2, ob ) + +Solves matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` using alternative indexing semantics and where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); +B = new Float64Array( [ 0.0, 5.0, 7.0, 0.0, 8.0 ] ); + +dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 2, B, 2, 1, 1 ); +// B => [ 0.0, 30.0, 6.0, 0.0, 12.0 ] +``` + +The function has the following parameters: + +- **side**: specifies whether `op( A )` appears on the left or right side of `X`. +- **uplo**: specifies whether the upper or lower triangular part of the matrix `A` is supplied. +- **transa**: specifies the form of `op( A )` to be used in the matrix multiplication. +- **diag**: specifies whether or not `A` is unit triangular. +- **m**: number of rows in `B`. +- **n**: number of columns in `B`. +- **alpha**: scalar constant. +- **A**: input matrix `A`. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **B**: input matrix `B`. +- **sb1**: stride of the first dimension of `B`. +- **sb2**: stride of the second dimension of `B`. +- **ob**: starting index for `B`. + +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' ); + +A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); +B = new Float64Array( [ 0.0, 5.0, 7.0, 0.0, 8.0 ] ); + +dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 2, B, 2, 1, 1 ); +// B => [ 0.0, 30.0, 6.0, 0.0, 12.0 ] +``` + +
+ + + +
+ +## Notes + +- `dtrsm()` corresponds to the [BLAS][blas] level 3 function [`dtrsm`][dtrsm]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dtrsm = require( '@stdlib/blas/base/dtrsm' ); + +var A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); +var B = new Float64Array( [ 5.0, 0.0, 7.0, 8.0 ] ); + +dtrsm( 'row-major', 'left', 'lower', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); +console.log( B ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dtrsm/benchmark/benchmark.js new file mode 100644 index 000000000000..92a1dd14fbb4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrsm = require( './../lib/dtrsm.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var A; + var B; + + A = uniform( N*N, 1.0, 10.0, { + 'dtype': 'float64' + }); + B = uniform( N*N, 1.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 = dtrsm( 'column-major', 'left', 'upper', 'no-transpose', 'non-unit', N, N, 1.0, A, N, B, 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 min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':order=column-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dtrsm/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..19356e321165 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/benchmark/benchmark.ndarray.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrsm = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var A; + var B; + + A = uniform( N*N, 1.0, 10.0, { + 'dtype': 'float64' + }); + B = uniform( N*N, 1.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 = dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', N, N, 1.0, A, 1, N, 0, B, 1, N, 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 N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:order=column-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dtrsm/docs/repl.txt new file mode 100644 index 000000000000..bea096e10345 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/docs/repl.txt @@ -0,0 +1,155 @@ + +{{alias}}( ord, side, uplo, transa, diag, m, n, alpha, A, LDA, B, LDB ) + Solves matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` + where `alpha` is a scalar, `X` and `B` are m by n matrices, `A` is a unit, + or non-unit, upper or lower triangular matrix and `op(A)` is one of + `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `M` or `N` are equal to `0`, the function returns `B` unchanged. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + side: string + Specifies whether `op(A)` appears on the left or right side of `X`. + Must be either 'left' or 'right'. + + uplo: string + Specifies whether the upper or lower triangular matrix of `A` is + supplied. Must be either 'upper' or 'lower'. + + transa: string + Specifies the form of `op(A)` to be used in the matrix + multiplication. + + diag: string + Specifies whether `A` is unit triangular. Must be either 'unit' or + 'non-unit'. + + m: integer + Number of rows in `B`. + + n: integer + Number of columns in `B`. + + alpha: number + Scalar constant. + + A: Float64Array + Triangular matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + B: Float64Array + Triangular matrix `B`. + + LDB: integer + Stride of the first dimension of `B` (a.k.a., leading dimension of the + matrix `B`). + + Returns + ------- + B: Float64Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 3.0, 0.0, 4.0 ] ); + > var B = new {{alias:@stdlib/array/float64}}( [ 5.0, 7.0, 0.0, 8.0 ] ); + > var ord = 'row-major'; + > var sd = 'left'; + > var ul = 'upper'; + > var ta = 'no-transpose'; + > var dg = 'non-unit'; + > {{alias}}( ord, sd, ul, ta, dg, 2, 2, 6.0, A, 2, B, 2 ) + [ 30.0, 6.0, 0.0, 12.0 ] + + +{{alias}}.ndarray( s, ul, ta, d, m, n, α, A, sa1, sa2, oa, B, sb1, sb2, ob ) + Solves matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` + using alternative indexing semantics where `alpha` is a scalar, `X` and + `B` are m by n matrices, `A` is a unit, or non-unit, upper or lower + triangular matrix and `op(A)` is one of `op(A) = A` or + `op(A) = A^T`. The matrix `X` is overwritten on `B`. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + s: string + Specifies whether `op(A)` appears on the left or right side of `X`. + Must be either 'left' or 'right'. + + ul: string + Specifies whether the upper or lower triangular matrix of `A` is + supplied. Must be either 'upper' or 'lower'. + + ta: string + Specifies the form of `op(A)` to be used in the matrix + multiplication. + + d: string + Specifies whether `A` is unit triangular. Must be either 'unit' or + 'non-unit'. + + m: integer + Number of rows in `B`. + + n: integer + Number of columns in `B`. + + α: number + Scalar constant. + + A: Float64Array + Triangular matrix `A`. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + B: Float64Array + Triangular matrix `B`. + + sb1: integer + Stride of the first dimension of `B`. + + sb2: integer + Stride of the second dimension of `B`. + + ob: integer + Starting index for `B`. + + Returns + ------- + B: Float64Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 3.0, 0.0, 4.0 ] ); + > var B = new {{alias:@stdlib/array/float64}}( [ 5.0, 7.0, 0.0, 8.0 ] ); + > var s = 'left'; + > var ul = 'upper'; + > var ta = 'no-transpose'; + > var dg = 'non-unit'; + > {{alias}}.ndarray( s, ul, ta, dg, 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ) + [ 30.0, 6.0, 0.0, 12.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dtrsm/docs/types/index.d.ts new file mode 100644 index 000000000000..d6c753e49f89 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/docs/types/index.d.ts @@ -0,0 +1,129 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout, MatrixTriangle, DiagonalType, OperationSide, TransposeOperation } from '@stdlib/types/blas'; + +/** +* Interface describing `dtrsm`. +*/ +interface Routine { + /** + * Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. + * + * @param order - storage layout of `A` and `B` + * @param side - specifies whether `op( A )` appears on the left or right of `X` + * @param uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied + * @param transa - specifies the form of `op( A )` to be used in matrix multiplication + * @param diag - specifies whether or not `A` is unit triangular + * @param m - number of rows in `B` + * @param n - number of columns in `B` + * @param alpha - scalar constant + * @param A - input matrix `A` + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param B - input matrix `B` + * @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) + * @returns `B` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + * var B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + * + * dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + * // B => [ 30.0, 6.0, 0.0, 12.0 ] + */ + ( order: Layout, side: OperationSide, uplo: MatrixTriangle, transa: TransposeOperation, diag: DiagonalType, m: number, n: number, alpha: number, A: Float64Array, LDA: number, B: Float64Array, LDB: number ): Float64Array; + + /** + * Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. + * + * @param side - specifies whether `op( A )` appears on the left or right of `X` + * @param uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied + * @param transa - specifies the form of `op( A )` to be used in matrix multiplication + * @param diag - specifies whether or not `A` is unit triangular + * @param m - number of rows in `B` + * @param n - number of columns in `B` + * @param alpha - scalar constant + * @param A - input matrix `A` + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @param B - input matrix `B` + * @param strideB1 - stride of the first dimension of `B` + * @param strideB2 - stride of the second dimension of `B` + * @param offsetB - starting index for `B` + * @returns `B` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); + * var B = new Float64Array( [ 0.0, 5.0, 7.0, 0.0, 8.0 ] ); + * + * dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 2, B, 2, 1, 1 ); + * // B => [ 0.0, 30.0, 6.0, 0.0, 12.0 ] + */ + ndarray( side: OperationSide, uplo: MatrixTriangle, transa: TransposeOperation, diag: DiagonalType, m: number, n: number, alpha: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, B: Float64Array, strideB1: number, strideB2: number, offsetB: number ): Float64Array; +} + +/** +* Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. +* +* @param order - storage layout of `A` and `B` +* @param side - specifies whether `op( A )` appears on the left or right of `X` +* @param uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied +* @param transa - specifies the form of `op( A )` to be used in matrix multiplication +* @param diag - specifies whether or not `A` is unit triangular +* @param m - number of rows in `B` +* @param n - number of columns in `B` +* @param alpha - scalar constant +* @param A - input matrix `A` +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param B - input matrix `B` +* @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @returns `B` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); +* var B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); +* +* dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); +* // B => [ 30.0, 6.0, 0.0, 12.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); +* var B = new Float64Array( [ 0.0, 5.0, 7.0, 0.0, 8.0 ] ); +* +* dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 2, B, 2, 1, 1 ); +* // B => [ 0.0, 30.0, 6.0, 0.0, 12.0 ] +*/ +declare var dtrsm: Routine; + + +// EXPORTS // + +export = dtrsm; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dtrsm/docs/types/test.ts new file mode 100644 index 000000000000..b9290b592791 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/docs/types/test.ts @@ -0,0 +1,486 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrsm = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 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( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 5, 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( true, 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( false, 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( null, 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( void 0, 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( [], 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( {}, 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( ( x: number ): number => x, 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 5, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', true, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', false, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', null, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', void 0, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', [], 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', {}, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', ( x: number ): number => x, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 5, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', true, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', false, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', null, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', void 0, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', [], 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', {}, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', ( x: number ): number => x, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 5, 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', true, 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', false, 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', null, 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', void 0, 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', [], 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', {}, 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', ( x: number ): number => x, 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 5, 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', true, 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', false, 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', null, 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', void 0, 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', [], 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', {}, 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', ( x: number ): number => x, 2, 2, 6.0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', '5', 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', true, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', false, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', null, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', void 0, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', [], 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', {}, 2, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', ( x: number ): number => x, 2, 6.0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, '5', 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, true, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, false, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, null, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, void 0, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, [], 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, {}, 6.0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, ( x: number ): number => x, 6.0, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, '5', A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, true, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, false, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, null, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, void 0, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, [], A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, {}, A, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, ( x: number ): number => x, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, '5', 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, 5, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, true, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, false, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, null, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, void 0, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, [], 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, {}, 2, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, ( x: number ): number => x, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, '5', B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, true, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, false, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, null, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, void 0, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, [], B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, {}, B, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, ( x: number ): number => x, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, '5', 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 5, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, true, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, false, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, null, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, void 0, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, [], 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, {}, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, '5' ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, true ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, false ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, null ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, void 0 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, [] ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, {} ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm(); // $ExpectError + dtrsm( 'row-major' ); // $ExpectError + dtrsm( 'row-major', 'left' ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper' ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose' ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit' ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2 ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B ); // $ExpectError + dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 5, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( true, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( false, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( null, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( void 0, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( [], 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( {}, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( ( x: number ): number => x, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 5, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', true, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', false, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', null, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', void 0, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', [], 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', {}, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', ( x: number ): number => x, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 5, 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', true, 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', false, 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', null, 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', void 0, 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', [], 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', {}, 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', ( x: number ): number => x, 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 5, 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', true, 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', false, 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', null, 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', void 0, 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', [], 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', {}, 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', ( x: number ): number => x, 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', '5', 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', true, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', false, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', null, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', void 0, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', [], 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', {}, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', ( x: number ): number => x, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, '5', 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, true, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, false, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, null, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, void 0, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, [], 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, {}, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, ( x: number ): number => x, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, '5', A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, true, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, false, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, null, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, void 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, [], A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, {}, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, ( x: number ): number => x, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float64Array... +{ + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, '5', 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, 5, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, true, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, false, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, null, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, void 0, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, [], 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, {}, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, ( x: number ): number => x, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, '5', 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, true, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, false, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, null, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, void 0, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, [], 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, {}, 1, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, ( x: number ): number => x, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, '5', 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, true, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, false, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, null, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, void 0, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, [], 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, {}, 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, ( x: number ): number => x, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, '5', B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, true, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, false, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, null, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, void 0, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, [], B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, {}, B, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, ( x: number ): number => x, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a Float64Array... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, '5', 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, 5, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, true, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, false, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, null, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, void 0, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, [], 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, {}, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, '5', 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, true, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, false, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, null, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, void 0, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, [], 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, {}, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourteenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, '5', 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, true, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, false, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, null, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, void 0, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, [], 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, {}, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifteenth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, '5' ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, true ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, false ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, null ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, void 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, [] ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, {} ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, ( 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( [ 1.0, 3.0, 0.0, 4.0 ] ); + const B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + dtrsm.ndarray(); // $ExpectError + dtrsm.ndarray( 'left' ); // $ExpectError + dtrsm.ndarray( 'left', 'upper' ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose' ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit' ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1 ); // $ExpectError + dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/examples/index.js b/lib/node_modules/@stdlib/blas/base/dtrsm/examples/index.js new file mode 100644 index 000000000000..2cc867cb7bac --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrsm = require( './../lib' ); + +var A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); +var B = new Float64Array( [ 5.0, 0.0, 7.0, 8.0 ] ); + +var out = dtrsm( 'column-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); +console.log( out ); +// => [ 30.0, 0.0, 6.0, 12.0 ] diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/lib/base.js b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/base.js new file mode 100644 index 000000000000..e1a6a870c9f8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/base.js @@ -0,0 +1,304 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-statements, max-depth, max-lines-per-function */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); + + +// MAIN // + +/** +* Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. +* +* @private +* @param {string} side - specifies whether `op( A )` appears on the left or right of `X` +* @param {string} uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied +* @param {string} transa - specifies the form of `op( A )` to be used in matrix multiplication +* @param {string} diag - specifies whether or not `A` is unit triangular +* @param {NonNegativeInteger} m - number of rows in `B` +* @param {NonNegativeInteger} n - number of columns in `B` +* @param {number} alpha - scalar constant +* @param {Float64Array} A - input matrix `A` +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} B - input matrix `B` +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` +* @returns {Float64Array} `B` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); +* var B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); +* +* dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 30.0, 6.0, 0.0, 12.0 ] +*/ +function dtrsm( side, uplo, transa, diag, m, n, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-params + var nounit; + var lside; + var upper; + var tmp; + var oa2; + var ob2; + var oa; + var ob; + var i; + var j; + var k; + + lside = side === 'left'; + nounit = diag === 'non-unit'; + upper = uplo === 'upper'; + + if ( m === 0 || n === 0 ) { + return B; + } + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + lside = !lside; + upper = !upper; + tmp = strideA1; + strideA1 = strideA2; + strideA2 = tmp; + tmp = strideB1; + strideB1 = strideB2; + strideB2 = tmp; + } + + if ( alpha === 0.0 ) { + for ( j = 0; j < n; j++ ) { + ob = offsetB + ( j * strideB2 ); + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] = 0.0; + } + } + return B; + } + if ( lside ) { + if ( transa === 'no-transpose' ) { + // B := alpha * inv( A ) * B + if ( upper ) { + for ( j = 0; j < n; j++ ) { + ob = offsetB + ( j * strideB2 ); + if ( alpha !== 1.0 ) { + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= alpha; + } + } + for ( k = m - 1; k >= 0; k-- ) { + oa = offsetA + ( k * strideA2 ); + oa2 = oa + ( k * strideA1 ); + ob2 = ob + ( k * strideB1 ); + if ( B[ ob2 ] !== 0.0 ) { + if ( nounit ) { + B[ ob2 ] /= A[ oa2 ]; + } + for ( i = 0; i <= k - 1; i++ ) { + B[ ob + ( i * strideB1 ) ] -= B[ ob2 ] * A[ oa + ( i * strideA1 ) ]; + } + } + } + } + return B; + } + // Lower + for ( j = 0; j < n; j++ ) { + ob = offsetB + ( j * strideB2 ); + if ( alpha !== 1.0 ) { + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= alpha; + } + } + for ( k = 0; k < m; k++ ) { + oa = offsetA + ( k * strideA2 ); + oa2 = oa + ( k * strideA1 ); + ob2 = ob + ( k * strideB1 ); + if ( B[ ob + ( k * strideB1 ) ] !== 0.0 ) { + if ( nounit ) { + B[ ob2 ] /= A[ oa2 ]; + } + for ( i = k + 1; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] -= B[ ob2 ] * A[ oa + ( i * strideA1 ) ]; + } + } + } + } + return B; + } + // B := alpha * inv( A**T ) * B + if ( upper ) { + for ( j = 0; j < n; j++ ) { + ob = offsetB + ( j * strideB2 ); + for ( i = 0; i < m; i++ ) { + oa = offsetA + ( i * strideA2 ); + oa2 = oa + ( i * strideA1 ); + tmp = alpha * B[ ob + ( i * strideB1 ) ]; + for ( k = 0; k <= i - 1; k++ ) { + tmp -= A[ oa + ( k * strideA1 ) ] * B[ ob + ( k * strideB1 ) ]; + } + if ( nounit ) { + tmp /= A[ oa2 ]; + } + B[ ob + ( i * strideB1 ) ] = tmp; + } + } + return B; + } + // Lower + for ( j = 0; j < n; j++ ) { + ob = offsetB + ( j * strideB2 ); + for ( i = m - 1; i >= 0; i-- ) { + oa = offsetA + ( i * strideA2 ); + oa2 = oa + ( i * strideA1 ); + tmp = alpha * B[ ob + ( i * strideB1 ) ]; + for ( k = i + 1; k < m; k++ ) { + tmp -= A[ oa + ( k * strideA1 ) ] * B[ ob + k ]; + } + if ( nounit ) { + tmp /= A[ oa2 ]; + } + B[ ob + ( i * strideB1 ) ] = tmp; + } + } + return B; + } + // Right + if ( transa === 'no-transpose' ) { + // B := alpha * B * inv( A ) + if ( upper ) { + for ( j = 0; j < n; j++ ) { + ob = offsetB + ( j * strideB2 ); + oa = offsetA + ( j * strideA2 ); + if ( alpha !== 1.0 ) { + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= alpha; + } + } + for ( k = 0; k <= j - 1; k++ ) { + ob2 = offsetB + ( k * strideB2 ); + if ( A[ oa + ( k * strideA1 ) ] !== 0.0 ) { + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] -= A[ oa + ( k * strideA1 ) ] * B[ ob2 + ( i * strideB1 ) ]; + } + } + } + if ( nounit ) { + tmp = 1.0 / A[ oa + j ]; + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= tmp; + } + } + } + return B; + } + // Lower + for ( j = n - 1; j >= 0; j-- ) { + ob = offsetB + ( j * strideB2 ); + oa = offsetA + ( j * strideA2 ); + if ( alpha !== 1.0 ) { + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= alpha; + } + } + for ( k = j + 1; k < n; k++ ) { + ob2 = offsetB + ( k * strideB2 ); + if ( A[ oa + k ] !== 0 ) { + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] -= A[ oa + ( k * strideA1 ) ] * B[ ob2 + ( i * strideB1 ) ]; + } + } + } + if ( nounit ) { + tmp = 1.0 / A[ oa + ( j * strideA1 ) ]; + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= tmp; + } + } + } + return B; + } + // B := alpha * B * inv( A**T ) + if ( upper ) { + for ( k = n - 1; k >= 0; k-- ) { + ob = offsetB + ( k * strideB2 ); + oa = offsetA + ( k * strideA2 ); + oa2 = oa + ( k * strideA1 ); + if ( nounit ) { + tmp = 1.0 / A[ oa2 ]; + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= tmp; + } + } + for ( j = 0; j <= k - 1; j++ ) { + ob2 = offsetB + ( j * strideB2 ); + if ( A[ oa + ( j * strideA1 ) ] !== 0 ) { + tmp = A[ oa + ( j * strideA1 ) ]; + for ( i = 0; i < m; i++ ) { + B[ ob2 + ( i * strideB1 ) ] -= tmp * B[ ob + ( i * strideB1 ) ]; + } + } + } + if ( alpha !== 1.0 ) { + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= alpha; + } + } + } + return B; + } + // Lower + for ( k = 0; k < n; k++ ) { + ob = offsetB + ( k * strideB2 ); + oa = offsetA + ( k * strideA2 ); + oa2 = oa + ( k * strideA1 ); + if ( nounit ) { + tmp = 1.0 / A[ oa2 ]; + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= tmp; + } + } + for ( j = k + 1; j < n; j++ ) { + ob2 = offsetB + ( j * strideB2 ); + if ( A[ oa + j ] !== 0 ) { + tmp = A[ oa + ( j * strideA1 ) ]; + for ( i = 0; i < m; i++ ) { + B[ ob2 + ( i * strideB1 ) ] -= tmp * B[ ob + ( i * strideB1 ) ]; + } + } + } + if ( alpha !== 1.0 ) { + for ( i = 0; i < m; i++ ) { + B[ ob + ( i * strideB1 ) ] *= alpha; + } + } + } + return B; +} + + +// EXPORTS // + +module.exports = dtrsm; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/lib/dtrsm.js b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/dtrsm.js new file mode 100644 index 000000000000..b314c3a0958e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/dtrsm.js @@ -0,0 +1,102 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var isOperationSide = require( '@stdlib/blas/base/assert/is-operation-side' ); +var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var isDiagonalType = require( '@stdlib/blas/base/assert/is-diagonal-type' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. +* +* @param {string} order - storage layout of `A` and `B` +* @param {string} side - specifies whether `op( A )` appears on the left or right of `X` +* @param {string} uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied +* @param {string} transa - specifies the form of `op( A )` to be used in matrix multiplication +* @param {string} diag - specifies whether or not `A` is unit triangular +* @param {NonNegativeInteger} m - number of rows in `B` +* @param {NonNegativeInteger} n - number of columns in `B` +* @param {number} alpha - scalar constant +* @param {Float64Array} A - input matrix `A` +* @param {NonNegativeInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} B - input matrix `B` +* @param {NonNegativeInteger} LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must be a valid side +* @throws {TypeError} third argument must specify whether the lower or upper triangular matrix is supplied +* @throws {TypeError} fourth argument must specify correct transpose operation +* @throws {TypeError} fifth argument must specify whether the matrix is unit triangular or not +* @returns {Float64Array} `B` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); +* var B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); +* +* dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); +* // B => [ 30.0, 6.0, 0.0, 12.0 ] +*/ +function dtrsm( order, side, uplo, transa, diag, m, n, alpha, A, LDA, B, LDB ) { // eslint-disable-line max-params + var sa1; + var sa2; + var sb1; + var sb2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isOperationSide( side ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a valid side. Value: `%s`.', side ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Thirds argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( !isTransposeOperation( transa ) ) { + throw new TypeError( format( 'invalid argument. Fourth argument must specify correct transpose operation. Value: `%s`.', transa ) ); + } + if ( !isDiagonalType( diag ) ) { + throw new TypeError( format( 'invalid argument. Fifth argument must specify whether the matrix is unit triangular or not. Value: `%s`.', diag ) ); + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } + return base( side, uplo, transa, diag, m, n, alpha, A, sa1, sa2, 0, B, sb1, sb2, 0 ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dtrsm; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/lib/index.js b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/index.js new file mode 100644 index 000000000000..4f14487d8202 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/index.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* BLAS routine to solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. +* +* @module @stdlib/blas/base/dtrsm +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dtrsm = require( '@stdlib/blas/base/dtrsm' ); +* +* var A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); +* var B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); +* +* dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); +* // B => [ 30.0, 6.0, 0.0, 12.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dtrsm = require( '@stdlib/blas/base/dtrsm' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); +* var B = new Float64Array( [ 0.0, 5.0, 7.0, 0.0, 8.0 ] ); +* +* dtrsm.ndarray( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 2, B, 2, 1, 1 ); +* // B => [ 0.0, 30.0, 6.0, 0.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 dtrsm; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dtrsm = main; +} else { + dtrsm = tmp; +} + + +// EXPORTS // + +module.exports = dtrsm; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/lib/main.js b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/main.js new file mode 100644 index 000000000000..8a497b58f053 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrsm = require( './dtrsm.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dtrsm, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dtrsm; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/ndarray.js new file mode 100644 index 000000000000..ec247045b44f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/lib/ndarray.js @@ -0,0 +1,85 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var isOperationSide = require( '@stdlib/blas/base/assert/is-operation-side' ); +var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' ); +var isDiagonalType = require( '@stdlib/blas/base/assert/is-diagonal-type' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`. +* +* @param {string} side - specifies whether `op( A )` appears on the left or right of `X` +* @param {string} uplo - specifies whether the upper or lower triangular part of the matrix `A` is supplied +* @param {string} transa - specifies the form of `op( A )` to be used in matrix multiplication +* @param {string} diag - specifies whether or not `A` is unit triangular +* @param {NonNegativeInteger} m - number of rows in `B` +* @param {NonNegativeInteger} n - number of columns in `B` +* @param {number} alpha - scalar constant +* @param {Float64Array} A - input matrix `A` +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @param {Float64Array} B - input matrix `B` +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` +* @throws {TypeError} first argument must be a valid side +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied. +* @throws {TypeError} third argument must specify correct transpose operation +* @throws {TypeError} fourth argument must specify whether the matrix is unit triangular or not +* @returns {Float64Array} `B` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); +* var B = new Float64Array( [ 0.0, 5.0, 7.0, 0.0, 8.0 ] ); +* +* dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 2, B, 2, 1, 1 ); +* // B => [ 0.0, 30.0, 6.0, 0.0, 12.0 ] +*/ +function dtrsm( side, uplo, transa, diag, m, n, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + if ( !isOperationSide( side ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid side. Value: `%s`.', side ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( !isTransposeOperation( transa ) ) { + throw new TypeError( format( 'invalid argument. Third argument must specify correct transpose operation. Value: `%s`.', transa ) ); + } + if ( !isDiagonalType( diag ) ) { + throw new TypeError( format( 'invalid argument. Fourth argument must specify whether the matrix is unit triangular or not. Value: `%s`.', diag ) ); + } + return base( side, uplo, transa, diag, m, n, alpha, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dtrsm; diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/package.json b/lib/node_modules/@stdlib/blas/base/dtrsm/package.json new file mode 100644 index 000000000000..7e15c841d4da --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/dtrsm", + "version": "0.0.0", + "description": "Solve matrix equation `op(A) * X = alpha * B` or `X * op(A) = alpha * B` where `alpha` is a scalar, `X` and `B` are `m` by `n` matrices, `A` is a unit, or non-unit, upper or lower triangular matrix and `op(A)` is one of `op(A) = A` or `op(A) = A^T`. The matrix `X` is overwritten on `B`.", + "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", + "blas", + "level 3", + "dtrsm", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.dtrsm.js b/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.dtrsm.js new file mode 100644 index 000000000000..b56f9a0b04b1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.dtrsm.js @@ -0,0 +1,509 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dtrsm = require( './../lib/dtrsm.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dtrsm, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( dtrsm.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.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() { + dtrsm( value, 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.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() { + dtrsm( 'column-major', value, 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.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() { + dtrsm( 'column-major', 'left', value, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.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() { + dtrsm( 'column-major', 'left', 'upper', value, 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.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() { + dtrsm( 'column-major', 'left', 'upper', 'no-transpose', value, 2, 2, 6.0, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A ) * B` ( column-major, lower )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + expected = new Float64Array( [ 30.0, -12.0, 0.0, 12.0 ] ); + + out = dtrsm( 'column-major', 'left', 'lower', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A^T ) * B` ( column-major, lower )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + expected = new Float64Array( [ -1.5, 10.5, -36, 12 ] ); + + out = dtrsm( 'column-major', 'left', 'lower', 'transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A ) * B` ( column-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.0 ] ); + + expected = new Float64Array( [ 30.0, 0.0, 6.0, 12.0 ] ); + + out = dtrsm( 'column-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A^T ) * B` ( column-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.0 ] ); + + expected = new Float64Array( [ 30.0, -22.5, 42, -19.5 ] ); + + out = dtrsm( 'column-major', 'left', 'upper', 'transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * B * inv( A )` ( column-major, lower )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + expected = new Float64Array( [ 30, 6, 0, 12 ] ); + + out = dtrsm( 'column-major', 'right', 'lower', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * B * inv( A )` ( column-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.0 ] ); + + expected = new Float64Array( [ 30, 0, -12, 12 ] ); + + out = dtrsm( 'column-major', 'right', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A ) * B` ( row-major, lower )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.0 ] ); + + expected = new Float64Array( [ 30.0, 0.0, -12.0, 12.0 ] ); + + out = dtrsm( 'row-major', 'left', 'lower', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A^T ) * B` ( row-major, lower )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.0 ] ); + + expected = new Float64Array( [ -1.5, -36, 10.5, 12 ] ); + + out = dtrsm( 'row-major', 'left', 'lower', 'transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A ) * B` ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + expected = new Float64Array( [ 30.0, 6.0, 0.0, 12.0 ] ); + + out = dtrsm( 'row-major', 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A^T ) * B` ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + expected = new Float64Array( [ 30.0, 42.0, -22.5, -19.5 ] ); + + out = dtrsm( 'row-major', 'left', 'upper', 'transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * B * inv( A )` ( row-major, lower )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 0.0, 3.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 0.0, 7.0, 8.0 ] ); + + expected = new Float64Array( [ 30, 0, 6, 12 ] ); + + out = dtrsm( 'row-major', 'right', 'lower', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * B * inv( A )` ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 5.0, 7.0, 0.0, 8.0 ] ); + + expected = new Float64Array( [ 30, -12, 0, 12 ] ); + + out = dtrsm( 'row-major', 'right', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A ) * B` ( column-major, lower, n = 3, m = 3 )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 5.0, 6.0, 0.0, 0.0, 9.0 ] ); + B = new Float64Array( [ 10.0, 11.0, 12.0, 0.0, 14.0, 15.0, 0.0, 0.0, 18.0 ] ); + + expected = new Float64Array( [ 60, -10.8, -4.8, 0, 16.8, -1.20, 0, 0, 12 ] ); + + out = dtrsm( 'column-major', 'left', 'lower', 'no-transpose', 'non-unit', 3, 3, 6.0, A, 3, B, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 10.0 ); + + t.end(); +}); + +tape( 'the function solves the matrix equation `B = alpha * inv( A ) * B` ( row-major, lower, n = 3, m = 3 )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 0.0, 0.0, 2.0, 5.0, 0.0, 3.0, 6.0, 9.0 ] ); + B = new Float64Array( [ 10.0, 0.0, 0.0, 11.0, 14.0, 0.0, 12.0, 15.0, 18.0 ] ); + + expected = new Float64Array( [ 60, 0.0, 0.0, -10.8, 16.8, 0.0, -4.8, -1.20, 12 ] ); + + out = dtrsm( 'row-major', 'left', 'lower', 'no-transpose', 'non-unit', 3, 3, 6.0, A, 3, B, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 10.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.js b/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.js new file mode 100644 index 000000000000..a56d939c278a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.js @@ -0,0 +1,83 @@ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 dtrsm = 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 dtrsm, '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 dtrsm.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 dtrsm = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dtrsm, 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 dtrsm; + var main; + + main = require( './../lib/dtrsm.js' ); + + dtrsm = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dtrsm, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.ndarray.js new file mode 100644 index 000000000000..3375d42e3586 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dtrsm/test/test.ndarray.js @@ -0,0 +1,346 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dtrsm = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dtrsm, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 15', function test( t ) { + t.strictEqual( dtrsm.length, 15, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 5.0, 7.0, 0.0, 8.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() { + dtrsm( value, 'lower', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 1, 2, 2, B, 1, 2, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 5.0, 7.0, 0.0, 8.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() { + dtrsm( 'left', value, 'no-transpose', 'non-unit', 2, 2, 6.0, A, 1, 2, 2, B, 1, 2, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 5.0, 7.0, 0.0, 8.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() { + dtrsm( 'left', 'lower', value, 'non-unit', 2, 2, 6.0, A, 1, 2, 2, B, 1, 2, 3 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 5.0, 7.0, 0.0, 8.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() { + dtrsm( 'left', 'lower', 'no-transpose', value, 2, 2, 6.0, A, 1, 2, 2, B, 1, 2, 3 ); + }; + } +}); + +tape( 'the function supports providing an offset to A & B ( column-major, lower )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 5.0, 7.0, 0.0, 8.0 ] ); + + expected = new Float64Array( [ 0.0, 0.0, 0.0, 30.0, -12.0, 0.0, 12.0 ] ); + + out = dtrsm( 'left', 'lower', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 1, 2, 2, B, 1, 2, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports providing an offset to A & B ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 0.0, 1.0, 3.0, 0.0, 4.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 5.0, 7.0, 0.0, 8.0 ] ); + + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 30, 6, 0, 12 ] ); + + out = dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 2, 1, 1, B, 2, 1, 4 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports accessing accessing arrays in a non contiguous order of columns ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 999.9, 1.0, 999.9, 3.0, 0.0, 999.9, 4.0 ] ); + B = new Float64Array( [ 999.9, 999.9, 999.9, 999.9, 5.0, 999.9, 7.0, 0.0, 999.9, 8.0 ] ); + + expected = new Float64Array( [ 999.9, 999.9, 999.9, 999.9, 30, 999.9, 6, 0, 999.9, 12 ] ); + + out = dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 3, 2, 1, B, 3, 2, 4 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports accessing accessing arrays in a non contiguous order of columns & rows ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 999.9, 1.0, 999.9, 3.0, 999.9, 999.9, 999.9, 0.0, 999.9, 4.0 ] ); + B = new Float64Array( [ 999.9, 999.9, 999.9, 999.9, 5.0, 999.9, 7.0, 999.9, 999.9, 999.9, 0.0, 999.9, 8.0 ] ); + + expected = new Float64Array( [ 999.9, 999.9, 999.9, 999.9, 30, 999.9, 6, 999.9, 999.9, 999.9, 0, 999.9, 12 ] ); + + out = dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 6, 2, 1, B, 6, 2, 4 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex and different access patterns for both A and B ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 999.9, 1.0, 999.9, 3.0, 999.9, 999.9, 999.9, 0.0, 999.9, 4.0 ] ); + B = new Float64Array( [ 999.9, 999.9, 999.9, 999.9, 5.0, 999.9, 999.9, 7.0, 999.9, 999.9, 999.9, 999.9, 0.0, 999.9, 999.9, 8.0 ] ); + + expected = new Float64Array( [ 999.9, 999.9, 999.9, 999.9, 30, 999.9, 999.9, 6, 999.9, 999.9, 999.9, 999.9, 0, 999.9, 999.9, 12 ] ); + + out = dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 6, 2, 1, B, 8, 3, 4 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports accessing elements in reverser order ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 4.0, 999.9, 0.0, 999.9, 999.9, 999.9, 3.0, 999.9, 1.0 ] ); + B = new Float64Array( [ 8.0, 999.9, 999.9, 0.0, 999.9, 999.9, 999.9, 999.9, 7.0, 999.9, 999.9, 5.0 ] ); + + expected = new Float64Array( [ 12, 999.9, 999.9, 0, 999.9, 999.9, 999.9, 999.9, 6, 999.9, 999.9, 30 ] ); + + out = dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, -6, -2, 8, B, -8, -3, 11 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports accessing elements of both arrays in different order ( row-major, upper )', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float64Array( [ 1.0, 999.9, 3.0, 999.9, 999.9, 999.9, 0.0, 999.9, 4.0 ] ); + B = new Float64Array( [ 8.0, 999.9, 999.9, 0.0, 999.9, 999.9, 999.9, 999.9, 7.0, 999.9, 999.9, 5.0 ] ); + + expected = new Float64Array( [ 12, 999.9, 999.9, 0, 999.9, 999.9, 999.9, 999.9, 6, 999.9, 999.9, 30 ] ); + + out = dtrsm( 'left', 'upper', 'no-transpose', 'non-unit', 2, 2, 6.0, A, 6, 2, 0, B, -8, -3, 11 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 2.0 ); + + t.end(); +});