From e72b6da836be74be61cd065f619ca245f26e626f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 10 Aug 2024 16:48:24 +0530 Subject: [PATCH] feat: add lapack/base/dptcon --- .../@stdlib/lapack/base/dptcon/README.md | 262 ++++++++++++ .../lapack/base/dptcon/benchmark/benchmark.js | 100 +++++ .../dptcon/benchmark/benchmark.ndarray.js | 100 +++++ .../@stdlib/lapack/base/dptcon/docs/repl.txt | 126 ++++++ .../lapack/base/dptcon/docs/types/index.d.ts | 132 ++++++ .../lapack/base/dptcon/docs/types/test.ts | 404 ++++++++++++++++++ .../lapack/base/dptcon/examples/index.js | 32 ++ .../@stdlib/lapack/base/dptcon/lib/base.js | 114 +++++ .../@stdlib/lapack/base/dptcon/lib/dptcon.js | 57 +++ .../@stdlib/lapack/base/dptcon/lib/index.js | 72 ++++ .../@stdlib/lapack/base/dptcon/lib/main.js | 35 ++ .../@stdlib/lapack/base/dptcon/lib/ndarray.js | 66 +++ .../@stdlib/lapack/base/dptcon/package.json | 69 +++ .../lapack/base/dptcon/test/test.dptcon.js | 132 ++++++ .../@stdlib/lapack/base/dptcon/test/test.js | 82 ++++ .../lapack/base/dptcon/test/test.ndarray.js | 92 ++++ 16 files changed, 1875 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/lib/dptcon.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/test/test.dptcon.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dptcon/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/README.md b/lib/node_modules/@stdlib/lapack/base/dptcon/README.md new file mode 100644 index 00000000000..ff7a0aa876d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/README.md @@ -0,0 +1,262 @@ + + +# dptcon + +> Compute the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T`. + +
+ +## Usage + +```javascript +var dptcon = require( '@stdlib/lapack/base/dptcon' ); +``` + +#### dptcon( N, D, E, anorm, rcond, work ) + +Computes the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T`. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +var E = new Float64Array( [ 1.0, 1.0 ] ); +var rcond = new Float64Array( 1 ); +var work = new Float64Array( 3 ); + +var out = dptcon( 3, D, E, 3.0, rcond, work ); +// returns 0 +``` + +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 off-diagonal elements of `U` or `L` from the factorization `A`. +- **anorm**: the 1-norm of `A`. +- **rcond**: an output [`Float64Array`][mdn-float64array] containing the reciprocal of the condition number of `A` +- **work**: a workspace array. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var D0 = new Float64Array( [ 0.0, 3.0, 2.0, 1.0 ] ); +var E0 = new Float64Array( [ 0.0, 1.0, 1.0 ] ); +var RCOND0 = new Float64Array( [ 0.0, 0.0 ] ); +var WORK0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0] ); + +// Create offset views... +var D1 = new Float64Array( D0.buffer, D0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var E1 = new Float64Array( E0.buffer, E0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var RCOND1 = new Float64Array( RCOND0.buffer, RCOND0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var WORK1 = new Float64Array( WORK0.buffer, WORK0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dptcon( 3, D1, E1, 3.0, RCOND1, WORK1 ); +// RCOND0 => [ 0.0, 0.07692307692307693 ] +// WORK0 => [ 0.0, 4.333333333333333, 4.0, 3.0 ] +``` + +#### dptcon.ndarray( N, D, sd, od, E, se, oe, anorm, rc, or, work, sw, ow ) + +Computes the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T` and alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +var E = new Float64Array( [ 1.0, 1.0 ] ); +var rcond = new Float64Array( 1 ); +var work = new Float64Array( 3 ); + +var out = dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); +// returns 0 +``` + +The function has the following additional parameters: + +- **sd**: stride length for `D`. +- **od**: starting index for `D`. +- **se**: stride length for `E`. +- **oe**: starting index for `E`. +- **or**: starting index for `rcond`. +- **sw**: stride length for `work`. +- **ow**: starting index for `work`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var D = new Float64Array( [ 0.0, 3.0, 2.0, 1.0 ] ); +var E = new Float64Array( [ 0.0, 1.0, 1.0 ] ); +var rcond = new Float64Array( 1 ); +var work = new Float64Array( 3 ); + +var out = dptcon.ndarray( 3, D, 1, 1, E, 1, 1, 3.0, rcond, 0, work, 1, 0 ); +// returns 0 +``` + +
+ + + +
+ +## Notes + +- 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`: the execution was successful. + - `<0`: the k-th argument had an illegal value, where `-k` equals the status code value. + +- `dptcon()` corresponds to the [LAPACK][LAPACK] routine [`dptcon`][lapack-dptcon]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dptcon = require( '@stdlib/lapack/base/dptcon' ); + +var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +var E = new Float64Array( [ 1.0, 1.0 ] ); +var rcond = new Float64Array( 1 ); +var work = new Float64Array( 3 ); + +var out = dptcon( 3, D, E, 3.0, rcond, work ); +console.log( out ); +console.log( rcond ); +console.log( work ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dptcon/benchmark/benchmark.js new file mode 100644 index 00000000000..db35f3cb31a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/benchmark/benchmark.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dptcon = require( './../lib/dptcon.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 rcond = new Float64Array( 1 ); + var work = new Float64Array( len ); + var D = uniform( len, 0.0, 100.0, options ); + var E = uniform( len - 1, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dptcon( len, D, E, 3.0, rcond, work ); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) ) { + 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/dptcon/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptcon/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..6687f9514b9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/benchmark/benchmark.ndarray.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dptcon = 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 rcond = new Float64Array( 1 ); + var work = new Float64Array( len ); + var D = uniform( len, 0.0, 100.0, options ); + var E = uniform( len - 1, 0.0, 100.0, options ); + return benchmark; + + function benchmark( b ) { + var d; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + d = dptcon( len, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); + if ( isnan( d ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( d ) ) { + 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(); diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dptcon/docs/repl.txt new file mode 100644 index 00000000000..095be96882a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/docs/repl.txt @@ -0,0 +1,126 @@ + +{{alias}}( N, D, E, anorm, rcond, work ) + Computes the reciprocal of the condition number of a real symmetric + positive definite tridiagonal matrix using the factorization `A = L*D*L^T`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + Parameters + ---------- + N: integer + Order of matrix `A`. + + D: Float64Array + The `N` diagonal elements of `A`. + + E: Float64Array + The `N-1` off-diagonal elements of `U` or `L` from the factorization + `A`. + + anorm: number + The 1-norm of `A`. + + rcond: Float64Array + Output array containing the reciprocal condition number of `A`. + + work: Float64Array + Workspace array. + + Returns + ------- + info: integer + 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`. + + Examples + -------- + > var D = new {{alias:@stdlib/array/float64}}( [ 3.0, 2.0, 1.0 ] ); + > var E = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var rcond = new {{alias:@stdlib/array/float64}}( 1 ); + > var work = new {{alias:@stdlib/array/float64}}( 3 ); + > {{alias}}( 3, D, E, 3.0, rcond, work ) + 0 + > rcond + [ 0.07692307692307693 ] + > work + [ 4.333333333333333, 4.0, 3.0 ] + + +{{alias}}.ndarray( N, D, sd, od, E, se, oe, anorm, rc, or, work, sw, ow ) + Computes the reciprocal of the condition number of a real symmetric + positive definite tridiagonal matrix using the factorization + `A = L*D*L^T` and 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 + The `N` diagonal elements of `A`. + + sd: integer + Stride length for `D`. + + od: integer + Starting index for `D`. + + E: Float64Array + The `N-1` off-diagonal elements of `U` or `L` from the factorization + `A`. + + se: integer + Stride length for `E`. + + oe: integer + Starting index for `E`. + + anorm: number + The 1-norm of `A`. + + rc: Float64Array + Output array containing the reciprocal condition number of `A`. + + or: integer + Starting index for `rc`. + + work: Float64Array + Workspace array. + + sw: integer + Stride length for `work`. + + ow: integer + Starting index for `work`. + + Returns + ------- + info: integer + 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`. + + Examples + -------- + > var D = new {{alias:@stdlib/array/float64}}( [ 0.0, 3.0, 2.0, 1.0 ] ); + > var E = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] ); + > var rcond = new {{alias:@stdlib/array/float64}}( 1 ); + > var work = new {{alias:@stdlib/array/float64}}( 3 ); + > {{alias}}.ndarray( 3, D, 1, 1, E, 1, 1, 3.0, rcond, 0, work, 1, 0 ) + 0 + > rcond + [ 0.07692307692307693 ] + > work + [ 4.333333333333333, 4.0, 3.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dptcon/docs/types/index.d.ts new file mode 100644 index 00000000000..039abf26862 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/docs/types/index.d.ts @@ -0,0 +1,132 @@ +/** +* @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 + +/** +* 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 `dptcon`. +*/ +interface Routine { + /** + * Computes the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T`. + * + * @param N - order of matrix `A` + * @param D - `N` diagonal elements of matrix `D` from the factorization `A = L*D*L^T` + * @param E - `N-1` off-diagonal elements of matrix `U` or `L` from the factorization `A` + * @param anorm - 1-norm of `A` + * @param rcond - array containing the reciprocal of the condition number of `A` + * @param work - workspace array + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + * var E = new Float64Array( [ 1.0, 1.0 ] ); + * var rcond = new Float64Array( 1 ); + * var work = new Float64Array( 3 ); + * + * var out = dptcon( 3, D, E, 3.0, rcond, work ); + * // returns 0 + */ + ( N: number, D: Float64Array, E: Float64Array, anorm: number, rcond: Float64Array, work: Float64Array ): StatusCode; + + /** + * Computes the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T` and alternative indexing semantics. + * + * @param N - order of matrix `A` + * @param D - `N` diagonal elements of matrix `D` from the factorization `A = L*D*L^T` + * @param strideD - stride length for `D` + * @param offsetD - starting index of `D` + * @param E - `N-1` off-diagonal elements of matrix `U` or `L` from the factorization `A` + * @param strideE - stride length for `E` + * @param offsetE - starting index of `E` + * @param anorm - 1-norm of `A` + * @param rcond - array containing the reciprocal of the condition number of `A` + * @param offsetR - starting index of `rcond` + * @param work - workspace array + * @param strideW - stride length for `work` + * @param offsetW - starting index of `work` + * @returns status code + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + * var E = new Float64Array( [ 1.0, 1.0 ] ); + * var rcond = new Float64Array( 1 ); + * var work = new Float64Array( 3 ); + * + * var out = dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); + * // returns 0 + */ + ndarray( N: number, D: Float64Array, strideD: number, offsetD: number, E: Float64Array, strideE: number, offsetE: number, anorm: number, rcond: Float64Array, offsetR: number, work: Float64Array, strideW: number, offsetW: number ): StatusCode; +} + +/** +* Computes the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T`. +* +* @param N - order of matrix `A` +* @param D - `N` diagonal elements of matrix `D` from the factorization `A = L*D*L^T` +* @param E - `N-1` off-diagonal elements of matrix `U` or `L` from the factorization `A` +* @param anorm - 1-norm of `A` +* @param rcond - array containing the reciprocal of the condition number of `A` +* @param work - workspace array +* @returns status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +* var E = new Float64Array( [ 1.0, 1.0 ] ); +* var rcond = new Float64Array( 1 ); +* var work = new Float64Array( 3 ); +* +* var out = dptcon( 3, D, E, 3.0, rcond, work ); +* // returns 0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +* var E = new Float64Array( [ 1.0, 1.0 ] ); +* var rcond = new Float64Array( 1 ); +* var work = new Float64Array( 3 ); +* +* var out = dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); +* // returns 0 +*/ +declare var dptcon: Routine; + + +// EXPORTS // + +export = dptcon; diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dptcon/docs/types/test.ts new file mode 100644 index 00000000000..0b5841b98bd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/docs/types/test.ts @@ -0,0 +1,404 @@ +/* +* @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 dptcon = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon( 3, D, E, 3.0, rcond, work ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon( '5', D, E, 3.0, rcond, work ); // $ExpectError + dptcon( true, D, E, 3.0, rcond, work ); // $ExpectError + dptcon( false, D, E, 3.0, rcond, work ); // $ExpectError + dptcon( null, D, E, 3.0, rcond, work ); // $ExpectError + dptcon( void 0, D, E, 3.0, rcond, work ); // $ExpectError + dptcon( [], D, E, 3.0, rcond, work ); // $ExpectError + dptcon( {}, D, E, 3.0, rcond, work ); // $ExpectError + dptcon( ( x: number ): number => x, D, E, 3.0, rcond, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon( 3, '5', E, 3.0, rcond, work ); // $ExpectError + dptcon( 3, 5, E, 3.0, rcond, work ); // $ExpectError + dptcon( 3, true, E, 3.0, rcond, work ); // $ExpectError + dptcon( 3, false, E, 3.0, rcond, work ); // $ExpectError + dptcon( 3, null, E, 3.0, rcond, work ); // $ExpectError + dptcon( 3, void 0, E, 3.0, rcond, work ); // $ExpectError + dptcon( 3, [], E, 3.0, rcond, work ); // $ExpectError + dptcon( 3, {}, E, 3.0, rcond, work ); // $ExpectError + dptcon( 3, ( x: number ): number => x, E, 3.0, rcond, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon( 3, D, '5', 3.0, rcond, work ); // $ExpectError + dptcon( 3, D, 5, 3.0, rcond, work ); // $ExpectError + dptcon( 3, D, true, 3.0, rcond, work ); // $ExpectError + dptcon( 3, D, false, 3.0, rcond, work ); // $ExpectError + dptcon( 3, D, null, 3.0, rcond, work ); // $ExpectError + dptcon( 3, D, void 0, 3.0, rcond, work ); // $ExpectError + dptcon( 3, D, [], 3.0, rcond, work ); // $ExpectError + dptcon( 3, D, {}, 3.0, rcond, work ); // $ExpectError + dptcon( 3, D, ( x: number ): number => x, 3.0, rcond, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon( 3, D, E, '5', rcond, work ); // $ExpectError + dptcon( 3, D, E, true, rcond, work ); // $ExpectError + dptcon( 3, D, E, false, rcond, work ); // $ExpectError + dptcon( 3, D, E, null, rcond, work ); // $ExpectError + dptcon( 3, D, E, void 0, rcond, work ); // $ExpectError + dptcon( 3, D, E, [], rcond, work ); // $ExpectError + dptcon( 3, D, E, {}, rcond, work ); // $ExpectError + dptcon( 3, D, E, ( x: number ): number => x, rcond, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon( 3, D, E, 3.0, '5', work ); // $ExpectError + dptcon( 3, D, E, 3.0, 5, work ); // $ExpectError + dptcon( 3, D, E, 3.0, true, work ); // $ExpectError + dptcon( 3, D, E, 3.0, false, work ); // $ExpectError + dptcon( 3, D, E, 3.0, null, work ); // $ExpectError + dptcon( 3, D, E, 3.0, void 0, work ); // $ExpectError + dptcon( 3, D, E, 3.0, [], work ); // $ExpectError + dptcon( 3, D, E, 3.0, {}, work ); // $ExpectError + dptcon( 3, D, E, 3.0, ( x: number ): number => x, work ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + + dptcon( 3, D, E, 3.0, rcond, '5' ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, 5 ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, true ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, false ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, null ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, void 0 ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, [] ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, {} ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon(); // $ExpectError + dptcon( 3 ); // $ExpectError + dptcon( 3, D ); // $ExpectError + dptcon( 3, D, E ); // $ExpectError + dptcon( 3, D, E, 3.0 ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond ); // $ExpectError + dptcon( 3, D, E, 3.0, rcond, work, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( '5', D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( true, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( false, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( null, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( void 0, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( [], D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( {}, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( ( x: number ): number => x, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, '5', 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, 5, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, true, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, false, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, null, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, void 0, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, [], 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, {}, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, ( x: number ): number => x, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, '5', 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, true, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, false, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, null, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, void 0, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, [], 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, {}, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, ( x: number ): number => x, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, '5', E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, true, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, false, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, null, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, void 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, [], E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, {}, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, ( x: number ): number => x, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, '5', 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, 5, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, true, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, false, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, null, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, void 0, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, [], 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, {}, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, ( x: number ): number => x, 1, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, E, '5', 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, true, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, false, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, null, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, void 0, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, [], 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, {}, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, ( x: number ): number => x, 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, E, 1, '5', 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, true, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, false, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, null, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, void 0, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, [], 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, {}, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, ( x: number ): number => x, 3.0, rcond, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, '5', rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, true, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, false, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, null, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, void 0, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, [], rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, {}, rcond, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, ( x: number ): number => x, rcond, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, '5', 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, 5, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, true, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, false, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, null, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, void 0, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, [], 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, {}, 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, ( x: number ): number => x, 0, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, '5', work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, true, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, false, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, null, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, void 0, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, [], work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, {}, work, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, ( x: number ): number => x, work, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a Float64Array... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, '5', 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, 5, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, true, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, false, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, null, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, void 0, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, [], 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, {}, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, '5', 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, true, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, false, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, null, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, void 0, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, [], 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, {}, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, '5' ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, true ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, false ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, null ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, void 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, [] ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, {} ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + const E = new Float64Array( [ 1.0, 1.0 ] ); + const rcond = new Float64Array( [ 0.0 ] ); + const work = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + + dptcon.ndarray(); // $ExpectError + dptcon.ndarray( 3 ); // $ExpectError + dptcon.ndarray( 3, D ); // $ExpectError + dptcon.ndarray( 3, D, 1 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1 ); // $ExpectError + dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dptcon/examples/index.js new file mode 100644 index 00000000000..d398c7f73eb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/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 dptcon = require( './../lib/' ); + +var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +var E = new Float64Array( [ 1.0, 1.0 ] ); +var rcond = new Float64Array( 1 ); +var work = new Float64Array( 3 ); + +var out = dptcon( 3, D, E, 3.0, rcond, work ); +console.log( out ); +console.log( rcond ); +console.log( work ); diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/base.js new file mode 100644 index 00000000000..02b07c142b2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/base.js @@ -0,0 +1,114 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var idamax = require( '@stdlib/blas/base/idamax' ).ndarray; +var abs = require( '@stdlib/math/base/special/abs' ); + + +// MAIN // + +/** +* Computes the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T`. +* +* @private +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} D - `N` diagonal elements of matrix `D` from the factorization `A = L*D*L^T` +* @param {integer} strideD - stride length for `D` +* @param {NonNegativeInteger} offsetD - starting index of `D` +* @param {Float64Array} E - `N-1` off-diagonal elements of matrix `U` or `L` from the factorization `A` +* @param {integer} strideE - stride length for `E` +* @param {NonNegativeInteger} offsetE - starting index of `E` +* @param {number} anorm - 1-norm of `A` +* @param {Float64Array} rcond - array containing the reciprocal of the condition number of `A` +* @param {NonNegativeInteger} offsetR - starting index of `rcond` +* @param {Float64Array} work - workspace array +* @param {integer} strideW - stride length for `work` +* @param {NonNegativeInteger} offsetW - starting index of `work` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +* var E = new Float64Array( [ 1.0, 1.0 ] ); +* var rcond = new Float64Array( 1 ); +* var work = new Float64Array( 3 ); +* +* var out = dptcon( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); +* // returns 0 +*/ +function dptcon( N, D, strideD, offsetD, E, strideE, offsetE, anorm, rcond, offsetR, work, strideW, offsetW ) { + var ainvnm; + var ix; + var i; + + if ( N < 0 ) { + return -1; + } + if ( anorm < 0.0 ) { + return -4; + } + + rcond[ offsetR ] = 0.0; + if ( N === 0 ) { + rcond[ offsetR ] = 1.0; + return 0; + } + if ( anorm === 0.0 ) { + return 0; + } + + // Check that D(1:N) is positive. + for ( i = 0; i < N; i++ ) { + if ( D[ offsetD + ( i * strideD ) ] <= 0.0 ) { + return 0; + } + } + + work[ offsetW ] = 1.0; + for ( i = 1; i < N; i++ ) { + work[ offsetW + ( i * strideW ) ] = 1.0 + ( work[ offsetW + ( ( i - 1 ) * strideW ) ] * abs( E[ offsetE + ( ( i - 1 ) * strideE ) ] ) ); + } + + // Solve `D*M(L)^T*x = b`. + work[ offsetW + ( ( N - 1 ) * strideW ) ] /= D[ offsetD + ( ( N - 1 ) * strideD ) ]; + for ( i = N - 2; i >= 0; i-- ) { + work[ offsetW + ( i * strideW ) ] = ( work[ offsetW + ( i * strideW ) ] / D[ offsetD + ( i * strideD ) ] ) + ( work[ offsetW + ( ( i + 1 ) * strideW ) ] * abs( E[ offsetE + ( i * strideE ) ] ) ); + } + + // Compute `ainvnm = max(x(i))`. + ix = idamax( N, work, strideW, offsetW ); + ainvnm = abs( work[ offsetW + ( ix * strideW ) ] ); + + // Compute the reciprocal condition number. + if ( ainvnm !== 0.0 ) { + rcond[ offsetR ] = ( 1.0 / ainvnm ) / anorm; + } + return 0; +} + + +// EXPORTS // + +module.exports = dptcon; diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/lib/dptcon.js b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/dptcon.js new file mode 100644 index 00000000000..85256a60bab --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/dptcon.js @@ -0,0 +1,57 @@ +/** +* @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 reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T`. +* +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} D - `N` diagonal elements of matrix `D` from the factorization `A = L*D*L^T` +* @param {Float64Array} E - `N-1` off-diagonal elements of matrix `U` or `L` from the factorization `A` +* @param {number} anorm - 1-norm of `A` +* @param {Float64Array} rcond - array containing the reciprocal of the condition number of `A` +* @param {Float64Array} work - workspace array +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +* var E = new Float64Array( [ 1.0, 1.0 ] ); +* var rcond = new Float64Array( 1 ); +* var work = new Float64Array( 3 ); +* +* var out = dptcon( 3, D, E, 3.0, rcond, work ); +* // returns 0 +*/ +function dptcon( N, D, E, anorm, rcond, work ) { + return base( N, D, 1, 0, E, 1, 0, anorm, rcond, 0, work, 1, 0 ); +} + + +// EXPORTS // + +module.exports = dptcon; diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/index.js new file mode 100644 index 00000000000..1bc6db518d0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to compute the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T`. +* +* @module @stdlib/lapack/base/dptcon +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dptcon = require( '@stdlib/lapack/base/dptcon' ); +* +* var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +* var E = new Float64Array( [ 1.0, 1.0 ] ); +* var rcond = new Float64Array( 1 ); +* var work = new Float64Array( 3 ); +* +* var out = dptcon( 3, D, E, 3.0, rcond, work ); +* // returns 0 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dptcon = require( '@stdlib/lapack/base/dptcon' ); +* +* var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +* var E = new Float64Array( [ 1.0, 1.0 ] ); +* var rcond = new Float64Array( 1 ); +* var work = new Float64Array( 3 ); +* +* var out = dptcon.ndarray( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); +* // 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 dptcon; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dptcon = main; +} else { + dptcon = tmp; +} + + +// EXPORTS // + +module.exports = dptcon; diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/main.js new file mode 100644 index 00000000000..b0c60df5d11 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/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 dptcon = require( './dptcon.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dptcon, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dptcon; diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/ndarray.js new file mode 100644 index 00000000000..e2d5e1b195e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/lib/ndarray.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Computes the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T` and alternative indexing semantics. +* +* @param {NonNegativeInteger} N - order of matrix `A` +* @param {Float64Array} D - `N` diagonal elements of matrix `D` from the factorization `A = L*D*L^T` +* @param {integer} strideD - stride length for `D` +* @param {NonNegativeInteger} offsetD - starting index of `D` +* @param {Float64Array} E - `N-1` off-diagonal elements of matrix `U` or `L` from the factorization `A` +* @param {integer} strideE - stride length for `E` +* @param {NonNegativeInteger} offsetE - starting index of `E` +* @param {number} anorm - 1-norm of `A` +* @param {Float64Array} rcond - array containing the reciprocal of the condition number of `A` +* @param {NonNegativeInteger} offsetR - starting index of `rcond` +* @param {Float64Array} work - workspace array +* @param {integer} strideW - stride length for `work` +* @param {NonNegativeInteger} offsetW - starting index of `work` +* @returns {integer} status code +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); +* var E = new Float64Array( [ 1.0, 1.0 ] ); +* var rcond = new Float64Array( 1 ); +* var work = new Float64Array( 3 ); +* +* var out = dptcon( 3, D, 1, 0, E, 1, 0, 3.0, rcond, 0, work, 1, 0 ); +* // returns 0 +*/ +function dptcon( N, D, strideD, offsetD, E, strideE, offsetE, anorm, rcond, offsetR, work, strideW, offsetW ) { + return base( N, D, strideD, offsetD, E, strideE, offsetE, anorm, rcond, offsetR, work, strideW, offsetW ); +} + + +// EXPORTS // + +module.exports = dptcon; diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/package.json b/lib/node_modules/@stdlib/lapack/base/dptcon/package.json new file mode 100644 index 00000000000..0c2ab450451 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dptcon", + "version": "0.0.0", + "description": "Compute the reciprocal of the condition number of a real symmetric positive definite tridiagonal matrix using the factorization `A = L*D*L^T`.", + "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", + "dptcon", + "cholesky", + "factorization", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/test/test.dptcon.js b/lib/node_modules/@stdlib/lapack/base/dptcon/test/test.dptcon.js new file mode 100644 index 00000000000..ea41b4ae60d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/test/test.dptcon.js @@ -0,0 +1,132 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dptcon = require( './../lib/dptcon.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 dptcon, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dptcon.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the function correctly computest the reciprocal of condition number', function test( t ) { + var expectedW; + var rcond; + var work; + var out; + var D; + var E; + + D = new Float64Array( [ 3.0, 2.0, 1.0 ] ); + E = new Float64Array( [ 1.0, 1.0 ] ); + rcond = new Float64Array( 1 ); + work = new Float64Array( 3 ); + + expectedW = new Float64Array( [ 4.333333333333333, 4.0, 3.0 ] ); + + out = dptcon( 3, D, E, 3.0, rcond, work ); + t.strictEqual( out, 0, 'returns expected value' ); + t.strictEqual( rcond[ 0 ], 0.07692307692307693, 'returns expected value' ); + isApprox( t, work, expectedW, 1.0 ); + t.end(); +}); + +tape( 'the function returns -1 if provided a negative value for `N`', function test( t ) { + var out; + var D; + + out = dptcon( -1, D, D, 3.0, D, D ); + t.strictEqual( out, -1, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns -4 if provided a negative value for `anorm`', function test( t ) { + var out; + var D; + + out = dptcon( 3, D, D, -3.0, D, D ); + t.strictEqual( out, -4, 'returns expected value' ); + t.end(); +}); + +tape( 'the function sets rcond to 1 if `N` is 0', function test( t ) { + var rcond; + var out; + + rcond = new Float64Array( 1 ); + out = dptcon( 0, new Float64Array( 0 ), new Float64Array( 0 ), 3.0, rcond, new Float64Array( 0 ) ); + t.strictEqual( out, 0, 'returns expected value' ); + t.strictEqual( rcond[ 0 ], 1.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function sets rcond to 0 if `anorm` is 0', function test( t ) { + var rcond; + var out; + + rcond = new Float64Array( 1 ); + out = dptcon( 3, new Float64Array( 3 ), new Float64Array( 2 ), 0.0, rcond, new Float64Array( 3 ) ); + t.strictEqual( out, 0, 'returns expected value' ); + t.strictEqual( rcond[ 0 ], 0.0, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/test/test.js b/lib/node_modules/@stdlib/lapack/base/dptcon/test/test.js new file mode 100644 index 00000000000..f08911b33a7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/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 dptcon = 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 dptcon, '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 dptcon.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 dptcon = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dptcon, 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 dptcon; + var main; + + main = require( './../lib/dptcon.js' ); + + dptcon = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dptcon, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dptcon/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dptcon/test/test.ndarray.js new file mode 100644 index 00000000000..39d5cd732b9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dptcon/test/test.ndarray.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dptcon = 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 dptcon, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( dptcon.length, 13, 'returns expected value' ); + t.end(); +}); + +tape( 'the function allows accessing elements from a strided array with different offset and order', function test( t ) { + var expectedW; + var rcond; + var work; + var out; + var D; + var E; + + D = new Float64Array( [ 999.9, 999.9, 1.0, 999.9, 2.0, 999.9, 3.0 ] ); + E = new Float64Array( [ 999.9, 1.0, 999.9, 999.9, 1.0, 999.9 ] ); + rcond = new Float64Array( [ 999.9, 999.9, 0.0, 999.9 ] ); + work = new Float64Array( [ 999.9, 999.9, 999.9, 999.9, 999.9, 999.9, 999.9, 999.9, 999.9 ] ); + + expectedW = new Float64Array( [ 999.9, 999.9, 999.9, 4.333333333333333, 999.9, 4.0, 999.9, 3.0, 999.9 ] ); + + out = dptcon( 3, D, -2, D.length - 1, E, 3, 1, 3.0, rcond, 2, work, 2, 3 ); + t.strictEqual( out, 0, 'returns expected value' ); + t.strictEqual( rcond[ 2 ], 0.07692307692307693, 'returns expected value' ); + isApprox( t, work, expectedW, 1.0 ); + t.end(); +});