diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md new file mode 100644 index 000000000000..0788688b6d88 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md @@ -0,0 +1,252 @@ + + +# dptts2 + +> Solve a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A`. + +
+ +## Usage + +```javascript +var dptts2 = require( '@stdlib/lapack/base/dptts2' ); +``` + +#### dptts2( order, N, NRHS, D, E, B, LDB ) + +Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +var E = new Float64Array( [ 2.0, 3.0 ] ); +var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dptts2( 'row-major', 3, 2, D, E, B, 2 ); +// B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **N**: order of the tridiagonal matrix `A`. +- **NRHS**: number of right-hand sides i.e. the number of columns in `B`. +- **D**: array containing the diagonal elements of `A`. +- **E**: array containing the subdiagonal elements of `A`. +- **B**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **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 D0 = new Float64Array( [ 0.0, 1.0, 1.0, 1.0 ] ); +var E0 = new Float64Array( [ 0.0, 2.0, 3.0 ] ); +var B0 = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +// Create offset views... +var D1 = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var E1 = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var B1 = new Float64Array( B0.buffer, B0.BYTES_PER_ELEMENT*2 ); // start at 2nd element + +dptts2( 'row-major', 3, 2, D1, E1, B1, 2 ); +// B0 => [ 0.0, 0.0, 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +``` + +#### dptts2.ndarray( N, NRHS, D, sd, od, E, se, oe, B, sb1, sb2, ob ) + +Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +var E = new Float64Array( [ 2.0, 3.0 ] ); +var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); +// B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +``` + +The function has the following parameters: + +- **N**: order of the tridiagonal matrix `A`. +- **NRHS**: number of right-hand sides i.e. the number of columns in `B`. +- **D**: array containing the diagonal elements of `A`. +- **sd**: stride length for `D`. +- **od**: starting index for `D`. +- **E**: array containing the subdiagonal elements of `A`. +- **se**: stride length for `E`. +- **oe**: starting index for `E`. +- **B**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **sb1**: stride of first dimension of `B`. +- **sb2**: stride of 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' ); + +var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +var E = new Float64Array( [ 2.0, 3.0 ] ); +var B = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 1 ); +// B => [ 0.0, 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +``` + +
+ + + +
+ +## Notes + +- `dptts2()` corresponds to [LAPACK][LAPACK] routine [`dptts2`][dptts2]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dptts2 = require( '@stdlib/lapack/base/dptts2' ); + +var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +var E = new Float64Array( [ 2.0, 3.0 ] ); +var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); +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/lapack/base/dptts2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.js new file mode 100644 index 000000000000..986f476703d6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @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 dptts2 = require( './../lib/dptts2.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 B; + var D = uniform( len, -10.0, 10.0, options ); + var E = uniform( len-1, -10.0, 10.0, options ); + + 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++ ) { + B = uniform( len * len, -10.0, 10.0, options ); + z = dptts2( 'row-major', len, len, D, E, B, len ); + 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 len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':order=row-major:size='+(len*len), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..9984161a517f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.ndarray.js @@ -0,0 +1,107 @@ +/** +* @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 dptts2 = 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 B; + var D = uniform( len, -10.0, 10.0, options ); + var E = uniform( len-1, -10.0, 10.0, options ); + + 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++ ) { + B = uniform( len * len, -10.0, 10.0, options ); + z = dptts2( len, len, D, 1, 0, E, 1, 0, B, len, 1, 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 len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 5; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':ndarray:order=row-major:size='+(len*len), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt new file mode 100644 index 000000000000..574264694c40 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt @@ -0,0 +1,109 @@ + +{{alias}}( order, N, NRHS, D, E, B, LDB ) + Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` + factorization of `A`. + + 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'. + + N: integer + Order of the tridiagonal matrix `A`. + + NRHS: integer + Number of right-hand sides i.e. number of columns in `B`. + + D: Float64Array + Array containing the diagonal elements of `A`. + + E: Float64Array + Array containing the subdiagonal elements of `A`. + + B: Float64Array + Input matrix. + + LDB: integer + Stride of the first dimension of `B` (a.k.a., leading dimension of the + matrix `B`). + + Returns + ------- + B: Float64Array + Mutated input matrix. + + Examples + -------- + > var D = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0, 1.0 ] ); + > var E = new {{alias:@stdlib/array/float64}}( [ 2.0, 3.0 ] ); + > var B = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var ord = 'row-major'; + > {{alias}}( ord, 3, 2, D, E, B, 2 ) + [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] + + +{{alias}}.ndarray( N, NRHS, D, sd, od, E, se, oe, B, sb1, sb2, ob ) + Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` + factorization of `A` 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 + ---------- + N: integer + Order of the tridiagonal matrix `A`. + + NRHS: integer + Number of right-hand sides i.e. number of columns in `B`. + + D: Float64Array + Array containing the diagonal elements of `A`. + + sd: integer + Stride length for `D`. + + od: integer + Starting index for `D`. + + E: Float64Array + Array containing the subdiagonal elements of `A`. + + se: integer + Stride length for `E`. + + oe: integer + Starting index for `E`. + + B: Float64Array + Input matrix. + + sb1: integer + Stride of first dimension of `B`. + + sb2: integer + Stride of second dimension of `B`. + + ob: integer + Starting index for `B`. + + Returns + ------- + B: Float64Array + Mutated input matrix. + + Examples + -------- + > var D = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0, 1.0 ] ); + > var E = new {{alias:@stdlib/array/float64}}( [ 0.0, 2.0, 3.0 ] ); + > var B = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}.ndarray( 3, 2, D, 1, 1, E, 1, 1, B, 2, 1, 1 ) + [ 0.0, 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/index.d.ts new file mode 100644 index 000000000000..84d26ac057bc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/index.d.ts @@ -0,0 +1,120 @@ +/* +* @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 } from '@stdlib/types/blas'; + +/** +* Interface describing `dptts2`. +*/ +interface Routine { + /** + * Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A`. + * + * @param order - storage layout + * @param N - order of tridiagonal matrix `A` + * @param NRHS - number of right hand sides i.e. number of columns in matrix `B` + * @param D - array containing the diagonal elements of `A` + * @param E - array containing the subdiagonal elements of `A` + * @param B - input matrix + * @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) + * @returns output matrix + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + * var E = new Float64Array( [ 2.0, 3.0 ] ); + * var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * dptts2( 'row-major', 3, 2, D, E, B, 2 ); + * // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] + */ + ( order: Layout, N: number, NRHS: number, D: Float64Array, E: Float64Array, B: Float64Array, LDB: number ): Float64Array; + + /** + * Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` using alternative indexing semantics. + * + * @param N - order of tridiagonal matrix `A` + * @param NRHS - number of right hand sides i.e. number of columns in matrix `B` + * @param D - array containing the diagonal elements of `A` + * @param strideD - stride length for `D` + * @param offsetD - starting index for `D` + * @param E - array containing the subdiagonal elements of `A` + * @param strideE - stride length for `E` + * @param offsetE - starting index for `E` + * @param B - input matrix + * @param strideB1 - stride of the first dimension of `B` + * @param strideB2 - stride of the second dimension of `B` + * @param offsetB - index offset for `B` + * @returns output matrix + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + * var E = new Float64Array( [ 2.0, 3.0 ] ); + * var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); + * // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] + */ + ndarray( N: number, NRHS: number, D: Float64Array, strideD: number, offsetD: number, E: Float64Array, strideE: number, offsetE: number, B: Float64Array, strideB1: number, strideB2: number, offsetB: number ): Float64Array; +} + +/** +* Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A`. +* +* @param order - storage layout +* @param N - order of tridiagonal matrix `A` +* @param NRHS - number of right hand sides i.e. number of columns in matrix `B` +* @param D - array containing the diagonal elements of `A` +* @param E - array containing the subdiagonal elements of `A` +* @param B - input matrix +* @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @returns output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var E = new Float64Array( [ 2.0, 3.0 ] ); +* var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dptts2( 'row-major', 3, 2, D, E, B, 2 ); +* // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var E = new Float64Array( [ 2.0, 3.0 ] ); +* var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); +* // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +*/ +declare var dptts2: Routine; + + +// EXPORTS // + +export = dptts2; diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts new file mode 100644 index 000000000000..f3aac0081ce9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts @@ -0,0 +1,381 @@ +/* +* @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 dptts2 = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2( 'row-major', 3, 2, D, E, B, 2 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2( 5, 3, 2, D, E, B, 2 ); // $ExpectError + dptts2( true, 3, 2, D, E, B, 2 ); // $ExpectError + dptts2( false, 3, 2, D, E, B, 2 ); // $ExpectError + dptts2( null, 3, 2, D, E, B, 2 ); // $ExpectError + dptts2( void 0, 3, 2, D, E, B, 2 ); // $ExpectError + dptts2( [], 3, 2, D, E, B, 2 ); // $ExpectError + dptts2( {}, 3, 2, D, E, B, 2 ); // $ExpectError + dptts2( ( x: number ): number => x, 3, 2, D, E, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2( 'row-major', '5', 2, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', true, 2, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', false, 2, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', null, 2, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', void 0, 2, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', [], 2, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', {}, 2, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', ( x: number ): number => x, 2, D, E, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2( 'row-major', 3, '5', D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, true, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, false, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, null, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, void 0, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, [], D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, {}, D, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, ( x: number ): number => x, D, E, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... +{ + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2( 'row-major', 3, 2, '5', E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, 5, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, true, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, false, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, null, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, void 0, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, [], E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, {}, E, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, ( x: number ): number => x, E, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2( 'row-major', 3, 2, D, '5', B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, 5, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, true, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, false, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, null, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, void 0, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, [], B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, {}, B, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, ( x: number ): number => x, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + + dptts2( 'row-major', 3, 2, D, E, '5', 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, 5, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, true, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, false, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, null, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, void 0, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, [], 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, {}, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2( 'row-major', 3, 2, D, E, B, '5' ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B, true ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B, false ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B, null ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B, void 0 ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B, [] ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B, {} ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2(); // $ExpectError + dptts2( 'row-major' ); // $ExpectError + dptts2( 'row-major', 3 ); // $ExpectError + dptts2( 'row-major', 3, 2 ); // $ExpectError + dptts2( 'row-major', 3, 2, D ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B ); // $ExpectError + dptts2( 'row-major', 3, 2, D, E, B, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, 0, E, 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 number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( '5', 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( true, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( false, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( null, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( void 0, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( [], 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( {}, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( ( x: number ): number => x, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, '5', D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, true, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, false, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, null, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, void 0, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, [], D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, {}, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, ( x: number ): number => x, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, '5', 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, 5, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, true, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, false, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, null, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, void 0, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, [], 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, {}, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, ( x: number ): number => x, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, '5', 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, true, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, false, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, null, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, void 0, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, [], 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, {}, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, ( x: number ): number => x, 0, E, 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 D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, '5', E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, true, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, false, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, null, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, void 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, [], E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, {}, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, ( x: number ): number => x, E, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, 0, '5', 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, 5, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, true, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, false, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, null, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, void 0, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, [], 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, {}, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, ( x: number ): number => x, 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 D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, 0, E, '5', 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, true, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, false, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, null, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, void 0, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, [], 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, {}, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, ( x: number ): number => x, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, '5', B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, true, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, false, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, null, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, void 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, [], B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, {}, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, ( x: number ): number => x, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, '5', 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, 5, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, true, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, false, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, null, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, void 0, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, [], 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, {}, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, '5', 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, true, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, false, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, null, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, void 0, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, [], 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, {}, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, '5', 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, true, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, false, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, null, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, void 0, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, [], 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, {}, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, '5' ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, true ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, false ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, null ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, void 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, [] ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, {} ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 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 D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + const E = new Float64Array( [ 2.0, 3.0 ] ); + const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + dptts2.ndarray(); // $ExpectError + dptts2.ndarray( 3 ); // $ExpectError + dptts2.ndarray( 3, 2 ); // $ExpectError + dptts2.ndarray( 3, 2, D ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1 ); // $ExpectError + dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dptts2/examples/index.js new file mode 100644 index 000000000000..8364df1d06e4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/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 dptts2 = require( './../lib/' ); + +var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +var E = new Float64Array( [ 2.0, 3.0 ] ); +var B = new Float64Array( [ 1.0, 3.0, 5.0, 2.0, 4.0, 6.0 ] ); + +dptts2( 'column-major', 3, 2, D, E, B, 3 ); +console.log( B ); diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js new file mode 100644 index 000000000000..7a00df8098a2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.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. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var dscal = require( '@stdlib/blas/base/dscal' ); + + +// MAIN // + +/** +* Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. +* +* @private +* @param {NonNegativeInteger} N - order of tridiagonal matrix `A` +* @param {NonNegativeInteger} NRHS - number of right hand sides i.e. number of columns in matrix `B` +* @param {Float64Array} D - array containing the diagonal elements of `A` +* @param {integer} strideD - stride length for `D` +* @param {integer} offsetD - starting index for `D` +* @param {Float64Array} E - array containing the subdiagonal elements of `A` +* @param {integer} strideE - stride length for `E` +* @param {integer} offsetE - starting index for `E` +* @param {Float64Array} B - input matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {integer} offsetB - index offset for `B` +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var E = new Float64Array( [ 2.0, 3.0 ] ); +* var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dptts2( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); +* // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +*/ +function dptts2( N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ) { + var ob; + var se; + var i; + var j; + + if ( N <= 1 ) { + if ( N === 1 ) { + if ( isRowMajor( [ strideB1, strideB2 ] ) ) { + dscal( NRHS, 1.0 / D[ 0 ], B, strideB1 ); + return B; + } + // column-major + dscal( NRHS, 1.0 / D[ 0 ], B, strideB2 ); + return B; + } + return B; + } + for ( j = 0; j < NRHS; j++ ) { + ob = offsetB + ( j * strideB2 ); + se = 1; + for ( i = 1; i < N; i++ ) { + B[ ob + ( i * strideB1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * strideB1 ) ]; + se += strideE; + } + B[ ob + ( ( N - 1 ) * strideB1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; + se = N - 2; + for ( i = N - 2; i >= 0; i-- ) { + B[ ob + ( i * strideB1 ) ] = ( B[ ob + ( i * strideB1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1) * strideB1 ) ] ); + se -= strideE; + } + } + return B; +} + + +// EXPORTS // + +module.exports = dptts2; diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js new file mode 100644 index 000000000000..cb9154f10069 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js @@ -0,0 +1,72 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A`. +* +* @param {string} order - storage layout +* @param {NonNegativeInteger} N - order of tridiagonal matrix `A` +* @param {NonNegativeInteger} NRHS - number of right hand sides i.e. number of columns in matrix `B` +* @param {Float64Array} D - array containing the diagonal elements of `A` +* @param {Float64Array} E - array containing the subdiagonal elements of `A` +* @param {Float64Array} B - input matrix +* @param {PositiveInteger} 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 +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var E = new Float64Array( [ 2.0, 3.0 ] ); +* var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dptts2( 'row-major', 3, 2, D, E, B, 2 ); +* // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +*/ +function dptts2( order, N, NRHS, D, E, B, LDB ) { + var sb1; + var sb2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( order === 'column-major' ) { + sb1 = 1; + sb2 = LDB; + } else { // order === 'row-major' + sb1 = LDB; + sb2 = 1; + } + return base( N, NRHS, D, 1, 0, E, 1, 0, B, sb1, sb2, 0 ); +} + + +// EXPORTS // + +module.exports = dptts2; diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js new file mode 100644 index 000000000000..ba365cc36fc5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js @@ -0,0 +1,70 @@ +/** +* @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 solve a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. +* +* @module @stdlib/lapack/base/dptts2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dptts2 = require( '@stdlib/lapack/base/dptts2' ); +* +* var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var E = new Float64Array( [ 2.0, 3.0 ] ); +* var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dptts2( 'row-major', 3, 2, D, E, B, 2 ); +* // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dptts2 = require( '@stdlib/lapack/base/dptts2' ); +* +* var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var E = new Float64Array( [ 2.0, 3.0 ] ); +* var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); +* // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.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 dptts2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dptts2 = main; +} else { + dptts2 = tmp; +} + + +// EXPORTS // + +module.exports = dptts2; diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/main.js new file mode 100644 index 000000000000..92db9a592fc7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/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 dptts2 = require( './dptts2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dptts2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dptts2; diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js new file mode 100644 index 000000000000..78af1defa804 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/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. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` using alternative indexing semantics. +* +* @param {NonNegativeInteger} N - order of tridiagonal matrix `A` +* @param {NonNegativeInteger} NRHS - number of right hand sides i.e. number of columns in matrix `B` +* @param {Float64Array} D - array containing the diagonal elements of `A` +* @param {integer} strideD - stride length for `D` +* @param {integer} offsetD - starting index for `D` +* @param {Float64Array} E - array containing the subdiagonal elements of `A` +* @param {integer} strideE - stride length for `E` +* @param {integer} offsetE - starting index for `E` +* @param {Float64Array} B - input matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {integer} offsetB - index offset for `B` +* @throws {TypeError} first argument must be a valid order +* @returns {Float64Array} output matrix +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var E = new Float64Array( [ 2.0, 3.0 ] ); +* var B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dptts2( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); +* // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] +*/ +function dptts2( N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ) { + return base( N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ); +} + + +// EXPORTS // + +module.exports = dptts2; diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/package.json b/lib/node_modules/@stdlib/lapack/base/dptts2/package.json new file mode 100644 index 000000000000..c0c734609617 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dptts2", + "version": "0.0.0", + "description": "Solve a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A`", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "lapack", + "dptts2", + "factorization", + "tridiagonal", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.dptts2.js b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.dptts2.js new file mode 100644 index 000000000000..a24276284874 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.dptts2.js @@ -0,0 +1,185 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var dptts2 = require( './../lib/dptts2.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 dptts2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dptts2.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var E; + var D; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + E = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + D = new Float64Array( [ 2.0, 3.0 ] ); + B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.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() { + dptts2( value, 3, 2, E, D, B, 3 ); + }; + } +}); + +tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` (row-major)', function test( t ) { + var expected; + var out; + var D; + var E; + var B; + + D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + E = new Float64Array( [ 2.0, 3.0 ] ); + B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] ); + out = dptts2( 'row-major', 3, 2, D, E, B, 2 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 1.0e-7 ); + + t.end(); +}); + +tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` (column-major)', function test( t ) { + var expected; + var out; + var D; + var E; + var B; + + D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + E = new Float64Array( [ 2.0, 3.0 ] ); + B = new Float64Array( [ 1.0, 3.0, 5.0, 2.0, 4.0, 6.0 ] ); + + expected = new Float64Array( [ 11.0, -5.0, 2.0, 38.0, -18.0, 6.0 ] ); + out = dptts2( 'column-major', 3, 2, D, E, B, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 1.0e-7 ); + + t.end(); +}); + +tape( 'the function returns B unchanged when `N==1`', function test( t ) { + var expected; + var out; + var D; + var E; + var B; + + D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + E = new Float64Array( [ 2.0, 3.0 ] ); + B = new Float64Array( [ 1.0, 3.0, 5.0, 2.0, 4.0, 6.0 ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 2.0, 4.0, 6.0 ] ); + out = dptts2( 'column-major', 1, 2, D, E, B, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 1.0e-7 ); + + t.end(); +}); + +tape( 'the function returns B unchanged when `N<1`', function test( t ) { + var expected; + var out; + var D; + var E; + var B; + + D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + E = new Float64Array( [ 2.0, 3.0 ] ); + B = new Float64Array( [ 1.0, 3.0, 5.0, 2.0, 4.0, 6.0 ] ); + + expected = new Float64Array( [ 1.0, 3.0, 5.0, 2.0, 4.0, 6.0 ] ); + out = dptts2( 'column-major', 0, 2, D, E, B, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 1.0e-7 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js new file mode 100644 index 000000000000..72cb218020b7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/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 dptts2 = 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 dptts2, '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 dptts2.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 dptts2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dptts2, 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 dptts2; + var main; + + main = require( './../lib/dptts2.js' ); + + dptts2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dptts2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js new file mode 100644 index 000000000000..0aca2d073900 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js @@ -0,0 +1,148 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var dptts2 = 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 dptts2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( dptts2.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` (row-major, offsetD=3, offsetE=4, offsetB=6)', function test( t ) { + var expected; + var out; + var D; + var E; + var B; + + D = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ] ); + E = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 2.0, 3.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] ); + out = dptts2( 3, 2, D, 1, 3, E, 1, 4, B, 2, 1, 6 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 1.0e-7 ); + + t.end(); +}); + +tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` (row-major, offsetD=3, strideD=2, offsetE=4, offsetB=6)', function test( t ) { + var expected; + var out; + var D; + var E; + var B; + + D = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 ] ); + E = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 2.0, 3.0 ] ); + B = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] ); + out = dptts2( 3, 2, D, 2, 3, E, 1, 4, B, 2, 1, 6 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 1.0e-7 ); + + t.end(); +}); + +tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` (row-major, strideB1=-2, strideB2=-1)', function test( t ) { + var expected; + var out; + var D; + var E; + var B; + + D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + E = new Float64Array( [ 2.0, 3.0 ] ); + B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + expected = new Float64Array( [ 22, 26, -73, -86, 151, 178 ] ); + out = dptts2( 3, 2, D, 1, 0, E, 1, 0, B, -2, -1, 5 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 1.0e-7 ); + + t.end(); +}); + +tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A` (row-major, strideB1=-3, strideB2=-2)', function test( t ) { + var expected; + var out; + var D; + var E; + var B; + + D = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + E = new Float64Array( [ 2.0, 3.0 ] ); + B = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0, 0.0, 4.0, 0.0, 0.0, 0.0, 5.0, 0.0, 6.0 ] ); + + expected = new Float64Array( [ 22, 0, 26, 0, 0, 0, -73, 0, -86, 0, 0, 0, 151, 0, 178 ] ); + out = dptts2( 3, 2, D, 1, 0, E, 1, 0, B, -6, -2, B.length - 1 ); + t.strictEqual( out, B, 'returns expected value' ); + isApprox( t, B, expected, 1.0e-7 ); + + t.end(); +});