diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/README.md b/lib/node_modules/@stdlib/lapack/base/dtrti2/README.md new file mode 100644 index 00000000000..03102c0daa5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/README.md @@ -0,0 +1,229 @@ + + +# dtrti2 + +> Compute the inverse of a triangular matrix. + +
+ +## Usage + +```javascript +var dtrti2 = require( '@stdlib/lapack/base/dtrti2' ); +``` + +#### dtrti2( order, uplo, diag, N, A, LDA ) + +Computes the inverse of a triangular matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); +// A => [ 1.0, -0.5, 0.0, 0.25 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether to copy the upper or lower triangular/trapezoidal part of a matrix `A`. +- **diag**: specifies whether or not `A` is unit triangular. +- **N**: order of matrix `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 0.0, 4.0 ] ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dtrti2( 'row-major', 'upper', 'non-unit', 2, A1, 2 ); +// A0 => [ 0.0, 1.0, -0.5, 0.0, 0.25 ] +``` + +#### dtrti2.ndarray( uplo, diag, N, A, strideA1, strideA2, offsetA ) + +Computes the inverse of a triangular matrix using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, 0 ); +// A => [ 1.0, -0.5, 0.0, 0.25 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether to copy the upper or lower triangular/trapezoidal part of a matrix `A`. +- **diag**: specifies whether or not `A` is unit triangular. +- **N**: order of matrix `A`. +- **A**: input [`Float64Array`][mdn-float64array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 0.0, 4.0 ] ); +dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, 2 ); +// A => [ 0.0, 0.0, 1.0, -0.5, 0.0, 0.25 ] +``` + +
+ + + +
+ +## Notes + +- `dtrti2()` corresponds to the [LAPACK][lapack] routine [`dtrti2`][lapack-dtrti2]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dtrti2 = require( '@stdlib/lapack/base/dtrti2' ); + +var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); +console.log( A ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/benchmark/benchmark.js new file mode 100644 index 00000000000..bb97333dd95 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/benchmark/benchmark.js @@ -0,0 +1,97 @@ +/** +* @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 floor = require( '@stdlib/math/base/special/floor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dtrti2 = require( './../lib/dtrti2.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len * len, -100.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dtrti2( 'row-major', 'upper', 'non-unit', len, x, len ); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 0.5 ) ); + f = createBenchmark( len ); + bench( pkg+':order=row-major,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..cf0b3906c35 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/benchmark/benchmark.ndarray.js @@ -0,0 +1,97 @@ +/** +* @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 floor = require( '@stdlib/math/base/special/floor' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dtrti2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len * len, -100.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dtrti2( 'upper', 'non-unit', len, x, len, 1, 0 ); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out[ i%out.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 0.5 ) ); + f = createBenchmark( len ); + bench( pkg+':ndarray:order=row-major,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/repl.txt new file mode 100644 index 00000000000..3585512d050 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/repl.txt @@ -0,0 +1,87 @@ + +{{alias}}( order, uplo, diag, N, A, LDA ) + Computes the inverse of a triangular matrix. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether to copy the upper or lower triangular/trapezoidal part + of a matrix `A`. + + diag: string + Specifies whether or not `A` is unit triangular. + + N: integer + Order of the matrix `A`. + + A: Float64Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + A: Float64Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 4.0 ] ); + > {{alias}}( 'row-major', 'upper', 'non-unit', 2, A, 2 ) + [ 1.0, -0.5, 0.0, 0.25 ] + + +{{alias}}.ndarray( uplo, diag, N, A, strideA1, strideA2, offsetA ) + Computes the inverse of a triangular matrix using alternative indexing + semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + uplo: string + Specifies whether to copy the upper or lower triangular/trapezoidal part + of a matrix `A`. + + diag: string + Specifies whether or not `A` is unit triangular. + + N: integer + Order of the matrix `A`. + + A: Float64Array + Input matrix `A`. + + strideA1: integer + Stride of the first dimension of `A`. + + strideA2: integer + Stride of the second dimension of `A`. + + offsetA: integer + Starting index for `A`. + + Returns + ------- + A: Float64Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 0.0, 4.0 ] ); + > {{alias}}.ndarray( 'upper', 'non-unit', 2, A, 2, 1, 1 ) + [ 0.0, 1.0, -0.5, 0.0, 0.25 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/types/index.d.ts new file mode 100644 index 00000000000..bc3bd882a89 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/types/index.d.ts @@ -0,0 +1,101 @@ +/** +* @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 } from '@stdlib/types/blas'; + +/** +* Interface describing `dtrti2`. +*/ +interface Routine { + /** + * Computes the inverse of a triangular matrix. + * + * @param order - storage layout + * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param diag - specifies whether or not `A` is unit triangular + * @param N - order of matrix `A` + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @returns output matrix + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + * dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); + * // A => [ 1.0, -0.5, 0.0, 0.25 ] + */ + ( order: Layout, uplo: MatrixTriangle, diag: DiagonalType, N: number, A: Float64Array, LDA: number ): Float64Array; + + /** + * Computes the inverse of a triangular matrix using alternative indexing semantics. + * + * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param diag - specifies whether or not `A` is unit triangular + * @param N - order of matrix `A` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @returns output matrix + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + * dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, 0 ); + * // A => [ 1.0, -0.5, 0.0, 0.25 ] + */ + ndarray( uplo: MatrixTriangle, diag: DiagonalType, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; +} + +/** +* Computes the inverse of a triangular matrix. +* +* @param order - storage layout +* @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param diag - specifies whether or not `A` is unit triangular +* @param N - order of matrix `A` +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @returns output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +* dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); +* // A => [ 1.0, -0.5, 0.0, 0.25 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +* dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, 0 ); +* // A => [ 1.0, -0.5, 0.0, 0.25 ] +*/ +declare var dtrti2: Routine; + + +// EXPORTS // + +export = dtrti2; diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/types/test.ts new file mode 100644 index 00000000000..77fd81404d0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/docs/types/test.ts @@ -0,0 +1,245 @@ +/* +* @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 dtrti2 = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + + dtrti2( 5, 'upper', 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( true, 'upper', 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( false, 'upper', 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( null, 'upper', 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( void 0, 'upper', 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( [], 'upper', 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( {}, 'upper', 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( ( x: number ): number => x, 'upper', 'non-unit', 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + + dtrti2( 'row-major', 5, 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', true, 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', false, 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', null, 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', void 0, 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', [], 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', {}, 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', ( x: number ): number => x, 'non-unit', 2, A, 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, 2.0, 0.0, 4.0 ] ); + + dtrti2( 'row-major', 'upper', 5, 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', true, 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', false, 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', null, 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', void 0, 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', [], 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', {}, 2, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', ( x: number ): number => x, 2, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + + dtrti2( 'row-major', 'upper', 'non-unit', '5', A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', true, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', false, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', null, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', void 0, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', [], A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', {}, A, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', ( x: number ): number => x, A, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + + dtrti2( 'row-major', 'upper', 'non-unit', 2, '5', 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, 5, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, true, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, false, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, null, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, void 0, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, [], 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, {}, 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, ( x: number ): number => x, 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, 2.0, 0.0, 4.0 ] ); + + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, '5' ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, true ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, false ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, null ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, void 0 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, [] ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, {} ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + + dtrti2(); // $ExpectError + dtrti2( 'row-major' ); // $ExpectError + dtrti2( 'row-major', 'upper' ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit' ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2 ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A ); // $ExpectError + dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 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, 2.0, 0.0, 4.0 ] ); + + dtrti2.ndarray( 5, 'non-unit', 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( true, 'non-unit', 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( false, 'non-unit', 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( null, 'non-unit', 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( void 0, 'non-unit', 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( [], 'non-unit', 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( {}, 'non-unit', 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( ( x: number ): number => x, 'non-unit', 2, A, 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, 2.0, 0.0, 4.0 ] ); + + dtrti2.ndarray( 'upper', 5, 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', true, 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', false, 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', null, 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', void 0, 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', [], 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', {}, 2, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', ( x: number ): number => x, 2, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + + dtrti2.ndarray( 'upper', 'non-unit', '5', A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', true, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', false, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', null, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', void 0, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', [], A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', {}, A, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', ( x: number ): number => x, A, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + + dtrti2.ndarray( 'upper', 'non-unit', 2, '5', 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, 5, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, true, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, false, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, null, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, void 0, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, [], 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, {}, 2, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, ( x: number ): number => x, 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, 2.0, 0.0, 4.0 ] ); + + dtrti2.ndarray( 'upper', 'non-unit', 2, A, '5', 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, true, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, false, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, null, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, void 0, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, [], 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, {}, 1, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, '5', 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, true, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, false, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, null, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, void 0, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, [], 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, {}, 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, ( x: number ): number => x, 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, 2.0, 0.0, 4.0 ] ); + + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, '5' ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, true ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, false ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, null ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, void 0 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, [] ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, {} ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 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, 2.0, 0.0, 4.0 ] ); + + dtrti2.ndarray(); // $ExpectError + dtrti2.ndarray( 'upper' ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit' ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1 ); // $ExpectError + dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/examples/index.js new file mode 100644 index 00000000000..5f058f7275a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/examples/index.js @@ -0,0 +1,26 @@ +/** +* @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 dtrti2 = require( './../lib' ); + +var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); +console.log( A ); diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/base.js new file mode 100644 index 00000000000..4b8c5bb758e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/base.js @@ -0,0 +1,101 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var dscal = require( '@stdlib/blas/base/dscal' ).ndarray; +var dtrmv = require( '@stdlib/blas/base/dtrmv' ).ndarray; + + +// MAIN // + +/** +* Computes the inverse of a triangular matrix. +* +* @private +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {string} diag - specifies whether or not `A` is unit triangular +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +* dtrti2( 'upper', 'non-unit', 2, A, 2, 1, 0 ); +* // A => [ 1.0, -0.5, 0.0, 0.25 ] +*/ +function dtrti2( uplo, diag, N, A, strideA1, strideA2, offsetA ) { + var nounit; + var upper; + var ajj; + var tmp; + var j; + + upper = ( uplo === 'upper' ); + nounit = ( diag === 'non-unit' ); + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + upper = !upper; + tmp = strideA1; + strideA1 = strideA2; + strideA2 = tmp; + } + + if ( upper ) { + for ( j = 0; j < N; j++ ) { + if ( nounit ) { + A[ offsetA + ( j * strideA1 ) + ( j * strideA2 ) ] = 1.0 / A[ offsetA + ( j * strideA1 ) + ( j * strideA2 ) ]; + ajj = -A[ offsetA + ( j * strideA1 ) + ( j * strideA2 ) ]; + } else { + ajj = -1.0; + } + // Compute elements 1:j-1 of j-th column + dtrmv( 'upper', 'no-transpose', diag, j, A, strideA1, strideA2, offsetA, A, strideA1, offsetA + ( j * strideA2 ) ); + dscal( j, ajj, A, strideA1, offsetA + ( j * strideA2 ) ); + } + return A; + } + // Compute inverse of lower triangular matrix + for ( j = N - 1; j >= 0; j-- ) { + if ( nounit ) { + A[ offsetA + ( j * strideA1 ) + ( j * strideA2 ) ] = 1.0 / A[ offsetA + ( j * strideA1 ) + ( j * strideA2 ) ]; + ajj = -A[ offsetA + ( j * strideA1 ) + ( j * strideA2 ) ]; + } else { + ajj = -1.0; + } + if ( j < N - 1 ) { + // Compute elements j+1:N of j-th column + dtrmv( 'lower', 'no-transpose', diag, N - j - 1, A, strideA1, strideA2, offsetA + ( ( j + 1 ) * strideA1 ) + ( ( j + 1 ) * strideA2 ), A, strideA1, offsetA + ( j * strideA2 ) + ( ( j + 1 ) * strideA1 ) ); + dscal( N - j - 1, ajj, A, strideA1, offsetA + ( j * strideA2 ) + ( ( j + 1 ) * strideA1 ) ); + } + } + return A; +} + + +// EXPORTS // + +module.exports = dtrti2; diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/dtrti2.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/dtrti2.js new file mode 100644 index 00000000000..8ee7cb7698d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/dtrti2.js @@ -0,0 +1,78 @@ +/** +* @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 isDiagonalType = require( '@stdlib/blas/base/assert/is-diagonal-type' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the inverse of a triangular matrix. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {string} diag - specifies whether or not `A` is unit triangular +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} A - input matrix +* @param {NonNegativeInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @throws {TypeError} third argument must specify whether the matrix is unit triangular or not +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +* dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); +* // A => [ 1.0, -0.5, 0.0, 0.25 ] +*/ +function dtrti2( order, uplo, diag, N, A, LDA ) { + var sa1; + var sa2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( !isDiagonalType( diag ) ) { + throw new TypeError( format( 'invalid argument. Third argument must specify whether the matrix is unit triangular or not. Value: `%s`.', diag ) ); + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( uplo, diag, N, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = dtrti2; diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/index.js new file mode 100644 index 00000000000..13514522f0c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/index.js @@ -0,0 +1,64 @@ +/** +* @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'; + +/** +* LAPACK routine to compute the inverse of a triangular matrix. +* +* @module @stdlib/lapack/base/dtrti2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dtrti2 = require( '@stdlib/lapack/base/dtrti2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +* dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); +* // A => [ 1.0, -0.5, 0.0, 0.25 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dtrti2 = require( '@stdlib/lapack/base/dtrti2' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +* dtrti2.ndarray( 'upper', 'non-unit', 2, A, 2, 1, 0 ); +* // A => [ 1.0, -0.5, 0.0, 0.25 ] +*/ + +// 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 dtrti2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dtrti2 = main; +} else { + dtrti2 = tmp; +} + + +// EXPORTS // + +module.exports = dtrti2; diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/main.js new file mode 100644 index 00000000000..513c508b097 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/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 dtrti2 = require( './dtrti2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dtrti2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dtrti2; diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/ndarray.js new file mode 100644 index 00000000000..d6307144cae --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/lib/ndarray.js @@ -0,0 +1,65 @@ +/** +* @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 isDiagonalType = require( '@stdlib/blas/base/assert/is-diagonal-type' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the inverse of a triangular matrix using alternative indexing semantics. +* +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {string} diag - specifies whether or not `A` is unit triangular +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @throws {TypeError} first argument must specify whether the lower or upper triangular matrix is supplied +* @throws {TypeError} second argument must specify whether the matrix is unit triangular or not +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); +* dtrti2( 'upper', 'non-unit', 2, A, 2, 1, 0 ); +* // A => [ 1.0, -0.5, 0.0, 0.25 ] +*/ +function dtrti2( uplo, diag, N, A, strideA1, strideA2, offsetA ) { + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. First argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( !isDiagonalType( diag ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether the matrix is unit triangular or not. Value: `%s`.', diag ) ); + } + return base( uplo, diag, N, A, strideA1, strideA2, offsetA ); +} + + +// EXPORTS // + +module.exports = dtrti2; diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/package.json b/lib/node_modules/@stdlib/lapack/base/dtrti2/package.json new file mode 100644 index 00000000000..1fb867224ec --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/lapack/base/dtrti2", + "version": "0.0.0", + "description": "Compute the inverse of a triangular matrix.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "lapack", + "dtrti2", + "inverse", + "triangular", + "matrix", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.dtrti2.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.dtrti2.js new file mode 100644 index 00000000000..3ab2d00d957 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.dtrti2.js @@ -0,0 +1,261 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dtrti2 = require( './../lib/dtrti2.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 dtrti2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dtrti2.length, 6, '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 i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 5, + true, + false + ]; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 4.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() { + dtrti2( value, 'upper', 'non-unit', 2, A, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 5, + true, + false + ]; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 4.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() { + dtrti2( 'row-major', value, 'non-unit', 2, A, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 5, + true, + false + ]; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 4.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() { + dtrti2( 'row-major', 'upper', value, 2, A, 2 ); + }; + } +}); + +tape( 'the function correctly computes inverse of upper triangular non-unit matrix ( row-major )', function test( t ) { + var expected; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + expected = new Float64Array( [ 1, -0.5, 0, 0.25 ] ); + out = dtrti2( 'row-major', 'upper', 'non-unit', 2, A, 2 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function correctly computes inverse of lower triangular non-unit rectangular matrix ( row-major )', function test( t ) { + var expected; + var out; + var A; + + A = new Float64Array( [ 1.0, 0.0, 2.0, 4.0 ] ); + expected = new Float64Array( [ 1, 0.0, -0.5, 0.25 ] ); + out = dtrti2( 'row-major', 'lower', 'non-unit', 2, A, 2 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function correctly computes inverse of lower triangular non-unit matrix ( column-major )', function test( t ) { + var expected; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 4.0 ] ); + expected = new Float64Array( [ 1, -0.5, 0.0, 0.25 ] ); + out = dtrti2( 'column-major', 'lower', 'non-unit', 2, A, 2 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function correctly computes inverse of upper triangular non-unit matrix ( column-major )', function test( t ) { + var expected; + var out; + var A; + + A = new Float64Array( [ 1.0, 0.0, 2.0, 4.0 ] ); + expected = new Float64Array( [ 1, 0.0, -0.5, 0.25 ] ); + out = dtrti2( 'column-major', 'upper', 'non-unit', 2, A, 2 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function correctly computes inverse of upper triangular unit matrix ( column-major )', function test( t ) { + var expected; + var out; + var A; + + A = new Float64Array( [ 1.0, 0.0, 2.0, 1.0 ] ); + expected = new Float64Array( [ 1, 0.0, -2.0, 1.0 ] ); + out = dtrti2( 'column-major', 'upper', 'unit', 2, A, 2 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function correctly computes inverse of lower triangular unit matrix ( column-major )', function test( t ) { + var expected; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 1.0 ] ); + expected = new Float64Array( [ 1, -2.0, 0.0, 1.0 ] ); + out = dtrti2( 'column-major', 'lower', 'unit', 2, A, 2 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function correctly computes inverse of upper triangular unit matrix ( row-major )', function test( t ) { + var expected; + var out; + var A; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 1.0 ] ); + expected = new Float64Array( [ 1, -2.0, 0.0, 1.0 ] ); + out = dtrti2( 'row-major', 'upper', 'unit', 2, A, 2 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function correctly computes inverse of lower triangular unit matrix ( row-major )', function test( t ) { + var expected; + var out; + var A; + + A = new Float64Array( [ 1.0, 0.0, 2.0, 1.0 ] ); + expected = new Float64Array( [ 1, 0.0, -2.0, 1.0 ] ); + out = dtrti2( 'row-major', 'lower', 'unit', 2, A, 2 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.js new file mode 100644 index 00000000000..b164d664035 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.js @@ -0,0 +1,82 @@ +/** +* @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 dtrti2 = 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 dtrti2, '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 dtrti2.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 dtrti2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dtrti2, 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 dtrti2; + var main; + + main = require( './../lib/dtrti2.js' ); + + dtrti2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dtrti2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.ndarray.js new file mode 100644 index 00000000000..71a40dbf3ff --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dtrti2/test/test.ndarray.js @@ -0,0 +1,194 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dtrti2 = 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 dtrti2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dtrti2.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 5, + true, + false + ]; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 4.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() { + dtrti2( value, 'non-unit', 2, A, 2, 1, 0 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + 5, + true, + false + ]; + + A = new Float64Array( [ 1.0, 2.0, 0.0, 4.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() { + dtrti2( 'upper', value, 2, A, 2, 1, 0 ); + }; + } +}); + +tape( 'the function supports accessing elements from non-contiguous alignment of row and column ( row-major )', function test( t ) { + var expected; + var out; + var A; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 4, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 4, 999, 2, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 4, + 999, 999, 999, 999, 999, 999 + ]); + + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, -0.5, 999, -0.75, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0.25, 999, -0.125, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 0.25, + 999, 999, 999, 999, 999, 999 + ]); + + out = dtrti2( 'upper', 'non-unit', 3, A, 12, 2, 7 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function supports accessing elements from non-contiguous alignment of row and column in reverse order ( row-major )', function test( t ) { + var expected; + var out; + var A; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 4, 999, 0, 999, 0, + 999, 999, 999, 999, 999, 999, + 999, 2, 999, 4, 999, 0, + 999, 999, 999, 999, 999, 999, + 999, 4, 999, 2, 999, 1, + 999, 999, 999, 999, 999, 999 + ]); + + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 0.25, 999, 0, 999, 0, + 999, 999, 999, 999, 999, 999, + 999, -0.125, 999, 0.25, 999, 0, + 999, 999, 999, 999, 999, 999, + 999, -0.75, 999, -0.5, 999, 1, + 999, 999, 999, 999, 999, 999 + ]); + + out = dtrti2( 'upper', 'non-unit', 3, A, -12, -2, 35); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +});