-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add constants/float16/fourth-root-eps
#9610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 6 commits
0809ce2
f3a7bbc
a81b32e
9586415
1520f85
811b7c8
f60dc9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| <!-- | ||
|
|
||
| @license Apache-2.0 | ||
|
|
||
| Copyright (c) 2026 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. | ||
|
|
||
| --> | ||
|
|
||
| # FLOAT16_FOURTH_ROOT_EPS | ||
|
|
||
| > [Fourth root][nth-root] of [half-precision floating-point epsilon][@stdlib/constants/float16/eps]. | ||
|
|
||
| <section class="usage"> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```javascript | ||
| var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' ); | ||
| ``` | ||
|
|
||
| #### FLOAT16_FOURTH_ROOT_EPS | ||
|
|
||
| [Fourth root][nth-root] of [half-precision floating-point epsilon][@stdlib/constants/float16/eps]. | ||
|
|
||
| ```javascript | ||
| var bool = ( FLOAT16_FOURTH_ROOT_EPS === 0.1767578125 ); | ||
| // returns true | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.usage --> | ||
|
|
||
| <section class="examples"> | ||
|
|
||
| ## Examples | ||
|
|
||
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| ```javascript | ||
| var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' ); | ||
|
|
||
| var out = FLOAT16_FOURTH_ROOT_EPS; | ||
| // returns 0.1767578125 | ||
| ``` | ||
|
|
||
| </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 | ||
| #include "stdlib/constants/float16/fourth_root_eps.h" | ||
| ``` | ||
|
|
||
| #### STDLIB_CONSTANT_FLOAT16_FOURTH_ROOT_EPS | ||
|
|
||
| Macro for the [fourth root][nth-root] of [half-precision floating-point epsilon][@stdlib/constants/float16/eps]. | ||
|
|
||
| </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"> | ||
|
|
||
| </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"> | ||
|
|
||
| [nth-root]: https://en.wikipedia.org/wiki/Nth_root | ||
|
|
||
| [@stdlib/constants/float16/eps]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float16/eps | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.links --> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| {{alias}} | ||
| Fourth root of half-precision floating-point epsilon. | ||
|
|
||
| Examples | ||
| -------- | ||
| > {{alias}} | ||
| 0.1767578125 | ||
|
|
||
| See Also | ||
| -------- |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 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 | ||
|
|
||
| /** | ||
| * Fourth root of half-precision floating-point epsilon. | ||
| * | ||
| * @example | ||
| * var eps = FLOAT16_FOURTH_ROOT_EPS; | ||
| * // returns 0.1767578125 | ||
| */ | ||
| declare const FLOAT16_FOURTH_ROOT_EPS: number; | ||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| export = FLOAT16_FOURTH_ROOT_EPS; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 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 FLOAT16_FOURTH_ROOT_EPS = require( './index' ); | ||
|
|
||
|
|
||
| // TESTS // | ||
|
|
||
| // The export is a number... | ||
| { | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-expressions | ||
| FLOAT16_FOURTH_ROOT_EPS; // $ExpectType number | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 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 FLOAT16_FOURTH_ROOT_EPS = require( './../lib' ); | ||
|
|
||
| console.log( FLOAT16_FOURTH_ROOT_EPS ); | ||
| // => 0.1767578125 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 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. | ||
| */ | ||
|
|
||
| #ifndef STDLIB_CONSTANTS_FLOAT16_FOURTH_ROOT_EPS_H | ||
| #define STDLIB_CONSTANTS_FLOAT16_FOURTH_ROOT_EPS_H | ||
|
|
||
| /** | ||
| * Macro for the fourth root of half-precision floating-point epsilon. | ||
| */ | ||
| #define STDLIB_CONSTANT_FLOAT16_FOURTH_ROOT_EPS 0.1767578125f | ||
|
||
|
|
||
| #endif /* !STDLIB_CONSTANTS_FLOAT16_FOURTH_ROOT_EPS_H */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /** | ||
| * @license Apache-2.0 | ||
| * | ||
| * Copyright (c) 2026 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'; | ||
|
|
||
| /** | ||
| * Fourth root of half-precision floating-point epsilon. | ||
| * | ||
| * @module @stdlib/constants/float16/fourth-root-eps | ||
| * @type {number} | ||
| * | ||
| * @example | ||
| * var FLOAT16_FOURTH_ROOT_EPS = require( '@stdlib/constants/float16/fourth-root-eps' ); | ||
| * // returns 0.1767578125 | ||
| */ | ||
|
|
||
|
|
||
| // MAIN // | ||
|
|
||
| /** | ||
| * Fourth root of half-precision floating-point epsilon. | ||
| * | ||
| * ```tex | ||
| * \sqrt{\sqrt{\frac{1}{2^{10}}}} | ||
| * ``` | ||
| * | ||
| * @constant | ||
| * @type {number} | ||
| * @default 0.1767578125 | ||
| * @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985} | ||
| * @see [Machine Epsilon]{@link https://en.wikipedia.org/wiki/Machine_epsilon} | ||
| */ | ||
| var FLOAT16_FOURTH_ROOT_EPS = 0.1767578125; | ||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = FLOAT16_FOURTH_ROOT_EPS; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| { | ||
| "options": {}, | ||
| "fields": [ | ||
| { | ||
| "field": "src", | ||
| "resolve": true, | ||
| "relative": true | ||
| }, | ||
| { | ||
| "field": "include", | ||
| "resolve": true, | ||
| "relative": true | ||
| }, | ||
| { | ||
| "field": "libraries", | ||
| "resolve": false, | ||
| "relative": false | ||
| }, | ||
| { | ||
| "field": "libpath", | ||
| "resolve": true, | ||
| "relative": false | ||
| } | ||
| ], | ||
| "confs": [ | ||
| { | ||
| "src": [], | ||
| "include": [ | ||
| "./include" | ||
| ], | ||
| "libraries": [], | ||
| "libpath": [], | ||
| "dependencies": [] | ||
| } | ||
| ] | ||
| } |
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.
Better to add the C header file for this given that we now have extended support for
H_Hmacro?cc:- @kgryte
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.
okay understood!