From dea84e94bd38b7dd80f4c75a8434d348dc05cd1f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 11:13:42 +0530 Subject: [PATCH 01/18] feat: init lapack/base/dptts2 --- .../lapack/base/dptts2/docs/types/index.d.ts | 121 ++++++ .../lapack/base/dptts2/docs/types/test.ts | 398 ++++++++++++++++++ .../lapack/base/dptts2/examples/index.js | 29 ++ .../@stdlib/lapack/base/dptts2/lib/base.js | 104 +++++ .../@stdlib/lapack/base/dptts2/lib/dptts2.js | 72 ++++ .../@stdlib/lapack/base/dptts2/lib/index.js | 71 ++++ .../@stdlib/lapack/base/dptts2/lib/main.js | 35 ++ .../@stdlib/lapack/base/dptts2/lib/ndarray.js | 69 +++ 8 files changed, 899 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js 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..46cbd7d7b9d6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/index.d.ts @@ -0,0 +1,121 @@ +/* +* @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 off-diagonal 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`. + * + * @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 strideD - stride length for `D` + * @param offsetD - index offset for `D` + * @param E - array containing the off-diagonal elements of `A` + * @param strideE - stride length for `E` + * @param offsetE - index offset 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( 'row-major', 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( order: Layout, 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 off-diagonal 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( 'row-major', 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..3b58d3ebafe2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts @@ -0,0 +1,398 @@ +/* +* @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( 'row-major', 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 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.ndarray( 5, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( true, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( false, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( null, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( void 0, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( [], 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( {}, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( ( x: number ): number => x, 3, 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( 'row-major', '5', 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', true, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', false, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', null, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', void 0, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', [], 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', {}, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', ( 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 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.ndarray( 'row-major', 3, '5', D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, true, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, false, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, null, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, void 0, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, [], D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, {}, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 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.ndarray( 'row-major', 3, 2, '5', 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, 5, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, true, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, false, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, null, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, void 0, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, [], 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, {}, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 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( 'row-major', 3, 2, D, '5', 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, true, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, false, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, null, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, void 0, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, [], 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, {}, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 sixth 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( 'row-major', 3, 2, D, 1, '5', E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, true, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, false, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, null, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, void 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, [], E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, {}, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 seventh 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( 'row-major', 3, 2, D, 1, 0, '5', 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, 5, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, true, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, false, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, null, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, void 0, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, [], 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, {}, 1, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 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( 'row-major', 3, 2, D, 1, 0, E, '5', 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, true, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, false, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, null, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, void 0, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, [], 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, {}, 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 a ninth 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( 'row-major', 3, 2, D, 1, 0, E, 1, '5', B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, true, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, false, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, null, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, void 0, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, [], B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, {}, B, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 tenth 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, '5', 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, 5, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, true, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, false, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, null, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, void 0, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, [], 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, {}, 2, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, '5', 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, true, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, false, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, null, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, void 0, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, [], 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, {}, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, '5', 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, true, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, false, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, null, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, void 0, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, [], 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, {}, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 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 thirteenth 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, '5' ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, true ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, false ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, null ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, void 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, [] ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, {} ); // $ExpectError + dptts2.ndarray( 'row-major', 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( 'row-major' ); // $ExpectError + dptts2.ndarray( 'row-major', 3 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2 ); // $ExpectError + dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1 ); // $ExpectError + dptts2.ndarray( 'row-major', 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..f5649de30256 --- /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, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dptts2( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); +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..d831f2114cbc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var 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 {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 {integer} strideD - stride length for `D` +* @param {integer} offsetD - index offset for `D` +* @param {Float64Array} E - array containing the off-diagonal elements of `A` +* @param {integer} strideE - stride length for `E` +* @param {integer} offsetE - index offset 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( 'row-major', 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( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + var ob; + var se; + var i; + var j; + + if ( N <= 1 ) { + if ( N === 1 ) { + if ( order === 'column-major' ) { + dscal( NRHS, 1.0 / D[ 0 ], B, strideB2 ); + return B; + } + // order === 'row-major' + dscal( NRHS, 1.0 / D[ 0 ], B, strideB1 ); + return B; + } + } + if ( order === 'column-major' ) { + for ( j = 0; j < NRHS; j++ ) { + ob = offsetB + ( j * strideB1 ); + for ( i = 1, se = 1; i < N; i++, se += strideE ) { + B[ ob + ( i * strideB2 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( (i-1) * strideB2 ) ]; // eslint-disable-line max-len + } + B[ offsetB + ( ( N - 1) * strideB1 ) + ( j * strideB2 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len + for ( i = N - 2, se = N - 2; i >= 0; i--, se -= strideE ) { + B[ ob + ( i * strideB2 ) ] = ( B[ ob + ( i * strideB2 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ offsetB + ( j * strideB1 ) + ( (i+1) * strideB2 ) ] ); // eslint-disable-line max-len + } + } + return B; + } + // order === 'row-major' + for ( j = 0; j < NRHS; j++ ) { + ob = offsetB + ( j * strideB2 ); + for ( i = 1, se = 1; i < N; i++, se += strideE ) { + B[ ob + ( i * strideB1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * strideB1 ) ]; // eslint-disable-line max-len + } + B[ offsetB + ( ( ob - 1 ) * strideB1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len + for ( i = N - 2, se = N - 2; i >= 0; i--, se -= strideE ) { + B[ ob + ( i * strideB1 ) ] = ( B[ ob + ( i * strideB1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1 ) * strideB1 ) ] ); // eslint-disable-line max-len + } + } + 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..83c79af812be --- /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 off-diagonal 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( order, 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..7fa59062ce21 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js @@ -0,0 +1,71 @@ + +/** +* @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( 'row-major', 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..7789a0b0bafe --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js @@ -0,0 +1,69 @@ +/** +* @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 {integer} strideD - stride length for `D` +* @param {integer} offsetD - index offset for `D` +* @param {Float64Array} E - array containing the off-diagonal elements of `A` +* @param {integer} strideE - stride length for `E` +* @param {integer} offsetE - index offset 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( 'row-major', 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( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + return base( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ); +} + + +// EXPORTS // + +module.exports = dptts2; From 4f682275c572c07b3e6ec236712063818a0126a9 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 11:15:04 +0530 Subject: [PATCH 02/18] feat: add package.json --- .../@stdlib/lapack/base/dptts2/package.json | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/package.json 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..544fe54c8dcd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dlaswp", + "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" + ] +} From eb0f4c0d63284e410eac219f65091f654cd428b6 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 12:02:46 +0530 Subject: [PATCH 03/18] feat: add README --- .../@stdlib/lapack/base/dptts2/README.md | 253 ++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/README.md 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..882de982b870 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md @@ -0,0 +1,253 @@ + + +# dlaswp + +> 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 off-diagonal 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 1st element +var E1 = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); // start at 1st 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( order, 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( 'row-major', 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: + +- **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`. +- **sd**: stride length for `D`. +- **od**: starting index for `D`. +- **E**: array containing the off-diagonal 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( 'row-major', 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( 'row-major', 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 +``` + +
+ + + +
+ + + + + + + + + + + + + + From 7b0a1d888e2e44ae5a554c204e6abcabcd6ce877 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 12:03:13 +0530 Subject: [PATCH 04/18] docs: fix description --- .../@stdlib/lapack/base/dptts2/docs/types/index.d.ts | 6 +++--- lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js | 4 ++-- lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) 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 index 46cbd7d7b9d6..3088a065bd7e 100644 --- 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 @@ -51,17 +51,17 @@ interface Routine { ( 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`. + * Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A` using alternative indexing semantics. * * @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 strideD - stride length for `D` - * @param offsetD - index offset for `D` + * @param offsetD - starting index for `D` * @param E - array containing the off-diagonal elements of `A` * @param strideE - stride length for `E` - * @param offsetE - index offset 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` diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js index d831f2114cbc..fc588f227748 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js @@ -34,10 +34,10 @@ var dscal = require( '@stdlib/blas/base/dscal' ); * @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 - index offset for `D` +* @param {integer} offsetD - starting index for `D` * @param {Float64Array} E - array containing the off-diagonal elements of `A` * @param {integer} strideE - stride length for `E` -* @param {integer} offsetE - index offset 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` diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js index 7789a0b0bafe..500f5df11399 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js @@ -28,17 +28,17 @@ var base = require( './base.js' ); // MAIN // /** -* Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. +* Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A` using alternative indexing semantics. * * @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 {integer} strideD - stride length for `D` -* @param {integer} offsetD - index offset for `D` +* @param {integer} offsetD - starting index for `D` * @param {Float64Array} E - array containing the off-diagonal elements of `A` * @param {integer} strideE - stride length for `E` -* @param {integer} offsetE - index offset 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` From 22538b5798c435c07ea81b2d32b2091cbbbce67a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 12:03:37 +0530 Subject: [PATCH 05/18] bench: add js and ndarray benchmarks --- .../lapack/base/dptts2/benchmark/benchmark.js | 107 ++++++++++++++++++ .../dptts2/benchmark/benchmark.ndarray.js | 107 ++++++++++++++++++ 2 files changed, 214 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.ndarray.js 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..c6a1c71466dd --- /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( 'row-major', 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(); From 04ce1d98ed91536fbe44fe27bd84e2a59be284d0 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 13:09:03 +0530 Subject: [PATCH 06/18] fix: incorrect implementation --- .../@stdlib/lapack/base/dptts2/lib/base.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js index fc588f227748..cd34ba4b30f7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js @@ -68,18 +68,19 @@ function dptts2( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, st } // order === 'row-major' dscal( NRHS, 1.0 / D[ 0 ], B, strideB1 ); - return B; } + return B; } if ( order === 'column-major' ) { for ( j = 0; j < NRHS; j++ ) { - ob = offsetB + ( j * strideB1 ); + ob = offsetB + ( j * strideB2 ); for ( i = 1, se = 1; i < N; i++, se += strideE ) { - B[ ob + ( i * strideB2 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( (i-1) * strideB2 ) ]; // eslint-disable-line max-len + // console.log( "B[ ob + ( i * strideB2 ) ]: ", B[ ob + ( i * strideB2 ) ] ); + B[ ob + ( i * strideB1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( (i-1) * strideB1 ) ]; // eslint-disable-line max-len } - B[ offsetB + ( ( N - 1) * strideB1 ) + ( j * strideB2 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len + B[ ob + ( ( N - 1 ) * strideB1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len for ( i = N - 2, se = N - 2; i >= 0; i--, se -= strideE ) { - B[ ob + ( i * strideB2 ) ] = ( B[ ob + ( i * strideB2 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ offsetB + ( j * strideB1 ) + ( (i+1) * strideB2 ) ] ); // eslint-disable-line max-len + B[ ob + ( i * strideB1 ) ] = ( B[ ob + ( i * strideB1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1) * strideB1 ) ] ); // eslint-disable-line max-len } } return B; @@ -90,7 +91,7 @@ function dptts2( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, st for ( i = 1, se = 1; i < N; i++, se += strideE ) { B[ ob + ( i * strideB1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * strideB1 ) ]; // eslint-disable-line max-len } - B[ offsetB + ( ( ob - 1 ) * strideB1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len + B[ ob + ( ( N - 1 ) * strideB1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len for ( i = N - 2, se = N - 2; i >= 0; i--, se -= strideE ) { B[ ob + ( i * strideB1 ) ] = ( B[ ob + ( i * strideB1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1 ) * strideB1 ) ] ); // eslint-disable-line max-len } From 0370eba4cc217babe29b3fa1f28154275b021c75 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 13:10:04 +0530 Subject: [PATCH 07/18] test: add js and ndarray tests --- .../lapack/base/dptts2/test/test.dptts2.js | 185 ++++++++++++++++++ .../@stdlib/lapack/base/dptts2/test/test.js | 83 ++++++++ .../lapack/base/dptts2/test/test.ndarray.js | 149 ++++++++++++++ 3 files changed, 417 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/test/test.dptts2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js 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..6b28afa70485 --- /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..0b0c517c2e22 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js @@ -0,0 +1,83 @@ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var 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..76040eeb11f8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js @@ -0,0 +1,149 @@ +/** +* @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 13', function test( t ) { + t.strictEqual( dptts2.length, 13, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var 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, 1, 0, D, 1, 0, B, 3, 1, 0 ); + }; + } +}); + +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( 'row-major', 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( 'row-major', 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(); +}); From 8fafe31596503b6712455cbea76ddb20ca7ea58a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 13:18:12 +0530 Subject: [PATCH 08/18] docs: add repl --- .../@stdlib/lapack/base/dptts2/docs/repl.txt | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt 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..f6924b80f223 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt @@ -0,0 +1,125 @@ + +{{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 ] + + // Using typed array views: + > var D0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0, 1.0 ] ); + > var E0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 2.0, 3.0 ] ); + > var B0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); + > E = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); + > B = new Float64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( ord, 3, 2, D, E, B, 2 ); + > B0 + [ 0.0, 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] + + +{{alias}}.ndarray( order, 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 + ---------- + 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`. + + 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 ] ); + > var ord = 'row-major'; + > {{alias}}.ndarray( ord, 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 + -------- From f5505cc3dff80a396daec0f9fc2fec480a23a305 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 13:18:45 +0530 Subject: [PATCH 09/18] docs: fix incorrect description --- lib/node_modules/@stdlib/lapack/base/dptts2/README.md | 4 ++-- .../@stdlib/lapack/base/dptts2/docs/types/index.d.ts | 6 +++--- .../@stdlib/lapack/base/dptts2/examples/index.js | 4 ++-- lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js | 2 +- lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js | 2 +- lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md index 882de982b870..ba9055e8f45d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md @@ -51,7 +51,7 @@ 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`. -- **E**: array containing the off-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`). @@ -99,7 +99,7 @@ The function has the following parameters: - **D**: array containing the diagonal elements of `A`. - **sd**: stride length for `D`. - **od**: starting index for `D`. -- **E**: array containing the off-diagonal elements of `A`. +- **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]. 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 index 3088a065bd7e..bd1f3c42094e 100644 --- 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 @@ -33,7 +33,7 @@ interface Routine { * @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 off-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 @@ -59,7 +59,7 @@ interface Routine { * @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 off-diagonal elements of `A` + * @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 @@ -88,7 +88,7 @@ interface Routine { * @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 off-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 diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dptts2/examples/index.js index f5649de30256..8364df1d06e4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/examples/index.js @@ -23,7 +23,7 @@ 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, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var B = new Float64Array( [ 1.0, 3.0, 5.0, 2.0, 4.0, 6.0 ] ); -dptts2( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 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 index cd34ba4b30f7..0ea920d8290f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js @@ -35,7 +35,7 @@ var dscal = require( '@stdlib/blas/base/dscal' ); * @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 off-diagonal elements of `A` +* @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 diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js index 83c79af812be..0f5740bbf7ae 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js @@ -34,7 +34,7 @@ var base = require( './base.js' ); * @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 off-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 diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js index 500f5df11399..4fb3e11ef791 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js @@ -36,7 +36,7 @@ var base = require( './base.js' ); * @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 off-diagonal elements of `A` +* @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 From 0266e72f74cc575f5f394d08ad2fe410c4e83c5b Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 18 Jul 2024 13:28:05 +0530 Subject: [PATCH 10/18] fix: incorrect readme example --- lib/node_modules/@stdlib/lapack/base/dptts2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md index ba9055e8f45d..dea21fbe8433 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md @@ -150,7 +150,7 @@ 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, 1, 0, E, 1, 0, B, 2, 1, 0 ); +dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); console.log( B ); ``` From e547872ceab571c7a2cf1b3a4d34c6172cb14ac2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 22 Jul 2024 18:36:51 +0530 Subject: [PATCH 11/18] refactor: base implementation --- .../@stdlib/lapack/base/dptts2/lib/base.js | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js index 0ea920d8290f..6ebca6789789 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js @@ -55,11 +55,23 @@ var dscal = require( '@stdlib/blas/base/dscal' ); * // B => [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] */ function dptts2( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + var sb0; + var sb1; var ob; var se; var i; var j; + if ( order === 'row-major' ) { + // For row-major matrices, the last dimension has the fastest changing index... + sb0 = strideB2; // stride for innermost loop + sb1 = strideB1; // stride for outermost loop + } else { // order == 'column-major' + // For column-major matrices, the first dimension has the fastest changing index... + sb0 = strideB1; // stride for innermost loop + sb1 = strideB2; // stride for outermost loop + } + if ( N <= 1 ) { if ( N === 1 ) { if ( order === 'column-major' ) { @@ -73,27 +85,34 @@ function dptts2( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, st } if ( order === 'column-major' ) { for ( j = 0; j < NRHS; j++ ) { - ob = offsetB + ( j * strideB2 ); - for ( i = 1, se = 1; i < N; i++, se += strideE ) { - // console.log( "B[ ob + ( i * strideB2 ) ]: ", B[ ob + ( i * strideB2 ) ] ); - B[ ob + ( i * strideB1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( (i-1) * strideB1 ) ]; // eslint-disable-line max-len + ob = offsetB + ( j * sb1 ); + se = 1; + for ( i = 1; i < N; i++ ) { + B[ ob + ( i * sb0 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * sb0 ) ]; // eslint-disable-line max-len + se += strideE; } - B[ ob + ( ( N - 1 ) * strideB1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len - for ( i = N - 2, se = N - 2; i >= 0; i--, se -= strideE ) { - B[ ob + ( i * strideB1 ) ] = ( B[ ob + ( i * strideB1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1) * strideB1 ) ] ); // eslint-disable-line max-len + B[ ob + ( ( N - 1 ) * sb0 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len + se = N - 2; + for ( i = N - 2; i >= 0; i-- ) { + B[ ob + ( i * sb0 ) ] = ( B[ ob + ( i * sb0 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1) * sb0 ) ] ); // eslint-disable-line max-len + se -= strideE; } } return B; } // order === 'row-major' for ( j = 0; j < NRHS; j++ ) { - ob = offsetB + ( j * strideB2 ); - for ( i = 1, se = 1; i < N; i++, se += strideE ) { - B[ ob + ( i * strideB1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * strideB1 ) ]; // eslint-disable-line max-len + ob = offsetB + ( j * sb0 ); + se = 1; + for ( i = 1; i < N; i++ ) { + B[ ob + ( i * sb1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * sb1 ) ]; // eslint-disable-line max-len + se += strideE; } - B[ ob + ( ( N - 1 ) * strideB1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len - for ( i = N - 2, se = N - 2; i >= 0; i--, se -= strideE ) { - B[ ob + ( i * strideB1 ) ] = ( B[ ob + ( i * strideB1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1 ) * strideB1 ) ] ); // eslint-disable-line max-len + B[ ob + ( ( N - 1 ) * sb1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; + se = N - 2; + for ( i = N - 2; i >= 0; i-- ) { + B[ ob + ( i * sb1 ) ] = ( B[ ob + ( i * sb1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1 ) * sb1 ) ] ); // eslint-disable-line max-len + se -= strideE; } } return B; From aed64e39947dcbebbe736d5096ec90b3bdb17bff Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 22 Jul 2024 18:37:40 +0530 Subject: [PATCH 12/18] test: add negative stride test --- .../lapack/base/dptts2/test/test.ndarray.js | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) 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 index 76040eeb11f8..31db7d0505c3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js @@ -147,3 +147,41 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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( 'row-major', 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( 'row-major', 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(); +}); From 8e384fc5b01c98ea7741642e6c8b3b60cbd54d4d Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:12:20 +0530 Subject: [PATCH 13/18] chore: apply suggestions from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dptts2/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/package.json b/lib/node_modules/@stdlib/lapack/base/dptts2/package.json index 544fe54c8dcd..222b83802f22 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/package.json @@ -1,5 +1,5 @@ { - "name": "@stdlib/lapack/base/dlaswp", + "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", From dbc9969df740a61d0629dea261e3ff0f203bbd49 Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:13:03 +0530 Subject: [PATCH 14/18] chore: apply suggestion from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dptts2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md index dea21fbe8433..146e29679a5d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md @@ -18,7 +18,7 @@ limitations under the License. --> -# dlaswp +# dptts2 > Solve a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. From ed505419e5a5f0011f5b6d05d73d7ad1fe571dfb Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Tue, 23 Jul 2024 00:15:00 +0530 Subject: [PATCH 15/18] chore: apply code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js index 7fa59062ce21..f06b2b7dbca7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js @@ -1,4 +1,3 @@ - /** * @license Apache-2.0 * From 7e90b26e065b8cd8112245e564fb8bce7fec1c8a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 3 Aug 2024 12:10:14 +0530 Subject: [PATCH 16/18] refactor: remove order from base implementation and consequent changes --- .../dptts2/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/lapack/base/dptts2/docs/repl.txt | 20 +- .../lapack/base/dptts2/docs/types/index.d.ts | 7 +- .../lapack/base/dptts2/docs/types/test.ts | 262 ++++++++---------- .../@stdlib/lapack/base/dptts2/lib/base.js | 55 +--- .../@stdlib/lapack/base/dptts2/lib/dptts2.js | 2 +- .../@stdlib/lapack/base/dptts2/lib/index.js | 2 +- .../@stdlib/lapack/base/dptts2/lib/ndarray.js | 14 +- .../lapack/base/dptts2/test/test.ndarray.js | 51 +--- 9 files changed, 156 insertions(+), 259 deletions(-) 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 index c6a1c71466dd..9984161a517f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/benchmark/benchmark.ndarray.js @@ -65,7 +65,7 @@ function createBenchmark( len ) { 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, 1, 0, E, 1, 0, B, len, 1, 0 ); + 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' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt index f6924b80f223..ef2311ca2ee6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt @@ -45,19 +45,8 @@ > {{alias}}( ord, 3, 2, D, E, B, 2 ) [ 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] - // Using typed array views: - > var D0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0, 1.0 ] ); - > var E0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 2.0, 3.0 ] ); - > var B0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); - > E = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); - > B = new Float64Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( ord, 3, 2, D, E, B, 2 ); - > B0 - [ 0.0, 11.0, 38.0, -5.0, -18.0, 2.0, 6.0 ] - -{{alias}}.ndarray( order, N, NRHS, D, sd, od, E, se, oe, B, sb1, sb2, ob ) +{{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. @@ -67,10 +56,6 @@ 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`. @@ -117,8 +102,7 @@ > 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 ] ); - > var ord = 'row-major'; - > {{alias}}.ndarray( ord, 3, 2, D, 1, 1, E, 1, 1, B, 2, 1, 1 ) + > {{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 index bd1f3c42094e..343f055dece0 100644 --- 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 @@ -53,7 +53,6 @@ interface Routine { /** * Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A` using alternative indexing semantics. * - * @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` @@ -75,10 +74,10 @@ interface Routine { * 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 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( order: Layout, 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; + 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; } /** @@ -110,7 +109,7 @@ interface Routine { * 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 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; 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 index 3b58d3ebafe2..d927850ca01a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts @@ -1,3 +1,4 @@ + /* * @license Apache-2.0 * @@ -164,23 +165,23 @@ import dptts2 = require( './index' ); 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectType Float64Array + 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 string... +// 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, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( true, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( false, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( null, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( void 0, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( [], 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( {}, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( ( x: number ): number => x, 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + 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... @@ -189,46 +190,46 @@ import dptts2 = require( './index' ); 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( 'row-major', '5', 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', true, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', false, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', null, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', void 0, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', [], 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', {}, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', ( x: number ): number => x, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + 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 number... +// The compiler throws an error if the function is provided a third argument which is not 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( 'row-major', 3, '5', D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, true, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, false, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, null, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, void 0, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, [], D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, {}, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, ( x: number ): number => x, D, 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, 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 Float64Array... +// 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( 'row-major', 3, 2, '5', 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, 5, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, true, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, false, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, null, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, void 0, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, [], 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, {}, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, ( x: number ): number => x, 1, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + 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... @@ -237,46 +238,46 @@ import dptts2 = require( './index' ); 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( 'row-major', 3, 2, D, '5', 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, true, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, false, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, null, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, void 0, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, [], 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, {}, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, ( x: number ): number => x, 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError + 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 number... +// 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 ] ); const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - dptts2.ndarray( 'row-major', 3, 2, D, 1, '5', E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, true, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, false, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, null, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, void 0, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, [], E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, {}, E, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, ( x: number ): number => x, E, 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, 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 Float64Array... +// 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( 'row-major', 3, 2, D, 1, 0, '5', 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, 5, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, true, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, false, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, null, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, void 0, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, [], 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, {}, 1, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, ( x: number ): number => x, 1, 0, B, 2, 1, 0 ); // $ExpectError + 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... @@ -285,46 +286,46 @@ import dptts2 = require( './index' ); 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( 'row-major', 3, 2, D, 1, 0, E, '5', 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, true, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, false, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, null, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, void 0, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, [], 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, {}, 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, ( x: number ): number => x, 0, B, 2, 1, 0 ); // $ExpectError + 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 number... +// 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 ] ); - const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, '5', B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, true, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, false, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, null, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, void 0, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, [], B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, {}, B, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, ( x: number ): number => x, B, 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, 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 Float64Array... +// 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, '5', 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, 5, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, true, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, false, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, null, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, void 0, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, [], 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, {}, 2, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError + 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... @@ -333,14 +334,14 @@ import dptts2 = require( './index' ); 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, '5', 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, true, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, false, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, null, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, void 0, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, [], 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, {}, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, ( x: number ): number => x, 1, 0 ); // $ExpectError + 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... @@ -349,30 +350,14 @@ import dptts2 = require( './index' ); 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, '5', 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, true, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, false, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, null, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, void 0, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, [], 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, {}, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 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 thirteenth 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, '5' ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, true ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, false ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, null ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, void 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, [] ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, {} ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, ( x: number ): number => x ); // $ExpectError + 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... @@ -382,17 +367,16 @@ import dptts2 = require( './index' ); const B = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); dptts2.ndarray(); // $ExpectError - dptts2.ndarray( 'row-major' ); // $ExpectError - dptts2.ndarray( 'row-major', 3 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1 ); // $ExpectError - dptts2.ndarray( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0, 10 ); // $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/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js index 6ebca6789789..7a00df8098a2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/base.js @@ -16,10 +16,13 @@ * 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' ); @@ -29,7 +32,6 @@ var dscal = require( '@stdlib/blas/base/dscal' ); * Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. * * @private -* @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` @@ -51,67 +53,38 @@ var dscal = require( '@stdlib/blas/base/dscal' ); * 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, 1, 0, E, 1, 0, B, 2, 1, 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( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params - var sb0; - var sb1; +function dptts2( N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ) { var ob; var se; var i; var j; - if ( order === 'row-major' ) { - // For row-major matrices, the last dimension has the fastest changing index... - sb0 = strideB2; // stride for innermost loop - sb1 = strideB1; // stride for outermost loop - } else { // order == 'column-major' - // For column-major matrices, the first dimension has the fastest changing index... - sb0 = strideB1; // stride for innermost loop - sb1 = strideB2; // stride for outermost loop - } - if ( N <= 1 ) { if ( N === 1 ) { - if ( order === 'column-major' ) { - dscal( NRHS, 1.0 / D[ 0 ], B, strideB2 ); + if ( isRowMajor( [ strideB1, strideB2 ] ) ) { + dscal( NRHS, 1.0 / D[ 0 ], B, strideB1 ); return B; } - // order === 'row-major' - dscal( NRHS, 1.0 / D[ 0 ], B, strideB1 ); - } - return B; - } - if ( order === 'column-major' ) { - for ( j = 0; j < NRHS; j++ ) { - ob = offsetB + ( j * sb1 ); - se = 1; - for ( i = 1; i < N; i++ ) { - B[ ob + ( i * sb0 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * sb0 ) ]; // eslint-disable-line max-len - se += strideE; - } - B[ ob + ( ( N - 1 ) * sb0 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; // eslint-disable-line max-len - se = N - 2; - for ( i = N - 2; i >= 0; i-- ) { - B[ ob + ( i * sb0 ) ] = ( B[ ob + ( i * sb0 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1) * sb0 ) ] ); // eslint-disable-line max-len - se -= strideE; - } + // column-major + dscal( NRHS, 1.0 / D[ 0 ], B, strideB2 ); + return B; } return B; } - // order === 'row-major' for ( j = 0; j < NRHS; j++ ) { - ob = offsetB + ( j * sb0 ); + ob = offsetB + ( j * strideB2 ); se = 1; for ( i = 1; i < N; i++ ) { - B[ ob + ( i * sb1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * sb1 ) ]; // eslint-disable-line max-len + B[ ob + ( i * strideB1 ) ] -= E[ offsetE + se - 1 ] * B[ ob + ( ( i - 1 ) * strideB1 ) ]; se += strideE; } - B[ ob + ( ( N - 1 ) * sb1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; + B[ ob + ( ( N - 1 ) * strideB1 ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; se = N - 2; for ( i = N - 2; i >= 0; i-- ) { - B[ ob + ( i * sb1 ) ] = ( B[ ob + ( i * sb1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1 ) * sb1 ) ] ); // eslint-disable-line max-len + B[ ob + ( i * strideB1 ) ] = ( B[ ob + ( i * strideB1 ) ] / D[ offsetD + ( i * strideD ) ] ) - ( E[ offsetE + se ] * B[ ob + ( ( i + 1) * strideB1 ) ] ); se -= strideE; } } diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js index 0f5740bbf7ae..c1a673d0f45d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js @@ -63,7 +63,7 @@ function dptts2( order, N, NRHS, D, E, B, LDB ) { sb1 = LDB; sb2 = 1; } - return base( order, N, NRHS, D, 1, 0, E, 1, 0, B, sb1, sb2, 0 ); + return base( N, NRHS, D, 1, 0, E, 1, 0, B, sb1, sb2, 0 ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js index 7fa59062ce21..d51afd15eaec 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/index.js @@ -43,7 +43,7 @@ * 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 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 ] */ diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js index 4fb3e11ef791..4f978e9842ce 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js @@ -16,12 +16,12 @@ * limitations under the License. */ +/* eslint-disable max-len, max-params */ + 'use strict'; // MODULES // -var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); -var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -30,7 +30,6 @@ var base = require( './base.js' ); /** * Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A` using alternative indexing semantics. * -* @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` @@ -53,14 +52,11 @@ var base = require( './base.js' ); * 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, 1, 0, E, 1, 0, B, 2, 1, 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( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params - if ( !isLayout( order ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); - } - return base( order, N, NRHS, D, strideD, offsetD, E, strideE, offsetE, B, strideB1, strideB2, offsetB ); +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 ); } 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 index 31db7d0505c3..62a2f2b29a43 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js @@ -66,50 +66,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 13', function test( t ) { - t.strictEqual( dptts2.length, 13, 'returns expected value' ); +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( dptts2.length, 12, '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, 1, 0, D, 1, 0, B, 3, 1, 0 ); - }; - } -}); - 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; @@ -122,7 +83,7 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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( 'row-major', 3, 2, D, 1, 3, E, 1, 4, B, 2, 1, 6 ); + 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 ); @@ -141,7 +102,7 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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( 'row-major', 3, 2, D, 2, 3, E, 1, 4, B, 2, 1, 6 ); + 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 ); @@ -160,7 +121,7 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, -2, -1, 5 ); + 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 ); @@ -179,7 +140,7 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, -6, -2, B.length - 1 ); + 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 ); From 5be7b6902858135763bebf2fa50d5020ba03e1e5 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 3 Aug 2024 12:17:22 +0530 Subject: [PATCH 17/18] chore: apply suggestion from code review --- .../@stdlib/lapack/base/dptts2/README.md | 19 +++++++++---------- .../@stdlib/lapack/base/dptts2/docs/repl.txt | 4 ++-- .../lapack/base/dptts2/docs/types/index.d.ts | 6 +++--- .../@stdlib/lapack/base/dptts2/lib/dptts2.js | 2 +- .../@stdlib/lapack/base/dptts2/lib/ndarray.js | 2 +- .../@stdlib/lapack/base/dptts2/package.json | 2 +- .../lapack/base/dptts2/test/test.dptts2.js | 4 ++-- .../lapack/base/dptts2/test/test.ndarray.js | 8 ++++---- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md index 146e29679a5d..0788688b6d88 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/README.md @@ -20,7 +20,7 @@ limitations under the License. # dptts2 -> Solve a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. +> Solve a tridiagonal system of the form `A * X = B` using `L * D * L^T` factorization of `A`.
@@ -32,7 +32,7 @@ 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`. +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' ); @@ -68,17 +68,17 @@ 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 1st element -var E1 = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); // start at 1st element +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( order, N, NRHS, D, sd, od, E, se, oe, B, sb1, sb2, ob ) +#### 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. +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' ); @@ -87,13 +87,12 @@ 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 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: -- **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`. @@ -118,7 +117,7 @@ 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 1 ); +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 ] ``` @@ -150,7 +149,7 @@ 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( 'row-major', 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); +dptts2.ndarray( 3, 2, D, 1, 0, E, 1, 0, B, 2, 1, 0 ); console.log( B ); ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt index ef2311ca2ee6..574264694c40 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( order, N, NRHS, D, E, B, LDB ) - Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` + 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 @@ -47,7 +47,7 @@ {{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` + 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 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 index 343f055dece0..84d26ac057bc 100644 --- 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 @@ -27,7 +27,7 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. + * 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` @@ -51,7 +51,7 @@ interface Routine { ( 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. + * 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` @@ -81,7 +81,7 @@ interface Routine { } /** -* Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. +* 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` diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js index c1a673d0f45d..cb9154f10069 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/dptts2.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Solves a tridiagonal system of the form `A * X = B` using `L * D * L ** T` factorization of `A`. +* 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` diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js index 4f978e9842ce..78af1defa804 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/lib/ndarray.js @@ -28,7 +28,7 @@ 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. +* 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` diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/package.json b/lib/node_modules/@stdlib/lapack/base/dptts2/package.json index 222b83802f22..c0c734609617 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/package.json @@ -1,7 +1,7 @@ { "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`", + "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", 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 index 6b28afa70485..a24276284874 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.dptts2.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.dptts2.js @@ -108,7 +108,7 @@ tape( 'the function throws an error if provided a first argument which is not a } }); -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 ) { +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; @@ -127,7 +127,7 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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 ) { +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; 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 index 62a2f2b29a43..0aca2d073900 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.ndarray.js @@ -71,7 +71,7 @@ tape( 'the function has an arity of 12', function test( t ) { 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 ) { +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; @@ -90,7 +90,7 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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 ) { +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; @@ -109,7 +109,7 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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 ) { +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; @@ -128,7 +128,7 @@ tape( 'the function solves a tridiagonal system of the form `A * X = B` using `L 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 ) { +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; From 74a6898be40701c220d91d888b21a54e91e11e0b Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Sat, 3 Aug 2024 12:21:26 +0530 Subject: [PATCH 18/18] chore: apply suggestions from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts | 1 - lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js | 1 - 2 files changed, 2 deletions(-) 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 index d927850ca01a..f3aac0081ce9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/docs/types/test.ts @@ -1,4 +1,3 @@ - /* * @license Apache-2.0 * diff --git a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js index 0b0c517c2e22..72cb218020b7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dptts2/test/test.js @@ -1,4 +1,3 @@ - /** * @license Apache-2.0 *