From 9b1517c8b62e65885a5f22aa42c4d0051707bb72 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 13 Jul 2024 11:15:02 +0530 Subject: [PATCH 01/18] feat: init lapack/base/dpttrf --- .../@stdlib/lapack/base/dpttrf/README.md | 252 ++++++++++++++++++ .../lapack/base/dpttrf/examples/index.js | 32 +++ .../@stdlib/lapack/base/dpttrf/lib/base.js | 120 +++++++++ .../@stdlib/lapack/base/dpttrf/lib/dpttrf.js | 56 ++++ .../@stdlib/lapack/base/dpttrf/lib/index.js | 60 +++++ .../@stdlib/lapack/base/dpttrf/lib/main.js | 35 +++ .../@stdlib/lapack/base/dpttrf/lib/ndarray.js | 61 +++++ .../@stdlib/lapack/base/dpttrf/package.json | 68 +++++ 8 files changed, 684 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/package.json diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md new file mode 100644 index 000000000000..7d5e91b82a23 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md @@ -0,0 +1,252 @@ + + +# dpttrf + +> Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. + +
+ +## Usage + +```javascript +var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); +``` + +#### dpttrf( N, D, E, info ) + +Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var N = 3; +var info = 0; +var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +var E = new Float64Array( [ 1.0, 2.0 ] ); + +dpttrf( N, D, E, info ); +// D => [ 4, 4.75, ~5.15789 ] +// E => [ 0.25, ~0.4210 ] +``` + +The function has the following parameters: + +- **N**: order of matrix `A`. +- **D**: the N diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. +- **E**: the N-1 subdiagonal elements of `A` as a [`Float64Array`][mdn-float64array]. +- **info**: status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0`. + +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' ); + +var N = 3; +var info = 0; + +// Initial arrays... +var D0 = new Float64Array( [ 0.0, 4.0, 5.0, 6.0 ] ); +var E0 = new Float64Array( [ 0.0, 1.0, 2.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 + +dpttrf( N, D1, E1, info ); +// D0 => [ 0.0, 4.0, 4.75, ~5.15789 ] +// E0 => [ 0.0, 0.25, ~0.4210 ] +``` + +#### dpttrf.ndarray( N, D, strideD, offsetD, E, strideE, offsetE, info ) + +Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var N = 3; +var info = 0; +var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +var E = new Float64Array( [ 1.0, 2.0 ] ); + +dpttrf.ndarray( N, D, 1, 0, E, 1, 0, info ); +// D => [ 4, 4.75, ~5.15789 ] +// E => [ 0.25, ~0.4210 ] +``` + +The function has the following additional parameters: + +- **strideD**: `D` stride length. +- **offsetD**: starting index for `D`. +- **strideE**: `E` stride length. +- **offsetE**: starting index for `E`. + +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 N = 3; +var info = 0; +var D = new Float64Array( [ 0.0, 4.0, 5.0, 6.0 ] ); +var E = new Float64Array( [ 0.0, 1.0, 2.0 ] ); + +dpttrf.ndarray( N, D, 1, 1, E, 1, 1, info ); +// D => [ 0.0, 4.0, 4.75, ~5.15789 ] +// E => [ 0.0, 0.25, ~0.4210 ] +``` + +
+ + + +
+ +## Notes + +- `dpttrf()` corresponds to the [LAPACK][LAPACK] level 1 function [`dpttrf`][dpttrf]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); + +// Specify input data: +var N = 3; +var info = 0; +var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +var E = new Float64Array( [ 1.0, 2.0 ] ); + +// Perform the `L * D * L ** T` factorization: +dpttrf( N, D, E, info ); +console.log( D, E, info ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js new file mode 100644 index 000000000000..859ed9ee22a1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js @@ -0,0 +1,32 @@ +/** +* @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 dpttrf = require( './../lib' ); + +// Specify input data: +var N = 3; +var info = 0; +var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +var E = new Float64Array( [ 1.0, 2.0 ] ); + +// Perform the `L * D * L ** T` factorization: +dpttrf( N, D, E, info ); +console.log( D, E, info ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js new file mode 100644 index 000000000000..fe30643d6bd4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js @@ -0,0 +1,120 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* +* @private +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} D - the N diagonal elements of `A` +* @param {integer} strideD - `D` stride length +* @param {NonNegativeInteger} offsetD - starting index of `D` +* @param {Float64Array} E - the ( N-1 ) subdiagonal elements of `A` +* @param {integer} strideE - `E` stride length +* @param {NonNegativeInteger} offsetE - starting index of `E` +* @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var N = 3; +* var info = 0; +* var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +* var E = new Float64Array( [ 1.0, 2.0 ] ); +* +* dpttrf( N, D, 1, 0, E, 1, 0, info ); +* // D => [ 4, 4.75, ~5.15789 ] +* // E => [ 0.25, ~0.4210 ] +*/ +function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE, info ) { + var i4; + var ei; + var i; + var j; + var k; + + // Quick return if possible + if ( N <= 0 ) { + return 0; + } + // Compute the `L * D * L**T` factorization of `A` + i4 = ( N - 1 ) % 4; + for ( k = 0, i = k, j = k; k < i4; i += strideE, j += strideD, k++ ) { + if ( D[ offsetD + j ] <= 0.0 ) { + info = k; + return info; + } + ei = E[ offsetE + i ]; + E[ offsetE + i ] = ei / D[ offsetD + j ]; + D[ offsetD + j + 1 ] -= E[ offsetE + i ] * ei; + } + for ( k = i4, i = k, j = k; k < N - 4; k += 4, i += 4 * strideE, j += 4 * strideD ) { // eslint-disable-line max-len + // Drop out of loop if `D[ offsetD + j ]` is not positive definite + if ( D[ offsetD + j ] <= 0.0 ) { + info = k; + return info; + } + // Solve for `E[ offsetE + i ]` and `D[ offsetD + j + 1 ]` + ei = E[ offsetE + i ]; + E[ offsetE + i ] = ei / D[ offsetD + j ]; + D[ offsetD + j + 1 ] -= E[ offsetE + i ] * ei; + + if ( D[ offsetD + j + 1 ] <= 0.0 ) { + info = k + 1; + return info; + } + // Solve for `E[ offsetE + i + 1 ]` and `D[ offsetD + j + 2 ]` + ei = E[ offsetE + i + 1 ]; + E[ offsetE + i + 1 ] = ei / D[ offsetD + j + 1 ]; + D[ offsetD + j + 2 ] -= E[ offsetE + i + 1 ] * ei; + + if ( D[ offsetD + j + 2 ] <= 0.0 ) { + info = k + 2; + return info; + } + // Solve for `E[ offsetE + i + 2 ]` and `D[ offsetD + j + 3 ]` + ei = E[ offsetE + i + 2 ]; + E[ offsetE + i + 2 ] = ei / D[ offsetD + j + 2 ]; + D[ offsetD + j + 3 ] -= E[ offsetE + i + 2 ] * ei; + + if ( D[ offsetD + j + 3 ] <= 0.0 ) { + info = k + 3; + return info; + } + // Solve for `E[ offsetE + i + 3 ]` and `D[ offsetD + j + 4 ]` + ei = E[ offsetE + i + 3 ]; + E[ offsetE + i + 3 ] = ei / D[ offsetD + j + 3 ]; + D[ offsetD + j + 4 ] -= E[ offsetE + i + 3 ] * ei; + } + // Check `D[ N - 1 ]` for positive definiteness + if ( D[ offsetD + N - 1 ] <= 0.0 ) { + info = N - 1; + return info; + } + return info; +} + + +// EXPORTS // + +module.exports = dpttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js new file mode 100644 index 000000000000..60a3bf490655 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js @@ -0,0 +1,56 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} D - the N diagonal elements of `A` +* @param {Float64Array} E - the ( N-1 ) subdiagonal elements of `A` +* @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var N = 3; +* var info = 0; +* var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +* var E = new Float64Array( [ 1.0, 2.0 ] ); +* +* dpttrf( N, D, E, info ); +* // D => [ 4, 4.75, ~5.15789 ] +* // E => [ 0.25, ~0.4210 ] +*/ +function dpttrf( N, D, E, info ) { + return base( N, D, 1, 0, E, 1, 0, info ); +} + + +// EXPORTS // + +module.exports = dpttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js new file mode 100644 index 000000000000..51972f8b40e8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* +* @module @stdlib/lapack/base/dpttrf +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); +* +* var N = 3; +* var info = 0; +* var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +* var E = new Float64Array( [ 1.0, 2.0 ] ); +* +* dpttrf( N, D, E, info ); +* // returns 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 dpttrf; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dpttrf = main; +} else { + dpttrf = tmp; +} + + +// EXPORTS // + +module.exports = dpttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/main.js new file mode 100644 index 000000000000..379eea00a54e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/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 dpttrf = require( './dpttrf.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dpttrf, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dpttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js new file mode 100644 index 000000000000..3097fad24767 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js @@ -0,0 +1,61 @@ +/** +* @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 base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. +* +* @private +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} D - the N diagonal elements of `A` +* @param {integer} strideD - `D` stride length +* @param {NonNegativeInteger} offsetD - starting index of `D` +* @param {Float64Array} E - the ( N-1 ) subdiagonal elements of `A` +* @param {integer} strideE - `E` stride length +* @param {NonNegativeInteger} offsetE - starting index of `E` +* @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var N = 3; +* var info = 0; +* var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +* var E = new Float64Array( [ 1.0, 2.0 ] ); +* +* dpttrf( N, D, 1, 0, E, 1, 0, info ); +* // D => [ 4, 4.75, ~5.15789 ] +* // E => [ 0.25, ~0.4210 ] +*/ +function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE, info ) { + return base( N, D, strideD, offsetD, E, strideE, offsetE, info ); +} + + +// EXPORTS // + +module.exports = dpttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json b/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json new file mode 100644 index 000000000000..96fdf9dc59dd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/lapack/base/dpttrf", + "version": "0.0.0", + "description": "Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `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", + "dpttrf", + "cholesky", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} From 32d82a6540251602934e3560449ff484d7d20b44 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 13 Jul 2024 11:24:39 +0530 Subject: [PATCH 02/18] docs: add repl.txt --- .../@stdlib/lapack/base/dpttrf/docs/repl.txt | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt new file mode 100644 index 000000000000..1f21eaadfeb5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt @@ -0,0 +1,108 @@ + +{{alias}}( N, D, E, info ) + Computes the `L * D * L ** T` factorization of real symmetric positive + definite tridiagonal matrix `A`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + + N: integer + Order of matrix `A`. + + D: Float64Array + Diagonal elements of `A`. + + E: Float64Array + Subdiagonal elements of `A`. + + info: integer + Status code. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var N = 3; + > var info = 0; + > var D = new {{alias:@stdlib/array/float64}}( [ 4.0, 5.0, 6.0 ] ); + > var E = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); + > {{alias}}( N, D, E, info ) + 0 + > D + [ 4, 4.75, ~5.15789 ] + > E + [ 0.25, ~0.42105 ] + + // Using typed array views: + > var D0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 4.0, 5.0, 6.0 ] ); + > var E0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0 ] ); + > D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); + > E = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( N, D, E, info ) + 0 + > D0 + [ 0.0, 4.0, 4.75, ~5.15789 ] + > E0 + [ 0.0, 0.25, ~0.42105 ] + + +{{alias}}.ndarray( N, D, strideD, offsetD, E, strideE, offsetE, info ) + Computes the `L * D * L ** T` factorization of real symmetric positive + definite tridiagonal matrix `A` using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Order of matrix `A`. + + D: Float64Array + Diagonal elements of `A`. + + strideD: integer + Stride length for `D`. + + offsetD: integer + Starting index for `D`. + + E: Float64Array + Subdiagonal elements of `A`. + + strideE: integer + Stride length for `E`. + + offsetE: integer + Starting index for `E`. + + info: integer + Status code. + + Returns + ------- + info: integer + Status code. + + Examples + -------- + > var N = 3; + > var info = 0; + > var D = new {{alias:@stdlib/array/float64}}( [ 0.0, 4.0, 5.0, 6.0 ] ); + > var E = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0 ] ); + > {{alias}}.ndarray( N, D, 1, 1, E, 1, 1, info ) + 0 + > D + [ 0.0, 4.0, 4.75, ~5.15789 ] + > E + [ 0.0, 0.25, ~0.42105 ] + + See Also + -------- From 07589d5b11bfc8395447d0d36d309121a921926c Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 13 Jul 2024 11:25:08 +0530 Subject: [PATCH 03/18] fix: incorrect description for strideXY parameters --- lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js | 4 ++-- lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js index fe30643d6bd4..d306d53bdd67 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js @@ -26,10 +26,10 @@ * @private * @param {NonNegativeInteger} N - order of matrix `A` * @param {Float64Array} D - the N diagonal elements of `A` -* @param {integer} strideD - `D` stride length +* @param {integer} strideD - stride length for `D` * @param {NonNegativeInteger} offsetD - starting index of `D` * @param {Float64Array} E - the ( N-1 ) subdiagonal elements of `A` -* @param {integer} strideE - `E` stride length +* @param {integer} strideE - stride length for `E` * @param {NonNegativeInteger} offsetE - starting index of `E` * @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns {integer} status code diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js index 3097fad24767..f348c750a2d0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js @@ -31,10 +31,10 @@ var base = require( './base.js' ); * @private * @param {NonNegativeInteger} N - order of matrix `A` * @param {Float64Array} D - the N diagonal elements of `A` -* @param {integer} strideD - `D` stride length +* @param {integer} strideD - stride length for `D` * @param {NonNegativeInteger} offsetD - starting index of `D` * @param {Float64Array} E - the ( N-1 ) subdiagonal elements of `A` -* @param {integer} strideE - `E` stride length +* @param {integer} strideE - stride length for `E` * @param {NonNegativeInteger} offsetE - starting index of `E` * @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns {integer} status code From 009c5f7f089fc989a87b3ed21c8a16b6a0b9f8aa Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 13 Jul 2024 11:34:02 +0530 Subject: [PATCH 04/18] docs: add types --- .../lapack/base/dpttrf/docs/types/index.d.ts | 116 ++++++++ .../lapack/base/dpttrf/docs/types/test.ts | 260 ++++++++++++++++++ 2 files changed, 376 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts new file mode 100644 index 000000000000..8ce248b6cbf4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts @@ -0,0 +1,116 @@ +/** +* @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 + +/// + +/** +* Interface describing `dpttrf`. +*/ +interface Routine { + /** + * Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. + * + * @param N - order of matrix `A` + * @param D - the N diagonal elements of `A` + * @param E - the ( N-1 ) subdiagonal elements of `A` + * @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var N = 3; + * var info = 0; + * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); + * var E = new Float64Array( [ 1.0, 2.0 ] ); + * + * dpttrf( N, D, E, info ); + * // D => [ 4, 4.75, ~5.15789 ] + * // E => [ 0.25, ~0.4210 ] + */ + ( N: number, D: Float64Array, E: Float64Array, info: number ): number; + + /** + * Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. + * + * @param N - order of matrix `A` + * @param D - the N diagonal elements of `A` + * @param strideD - stride length for `D` + * @param offsetD - starting index of `D` + * @param E - the ( N-1 ) subdiagonal elements of `A` + * @param strideE - stride length for `E` + * @param offsetE - starting index of `E` + * @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var N = 3; + * var info = 0; + * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); + * var E = new Float64Array( [ 1.0, 2.0 ] ); + * + * dpttrf.ndarray( N, D, 1, 0, E, 1, 0, info ); + * // D => [ 4, 4.75, ~5.15789 ] + * // E => [ 0.25, ~0.4210 ] + */ + ndarray( N: number, D: Float64Array, strideD: number, offsetD: number, E: Float64Array, strideE: number, offsetE: number, info: number ): number; +} + +/** +* Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* +* @param N - order of matrix `A` +* @param D - the N diagonal elements of `A` +* @param E - the ( N-1 ) subdiagonal elements of `A` +* @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var N = 3; +* var info = 0; +* var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +* var E = new Float64Array( [ 1.0, 2.0 ] ); +* +* dpttrf( N, D, E, info ); +* // D => [ 4, 4.75, ~5.15789 ] +* // E => [ 0.25, ~0.4210 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var N = 3; +* var info = 0; +* var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +* var E = new Float64Array( [ 1.0, 2.0 ] ); +* +* dpttrf.ndarray( N, D, 1, 0, E, 1, 0, info ); +* // D => [ 4, 4.75, ~5.15789 ] +* // E => [ 0.25, ~0.4210 ] +*/ +declare var dpttrf: Routine; + + +// EXPORTS // + +export = dpttrf; diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/test.ts new file mode 100644 index 000000000000..c833805b06b0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/test.ts @@ -0,0 +1,260 @@ +/** +* @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 dpttrf = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf( 3, D, E, info ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf( '5', D, E, info ); // $ExpectError + dpttrf( true, D, E, info ); // $ExpectError + dpttrf( false, D, E, info ); // $ExpectError + dpttrf( null, D, E, info ); // $ExpectError + dpttrf( void 0, D, E, info ); // $ExpectError + dpttrf( [], D, E, info ); // $ExpectError + dpttrf( {}, D, E, info ); // $ExpectError + dpttrf( ( x: number ): number => x, D, E, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const info = 0; + const E = new Float64Array( 2 ); + + dpttrf( 3, '5', E, info ); // $ExpectError + dpttrf( 3, 5, E, info ); // $ExpectError + dpttrf( 3, true, E, info ); // $ExpectError + dpttrf( 3, false, E, info ); // $ExpectError + dpttrf( 3, null, E, info ); // $ExpectError + dpttrf( 3, void 0, E, info ); // $ExpectError + dpttrf( 3, [], E, info ); // $ExpectError + dpttrf( 3, {}, E, info ); // $ExpectError + dpttrf( 3, ( x: number ): number => x, E, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const info = 0; + const D = new Float64Array( 3 ); + + dpttrf( 3, D, '5', info ); // $ExpectError + dpttrf( 3, D, 5, info ); // $ExpectError + dpttrf( 3, D, true, info ); // $ExpectError + dpttrf( 3, D, false, info ); // $ExpectError + dpttrf( 3, D, null, info ); // $ExpectError + dpttrf( 3, D, void 0, info ); // $ExpectError + dpttrf( 3, D, [], info ); // $ExpectError + dpttrf( 3, D, {}, info ); // $ExpectError + dpttrf( 3, D, ( x: number ): number => x, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf( 3, D, E, '5' ); // $ExpectError + dpttrf( 3, D, E, true ); // $ExpectError + dpttrf( 3, D, E, false ); // $ExpectError + dpttrf( 3, D, E, null ); // $ExpectError + dpttrf( 3, D, E, void 0 ); // $ExpectError + dpttrf( 3, D, E, [] ); // $ExpectError + dpttrf( 3, D, E, {} ); // $ExpectError + dpttrf( 3, D, E, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf(); // $ExpectError + dpttrf( 3 ); // $ExpectError + dpttrf( 3, D ); // $ExpectError + dpttrf( 3, D, E ); // $ExpectError + dpttrf( 3, D, E, info, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, info ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf.ndarray( '5', D, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( true, D, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( false, D, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( null, D, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( void 0, D, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( [], D, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( {}, D, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( ( x: number ): number => x, D, 1, 0, E, 1, 0, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const info = 0; + const E = new Float64Array( 2 ); + + dpttrf.ndarray( 3, '5', 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, 5, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, true, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, false, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, null, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, void 0, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, [], 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, {}, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, ( x: number ): number => x, 1, 0, E, 1, 0, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf.ndarray( 3, D, '5', 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, true, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, false, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, null, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, void 0, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, [], 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, {}, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, ( x: number ): number => x, 0, E, 1, 0, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf.ndarray( 3, D, 1, '5', E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, true, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, false, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, null, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, void 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, [], E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, {}, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, ( x: number ): number => x, E, 1, 0, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const info = 0; + const D = new Float64Array( 3 ); + + dpttrf.ndarray( 3, D, 1, 0, '5', 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, 5, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, true, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, false, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, null, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, void 0, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, [], 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, {}, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, ( x: number ): number => x, 1, 0, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf.ndarray( 3, D, 1, 0, E, '5', 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, true, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, false, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, null, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, void 0, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, [], 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, {}, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, ( x: number ): number => x, 0, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf.ndarray( 3, D, 1, 0, E, 1, '5', info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, true, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, false, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, null, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, void 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, [], info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, {}, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, ( x: number ): number => x, info ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, '5' ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, true ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, false ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, null ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, void 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, [] ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, {} ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const info = 0; + const D = new Float64Array( 3 ); + const E = new Float64Array( 2 ); + + dpttrf.ndarray(); // $ExpectError + dpttrf.ndarray( 3 ); // $ExpectError + dpttrf.ndarray( 3, D ); // $ExpectError + dpttrf.ndarray( 3, D, 1 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, info, 10 ); // $ExpectError +} From 79772e25dfe1f2fa4bda46ec7df0a0e026ccbfa1 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 13 Jul 2024 11:41:09 +0530 Subject: [PATCH 05/18] bench: add benchmark --- .../lapack/base/dpttrf/benchmark/benchmark.js | 98 +++++++++++++++++++ .../dpttrf/benchmark/benchmark.ndarray.js | 98 +++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.js new file mode 100644 index 000000000000..d0cceb4af0ef --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.js @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2019 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 pkg = require( './../package.json' ).name; +var dpttrf = require( './../lib/dpttrf.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 info; + var D = uniform( len, 0.0, 100.0, options ); + var E= uniform( len, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dpttrf( len, D, E, info ); + if ( isnan( d ) || isnan( D[ i%D.length ] || isnan( E[ i%E.length ] ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) || isnan( D[ i%D.length ] || isnan( E[ i%E.length ] ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..604c7c443191 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.ndarray.js @@ -0,0 +1,98 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2019 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 pkg = require( './../package.json' ).name; +var dpttrf = 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 info; + var D = uniform( len, 0.0, 100.0, options ); + var E= uniform( len, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dpttrf( len, D, 1, 0, E, 1, 0, info ); + if ( isnan( d ) || isnan( D[ i%D.length ] || isnan( E[ i%E.length ] ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) || isnan( D[ i%D.length ] || isnan( E[ i%E.length ] ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':ndarray:len='+len, f ); + } +} + +main(); From b516805938ecd70ee1b3157ba9fadac04609ae4f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 13 Jul 2024 11:52:38 +0530 Subject: [PATCH 06/18] test: add tests --- .../lapack/base/dpttrf/test/test.dpttrf.js | 122 +++++++++++++++ .../@stdlib/lapack/base/dpttrf/test/test.js | 82 ++++++++++ .../lapack/base/dpttrf/test/test.ndarray.js | 147 ++++++++++++++++++ 3 files changed, 351 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js new file mode 100644 index 000000000000..47f7955bf69e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js @@ -0,0 +1,122 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dpttrf = require( './../lib/dpttrf.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 dpttrf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 4', function test( t ) { + t.strictEqual( dpttrf.length, 4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 3; + info = 0; + + D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + expectedD = new Float64Array( [ 4.0, 4.75, 5.157894736842105 ] ); + expectedE = new Float64Array( [ 0.25, 0.42105263157894735 ] ); + + info = dpttrf( N, D, E, info ); + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, D, expectedD, 2.0 ); + isApprox( t, E, expectedE, 2.0 ); + + t.end(); +}); + +tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 7; + info = 0; + + D = new Float64Array( [ 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + E = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] ); + + expectedD = new Float64Array( [ 4.0, 4.75, 5.157894736842105, 5.255102040816327, 4.955339805825243, 3.954937304075235, 0.89745368076885157 ] ); + expectedE = new Float64Array( [ 0.25, 0.42105263157894735, 0.58163265306122447, 0.76116504854368927, 1.0090125391849529, 1.5170910532051916 ] ); + + info = dpttrf( N, D, E, info ); + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, D, expectedD, 2.0 ); + isApprox( t, E, expectedE, 2.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.js new file mode 100644 index 000000000000..3c86332ae22d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dpttrf = 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 dpttrf, '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 dpttrf.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 dpttrf = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dpttrf, 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 dpttrf; + var main; + + main = require( './../lib/dpttrf.js' ); + + dpttrf = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dpttrf, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js new file mode 100644 index 000000000000..1b05ccb5cabb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js @@ -0,0 +1,147 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dpttrf = 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 dpttrf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dpttrf.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 3; + info = 0; + + D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + expectedD = new Float64Array( [ 4.0, 4.75, 5.157894736842105 ] ); + expectedE = new Float64Array( [ 0.25, 0.42105263157894735 ] ); + + info = dpttrf( N, D, 1, 0, E, 1, 0, info ); + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, D, expectedD, 2.0 ); + isApprox( t, E, expectedE, 2.0 ); + + t.end(); +}); + +tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 7; + info = 0; + + D = new Float64Array( [ 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + E = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] ); + + expectedD = new Float64Array( [ 4.0, 4.75, 5.157894736842105, 5.255102040816327, 4.955339805825243, 3.954937304075235, 0.89745368076885157 ] ); + expectedE = new Float64Array( [ 0.25, 0.42105263157894735, 0.58163265306122447, 0.76116504854368927, 1.0090125391849529, 1.5170910532051916 ] ); + + info = dpttrf( N, D, 1, 0, E, 1, 0, info ); + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, D, expectedD, 2.0 ); + isApprox( t, E, expectedE, 2.0 ); + + t.end(); +}); + +tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 2, offsetE = 3 )', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 3; + info = 0; + + D = new Float64Array( [ 0.0, 0.0, 4.0, 5.0, 6.0 ] ); + E = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 2.0 ] ); + + expectedD = new Float64Array( [ 0.0, 0.0, 4.0, 4.75, 5.157894736842105 ] ); + expectedE = new Float64Array( [ 0.0, 0.0, 0.0, 0.25, 0.42105263157894735 ] ); + + info = dpttrf( N, D, 1, 2, E, 1, 3, info ); + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, D, expectedD, 2.0 ); + isApprox( t, E, expectedE, 2.0 ); + + t.end(); +}); From 0589c69691a6703f35193f392a0da97633fedb98 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 13 Jul 2024 12:37:45 +0530 Subject: [PATCH 07/18] chore: wip --- .../@stdlib/lapack/base/dpttrf/README.md | 4 +- .../@stdlib/lapack/base/dpttrf/a.f | 122 ++++++++++++++++++ .../lapack/base/dpttrf/test/test.ndarray.js | 23 ++++ 3 files changed, 147 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/a.f diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md index 7d5e91b82a23..2f6b11176aa3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md @@ -96,9 +96,9 @@ dpttrf.ndarray( N, D, 1, 0, E, 1, 0, info ); The function has the following additional parameters: -- **strideD**: `D` stride length. +- **strideD**: stride length for `D`. - **offsetD**: starting index for `D`. -- **strideE**: `E` stride length. +- **strideE**: stride length for `E`. - **offsetE**: starting index for `E`. 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, diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/a.f b/lib/node_modules/@stdlib/lapack/base/dpttrf/a.f new file mode 100644 index 000000000000..5d2fb1098643 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/a.f @@ -0,0 +1,122 @@ + SUBROUTINE DPTTRF(N, D, E, INFO) +* +* -- LAPACK computational routine -- +* -- LAPACK is a software package provided by Univ. of Tennessee, -- +* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- +* +* .. Scalar Arguments .. + INTEGER INFO, N +* .. +* .. Array Arguments .. + DOUBLE PRECISION D( * ), E( * ) +* .. +* +* ===================================================================== +* +* .. Parameters .. + DOUBLE PRECISION ZERO + parameter( zero = 0.0d+0 ) +* .. +* .. Local Scalars .. + INTEGER I, I4 + DOUBLE PRECISION EI +* .. +* .. Intrinsic Functions .. + INTRINSIC mod +* .. +* .. Executable Statements .. +* +* Test the input parameters. +* + info = 0 +* +* Quick return if possible +* + IF( n.EQ.0 ) + $ RETURN +* +* Compute the L*D*L**T (or U**T*D*U) factorization of A. +* + i4 = mod( n-1, 4 ) + DO 10 i = 1, i4 + IF( d( i ).LE.zero ) THEN + info = i + GO TO 30 + END IF + ei = e( i ) + e( i ) = ei / d( i ) + d( i+1 ) = d( i+1 ) - e( i )*ei + 10 CONTINUE +* + DO 20 i = i4 + 1, n - 4, 4 +* +* Drop out of the loop if d(i) <= 0: the matrix is not positive +* definite. +* + IF( d( i ).LE.zero ) THEN + info = i + GO TO 30 + END IF +* +* Solve for e(i) and d(i+1). +* + ei = e( i ) + e( i ) = ei / d( i ) + d( i+1 ) = d( i+1 ) - e( i )*ei +* + IF( d( i+1 ).LE.zero ) THEN + info = i + 1 + GO TO 30 + END IF +* +* Solve for e(i+1) and d(i+2). +* + ei = e( i+1 ) + e( i+1 ) = ei / d( i+1 ) + d( i+2 ) = d( i+2 ) - e( i+1 )*ei +* + IF( d( i+2 ).LE.zero ) THEN + info = i + 2 + GO TO 30 + END IF +* +* Solve for e(i+2) and d(i+3). +* + ei = e( i+2 ) + e( i+2 ) = ei / d( i+2 ) + d( i+3 ) = d( i+3 ) - e( i+2 )*ei +* + IF( d( i+3 ).LE.zero ) THEN + info = i + 3 + GO TO 30 + END IF +* +* Solve for e(i+3) and d(i+4). +* + ei = e( i+3 ) + e( i+3 ) = ei / d( i+3 ) + d( i+4 ) = d( i+4 ) - e( i+3 )*ei + 20 CONTINUE +* +* Check d(n) for positive definiteness. +* + IF( d( n ).LE.zero ) + $ info = n +* + 30 CONTINUE + RETURN +* +* End of DPTTRF +* + END SUBROUTINE + + PROGRAM MAIN + INTEGER :: N = 7, INFO + DOUBLE PRECISION :: D(7), E(6) + D = [4, 5, 6, 7, 8, 9, 10] + E = [1, 2, 3, 4, 5, 6] + CALL DPTTRF(N, D, E, INFO) + print *, "D: ", D + print *, "E: ", E + print *, "INFO: ", INFO + END PROGRAM \ No newline at end of file diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js index 1b05ccb5cabb..120b336bb164 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js @@ -145,3 +145,26 @@ tape( 'the function computes the `L * D * L ** T` factorization of real symmetri t.end(); }); + +/** + * [ [1. 2. 3.] + * [2. 2. 3.] + * [3. 2. 3.] + * [4. 2. 3.]] + * + * + */ + + + // +A = [ 1, 1, 1, 1, 1 ], + [ 1, 1, 1, 2, 1 ], + [ 1, 1, 1, 1, 1 ], + [ 1, 0, 1, 3, 1 ], + [ 1, 1, 1, 1, 1 ] +// +x = [ 1, 1 ] +A = [ 1, 2 ], + [ 0, 1 ] +x = A * x +// x = [ 3, 1 ] From c9749fe3844fa6b5d78fa03a8c3734c2a2aa6fc7 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 22 Jul 2024 19:58:10 +0530 Subject: [PATCH 08/18] refactor: base implementation --- .../@stdlib/lapack/base/dpttrf/lib/base.js | 62 +++++-------------- 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js index d306d53bdd67..0266a6ecc225 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js @@ -47,68 +47,34 @@ * // E => [ 0.25, ~0.4210 ] */ function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE, info ) { - var i4; var ei; + var sd; + var se; var i; - var j; - var k; // Quick return if possible if ( N <= 0 ) { return 0; } // Compute the `L * D * L**T` factorization of `A` - i4 = ( N - 1 ) % 4; - for ( k = 0, i = k, j = k; k < i4; i += strideE, j += strideD, k++ ) { - if ( D[ offsetD + j ] <= 0.0 ) { - info = k; - return info; - } - ei = E[ offsetE + i ]; - E[ offsetE + i ] = ei / D[ offsetD + j ]; - D[ offsetD + j + 1 ] -= E[ offsetE + i ] * ei; - } - for ( k = i4, i = k, j = k; k < N - 4; k += 4, i += 4 * strideE, j += 4 * strideD ) { // eslint-disable-line max-len + se = 0; + sd = 0; + for ( i = 0; i < N - 1; i++ ) { // Drop out of loop if `D[ offsetD + j ]` is not positive definite - if ( D[ offsetD + j ] <= 0.0 ) { - info = k; - return info; - } - // Solve for `E[ offsetE + i ]` and `D[ offsetD + j + 1 ]` - ei = E[ offsetE + i ]; - E[ offsetE + i ] = ei / D[ offsetD + j ]; - D[ offsetD + j + 1 ] -= E[ offsetE + i ] * ei; - - if ( D[ offsetD + j + 1 ] <= 0.0 ) { - info = k + 1; + if ( D[ offsetD + sd ] <= 0.0 ) { + info = offsetD + sd; return info; } - // Solve for `E[ offsetE + i + 1 ]` and `D[ offsetD + j + 2 ]` - ei = E[ offsetE + i + 1 ]; - E[ offsetE + i + 1 ] = ei / D[ offsetD + j + 1 ]; - D[ offsetD + j + 2 ] -= E[ offsetE + i + 1 ] * ei; - if ( D[ offsetD + j + 2 ] <= 0.0 ) { - info = k + 2; - return info; - } - // Solve for `E[ offsetE + i + 2 ]` and `D[ offsetD + j + 3 ]` - ei = E[ offsetE + i + 2 ]; - E[ offsetE + i + 2 ] = ei / D[ offsetD + j + 2 ]; - D[ offsetD + j + 3 ] -= E[ offsetE + i + 2 ] * ei; - - if ( D[ offsetD + j + 3 ] <= 0.0 ) { - info = k + 3; - return info; - } - // Solve for `E[ offsetE + i + 3 ]` and `D[ offsetD + j + 4 ]` - ei = E[ offsetE + i + 3 ]; - E[ offsetE + i + 3 ] = ei / D[ offsetD + j + 3 ]; - D[ offsetD + j + 4 ] -= E[ offsetE + i + 3 ] * ei; + ei = E[ offsetE + se ]; + E[ offsetE + se ] = ei / D[ offsetD + sd ]; + D[ offsetD + sd + strideD ] -= E[ offsetE + se ] * ei; + se += strideE; + sd += strideD; } // Check `D[ N - 1 ]` for positive definiteness - if ( D[ offsetD + N - 1 ] <= 0.0 ) { - info = N - 1; + if ( D[ offsetD + ( ( N - 1 ) * strideD ) ] <= 0.0 ) { + info = ( N - 1 ) * sd; return info; } return info; From cd8b0aa037415e84bfca844ff01dfe1045867f97 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 22 Jul 2024 19:58:29 +0530 Subject: [PATCH 09/18] test: add tests for negative strides in dpttrf --- .../lapack/base/dpttrf/test/test.ndarray.js | 96 ++++++++++++++----- 1 file changed, 74 insertions(+), 22 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js index 120b336bb164..32bb8309f25f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js @@ -146,25 +146,77 @@ tape( 'the function computes the `L * D * L ** T` factorization of real symmetri t.end(); }); -/** - * [ [1. 2. 3.] - * [2. 2. 3.] - * [3. 2. 3.] - * [4. 2. 3.]] - * - * - */ - - - // -A = [ 1, 1, 1, 1, 1 ], - [ 1, 1, 1, 2, 1 ], - [ 1, 1, 1, 1, 1 ], - [ 1, 0, 1, 3, 1 ], - [ 1, 1, 1, 1, 1 ] -// -x = [ 1, 1 ] -A = [ 1, 2 ], - [ 0, 1 ] -x = A * x -// x = [ 3, 1 ] +tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 2, offsetE = 3, strideD = 3, strideE = 2 )', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 3; + info = 0; + + D = new Float64Array( [ 0.0, 0.0, 4.0, 0.0, 0.0, 5.0, 0.0, 0.0, 6.0 ] ); + E = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 2.0 ] ); + + expectedD = new Float64Array( [ 0.0, 0.0, 4.0, 0.0, 0.0, 4.75, 0.0, 0.0, 5.157894736842105 ] ); + expectedE = new Float64Array( [ 0.0, 0.0, 0.0, 0.25, 0.0, 0.42105263157894735 ] ); + + info = dpttrf( N, D, 3, 2, E, 2, 3, info ); + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, D, expectedD, 2.0 ); + isApprox( t, E, expectedE, 2.0 ); + + t.end(); +}); + +tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 6, offsetE = 3, strideD = -3, strideE = 2 )', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 3; + info = 0; + + D = new Float64Array( [ 6.0, 0.0, 0.0, 5.0, 0.0, 0.0, 4.0 ] ); + E = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 2.0 ] ); + + expectedD = new Float64Array( [ 5.157894736842105, 0.0, 0.0, 4.75, 0.0, 0.0, 4.0 ] ); + expectedE = new Float64Array( [ 0.0, 0.0, 0.0, 0.25, 0.0, 0.42105263157894735 ] ); + + info = dpttrf( N, D, -3, 6, E, 2, 3, info ); + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, D, expectedD, 2.0 ); + isApprox( t, E, expectedE, 2.0 ); + + t.end(); +}); + +tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 6, offsetE = 5, strideD = -3, strideE = -2 )', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 3; + info = 0; + + D = new Float64Array( [ 6.0, 0.0, 0.0, 5.0, 0.0, 0.0, 4.0 ] ); + E = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 1.0 ] ); + + expectedD = new Float64Array( [ 5.157894736842105, 0.0, 0.0, 4.75, 0.0, 0.0, 4.0 ] ); + expectedE = new Float64Array( [ 0.0, 0.0, 0.0, 0.42105263157894735, 0.0, 0.25 ] ); + + info = dpttrf( N, D, -3, 6, E, -2, 5, info ); + t.strictEqual( info, 0, 'returns expected value' ); + isApprox( t, D, expectedD, 2.0 ); + isApprox( t, E, expectedE, 2.0 ); + + t.end(); +}); From 6272c24f2dfa5fdd592887a484c2e29f92a1a7b3 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 22 Jul 2024 20:03:17 +0530 Subject: [PATCH 10/18] chore: apply code review --- .../@stdlib/lapack/base/dpttrf/README.md | 10 +- .../@stdlib/lapack/base/dpttrf/a.f | 122 ------------------ .../@stdlib/lapack/base/dpttrf/docs/repl.txt | 4 +- .../lapack/base/dpttrf/docs/types/index.d.ts | 18 +-- .../lapack/base/dpttrf/examples/index.js | 2 +- .../@stdlib/lapack/base/dpttrf/lib/base.js | 10 +- .../@stdlib/lapack/base/dpttrf/lib/dpttrf.js | 6 +- .../@stdlib/lapack/base/dpttrf/lib/index.js | 2 +- .../@stdlib/lapack/base/dpttrf/lib/ndarray.js | 6 +- .../@stdlib/lapack/base/dpttrf/package.json | 2 +- .../lapack/base/dpttrf/test/test.dpttrf.js | 4 +- .../lapack/base/dpttrf/test/test.ndarray.js | 12 +- 12 files changed, 38 insertions(+), 160 deletions(-) delete mode 100644 lib/node_modules/@stdlib/lapack/base/dpttrf/a.f diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md index 2f6b11176aa3..6531da48a566 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md @@ -20,7 +20,7 @@ limitations under the License. # dpttrf -> Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +> Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`.
@@ -32,7 +32,7 @@ var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); #### dpttrf( N, D, E, info ) -Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -50,7 +50,7 @@ dpttrf( N, D, E, info ); The function has the following parameters: - **N**: order of matrix `A`. -- **D**: the N diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. +- **D**: the `N` diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. - **E**: the N-1 subdiagonal elements of `A` as a [`Float64Array`][mdn-float64array]. - **info**: status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0`. @@ -79,7 +79,7 @@ dpttrf( N, D1, E1, info ); #### dpttrf.ndarray( N, D, strideD, offsetD, E, strideE, offsetE, info ) -Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. +Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -148,7 +148,7 @@ var info = 0; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); -// Perform the `L * D * L ** T` factorization: +// Perform the `L * D * L^T` factorization: dpttrf( N, D, E, info ); console.log( D, E, info ); ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/a.f b/lib/node_modules/@stdlib/lapack/base/dpttrf/a.f deleted file mode 100644 index 5d2fb1098643..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/a.f +++ /dev/null @@ -1,122 +0,0 @@ - SUBROUTINE DPTTRF(N, D, E, INFO) -* -* -- LAPACK computational routine -- -* -- LAPACK is a software package provided by Univ. of Tennessee, -- -* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- -* -* .. Scalar Arguments .. - INTEGER INFO, N -* .. -* .. Array Arguments .. - DOUBLE PRECISION D( * ), E( * ) -* .. -* -* ===================================================================== -* -* .. Parameters .. - DOUBLE PRECISION ZERO - parameter( zero = 0.0d+0 ) -* .. -* .. Local Scalars .. - INTEGER I, I4 - DOUBLE PRECISION EI -* .. -* .. Intrinsic Functions .. - INTRINSIC mod -* .. -* .. Executable Statements .. -* -* Test the input parameters. -* - info = 0 -* -* Quick return if possible -* - IF( n.EQ.0 ) - $ RETURN -* -* Compute the L*D*L**T (or U**T*D*U) factorization of A. -* - i4 = mod( n-1, 4 ) - DO 10 i = 1, i4 - IF( d( i ).LE.zero ) THEN - info = i - GO TO 30 - END IF - ei = e( i ) - e( i ) = ei / d( i ) - d( i+1 ) = d( i+1 ) - e( i )*ei - 10 CONTINUE -* - DO 20 i = i4 + 1, n - 4, 4 -* -* Drop out of the loop if d(i) <= 0: the matrix is not positive -* definite. -* - IF( d( i ).LE.zero ) THEN - info = i - GO TO 30 - END IF -* -* Solve for e(i) and d(i+1). -* - ei = e( i ) - e( i ) = ei / d( i ) - d( i+1 ) = d( i+1 ) - e( i )*ei -* - IF( d( i+1 ).LE.zero ) THEN - info = i + 1 - GO TO 30 - END IF -* -* Solve for e(i+1) and d(i+2). -* - ei = e( i+1 ) - e( i+1 ) = ei / d( i+1 ) - d( i+2 ) = d( i+2 ) - e( i+1 )*ei -* - IF( d( i+2 ).LE.zero ) THEN - info = i + 2 - GO TO 30 - END IF -* -* Solve for e(i+2) and d(i+3). -* - ei = e( i+2 ) - e( i+2 ) = ei / d( i+2 ) - d( i+3 ) = d( i+3 ) - e( i+2 )*ei -* - IF( d( i+3 ).LE.zero ) THEN - info = i + 3 - GO TO 30 - END IF -* -* Solve for e(i+3) and d(i+4). -* - ei = e( i+3 ) - e( i+3 ) = ei / d( i+3 ) - d( i+4 ) = d( i+4 ) - e( i+3 )*ei - 20 CONTINUE -* -* Check d(n) for positive definiteness. -* - IF( d( n ).LE.zero ) - $ info = n -* - 30 CONTINUE - RETURN -* -* End of DPTTRF -* - END SUBROUTINE - - PROGRAM MAIN - INTEGER :: N = 7, INFO - DOUBLE PRECISION :: D(7), E(6) - D = [4, 5, 6, 7, 8, 9, 10] - E = [1, 2, 3, 4, 5, 6] - CALL DPTTRF(N, D, E, INFO) - print *, "D: ", D - print *, "E: ", E - print *, "INFO: ", INFO - END PROGRAM \ No newline at end of file diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt index 1f21eaadfeb5..316365736294 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( N, D, E, info ) - Computes the `L * D * L ** T` factorization of real symmetric positive + Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. Indexing is relative to the first index. To introduce an offset, use typed @@ -53,7 +53,7 @@ {{alias}}.ndarray( N, D, strideD, offsetD, E, strideE, offsetE, info ) - Computes the `L * D * L ** T` factorization of real symmetric positive + Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `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/dpttrf/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts index 8ce248b6cbf4..19982315e8c9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts @@ -25,11 +25,11 @@ */ interface Routine { /** - * Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. + * Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. * * @param N - order of matrix `A` - * @param D - the N diagonal elements of `A` - * @param E - the ( N-1 ) subdiagonal elements of `A` + * @param D - the `N` diagonal elements of `A` + * @param E - the `N-1` subdiagonal elements of `A` * @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns status code * @@ -48,13 +48,13 @@ interface Routine { ( N: number, D: Float64Array, E: Float64Array, info: number ): number; /** - * Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. + * Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. * * @param N - order of matrix `A` - * @param D - the N diagonal elements of `A` + * @param D - the `N` diagonal elements of `A` * @param strideD - stride length for `D` * @param offsetD - starting index of `D` - * @param E - the ( N-1 ) subdiagonal elements of `A` + * @param E - the `N-1` subdiagonal elements of `A` * @param strideE - stride length for `E` * @param offsetE - starting index of `E` * @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` @@ -76,11 +76,11 @@ interface Routine { } /** -* Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. * * @param N - order of matrix `A` -* @param D - the N diagonal elements of `A` -* @param E - the ( N-1 ) subdiagonal elements of `A` +* @param D - the `N` diagonal elements of `A` +* @param E - the `N-1` subdiagonal elements of `A` * @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns status code * diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js index 859ed9ee22a1..b090c0064e28 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js @@ -27,6 +27,6 @@ var info = 0; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); -// Perform the `L * D * L ** T` factorization: +// Perform the `L * D * L^T` factorization: dpttrf( N, D, E, info ); console.log( D, E, info ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js index 0266a6ecc225..5ed47bdfcd06 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js @@ -21,14 +21,14 @@ // MAIN // /** -* Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. * * @private * @param {NonNegativeInteger} N - order of matrix `A` -* @param {Float64Array} D - the N diagonal elements of `A` +* @param {Float64Array} D - the `N` diagonal elements of `A` * @param {integer} strideD - stride length for `D` * @param {NonNegativeInteger} offsetD - starting index of `D` -* @param {Float64Array} E - the ( N-1 ) subdiagonal elements of `A` +* @param {Float64Array} E - the `N-1` subdiagonal elements of `A` * @param {integer} strideE - stride length for `E` * @param {NonNegativeInteger} offsetE - starting index of `E` * @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` @@ -52,11 +52,11 @@ function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE, info ) { var se; var i; - // Quick return if possible if ( N <= 0 ) { return 0; } - // Compute the `L * D * L**T` factorization of `A` + + // Compute the `L * D * L^T` factorization of `A` se = 0; sd = 0; for ( i = 0; i < N - 1; i++ ) { diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js index 60a3bf490655..f9da0b166de3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js @@ -26,11 +26,11 @@ var base = require( './base.js' ); // MAIN // /** -* Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. * * @param {NonNegativeInteger} N - order of matrix `A` -* @param {Float64Array} D - the N diagonal elements of `A` -* @param {Float64Array} E - the ( N-1 ) subdiagonal elements of `A` +* @param {Float64Array} D - the `N` diagonal elements of `A` +* @param {Float64Array} E - the `N-1` subdiagonal elements of `A` * @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns {integer} status code * diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js index 51972f8b40e8..9ff1fa29c359 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* LAPACK routine to compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. * * @module @stdlib/lapack/base/dpttrf * diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js index f348c750a2d0..44fe085b9378 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js @@ -26,14 +26,14 @@ var base = require( './base.js' ); // MAIN // /** -* Computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. +* Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. * * @private * @param {NonNegativeInteger} N - order of matrix `A` -* @param {Float64Array} D - the N diagonal elements of `A` +* @param {Float64Array} D - the `N` diagonal elements of `A` * @param {integer} strideD - stride length for `D` * @param {NonNegativeInteger} offsetD - starting index of `D` -* @param {Float64Array} E - the ( N-1 ) subdiagonal elements of `A` +* @param {Float64Array} E - the `N-1` subdiagonal elements of `A` * @param {integer} strideE - stride length for `E` * @param {NonNegativeInteger} offsetE - starting index of `E` * @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json b/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json index 96fdf9dc59dd..96f991082c00 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/lapack/base/dpttrf", "version": "0.0.0", - "description": "Compute the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`.", + "description": "Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js index 47f7955bf69e..cdd9ef1842c0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js @@ -71,7 +71,7 @@ tape( 'the function has an arity of 4', function test( t ) { t.end(); }); -tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { var expectedD; var expectedE; var info; @@ -96,7 +96,7 @@ tape( 'the function computes the `L * D * L ** T` factorization of real symmetri t.end(); }); -tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { var expectedD; var expectedE; var info; diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js index 32bb8309f25f..7d8e5a6abadb 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js @@ -71,7 +71,7 @@ tape( 'the function has an arity of 8', function test( t ) { t.end(); }); -tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { var expectedD; var expectedE; var info; @@ -96,7 +96,7 @@ tape( 'the function computes the `L * D * L ** T` factorization of real symmetri t.end(); }); -tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { var expectedD; var expectedE; var info; @@ -121,7 +121,7 @@ tape( 'the function computes the `L * D * L ** T` factorization of real symmetri t.end(); }); -tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 2, offsetE = 3 )', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 2, offsetE = 3 )', function test( t ) { var expectedD; var expectedE; var info; @@ -146,7 +146,7 @@ tape( 'the function computes the `L * D * L ** T` factorization of real symmetri t.end(); }); -tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 2, offsetE = 3, strideD = 3, strideE = 2 )', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 2, offsetE = 3, strideD = 3, strideE = 2 )', function test( t ) { var expectedD; var expectedE; var info; @@ -171,7 +171,7 @@ tape( 'the function computes the `L * D * L ** T` factorization of real symmetri t.end(); }); -tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 6, offsetE = 3, strideD = -3, strideE = 2 )', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 6, offsetE = 3, strideD = -3, strideE = 2 )', function test( t ) { var expectedD; var expectedE; var info; @@ -196,7 +196,7 @@ tape( 'the function computes the `L * D * L ** T` factorization of real symmetri t.end(); }); -tape( 'the function computes the `L * D * L ** T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 6, offsetE = 5, strideD = -3, strideE = -2 )', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 6, offsetE = 5, strideD = -3, strideE = -2 )', function test( t ) { var expectedD; var expectedE; var info; From ee0ae3ca5330f9a0ee66cad24db1e90184e33709 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 22 Jul 2024 20:20:50 +0530 Subject: [PATCH 11/18] refactor: base implementation to return info, not take it as a parameter, and consequent changes --- .../@stdlib/lapack/base/dpttrf/README.md | 27 +-- .../@stdlib/lapack/base/dpttrf/docs/repl.txt | 18 +- .../lapack/base/dpttrf/docs/types/index.d.ts | 24 +- .../lapack/base/dpttrf/docs/types/test.ts | 225 +++++++----------- .../lapack/base/dpttrf/examples/index.js | 4 +- .../@stdlib/lapack/base/dpttrf/lib/base.js | 9 +- .../@stdlib/lapack/base/dpttrf/lib/dpttrf.js | 10 +- .../@stdlib/lapack/base/dpttrf/lib/index.js | 18 +- .../@stdlib/lapack/base/dpttrf/lib/ndarray.js | 8 +- .../lapack/base/dpttrf/test/test.dpttrf.js | 10 +- .../lapack/base/dpttrf/test/test.ndarray.js | 22 +- 11 files changed, 156 insertions(+), 219 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md index 6531da48a566..c647c48f4332 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md @@ -30,7 +30,7 @@ limitations under the License. var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); ``` -#### dpttrf( N, D, E, info ) +#### dpttrf( N, D, E ) Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. @@ -38,11 +38,10 @@ Computes the `L * D * L^T` factorization of real symmetric positive definite tri var Float64Array = require( '@stdlib/array/float64' ); var N = 3; -var info = 0; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); -dpttrf( N, D, E, info ); +dpttrf( N, D, E ); // D => [ 4, 4.75, ~5.15789 ] // E => [ 0.25, ~0.4210 ] ``` @@ -52,7 +51,6 @@ The function has the following parameters: - **N**: order of matrix `A`. - **D**: the `N` diagonal elements of `A` as a [`Float64Array`][mdn-float64array]. - **E**: the N-1 subdiagonal elements of `A` as a [`Float64Array`][mdn-float64array]. -- **info**: status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0`. Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -62,7 +60,6 @@ Note that indexing is relative to the first index. To introduce an offset, use [ var Float64Array = require( '@stdlib/array/float64' ); var N = 3; -var info = 0; // Initial arrays... var D0 = new Float64Array( [ 0.0, 4.0, 5.0, 6.0 ] ); @@ -72,12 +69,12 @@ var E0 = new Float64Array( [ 0.0, 1.0, 2.0 ] ); 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 -dpttrf( N, D1, E1, info ); +dpttrf( N, D1, E1 ); // D0 => [ 0.0, 4.0, 4.75, ~5.15789 ] // E0 => [ 0.0, 0.25, ~0.4210 ] ``` -#### dpttrf.ndarray( N, D, strideD, offsetD, E, strideE, offsetE, info ) +#### dpttrf.ndarray( N, D, strideD, offsetD, E, strideE, offsetE ) Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. @@ -85,11 +82,10 @@ Computes the `L * D * L^T` factorization of real symmetric positive definite tri var Float64Array = require( '@stdlib/array/float64' ); var N = 3; -var info = 0; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); -dpttrf.ndarray( N, D, 1, 0, E, 1, 0, info ); +dpttrf.ndarray( N, D, 1, 0, E, 1, 0 ); // D => [ 4, 4.75, ~5.15789 ] // E => [ 0.25, ~0.4210 ] ``` @@ -109,11 +105,10 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the var Float64Array = require( '@stdlib/array/float64' ); var N = 3; -var info = 0; var D = new Float64Array( [ 0.0, 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 0.0, 1.0, 2.0 ] ); -dpttrf.ndarray( N, D, 1, 1, E, 1, 1, info ); +dpttrf.ndarray( N, D, 1, 1, E, 1, 1 ); // D => [ 0.0, 4.0, 4.75, ~5.15789 ] // E => [ 0.0, 0.25, ~0.4210 ] ``` @@ -127,6 +122,12 @@ dpttrf.ndarray( N, D, 1, 1, E, 1, 1, info ); ## Notes - `dpttrf()` corresponds to the [LAPACK][LAPACK] level 1 function [`dpttrf`][dpttrf]. +- function returns a status code indicating success or failure. +- `0` if successful. +- `<0` if i-th argument had an illegal value. +- `>0` if leading principal minor of order `i` is not positive. +- `N` if the factorization was completed, but `D(N) <= 0`.
@@ -144,13 +145,11 @@ var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); // Specify input data: var N = 3; -var info = 0; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); // Perform the `L * D * L^T` factorization: -dpttrf( N, D, E, info ); -console.log( D, E, info ); +dpttrf( N, D, E ); ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt index 316365736294..9c42b246093d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( N, D, E, info ) +{{alias}}( N, D, E ) Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. @@ -18,9 +18,6 @@ E: Float64Array Subdiagonal elements of `A`. - info: integer - Status code. - Returns ------- info: integer @@ -29,10 +26,9 @@ Examples -------- > var N = 3; - > var info = 0; > var D = new {{alias:@stdlib/array/float64}}( [ 4.0, 5.0, 6.0 ] ); > var E = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > {{alias}}( N, D, E, info ) + > {{alias}}( N, D, E ) 0 > D [ 4, 4.75, ~5.15789 ] @@ -44,7 +40,7 @@ > var E0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0 ] ); > D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); > E = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( N, D, E, info ) + > {{alias}}( N, D, E ) 0 > D0 [ 0.0, 4.0, 4.75, ~5.15789 ] @@ -52,7 +48,7 @@ [ 0.0, 0.25, ~0.42105 ] -{{alias}}.ndarray( N, D, strideD, offsetD, E, strideE, offsetE, info ) +{{alias}}.ndarray( N, D, strideD, offsetD, E, strideE, offsetE ) Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. @@ -83,9 +79,6 @@ offsetE: integer Starting index for `E`. - info: integer - Status code. - Returns ------- info: integer @@ -94,10 +87,9 @@ Examples -------- > var N = 3; - > var info = 0; > var D = new {{alias:@stdlib/array/float64}}( [ 0.0, 4.0, 5.0, 6.0 ] ); > var E = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0 ] ); - > {{alias}}.ndarray( N, D, 1, 1, E, 1, 1, info ) + > {{alias}}.ndarray( N, D, 1, 1, E, 1, 1 ) 0 > D [ 0.0, 4.0, 4.75, ~5.15789 ] diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts index 19982315e8c9..a143e5a893cf 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts @@ -20,32 +20,31 @@ /// + /** * Interface describing `dpttrf`. */ interface Routine { /** - * Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. + * Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. * * @param N - order of matrix `A` * @param D - the `N` diagonal elements of `A` * @param E - the `N-1` subdiagonal elements of `A` - * @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var N = 3; - * var info = 0; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * - * dpttrf( N, D, E, info ); + * dpttrf( N, D, E ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ - ( N: number, D: Float64Array, E: Float64Array, info: number ): number; + ( N: number, D: Float64Array, E: Float64Array ): number; /** * Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. @@ -57,42 +56,38 @@ interface Routine { * @param E - the `N-1` subdiagonal elements of `A` * @param strideE - stride length for `E` * @param offsetE - starting index of `E` - * @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var N = 3; - * var info = 0; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * - * dpttrf.ndarray( N, D, 1, 0, E, 1, 0, info ); + * dpttrf.ndarray( N, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ - ndarray( N: number, D: Float64Array, strideD: number, offsetD: number, E: Float64Array, strideE: number, offsetE: number, info: number ): number; + ndarray( N: number, D: Float64Array, strideD: number, offsetD: number, E: Float64Array, strideE: number, offsetE: number ): number; } /** -* Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. * * @param N - order of matrix `A` * @param D - the `N` diagonal elements of `A` * @param E - the `N-1` subdiagonal elements of `A` -* @param info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var N = 3; -* var info = 0; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, E, info ); +* dpttrf( N, D, E ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] * @@ -100,11 +95,10 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * * var N = 3; -* var info = 0; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf.ndarray( N, D, 1, 0, E, 1, 0, info ); +* dpttrf.ndarray( N, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/test.ts index c833805b06b0..36b410c96b9a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/test.ts @@ -1,4 +1,5 @@ -/** + +/* * @license Apache-2.0 * * Copyright (c) 2024 The Stdlib Authors. @@ -23,228 +24,183 @@ import dpttrf = require( './index' ); // The function returns a Float64Array... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); - dpttrf( 3, D, E, info ); // $ExpectType number + dpttrf( 3, D, E ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); - dpttrf( '5', D, E, info ); // $ExpectError - dpttrf( true, D, E, info ); // $ExpectError - dpttrf( false, D, E, info ); // $ExpectError - dpttrf( null, D, E, info ); // $ExpectError - dpttrf( void 0, D, E, info ); // $ExpectError - dpttrf( [], D, E, info ); // $ExpectError - dpttrf( {}, D, E, info ); // $ExpectError - dpttrf( ( x: number ): number => x, D, E, info ); // $ExpectError + dpttrf( '5', D, E ); // $ExpectError + dpttrf( true, D, E ); // $ExpectError + dpttrf( false, D, E ); // $ExpectError + dpttrf( null, D, E ); // $ExpectError + dpttrf( void 0, D, E ); // $ExpectError + dpttrf( [], D, E ); // $ExpectError + dpttrf( {}, D, E ); // $ExpectError + dpttrf( ( x: number ): number => x, D, E ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... { - const info = 0; const E = new Float64Array( 2 ); - dpttrf( 3, '5', E, info ); // $ExpectError - dpttrf( 3, 5, E, info ); // $ExpectError - dpttrf( 3, true, E, info ); // $ExpectError - dpttrf( 3, false, E, info ); // $ExpectError - dpttrf( 3, null, E, info ); // $ExpectError - dpttrf( 3, void 0, E, info ); // $ExpectError - dpttrf( 3, [], E, info ); // $ExpectError - dpttrf( 3, {}, E, info ); // $ExpectError - dpttrf( 3, ( x: number ): number => x, E, info ); // $ExpectError + dpttrf( 3, '5', E ); // $ExpectError + dpttrf( 3, 5, E ); // $ExpectError + dpttrf( 3, true, E ); // $ExpectError + dpttrf( 3, false, E ); // $ExpectError + dpttrf( 3, null, E ); // $ExpectError + dpttrf( 3, void 0, E ); // $ExpectError + dpttrf( 3, [], E ); // $ExpectError + dpttrf( 3, {}, E ); // $ExpectError + dpttrf( 3, ( x: number ): number => x, E ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... -{ - const info = 0; - const D = new Float64Array( 3 ); - - dpttrf( 3, D, '5', info ); // $ExpectError - dpttrf( 3, D, 5, info ); // $ExpectError - dpttrf( 3, D, true, info ); // $ExpectError - dpttrf( 3, D, false, info ); // $ExpectError - dpttrf( 3, D, null, info ); // $ExpectError - dpttrf( 3, D, void 0, info ); // $ExpectError - dpttrf( 3, D, [], info ); // $ExpectError - dpttrf( 3, D, {}, info ); // $ExpectError - dpttrf( 3, D, ( x: number ): number => x, info ); // $ExpectError -} - -// The compiler throws an error if the function is provided a fourth argument which is not a number... { const D = new Float64Array( 3 ); - const E = new Float64Array( 2 ); - dpttrf( 3, D, E, '5' ); // $ExpectError - dpttrf( 3, D, E, true ); // $ExpectError - dpttrf( 3, D, E, false ); // $ExpectError - dpttrf( 3, D, E, null ); // $ExpectError - dpttrf( 3, D, E, void 0 ); // $ExpectError - dpttrf( 3, D, E, [] ); // $ExpectError - dpttrf( 3, D, E, {} ); // $ExpectError - dpttrf( 3, D, E, ( x: number ): number => x ); // $ExpectError + dpttrf( 3, D, '5' ); // $ExpectError + dpttrf( 3, D, 5 ); // $ExpectError + dpttrf( 3, D, true ); // $ExpectError + dpttrf( 3, D, false ); // $ExpectError + dpttrf( 3, D, null ); // $ExpectError + dpttrf( 3, D, void 0 ); // $ExpectError + dpttrf( 3, D, [] ); // $ExpectError + dpttrf( 3, D, {} ); // $ExpectError + dpttrf( 3, D, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); dpttrf(); // $ExpectError dpttrf( 3 ); // $ExpectError dpttrf( 3, D ); // $ExpectError - dpttrf( 3, D, E ); // $ExpectError - dpttrf( 3, D, E, info, 10 ); // $ExpectError + dpttrf( 3, D, E, 10 ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a Float64Array... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, info ); // $ExpectType number + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0 ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not a number... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); - dpttrf.ndarray( '5', D, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( true, D, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( false, D, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( null, D, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( void 0, D, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( [], D, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( {}, D, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( ( x: number ): number => x, D, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( '5', D, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( true, D, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( false, D, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( null, D, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( void 0, D, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( [], D, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( {}, D, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( ( x: number ): number => x, D, 1, 0, E, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a Float64Array... { - const info = 0; const E = new Float64Array( 2 ); - dpttrf.ndarray( 3, '5', 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, 5, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, true, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, false, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, null, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, void 0, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, [], 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, {}, 1, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, ( x: number ): number => x, 1, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, '5', 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, 5, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, true, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, false, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, null, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, void 0, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, [], 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, {}, 1, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, ( x: number ): number => x, 1, 0, E, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); - dpttrf.ndarray( 3, D, '5', 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, true, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, false, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, null, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, void 0, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, [], 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, {}, 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, ( x: number ): number => x, 0, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, '5', 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, true, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, false, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, null, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, void 0, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, [], 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, {}, 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, ( x: number ): number => x, 0, E, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); - dpttrf.ndarray( 3, D, 1, '5', E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, true, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, false, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, null, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, void 0, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, [], E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, {}, E, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, ( x: number ): number => x, E, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, '5', E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, true, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, false, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, null, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, void 0, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, [], E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, {}, E, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, ( x: number ): number => x, E, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... { - const info = 0; const D = new Float64Array( 3 ); - dpttrf.ndarray( 3, D, 1, 0, '5', 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, 5, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, true, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, false, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, null, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, void 0, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, [], 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, {}, 1, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, ( x: number ): number => x, 1, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, '5', 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, 5, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, true, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, false, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, null, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, void 0, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, [], 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, {}, 1, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not a number... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); - dpttrf.ndarray( 3, D, 1, 0, E, '5', 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, true, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, false, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, null, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, void 0, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, [], 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, {}, 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, ( x: number ): number => x, 0, info ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, '5', 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, true, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, false, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, null, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, void 0, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, [], 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, {}, 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not a number... -{ - const info = 0; - const D = new Float64Array( 3 ); - const E = new Float64Array( 2 ); - - dpttrf.ndarray( 3, D, 1, 0, E, 1, '5', info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, true, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, false, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, null, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, void 0, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, [], info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, {}, info ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, ( x: number ): number => x, info ); // $ExpectError -} - -// The compiler throws an error if the function is provided an eighth argument which is not a number... { const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, '5' ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, true ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, false ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, null ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, void 0 ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, [] ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, {} ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, ( x: number ): number => x ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, '5' ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, true ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, false ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, null ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, void 0 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, [] ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, {} ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { - const info = 0; const D = new Float64Array( 3 ); const E = new Float64Array( 2 ); @@ -255,6 +211,5 @@ import dpttrf = require( './index' ); dpttrf.ndarray( 3, D, 1, 0 ); // $ExpectError dpttrf.ndarray( 3, D, 1, 0, E ); // $ExpectError dpttrf.ndarray( 3, D, 1, 0, E, 1 ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0 ); // $ExpectError - dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, info, 10 ); // $ExpectError + dpttrf.ndarray( 3, D, 1, 0, E, 1, 0, 10 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js index b090c0064e28..d612aa185038 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js @@ -23,10 +23,8 @@ var dpttrf = require( './../lib' ); // Specify input data: var N = 3; -var info = 0; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); // Perform the `L * D * L^T` factorization: -dpttrf( N, D, E, info ); -console.log( D, E, info ); +dpttrf( N, D, E ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js index 5ed47bdfcd06..b7b5ae8e1282 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js @@ -31,22 +31,21 @@ * @param {Float64Array} E - the `N-1` subdiagonal elements of `A` * @param {integer} strideE - stride length for `E` * @param {NonNegativeInteger} offsetE - starting index of `E` -* @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns {integer} status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var N = 3; -* var info = 0; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, 1, 0, E, 1, 0, info ); +* dpttrf( N, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ -function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE, info ) { +function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE ) { + var info; var ei; var sd; var se; @@ -77,7 +76,7 @@ function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE, info ) { info = ( N - 1 ) * sd; return info; } - return info; + return 0; } diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js index f9da0b166de3..611335a2d3f6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js @@ -26,28 +26,26 @@ var base = require( './base.js' ); // MAIN // /** -* Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. * * @param {NonNegativeInteger} N - order of matrix `A` * @param {Float64Array} D - the `N` diagonal elements of `A` * @param {Float64Array} E - the `N-1` subdiagonal elements of `A` -* @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns {integer} status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var N = 3; -* var info = 0; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, E, info ); +* dpttrf( N, D, E ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ -function dpttrf( N, D, E, info ) { - return base( N, D, 1, 0, E, 1, 0, info ); +function dpttrf( N, D, E ) { + return base( N, D, 1, 0, E, 1, 0 ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js index 9ff1fa29c359..2310dd389001 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js @@ -28,12 +28,24 @@ * var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); * * var N = 3; -* var info = 0; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, E, info ); -* // returns 0 +* dpttrf( N, D, E ); +* // D => [ 4, 4.75, ~5.15789 ] +* // E => [ 0.25, ~0.4210 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); +* +* var N = 3; +* var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); +* var E = new Float64Array( [ 1.0, 2.0 ] ); +* +* dpttrf.ndarray( N, D, 1, 0, E, 1, 0 ); +* // D => [ 4, 4.75, ~5.15789 ] +* // E => [ 0.25, ~0.4210 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js index 44fe085b9378..b19b82db996c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js @@ -36,23 +36,21 @@ var base = require( './base.js' ); * @param {Float64Array} E - the `N-1` subdiagonal elements of `A` * @param {integer} strideE - stride length for `E` * @param {NonNegativeInteger} offsetE - starting index of `E` -* @param {integer} info - status code, `0` if successful, `<0` if i-th argument had an illegal value, `>0` if leading principal minor of order `i` is not positive; if `N` then the factorization was completed, but `D(N) <= 0` * @returns {integer} status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); * * var N = 3; -* var info = 0; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, 1, 0, E, 1, 0, info ); +* dpttrf( N, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ -function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE, info ) { - return base( N, D, strideD, offsetD, E, strideE, offsetE, info ); +function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE ) { + return base( N, D, strideD, offsetD, E, strideE, offsetE ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js index cdd9ef1842c0..16ebd904de5d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js @@ -66,8 +66,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 4', function test( t ) { - t.strictEqual( dpttrf.length, 4, 'returns expected value' ); +tape( 'the function has an arity of 3', function test( t ) { + t.strictEqual( dpttrf.length, 3, 'returns expected value' ); t.end(); }); @@ -80,7 +80,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p var N; N = 3; - info = 0; D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); E = new Float64Array( [ 1.0, 2.0 ] ); @@ -88,7 +87,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p expectedD = new Float64Array( [ 4.0, 4.75, 5.157894736842105 ] ); expectedE = new Float64Array( [ 0.25, 0.42105263157894735 ] ); - info = dpttrf( N, D, E, info ); + info = dpttrf( N, D, E ); t.strictEqual( info, 0, 'returns expected value' ); isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); @@ -105,7 +104,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p var N; N = 7; - info = 0; D = new Float64Array( [ 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); E = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] ); @@ -113,7 +111,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p expectedD = new Float64Array( [ 4.0, 4.75, 5.157894736842105, 5.255102040816327, 4.955339805825243, 3.954937304075235, 0.89745368076885157 ] ); expectedE = new Float64Array( [ 0.25, 0.42105263157894735, 0.58163265306122447, 0.76116504854368927, 1.0090125391849529, 1.5170910532051916 ] ); - info = dpttrf( N, D, E, info ); + info = dpttrf( N, D, E ); t.strictEqual( info, 0, 'returns expected value' ); isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js index 7d8e5a6abadb..d58f3b554810 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js @@ -66,8 +66,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 8', function test( t ) { - t.strictEqual( dpttrf.length, 8, 'returns expected value' ); +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dpttrf.length, 7, 'returns expected value' ); t.end(); }); @@ -80,7 +80,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p var N; N = 3; - info = 0; D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); E = new Float64Array( [ 1.0, 2.0 ] ); @@ -88,7 +87,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p expectedD = new Float64Array( [ 4.0, 4.75, 5.157894736842105 ] ); expectedE = new Float64Array( [ 0.25, 0.42105263157894735 ] ); - info = dpttrf( N, D, 1, 0, E, 1, 0, info ); + info = dpttrf( N, D, 1, 0, E, 1, 0 ); t.strictEqual( info, 0, 'returns expected value' ); isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); @@ -105,7 +104,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p var N; N = 7; - info = 0; D = new Float64Array( [ 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); E = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0] ); @@ -113,7 +111,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p expectedD = new Float64Array( [ 4.0, 4.75, 5.157894736842105, 5.255102040816327, 4.955339805825243, 3.954937304075235, 0.89745368076885157 ] ); expectedE = new Float64Array( [ 0.25, 0.42105263157894735, 0.58163265306122447, 0.76116504854368927, 1.0090125391849529, 1.5170910532051916 ] ); - info = dpttrf( N, D, 1, 0, E, 1, 0, info ); + info = dpttrf( N, D, 1, 0, E, 1, 0 ); t.strictEqual( info, 0, 'returns expected value' ); isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); @@ -130,7 +128,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p var N; N = 3; - info = 0; D = new Float64Array( [ 0.0, 0.0, 4.0, 5.0, 6.0 ] ); E = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 2.0 ] ); @@ -138,7 +135,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p expectedD = new Float64Array( [ 0.0, 0.0, 4.0, 4.75, 5.157894736842105 ] ); expectedE = new Float64Array( [ 0.0, 0.0, 0.0, 0.25, 0.42105263157894735 ] ); - info = dpttrf( N, D, 1, 2, E, 1, 3, info ); + info = dpttrf( N, D, 1, 2, E, 1, 3 ); t.strictEqual( info, 0, 'returns expected value' ); isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); @@ -155,7 +152,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p var N; N = 3; - info = 0; D = new Float64Array( [ 0.0, 0.0, 4.0, 0.0, 0.0, 5.0, 0.0, 0.0, 6.0 ] ); E = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 2.0 ] ); @@ -163,7 +159,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p expectedD = new Float64Array( [ 0.0, 0.0, 4.0, 0.0, 0.0, 4.75, 0.0, 0.0, 5.157894736842105 ] ); expectedE = new Float64Array( [ 0.0, 0.0, 0.0, 0.25, 0.0, 0.42105263157894735 ] ); - info = dpttrf( N, D, 3, 2, E, 2, 3, info ); + info = dpttrf( N, D, 3, 2, E, 2, 3 ); t.strictEqual( info, 0, 'returns expected value' ); isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); @@ -180,7 +176,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p var N; N = 3; - info = 0; D = new Float64Array( [ 6.0, 0.0, 0.0, 5.0, 0.0, 0.0, 4.0 ] ); E = new Float64Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 2.0 ] ); @@ -188,7 +183,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p expectedD = new Float64Array( [ 5.157894736842105, 0.0, 0.0, 4.75, 0.0, 0.0, 4.0 ] ); expectedE = new Float64Array( [ 0.0, 0.0, 0.0, 0.25, 0.0, 0.42105263157894735 ] ); - info = dpttrf( N, D, -3, 6, E, 2, 3, info ); + info = dpttrf( N, D, -3, 6, E, 2, 3 ); t.strictEqual( info, 0, 'returns expected value' ); isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); @@ -205,7 +200,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p var N; N = 3; - info = 0; D = new Float64Array( [ 6.0, 0.0, 0.0, 5.0, 0.0, 0.0, 4.0 ] ); E = new Float64Array( [ 0.0, 0.0, 0.0, 2.0, 0.0, 1.0 ] ); @@ -213,7 +207,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p expectedD = new Float64Array( [ 5.157894736842105, 0.0, 0.0, 4.75, 0.0, 0.0, 4.0 ] ); expectedE = new Float64Array( [ 0.0, 0.0, 0.0, 0.42105263157894735, 0.0, 0.25 ] ); - info = dpttrf( N, D, -3, 6, E, -2, 5, info ); + info = dpttrf( N, D, -3, 6, E, -2, 5 ); t.strictEqual( info, 0, 'returns expected value' ); isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); From dbadee7d1328ab2aceb06fce9206bcbb0cc8a688 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 28 Jul 2024 03:24:31 -0700 Subject: [PATCH 12/18] bench: fix invocations and style --- .../@stdlib/lapack/base/dpttrf/benchmark/benchmark.js | 11 +++++------ .../lapack/base/dpttrf/benchmark/benchmark.ndarray.js | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.js index d0cceb4af0ef..90011e025b7a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. @@ -45,9 +45,8 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var info; var D = uniform( len, 0.0, 100.0, options ); - var E= uniform( len, 0.0, 100.0, options ); + var E = uniform( len, 0.0, 100.0, options ); return benchmark; function benchmark( b ) { @@ -56,13 +55,13 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - d = dpttrf( len, D, E, info ); - if ( isnan( d ) || isnan( D[ i%D.length ] || isnan( E[ i%E.length ] ) ) ) { + d = dpttrf( len, D, E ); + if ( isnan( d ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( d ) || isnan( D[ i%D.length ] || isnan( E[ i%E.length ] ) ) ) { + if ( isnan( d ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.ndarray.js index 604c7c443191..1bbdc5232ed4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* 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. @@ -45,9 +45,8 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var info; var D = uniform( len, 0.0, 100.0, options ); - var E= uniform( len, 0.0, 100.0, options ); + var E = uniform( len, 0.0, 100.0, options ); return benchmark; function benchmark( b ) { @@ -56,13 +55,13 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - d = dpttrf( len, D, 1, 0, E, 1, 0, info ); - if ( isnan( d ) || isnan( D[ i%D.length ] || isnan( E[ i%E.length ] ) ) ) { + d = dpttrf( len, D, 1, 0, E, 1, 0 ); + if ( isnan( d ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( d ) || isnan( D[ i%D.length ] || isnan( E[ i%E.length ] ) ) ) { + if ( isnan( d ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); From 72544d5982144a0a9d6f5515dfbce3471a37f950 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 28 Jul 2024 03:43:22 -0700 Subject: [PATCH 13/18] fix: add error handling and fix status return value --- .../lapack/base/dpttrf/examples/index.js | 4 +- .../@stdlib/lapack/base/dpttrf/lib/base.js | 46 +++++++++---------- .../@stdlib/lapack/base/dpttrf/lib/dpttrf.js | 8 +++- .../@stdlib/lapack/base/dpttrf/lib/index.js | 6 +-- .../@stdlib/lapack/base/dpttrf/lib/ndarray.js | 9 ++-- 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js index d612aa185038..2a1158854fd9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js @@ -21,10 +21,8 @@ var Float64Array = require( '@stdlib/array/float64' ); var dpttrf = require( './../lib' ); -// Specify input data: -var N = 3; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); // Perform the `L * D * L^T` factorization: -dpttrf( N, D, E ); +dpttrf( 3, D, E ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js index b7b5ae8e1282..ab3d8d7a91fb 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js @@ -36,45 +36,43 @@ * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, 1, 0, E, 1, 0 ); +* dpttrf( 3, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE ) { - var info; - var ei; - var sd; - var se; + var id; + var ie; + var v; var i; - if ( N <= 0 ) { + if ( N === 0 ) { return 0; } + ie = offsetE; + id = offsetD; - // Compute the `L * D * L^T` factorization of `A` - se = 0; - sd = 0; - for ( i = 0; i < N - 1; i++ ) { - // Drop out of loop if `D[ offsetD + j ]` is not positive definite - if ( D[ offsetD + sd ] <= 0.0 ) { - info = offsetD + sd; - return info; + // Compute the `L * D * L^T` factorization of `A`... + for ( i = 0; i < N-1; i++ ) { + // If `D[k] <= 0`, then the matrix is not positive definite... + if ( D[ id ] <= 0.0 ) { + return i+1; } + // Solve for E[k] and D[k+1]... + v = E[ ie ]; + E[ ie ] = v / D[ id ]; - ei = E[ offsetE + se ]; - E[ offsetE + se ] = ei / D[ offsetD + sd ]; - D[ offsetD + sd + strideD ] -= E[ offsetE + se ] * ei; - se += strideE; - sd += strideD; + id += strideD; + D[ id ] -= E[ ie ] * v; + + ie += strideE; } - // Check `D[ N - 1 ]` for positive definiteness - if ( D[ offsetD + ( ( N - 1 ) * strideD ) ] <= 0.0 ) { - info = ( N - 1 ) * sd; - return info; + // Check `D[k]` for positive definiteness... + if ( D[ id ] <= 0.0 ) { + return N; } return 0; } diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js index 611335a2d3f6..b6eef7355528 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js @@ -20,6 +20,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -31,20 +32,23 @@ var base = require( './base.js' ); * @param {NonNegativeInteger} N - order of matrix `A` * @param {Float64Array} D - the `N` diagonal elements of `A` * @param {Float64Array} E - the `N-1` subdiagonal elements of `A` +* @throws {RangeError} first argument must be a nonnegative integer * @returns {integer} status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, E ); +* dpttrf( 3, D, E ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ function dpttrf( N, D, E ) { + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', N ) ); + } return base( N, D, 1, 0, E, 1, 0 ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js index 2310dd389001..8ac661af44c2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js @@ -27,11 +27,10 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); * -* var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, E ); +* dpttrf( 3, D, E ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] * @@ -39,11 +38,10 @@ * var Float64Array = require( '@stdlib/array/float64' ); * var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); * -* var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf.ndarray( N, D, 1, 0, E, 1, 0 ); +* dpttrf.ndarray( 3, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js index b19b82db996c..3c889e34e9e0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js @@ -20,6 +20,7 @@ // MODULES // +var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -28,7 +29,6 @@ var base = require( './base.js' ); /** * Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. * -* @private * @param {NonNegativeInteger} N - order of matrix `A` * @param {Float64Array} D - the `N` diagonal elements of `A` * @param {integer} strideD - stride length for `D` @@ -36,20 +36,23 @@ var base = require( './base.js' ); * @param {Float64Array} E - the `N-1` subdiagonal elements of `A` * @param {integer} strideE - stride length for `E` * @param {NonNegativeInteger} offsetE - starting index of `E` +* @throws {RangeError} first argument must be a nonnegative integer * @returns {integer} status code * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, 1, 0, E, 1, 0 ); +* dpttrf( 3, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ function dpttrf( N, D, strideD, offsetD, E, strideE, offsetE ) { + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. First argument must be a nonnegative integer. Value: `%d`.', N ) ); + } return base( N, D, strideD, offsetD, E, strideE, offsetE ); } From 11fba4498a04d3009f5b6d4fe6950f4c22f16b27 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 28 Jul 2024 03:54:52 -0700 Subject: [PATCH 14/18] docs: update descriptions and repl help --- .../@stdlib/lapack/base/dpttrf/docs/repl.txt | 59 ++++++++++++++----- .../@stdlib/lapack/base/dpttrf/lib/base.js | 2 +- .../@stdlib/lapack/base/dpttrf/lib/dpttrf.js | 2 +- .../@stdlib/lapack/base/dpttrf/lib/index.js | 2 +- .../@stdlib/lapack/base/dpttrf/lib/ndarray.js | 2 +- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt index 9c42b246093d..ab24124b8e9a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/repl.txt @@ -1,34 +1,49 @@ {{alias}}( N, D, E ) - Computes the `L * D * L^T` factorization of real symmetric positive + Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`. Indexing is relative to the first index. To introduce an offset, use typed array views. + The function mutates both `D` and `E`. + Parameters ---------- - N: integer Order of matrix `A`. D: Float64Array - Diagonal elements of `A`. + The `N` diagonal elements of `A`. Upon successful factorization, `D` + will contain the `N` diagonal elements of the diagonal matrix `D` from + the `L * D * L^T` factorization of `A`. E: Float64Array - Subdiagonal elements of `A`. + The `N-1` subdiagonal elements of `A`. Upon successful factorization, + `E` will contain the `N-1` subdiagonal elements of the unit bidiagonal + factor `L` from the `L * D * L^T` factorization of `A`. `E` can also be + regarded as the superdiagonal of the unit bidiagonal factor `U` from the + `U^T * D * U` factorization of `A`. Returns ------- info: integer - Status code. + Status code. The status code indicates the following conditions: + + - if equal to zero, then the factorization was successful. + - if less than zero, then the k-th argument had an illegal value, where + `k = -info`. + - if greater than zero, then the leading principal minor of order `k` is + not positive, where `k = info`. If `k < N`, then the factorization + could not be completed. If `k = N`, then the factorization was + completed, but `D(N) <= 0`, meaning that the matrix `A` is not + positive definite. Examples -------- - > var N = 3; > var D = new {{alias:@stdlib/array/float64}}( [ 4.0, 5.0, 6.0 ] ); > var E = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0 ] ); - > {{alias}}( N, D, E ) + > {{alias}}( 3, D, E ) 0 > D [ 4, 4.75, ~5.15789 ] @@ -40,7 +55,7 @@ > var E0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0 ] ); > D = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); > E = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( N, D, E ) + > {{alias}}( 3, D, E ) 0 > D0 [ 0.0, 4.0, 4.75, ~5.15789 ] @@ -49,20 +64,24 @@ {{alias}}.ndarray( N, D, strideD, offsetD, E, strideE, offsetE ) - Computes the `L * D * L^T` factorization of real symmetric positive + Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `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. + The function mutates both `D` and `E`. + Parameters ---------- N: integer Order of matrix `A`. D: Float64Array - Diagonal elements of `A`. + The `N` diagonal elements of `A`. Upon successful factorization, `D` + will contain the `N` diagonal elements of the diagonal matrix `D` from + the `L * D * L^T` factorization of `A`. strideD: integer Stride length for `D`. @@ -71,7 +90,11 @@ Starting index for `D`. E: Float64Array - Subdiagonal elements of `A`. + The `N-1` subdiagonal elements of `A`. Upon successful factorization, + `E` will contain the `N-1` subdiagonal elements of the unit bidiagonal + factor `L` from the `L * D * L^T` factorization of `A`. `E` can also be + regarded as the superdiagonal of the unit bidiagonal factor `U` from the + `U^T * D * U` factorization of `A`. strideE: integer Stride length for `E`. @@ -82,14 +105,22 @@ Returns ------- info: integer - Status code. + Status code. The status code indicates the following conditions: + + - if equal to zero, then the factorization was successful. + - if less than zero, then the k-th argument had an illegal value, where + `k = -info`. + - if greater than zero, then the leading principal minor of order `k` is + not positive, where `k = info`. If `k < N`, then the factorization + could not be completed. If `k = N`, then the factorization was + completed, but `D(N) <= 0`, meaning that the matrix `A` is not + positive definite. Examples -------- - > var N = 3; > var D = new {{alias:@stdlib/array/float64}}( [ 0.0, 4.0, 5.0, 6.0 ] ); > var E = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0 ] ); - > {{alias}}.ndarray( N, D, 1, 1, E, 1, 1 ) + > {{alias}}.ndarray( 3, D, 1, 1, E, 1, 1 ) 0 > D [ 0.0, 4.0, 4.75, ~5.15789 ] diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js index ab3d8d7a91fb..e2b35f02b8f7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/base.js @@ -21,7 +21,7 @@ // MAIN // /** -* Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`. * * @private * @param {NonNegativeInteger} N - order of matrix `A` diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js index b6eef7355528..3fe9ec5a395c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/dpttrf.js @@ -27,7 +27,7 @@ var base = require( './base.js' ); // MAIN // /** -* Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`. * * @param {NonNegativeInteger} N - order of matrix `A` * @param {Float64Array} D - the `N` diagonal elements of `A` diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js index 8ac661af44c2..559cb9dc72ee 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* LAPACK routine to compute the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`. * * @module @stdlib/lapack/base/dpttrf * diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js index 3c889e34e9e0..1e6b25b49819 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/lib/ndarray.js @@ -27,7 +27,7 @@ var base = require( './base.js' ); // MAIN // /** -* Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. +* Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. * * @param {NonNegativeInteger} N - order of matrix `A` * @param {Float64Array} D - the `N` diagonal elements of `A` From b1f1d9d51edf059833f4c6f19ad8e65676964029 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 28 Jul 2024 03:59:08 -0700 Subject: [PATCH 15/18] refactor: add status code type definition --- .../lapack/base/dpttrf/docs/types/index.d.ts | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts index a143e5a893cf..7ef13b643d5e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/docs/types/index.d.ts @@ -18,15 +18,25 @@ // TypeScript Version: 4.1 -/// - +/** +* Status code. +* +* ## Notes +* +* The status code indicates the following conditions: +* +* - if equal to zero, then the factorization was successful. +* - if less than zero, then the k-th argument had an illegal value, where `k = -StatusCode`. +* - if greater than zero, then the leading principal minor of order `k` is not positive, where `k = StatusCode`. If `k < N`, then the factorization could not be completed. If `k = N`, then the factorization was completed, but `D(N) <= 0`, meaning that the matrix `A` is not positive definite. +*/ +type StatusCode = number; /** * Interface describing `dpttrf`. */ interface Routine { /** - * Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. + * Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`. * * @param N - order of matrix `A` * @param D - the `N` diagonal elements of `A` @@ -36,18 +46,17 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * - * dpttrf( N, D, E ); + * dpttrf( 3, D, E ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ - ( N: number, D: Float64Array, E: Float64Array ): number; + ( N: number, D: Float64Array, E: Float64Array ): StatusCode; /** - * Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. + * Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. * * @param N - order of matrix `A` * @param D - the `N` diagonal elements of `A` @@ -61,19 +70,18 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * - * var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * - * dpttrf.ndarray( N, D, 1, 0, E, 1, 0 ); + * dpttrf.ndarray( 3, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ - ndarray( N: number, D: Float64Array, strideD: number, offsetD: number, E: Float64Array, strideE: number, offsetE: number ): number; + ndarray( N: number, D: Float64Array, strideD: number, offsetD: number, E: Float64Array, strideE: number, offsetE: number ): StatusCode; } /** -* Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. +* Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`. * * @param N - order of matrix `A` * @param D - the `N` diagonal elements of `A` @@ -83,22 +91,20 @@ interface Routine { * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf( N, D, E ); +* dpttrf( 3, D, E ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var N = 3; * var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); * var E = new Float64Array( [ 1.0, 2.0 ] ); * -* dpttrf.ndarray( N, D, 1, 0, E, 1, 0 ); +* dpttrf.ndarray( 3, D, 1, 0, E, 1, 0 ); * // D => [ 4, 4.75, ~5.15789 ] * // E => [ 0.25, ~0.4210 ] */ From 49ca9a924254c3d475944d161cd0a3bd9d2673c5 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 28 Jul 2024 04:11:34 -0700 Subject: [PATCH 16/18] docs: update examples --- .../@stdlib/lapack/base/dpttrf/README.md | 61 ++++++++++--------- .../lapack/base/dpttrf/examples/index.js | 17 ++++-- .../@stdlib/lapack/base/dpttrf/package.json | 3 +- 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md index c647c48f4332..7f3bf7a5d132 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/README.md @@ -20,7 +20,7 @@ limitations under the License. # dpttrf -> Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. +> Compute the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`.
@@ -32,16 +32,15 @@ var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); #### dpttrf( N, D, E ) -Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`. +Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`. ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var N = 3; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); -dpttrf( N, D, E ); +dpttrf( 3, D, E ); // D => [ 4, 4.75, ~5.15789 ] // E => [ 0.25, ~0.4210 ] ``` @@ -59,33 +58,30 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var N = 3; - // Initial arrays... var D0 = new Float64Array( [ 0.0, 4.0, 5.0, 6.0 ] ); var E0 = new Float64Array( [ 0.0, 1.0, 2.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 -dpttrf( N, D1, E1 ); +dpttrf( 3, D1, E1 ); // D0 => [ 0.0, 4.0, 4.75, ~5.15789 ] // E0 => [ 0.0, 0.25, ~0.4210 ] ``` #### dpttrf.ndarray( N, D, strideD, offsetD, E, strideE, offsetE ) -Computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. +Computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A` using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var N = 3; var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 1.0, 2.0 ] ); -dpttrf.ndarray( N, D, 1, 0, E, 1, 0 ); +dpttrf.ndarray( 3, D, 1, 0, E, 1, 0 ); // D => [ 4, 4.75, ~5.15789 ] // E => [ 0.25, ~0.4210 ] ``` @@ -104,11 +100,10 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float64Array = require( '@stdlib/array/float64' ); -var N = 3; var D = new Float64Array( [ 0.0, 4.0, 5.0, 6.0 ] ); var E = new Float64Array( [ 0.0, 1.0, 2.0 ] ); -dpttrf.ndarray( N, D, 1, 1, E, 1, 1 ); +dpttrf.ndarray( 3, D, 1, 1, E, 1, 1 ); // D => [ 0.0, 4.0, 4.75, ~5.15789 ] // E => [ 0.0, 0.25, ~0.4210 ] ``` @@ -121,13 +116,16 @@ dpttrf.ndarray( N, D, 1, 1, E, 1, 1 ); ## Notes -- `dpttrf()` corresponds to the [LAPACK][LAPACK] level 1 function [`dpttrf`][dpttrf]. -- function returns a status code indicating success or failure. -- `0` if successful. -- `<0` if i-th argument had an illegal value. -- `>0` if leading principal minor of order `i` is not positive. -- `N` if the factorization was completed, but `D(N) <= 0`. +- Both functions mutate the input arrays `D` and `E`. + +- Both functions return a status code indicating success or failure. A status code indicates the following conditions: + + - `0`: factorization was successful. + - `<0`: the k-th argument had an illegal value, where `-k` equals the status code value. + - `0 < k < N`: the leading principal minor of order `k` is not positive and factorization could not be completed, where `k` equals the status code value. + - `N`: the leading principal minor of order `N` is not positive, and factorization was completed. + +- `dpttrf()` corresponds to the [LAPACK][LAPACK] routine [`dpttrf`][lapack-dpttrf].
@@ -140,16 +138,23 @@ dpttrf.ndarray( N, D, 1, 1, E, 1, 1 ); ```javascript -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var dpttrf = require( '@stdlib/lapack/base/dpttrf' ); -// Specify input data: -var N = 3; -var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); -var E = new Float64Array( [ 1.0, 2.0 ] ); +var opts = { + 'dtype': 'float64' +}; +var D = discreteUniform( 5, 1, 5, opts ); +console.log( D ); + +var E = discreteUniform( D.length-1, 1, 5, opts ); +console.log( E ); // Perform the `L * D * L^T` factorization: -dpttrf( N, D, E ); +var info = dpttrf( D.length, D, E ); +console.log( D ); +console.log( E ); +console.log( info ); ``` @@ -240,7 +245,7 @@ TODO [lapack]: https://www.netlib.org/lapack/explore-html/ -[dpttrf]: https://www.netlib.org/lapack/explore-html/d4/d2c/group__pttrf_ga8f112041da2b9b443f8761a1eaaf15b6.html#ga8f112041da2b9b443f8761a1eaaf15b6 +[lapack-dpttrf]: https://www.netlib.org/lapack/explore-html/d4/d2c/group__pttrf_ga8f112041da2b9b443f8761a1eaaf15b6.html#ga8f112041da2b9b443f8761a1eaaf15b6 [mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js index 2a1158854fd9..dd435aff0ec7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/examples/index.js @@ -18,11 +18,20 @@ 'use strict'; -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var dpttrf = require( './../lib' ); -var D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); -var E = new Float64Array( [ 1.0, 2.0 ] ); +var opts = { + 'dtype': 'float64' +}; +var D = discreteUniform( 5, 1, 5, opts ); +console.log( D ); + +var E = discreteUniform( D.length-1, 1, 5, opts ); +console.log( E ); // Perform the `L * D * L^T` factorization: -dpttrf( 3, D, E ); +var info = dpttrf( D.length, D, E ); +console.log( D ); +console.log( E ); +console.log( info ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json b/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json index 96f991082c00..08756d23d552 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/lapack/base/dpttrf", "version": "0.0.0", - "description": "Compute the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`.", + "description": "Compute the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -56,6 +56,7 @@ "lapack", "dpttrf", "cholesky", + "factorization", "linear", "algebra", "subroutines", From 18de20a97926aea6c34bbcbd7b2aa13f72acd6dc Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 28 Jul 2024 04:15:55 -0700 Subject: [PATCH 17/18] test: update test descriptions and test cases --- .../lapack/base/dpttrf/test/test.dpttrf.js | 13 +----------- .../lapack/base/dpttrf/test/test.ndarray.js | 21 +++++-------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js index 16ebd904de5d..31cef22638c4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js @@ -71,7 +71,7 @@ tape( 'the function has an arity of 3', function test( t ) { t.end(); }); -tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`', function test( t ) { var expectedD; var expectedE; var info; @@ -92,17 +92,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); - t.end(); -}); - -tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { - var expectedD; - var expectedE; - var info; - var D; - var E; - var N; - N = 7; D = new Float64Array( [ 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js index d58f3b554810..c7598789d453 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js @@ -71,7 +71,7 @@ tape( 'the function has an arity of 7', function test( t ) { t.end(); }); -tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { +tape( 'the function computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`', function test( t ) { var expectedD; var expectedE; var info; @@ -92,17 +92,6 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p isApprox( t, D, expectedD, 2.0 ); isApprox( t, E, expectedE, 2.0 ); - t.end(); -}); - -tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A`', function test( t ) { - var expectedD; - var expectedE; - var info; - var D; - var E; - var N; - N = 7; D = new Float64Array( [ 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] ); @@ -119,7 +108,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p t.end(); }); -tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 2, offsetE = 3 )', function test( t ) { +tape( 'the function supports providing index offsets', function test( t ) { var expectedD; var expectedE; var info; @@ -143,7 +132,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p t.end(); }); -tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 2, offsetE = 3, strideD = 3, strideE = 2 )', function test( t ) { +tape( 'the function supports providing positive strides', function test( t ) { var expectedD; var expectedE; var info; @@ -167,7 +156,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p t.end(); }); -tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 6, offsetE = 3, strideD = -3, strideE = 2 )', function test( t ) { +tape( 'the function supports providing mixed sign strides', function test( t ) { var expectedD; var expectedE; var info; @@ -191,7 +180,7 @@ tape( 'the function computes the `L * D * L^T` factorization of real symmetric p t.end(); }); -tape( 'the function computes the `L * D * L^T` factorization of real symmetric positive definite tridiagonal matrix `A` ( offsetD = 6, offsetE = 5, strideD = -3, strideE = -2 )', function test( t ) { +tape( 'the function supports providing negative strides', function test( t ) { var expectedD; var expectedE; var info; From 0369cb97fae2a9f1dabe6eeaf2c2a0a109ce2c7a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sun, 28 Jul 2024 04:22:42 -0700 Subject: [PATCH 18/18] test: add status code tests --- .../lapack/base/dpttrf/test/test.dpttrf.js | 82 +++++++++++++++++++ .../lapack/base/dpttrf/test/test.ndarray.js | 82 +++++++++++++++++++ 2 files changed, 164 insertions(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js index 31cef22638c4..28cb569d9ce6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.dpttrf.js @@ -71,6 +71,35 @@ tape( 'the function has an arity of 3', function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var D; + var E; + var i; + + values = [ + -1, + -2, + -3, + -4, + -5 + ]; + + D = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + E = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dpttrf( value, D, E ); + }; + } +}); + tape( 'the function computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`', function test( t ) { var expectedD; var expectedE; @@ -107,3 +136,56 @@ tape( 'the function computes the `L * D * L^T` factorization of a real symmetric t.end(); }); + +tape( 'the function returns a non-zero status code when a diagonal element is less than or equal to zero', function test( t ) { + var info; + var D; + var E; + var N; + + N = 3; + + D = new Float64Array( [ 0.0, 5.0, 6.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + info = dpttrf( N, D, E ); + t.strictEqual( info, 1, 'returns expected value' ); + + D = new Float64Array( [ 4.0, 0.0, 6.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + info = dpttrf( N, D, E ); + t.strictEqual( info, 2, 'returns expected value' ); + + D = new Float64Array( [ 4.0, 5.0, 0.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + info = dpttrf( N, D, E ); + t.strictEqual( info, 3, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function leaves the input arrays unchanged when `N` is equal to zero', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 0; + + D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + expectedD = new Float64Array( [ 4.0, 5.0, 6.0 ] ); + expectedE = new Float64Array( [ 1.0, 2.0 ] ); + + info = dpttrf( N, D, E ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( E, expectedE, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js index c7598789d453..a7ff392364f1 100644 --- a/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dpttrf/test/test.ndarray.js @@ -71,6 +71,35 @@ tape( 'the function has an arity of 7', function test( t ) { t.end(); }); +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var D; + var E; + var i; + + values = [ + -1, + -2, + -3, + -4, + -5 + ]; + + D = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + E = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dpttrf( value, D, 1, 0, E, 1, 0 ); + }; + } +}); + tape( 'the function computes the `L * D * L^T` factorization of a real symmetric positive definite tridiagonal matrix `A`', function test( t ) { var expectedD; var expectedE; @@ -203,3 +232,56 @@ tape( 'the function supports providing negative strides', function test( t ) { t.end(); }); + +tape( 'the function returns a non-zero status code when a diagonal element is less than or equal to zero', function test( t ) { + var info; + var D; + var E; + var N; + + N = 3; + + D = new Float64Array( [ 0.0, 5.0, 6.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + info = dpttrf( N, D, 1, 0, E, 1, 0 ); + t.strictEqual( info, 1, 'returns expected value' ); + + D = new Float64Array( [ 4.0, 0.0, 6.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + info = dpttrf( N, D, 1, 0, E, 1, 0 ); + t.strictEqual( info, 2, 'returns expected value' ); + + D = new Float64Array( [ 4.0, 5.0, 0.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + info = dpttrf( N, D, 1, 0, E, 1, 0 ); + t.strictEqual( info, 3, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function leaves the input arrays unchanged when `N` is equal to zero', function test( t ) { + var expectedD; + var expectedE; + var info; + var D; + var E; + var N; + + N = 0; + + D = new Float64Array( [ 4.0, 5.0, 6.0 ] ); + E = new Float64Array( [ 1.0, 2.0 ] ); + + expectedD = new Float64Array( [ 4.0, 5.0, 6.0 ] ); + expectedE = new Float64Array( [ 1.0, 2.0 ] ); + + info = dpttrf( N, D, 1, 0, E, 1, 0 ); + t.strictEqual( info, 0, 'returns expected value' ); + t.deepEqual( D, expectedD, 'returns expected value' ); + t.deepEqual( E, expectedE, 'returns expected value' ); + + t.end(); +});