From ff0a09a5f77556d6b2d5da111c2e85c99825a889 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Fri, 12 Jul 2024 10:42:56 +0530 Subject: [PATCH 01/13] feat: add lapack/base/dlamch --- .../@stdlib/lapack/base/dlamch/README.md | 170 ++++++++++++++++++ .../lapack/base/dlamch/benchmark/benchmark.js | 61 +++++++ .../@stdlib/lapack/base/dlamch/docs/repl.txt | 27 +++ .../lapack/base/dlamch/docs/types/index.d.ts | 42 +++++ .../lapack/base/dlamch/docs/types/test.ts | 45 +++++ .../lapack/base/dlamch/examples/index.js | 27 +++ .../@stdlib/lapack/base/dlamch/lib/dlamch.js | 108 +++++++++++ .../@stdlib/lapack/base/dlamch/lib/index.js | 46 +++++ .../@stdlib/lapack/base/dlamch/lib/main.js | 28 +++ .../@stdlib/lapack/base/dlamch/package.json | 64 +++++++ .../@stdlib/lapack/base/dlamch/test/test.js | 75 ++++++++ 11 files changed, 693 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/lib/dlamch.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js 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..826be23e1497 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/README.md @@ -0,0 +1,170 @@ + + +# dlamch + +> Determine double precision machine parameters. + +
+ +## Usage + +```javascript +var dlamch = require( '@stdlib/lapack/base/dlamch' ); +``` + +#### dlamch( cmach ) + +Determines double precision machine parameters. + +```javascript +var out = dlamch( 'E' ); +console.log( out ); +// => 1.1102230246251565E-016 +``` + +The function has the following parameters: + +- **cmach**: specifies the value to be returned. + +
+ + + +
+ +## Notes + +- `dlamch()` corresponds to the [LAPACK][lapack] function [`dlamch`][dlamch]. + +
+ + + +
+ +## Examples + + + +```javascript +var dlamch = require( '@stdlib/lapack/base/dlamch' ); + +var out = dlamch( 'E' ); +console.log( out ); + +out = dlamch( 'S' ); +console.log( 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..3968acbfccd4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/benchmark/benchmark.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 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' + ]; + + 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..c011cd138ae9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/docs/repl.txt @@ -0,0 +1,27 @@ + +{{alias}}( cmach ) + Determines double precision machine parameters. + + Parameters + ---------- + cmach: string + Specifies the value to be returned. + + Returns + ------- + y: number + Machine parameter. + + Examples + -------- + > var y = {{alias}}('E') + 1.1102230246251565E-016 + > y = {{alias}}('S') + 2.2250738585072014E-308 + > y = {{alias}}('B') + 2.0 + > y = {{alias}}('P') + 2.2204460492503131E-016 + + 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..d568d07450f1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/index.d.ts @@ -0,0 +1,42 @@ +/* +* @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 + +/** +* Determines double precision machine parameters. +* +* @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: 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..5506d56c3636 --- /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 number... +{ + 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 insufficient 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..7e40a3728dcc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/examples/index.js @@ -0,0 +1,27 @@ +/** +* @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( out ); + +out = dlamch( 'S' ); +console.log( out ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/lib/dlamch.js b/lib/node_modules/@stdlib/lapack/base/dlamch/lib/dlamch.js new file mode 100644 index 000000000000..a5f186b8f083 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/lib/dlamch.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 EPS = require( '@stdlib/constants/float64/eps' ); +var SMALLEST_NORMAL = require( '@stdlib/constants/float64/smallest-normal' ); +var MIN_EXPONENT = require( '@stdlib/constants/float64/min-base2-exponent' ); +var MAX_EXPONENT = require( '@stdlib/constants/float64/max-base2-exponent' ); + + +// VARIABLES // + +var DIGITS_ZERO = 53; +var RADIX_ZERO = 2.0; +var HUGE_ZERO = 1.7976931348623157E+308; + + +// MAIN // + +/** +* Determines double precision machine parameters. +* +* @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 ) { + var sfmin; + var small; + var eps; + var rnd; + + rnd = 1.0; + if ( rnd === 1.0 ) { + eps = EPS * 0.5; + } else { + eps = EPS; + } + + if ( cmach === 'E' ) { + return eps; + } + if ( cmach === 'S' ) { + sfmin = SMALLEST_NORMAL; + small = 1.0 / HUGE_ZERO; + if ( small >= sfmin ) { + sfmin = small * ( 1.0 + eps ); + } + return sfmin; + } + if ( cmach === 'B' ) { + return RADIX_ZERO; + } + if ( cmach === 'P' ) { + return eps * RADIX_ZERO; + } + if ( cmach === 'N' ) { + return DIGITS_ZERO; + } + if ( cmach === 'R' ) { + return rnd; + } + if ( cmach === 'M' ) { + return MIN_EXPONENT + 1; + } + if ( cmach === 'U' ) { + return SMALLEST_NORMAL; + } + if ( cmach === 'L' ) { + return MAX_EXPONENT + 1; + } + if ( cmach === 'O' ) { + return HUGE_ZERO; + } + return 0.0; +} + + +// EXPORTS // + +module.exports = dlamch; 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..f11506a0d828 --- /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 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 dlamch = require( './dlamch.js' ); + + +// EXPORTS // + +module.exports = dlamch; 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..d2df0e7d8e71 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/lib/main.js @@ -0,0 +1,28 @@ +/** +* @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 dlamch = require( './dlamch.js' ); + + +// 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..b4ed36bc0445 --- /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 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..d6795e4139c3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js @@ -0,0 +1,75 @@ +/** +* @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' ); + + +// VARIABLES // + +var VALUES = [ + 'E', + 'S', + 'B', + 'P', + 'N', + 'R', + 'M', + 'U', + 'L', + 'O' +]; + +var 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 +]; + + +// 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 out; + var i; + + for ( i = 0; i < VALUES.length; i++ ) { + out = dlamch( VALUES[ i ] ); + expected = EXPECTED[ i ]; + t.strictEqual( out, expected, 'returns expected value for '+VALUES[i] ); + } + t.end(); +}); From 87b2ecdc73a9af6d3bf222b9b5e8b518e2a8ba5a Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Fri, 12 Jul 2024 10:47:41 +0530 Subject: [PATCH 02/13] chore: apply suggestions from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dlamch/README.md | 1 - lib/node_modules/@stdlib/lapack/base/dlamch/docs/repl.txt | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/README.md b/lib/node_modules/@stdlib/lapack/base/dlamch/README.md index 826be23e1497..1aa3e394fdf0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlamch/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/README.md @@ -160,7 +160,6 @@ TODO @@ -162,7 +172,7 @@ TODO [lapack]: https://www.netlib.org/lapack/explore-html/ -[dlamch]: https://www.netlib.org/lapack/explore-html/d4/d86/group__lamch_gaeab255e77cbd3b0f31aea74ed0ce099e.html#gaeab255e77cbd3b0f31aea74ed0ce099e +[lapack-dlamch]: https://www.netlib.org/lapack/explore-html/d4/d86/group__lamch_gaeab255e77cbd3b0f31aea74ed0ce099e.html#gaeab255e77cbd3b0f31aea74ed0ce099e diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/package.json b/lib/node_modules/@stdlib/lapack/base/dlamch/package.json index b4ed36bc0445..3f80dc1f6353 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlamch/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/lapack/base/dlamch", "version": "0.0.0", - "description": "Determine double precision machine parameters.", + "description": "Determine double-precision floating-point machine parameters.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js index e69b0b21ff50..799d85001508 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/test/test.js @@ -24,55 +24,6 @@ var tape = require( 'tape' ); var dlamch = require( './../lib' ); -// VARIABLES // - -var VALUES = [ - 'E', - 'S', - 'B', - 'P', - 'N', - 'R', - 'M', - 'U', - 'L', - 'O', - 'e', - 's', - 'b', - 'p', - 'n', - 'r', - 'm', - 'u', - 'l', - 'o' -]; - -var 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 -]; - - // TESTS // tape( 'main export is a function', function test( t ) { @@ -83,13 +34,80 @@ tape( 'main export is a function', function test( t ) { tape( 'the function returns machine parameters', function test( t ) { var expected; - var out; + var values; + var actual; var i; - for ( i = 0; i < VALUES.length; i++ ) { - out = dlamch( VALUES[ i ] ); - expected = EXPECTED[ i ]; - t.strictEqual( out, expected, 'returns expected value for '+VALUES[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(); }); From 342562f983fa13b30f8d5b723e3527935ffbfd31 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 22 Aug 2024 00:59:20 -0700 Subject: [PATCH 13/13] docs: update examples --- .../@stdlib/lapack/base/dlamch/README.md | 28 +++++++++++++++++-- .../lapack/base/dlamch/examples/index.js | 28 +++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlamch/README.md b/lib/node_modules/@stdlib/lapack/base/dlamch/README.md index 2374311d5c78..ee86f565557f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlamch/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/README.md @@ -78,10 +78,34 @@ The function has the following parameters: var dlamch = require( '@stdlib/lapack/base/dlamch' ); var out = dlamch( 'E' ); -console.log( out ); +console.log( 'Precision: %d', out ); out = dlamch( 'S' ); -console.log( out ); +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/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlamch/examples/index.js index 7e40a3728dcc..bacc57fa50e4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlamch/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlamch/examples/index.js @@ -21,7 +21,31 @@ var dlamch = require( './../lib' ); var out = dlamch( 'E' ); -console.log( out ); +console.log( 'Precision: %d', out ); out = dlamch( 'S' ); -console.log( out ); +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 );