feat: add math/base/special/atanhf#9514
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com>
|
/stdlib lint-autofix |
@hrshya, the slash command failed to complete. Please check the workflow logs for details. |
Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com>
Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com>
Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com>
| */ | ||
| static double benchmark( void ) { | ||
| double elapsed; | ||
| double x; |
There was a problem hiding this comment.
Variables x and y declared as double instead of float here.
| // VARIABLES // | ||
|
|
||
| var opts = { | ||
| 'skip': ( typeof Math.atanhf !== 'function' ) // eslint-disable-line stdlib/no-builtin-math |
There was a problem hiding this comment.
Math.atanhf does not exist. Can only compare to Math.atanh.
| #include "stdlib/constants/float32/ninf.h" | ||
| #include <stdint.h> | ||
|
|
||
| static const float NEAR_ZERO = 1.0 / (1 << 28); // 2**-28 |
There was a problem hiding this comment.
| static const float NEAR_ZERO = 1.0 / (1 << 28); // 2**-28 | |
| static const float NEAR_ZERO = 1.0f / (1 << 28); // 2**-28 |
| int i; | ||
| for ( i = 0; i < 10; i++ ) { | ||
| v = stdlib_base_atanhf( x[ i ] ); | ||
| printf( "atanhf(%lf) = %lf\n", x[ i ], v ); |
There was a problem hiding this comment.
Should use %f instead of %lf.
| t.strictEqual( y, e, 'x: '+x[i]+'. E: '+e ); | ||
| } else { | ||
| delta = abs( y - e ); | ||
| tol = 1.3 * EPS * abs( e ); |
There was a problem hiding this comment.
Is there are reason why the "small negative" test case uses 1.3 * EPS here but 1.0 * EPS in test.js line 123?
There was a problem hiding this comment.
Thanks for pointing that out, that was not intentional
| /** | ||
| * Generates a random number on the interval [0,1). | ||
| * | ||
| * @return random number | ||
| */ | ||
| static float rand_float( void ) { | ||
| int r = rand(); | ||
| return (float)r / ( (float)RAND_MAX + 1.0f ); | ||
| } |
There was a problem hiding this comment.
Can you update this to use random_uniform instead? You can refer to tanf for this
| x = ( 2.0f * rand_float() ) - 1.0f; | ||
| y = stdlib_base_atanhf( x ); |
There was a problem hiding this comment.
This should be done outside the loop. tanf is a good example to refer to.
| * | ||
| * @return random number | ||
| */ | ||
| static float rand_float( void ) { |
There was a problem hiding this comment.
Same comment applies here and below, for random number generation.
| if ( y === e ) { | ||
| t.strictEqual( y, e, 'x: '+x[i]+'. E: '+e ); | ||
| } else { | ||
| delta = abs( y - e ); | ||
| tol = 1.3 * EPS * abs( e ); | ||
| t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. tol: '+tol+'.' ); | ||
| } |
There was a problem hiding this comment.
Can you refactor this to use assert/is-almost-same-value instead?
There was a problem hiding this comment.
Same comment applies below and for test.native.js
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: passed
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: passed
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
| if ( y === e ) { | ||
| t.strictEqual( y, e, 'x: '+x[i]+'. E: '+e ); | ||
| } else { | ||
| delta = abs( y - e ); | ||
| tol = 1.3 * EPS * abs( e ); | ||
| t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. tol: '+tol+'.' ); | ||
| } |
There was a problem hiding this comment.
Same comment applies below and for test.native.js
Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
PR Commit MessagePlease review the above commit message and make any necessary adjustments. |
PR-URL: stdlib-js#9514 Ref: stdlib-js#649 Co-authored-by: Karan Anand <anandkarancompsci@gmail.com> Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com> Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com> Reviewed-by: Karan Anand <anandkarancompsci@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com> Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com> Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Resolves none .
Description
This pull request:
math/base/special/atanhf.Related Issues
This pull request:
Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers