-
-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #2568 Co-authored-by: Athan Reines <[email protected]> Reviewed-by: Athan Reines <[email protected]> Signed-off-by: Pranav Goswami <[email protected]>
- Loading branch information
1 parent
b877636
commit 536f5db
Showing
10 changed files
with
805 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
<!-- | ||
@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. | ||
--> | ||
|
||
# dlamch | ||
|
||
> Determine double-precision floating-point machine parameters. | ||
<section class = "usage"> | ||
|
||
## 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. | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="notes"> | ||
|
||
## Notes | ||
|
||
- `dlamch()` corresponds to the [LAPACK][lapack] function [`dlamch`][lapack-dlamch]. | ||
|
||
</section> | ||
|
||
<!-- /.notes --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```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 ); | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
<!-- C interface documentation. --> | ||
|
||
* * * | ||
|
||
<section class="c"> | ||
|
||
## C APIs | ||
|
||
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> | ||
|
||
<section class="intro"> | ||
|
||
</section> | ||
|
||
<!-- /.intro --> | ||
|
||
<!-- C usage documentation. --> | ||
|
||
<section class="usage"> | ||
|
||
### Usage | ||
|
||
```c | ||
TODO | ||
``` | ||
|
||
#### TODO | ||
|
||
TODO. | ||
|
||
```c | ||
TODO | ||
``` | ||
|
||
TODO | ||
|
||
```c | ||
TODO | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="notes"> | ||
|
||
</section> | ||
|
||
<!-- /.notes --> | ||
|
||
<!-- C API usage examples. --> | ||
|
||
<section class="examples"> | ||
|
||
### Examples | ||
|
||
```c | ||
TODO | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
</section> | ||
|
||
<!-- /.c --> | ||
|
||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
|
||
<section class="related"> | ||
|
||
</section> | ||
|
||
<!-- /.related --> | ||
|
||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="links"> | ||
|
||
[lapack]: https://www.netlib.org/lapack/explore-html/ | ||
|
||
[lapack-dlamch]: https://www.netlib.org/lapack/explore-html/d4/d86/group__lamch_gaeab255e77cbd3b0f31aea74ed0ce099e.html#gaeab255e77cbd3b0f31aea74ed0ce099e | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
71 changes: 71 additions & 0 deletions
71
lib/node_modules/@stdlib/lapack/base/dlamch/benchmark/benchmark.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
-------- |
62 changes: 62 additions & 0 deletions
62
lib/node_modules/@stdlib/lapack/base/dlamch/docs/types/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
Oops, something went wrong.
536f5db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage Report
The above coverage report was generated for the changes in this push.