diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/README.md b/lib/node_modules/@stdlib/lapack/base/dlamch/README.md new file mode 100644 index 000000000000..ee86f565557f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/README.md @@ -0,0 +1,203 @@ + + +# dlamch + +> Determine double-precision floating-point machine parameters. + +
+ +## Usage + +```javascript +var dlamch = require( '@stdlib/lapack/base/dlamch' ); +``` + +#### dlamch( cmach ) + +Determines double-precision floating-point machine parameters. + +```javascript +var out = dlamch( 'E' ); +// returns 1.1102230246251565e-16 +``` + +The function has the following parameters: + +- **cmach**: specifies the value to be returned. The following characters are supported: + + - `'E'`/`'e'`: (eps) relative machine precision. + - `'S'`/`'s'`: (sfmin) safe minimum such that `1/sfmin` does not overflow. + - `'B'`/`'b'`: (base) base of the machine (also known as the floating-point radix). + - `'P'`/`'p'`: (prec) `eps*base`. + - `'N'`/`'n'`: (t) number of (base) digits in the mantissa. + - `'R'`/`'r'`: (rnd) `1.0` when rounding occurs in addition and `0.0` otherwise. + - `'M'`/`'m'`: (emin) minimum exponent before (gradual) underflow. + - `'U'`/`'u'`: (rmin) underflow threshold. + - `'L'`/`'l'`: (emax) largest exponent before overflow. + - `'O'`/`'o'`: (rmax) overflow threshold. + +
+ + + +
+ +## Notes + +- `dlamch()` corresponds to the [LAPACK][lapack] function [`dlamch`][lapack-dlamch]. + +
+ + + +
+ +## Examples + + + +```javascript +var dlamch = require( '@stdlib/lapack/base/dlamch' ); + +var out = dlamch( 'E' ); +console.log( 'Precision: %d', out ); + +out = dlamch( 'S' ); +console.log( 'Safe minimum: %d', out ); + +out = dlamch( 'B' ); +console.log( 'Base: %d', out ); + +out = dlamch( 'P' ); +console.log( 'Precision*base: %d', out ); + +out = dlamch( 'N' ); +console.log( 'Number of digits in mantissa: %d', out ); + +out = dlamch( 'R' ); +console.log( 'Rounding: %d', out ); + +out = dlamch( 'M' ); +console.log( 'Minimum exponent before underflow: %d', out ); + +out = dlamch( 'U' ); +console.log( 'Underflow threshold: %d', out ); + +out = dlamch( 'L' ); +console.log( 'Maximum exponent before overflow: %d', out ); + +out = dlamch( 'O' ); +console.log( 'Overflow threshold: %d', out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlamch/benchmark/benchmark.js new file mode 100644 index 000000000000..4a8ee3b15862 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/benchmark/benchmark.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pkg = require( './../package.json' ).name; +var dlamch = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var i; + + values = [ + 'E', + 'S', + 'B', + 'P', + 'N', + 'R', + 'M', + 'U', + 'L', + 'O', + 'e', + 's', + 'b', + 'p', + 'n', + 'r', + 'm', + 'u', + 'l', + 'o' + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = dlamch( values[ i%values.length ] ); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlamch/docs/repl.txt new file mode 100644 index 000000000000..4429304e1acf --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/docs/repl.txt @@ -0,0 +1,42 @@ + +{{alias}}( cmach ) + Determines double-precision floating-point machine parameters. + + The `cmach` parameter is a string which specifies the double-precision + machine parameter to be returned. The function recognizes the following + characters: + + - 'E'/'e': (eps) relative machine precision. + - 'S'/'s': (sfmin) safe minimum such that `1/sfmin` does not overflow. + - 'B'/'b': (base) base of the machine (also known as the radix). + - 'P'/'p': (prec) `eps*base`. + - 'N'/'n': (t) number of (base) digits in the mantissa. + - 'R'/'r': (rnd) `1.0` when rounding occurs in addition and `0.0` otherwise. + - 'M'/'m': (emin) minimum exponent before (gradual) underflow. + - 'U'/'u': (rmin) underflow threshold. + - 'L'/'l': (emax) largest exponent before overflow. + - 'O'/'o': (rmax) overflow threshold. + + Parameters + ---------- + cmach: string + Specifies the value to be returned. + + Returns + ------- + out: number + Machine parameter. + + Examples + -------- + > var y = {{alias}}( 'E' ) + 1.1102230246251565e-16 + > y = {{alias}}( 'S' ) + 2.2250738585072014e-308 + > y = {{alias}}( 'B' ) + 2.0 + > y = {{alias}}( 'P' ) + 2.2204460492503131e-16 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/index.d.ts new file mode 100644 index 000000000000..17cf2d14f088 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/index.d.ts @@ -0,0 +1,62 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Parameter type. +*/ +type CMACH = 'E' | 'e' | 'S' | 's' | 'B' | 'b' | 'P' | 'p' | 'N' | 'n' | 'R' | 'r' | 'M' | 'm' | 'U' | 'u' | 'L' | 'l' | 'O' | 'o'; + +/** +* Determines double-precision floating-point machine parameters. +* +* ## Notes +* +* - The `cmach` parameter is a string which specifies the double-precision machine parameter to be returned. The function recognizes the following characters: +* +* - `'E'`/`'e'`: (eps) relative machine precision. +* - `'S'`/`'s'`: (sfmin) safe minimum such that `1/sfmin` does not overflow. +* - `'B'`/`'b'`: (base) base of the machine (also known as the floating-point radix). +* - `'P'`/`'p'`: (prec) `eps*base`. +* - `'N'`/`'n'`: (t) number of (base) digits in the mantissa. +* - `'R'`/`'r'`: (rnd) `1.0` when rounding occurs in addition and `0.0` otherwise. +* - `'M'`/`'m'`: (emin) minimum exponent before (gradual) underflow. +* - `'U'`/`'u'`: (rmin) underflow threshold. +* - `'L'`/`'l'`: (emax) largest exponent before overflow. +* - `'O'`/`'o'`: (rmax) overflow threshold. +* +* @param cmach - specifies the value to be returned +* @returns machine parameter +* +* @example +* var out = dlamch( 'E' ); +* // returns ~1.1102230246251565E-016 +* +* out = dlamch( 'S' ); +* // returns ~2.2250738585072014E-308 +* +* out = dlamch( 'B' ); +* // returns 2.0 +*/ +declare function dlamch( x: CMACH | string ): number; + + +// EXPORTS // + +export = dlamch; diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/test.ts new file mode 100644 index 000000000000..4bc3ff164a04 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/test.ts @@ -0,0 +1,45 @@ +/* +* @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. +*/ + +import dlamch = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + dlamch( 'E' ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a string... +{ + dlamch( true ); // $ExpectError + dlamch( false ); // $ExpectError + dlamch( null ); // $ExpectError + dlamch( undefined ); // $ExpectError + dlamch( 5 ); // $ExpectError + dlamch( [] ); // $ExpectError + dlamch( {} ); // $ExpectError + dlamch( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + dlamch(); // $ExpectError + dlamch( 'E', 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlamch/examples/index.js new file mode 100644 index 000000000000..bacc57fa50e4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/examples/index.js @@ -0,0 +1,51 @@ +/** +* @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 dlamch = require( './../lib' ); + +var out = dlamch( 'E' ); +console.log( 'Precision: %d', out ); + +out = dlamch( 'S' ); +console.log( 'Safe minimum: %d', out ); + +out = dlamch( 'B' ); +console.log( 'Base: %d', out ); + +out = dlamch( 'P' ); +console.log( 'Precision*base: %d', out ); + +out = dlamch( 'N' ); +console.log( 'Number of digits in mantissa: %d', out ); + +out = dlamch( 'R' ); +console.log( 'Rounding: %d', out ); + +out = dlamch( 'M' ); +console.log( 'Minimum exponent before underflow: %d', out ); + +out = dlamch( 'U' ); +console.log( 'Underflow threshold: %d', out ); + +out = dlamch( 'L' ); +console.log( 'Maximum exponent before overflow: %d', out ); + +out = dlamch( 'O' ); +console.log( 'Overflow threshold: %d', out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlamch/lib/index.js new file mode 100644 index 000000000000..d97d57e35ef5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/lib/index.js @@ -0,0 +1,46 @@ +/** +* @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'; + +/** +* Determine double-precision floating-point machine parameters. +* +* @module @stdlib/lapack/base/dlamch +* +* @example +* var dlamch = require( '@stdlib/lapack/base/dlamch' ); +* +* var out = dlamch( 'E' ); +* // returns ~1.1102230246251565E-016 +* +* out = dlamch( 'S' ); +* // returns ~2.2250738585072014E-308 +* +* out = dlamch( 'B' ); +* // returns 2.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlamch/lib/main.js new file mode 100644 index 000000000000..30d5a958b629 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/lib/main.js @@ -0,0 +1,108 @@ +/** +* @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 FLOAT64_EPS = require( '@stdlib/constants/float64/eps' ); +var FLOAT64_SMALLEST_NORMAL = require( '@stdlib/constants/float64/smallest-normal' ); +var FLOAT64_MIN_EXPONENT = require( '@stdlib/constants/float64/min-base2-exponent' ); +var FLOAT64_MAX_EXPONENT = require( '@stdlib/constants/float64/max-base2-exponent' ); +var FLOAT64_MAX = require( '@stdlib/constants/float64/max' ); +var FLOAT64_PRECISION = require( '@stdlib/constants/float64/precision' ); +var lowercase = require( '@stdlib/string/base/lowercase' ); + + +// VARIABLES // + +var RADIX = 2.0; + + +// MAIN // + +/** +* Determines double-precision floating-point machine parameters. +* +* ## Notes +* +* - The `cmach` parameter is a string which specifies the double-precision machine parameter to be returned. The function recognizes the following characters: +* +* - `'E'`/`'e'`: (eps) relative machine precision. +* - `'S'`/`'s'`: (sfmin) safe minimum such that `1/sfmin` does not overflow. +* - `'B'`/`'b'`: (base) base of the machine (also known as the floating-point radix). +* - `'P'`/`'p'`: (prec) `eps*base`. +* - `'N'`/`'n'`: (t) number of (base) digits in the mantissa. +* - `'R'`/`'r'`: (rnd) `1.0` when rounding occurs in addition and `0.0` otherwise. +* - `'M'`/`'m'`: (emin) minimum exponent before (gradual) underflow. +* - `'U'`/`'u'`: (rmin) underflow threshold. +* - `'L'`/`'l'`: (emax) largest exponent before overflow. +* - `'O'`/`'o'`: (rmax) overflow threshold. +* +* @param {string} cmach - specifies the value to be returned +* @returns {number} machine parameter +* +* @example +* var out = dlamch( 'E' ); +* // returns ~1.1102230246251565e-016 +* +* out = dlamch( 'S' ); +* // returns ~2.2250738585072014e-308 +* +* out = dlamch( 'B' ); +* // returns 2.0 +*/ +function dlamch( cmach ) { + cmach = lowercase( cmach.charAt( 0 ) ); + if ( cmach === 'e' ) { + return FLOAT64_EPS * 0.5; + } + if ( cmach === 's' ) { + return FLOAT64_SMALLEST_NORMAL; + } + if ( cmach === 'b' ) { + return RADIX; + } + if ( cmach === 'p' ) { + return FLOAT64_EPS * 0.5 * RADIX; + } + if ( cmach === 'n' ) { + return FLOAT64_PRECISION; + } + if ( cmach === 'r' ) { + return 1.0; + } + if ( cmach === 'm' ) { + return FLOAT64_MIN_EXPONENT + 1; + } + if ( cmach === 'u' ) { + return FLOAT64_SMALLEST_NORMAL; + } + if ( cmach === 'l' ) { + return FLOAT64_MAX_EXPONENT + 1; + } + if ( cmach === 'o' ) { + return FLOAT64_MAX; + } + return 0.0; +} + + +// EXPORTS // + +module.exports = dlamch; diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/package.json b/lib/node_modules/@stdlib/lapack/base/dlamch/package.json new file mode 100644 index 000000000000..3f80dc1f6353 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/lapack/base/dlamch", + "version": "0.0.0", + "description": "Determine double-precision floating-point machine parameters.", + "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", + "dlamch", + "linear", + "algebra", + "subroutines", + "float64", + "double" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js new file mode 100644 index 000000000000..799d85001508 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js @@ -0,0 +1,113 @@ +/** +* @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 dlamch = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlamch, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns machine parameters', function test( t ) { + var expected; + var values; + var actual; + var i; + + values = [ + 'E', + 'S', + 'B', + 'P', + 'N', + 'R', + 'M', + 'U', + 'L', + 'O', + 'e', + 's', + 'b', + 'p', + 'n', + 'r', + 'm', + 'u', + 'l', + 'o' + ]; + + expected = [ + 1.1102230246251565e-16, + 2.2250738585072014e-308, + 2.0, + 2.2204460492503131e-16, + 53.0, + 1.0, + -1021.0, + 2.2250738585072014e-308, + 1024.0, + 1.7976931348623157e+308, + 1.1102230246251565e-16, + 2.2250738585072014e-308, + 2.0, + 2.2204460492503131e-16, + 53.0, + 1.0, + -1021.0, + 2.2250738585072014e-308, + 1024.0, + 1.7976931348623157e+308 + ]; + + for ( i = 0; i < values.length; i++ ) { + actual = dlamch( values[ i ] ); + t.strictEqual( actual, expected[ i ], 'returns expected value for '+values[i] ); + } + t.end(); +}); + +tape( 'the function returns `0` if provided an unrecognized string', function test( t ) { + var expected; + var values; + var actual; + var i; + + values = [ + '__foo__', + '**bar**', + '&&beep&&' + ]; + + expected = 0.0; + + for ( i = 0; i < values.length; i++ ) { + actual = dlamch( values[ i ] ); + t.strictEqual( actual, expected, 'returns expected value for '+values[i] ); + } + t.end(); +});