-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: add math/base/special/log10f
#8873
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?
feat: add math/base/special/log10f
#8873
Conversation
---
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: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: missing_dependencies
- task: lint_c_benchmarks
status: missing_dependencies
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- 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: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- 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: missing_dependencies
- 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
---
| var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); | ||
| var PINF = require( '@stdlib/constants/float32/pinf' ); | ||
| var NINF = require( '@stdlib/constants/float32/ninf' ); | ||
| var EPS = require( '@stdlib/constants/float32/eps' ); |
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.
@JavaTypedScript Can you please refactor this to use var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' ); instead as done here?
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.
@anandkaranubc Thank you for your suggestions, it really worked!
| t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e ); | ||
| } else { | ||
| delta = abs( y - e ); | ||
| tol = 106.0 * EPS * abs( e ); |
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.
That's a pretty high number. Are you sure this implementation matches the reference implementation you followed?
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.
Yes it was too high and now i have refactored with your suggestion. New to open source, so I missed it.
| t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e ); | ||
| } else { | ||
| delta = abs( y - e ); | ||
| tol = 106.0 * EPS * abs( e ); |
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.
For debugging, since you are following FreeBSD’s C implementation, you can start by comparing your C implementation with the reference one to identify any differences that could cause such a high tolerance value. After that, run this test file to verify your implementation:
NODE_ADDONS_PATTERN="@stdlib/math/base/special/log10f" make install-node-addons
make TESTS_FILTER='@stdlib/math/base/special/log10f/test/test.native.js' test
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.
Yes i have refactored this, Thank you for your guidance.
---
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: passed
- task: lint_package_json
status: na
- 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: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- 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
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
math/base/special/log10f
| var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); | ||
| var PINF = require( '@stdlib/constants/float32/pinf' ); | ||
| var NINF = require( '@stdlib/constants/float32/ninf' ); | ||
| var EPS = require( '@stdlib/constants/float32/eps' ); |
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.
This is not needed when you use ulpdiff
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.
Hey, thanks for your review, I have changed it.
| for ( i = 0; i < x.length; i++ ) { | ||
| y = log10f( x[i] ); | ||
| e = float64ToFloat32( expected[ i ] ); | ||
| if ( y === e ) { | ||
| t.strictEqual( y, e, 'x: '+x[i]+', y: '+y+', expected: '+e ); | ||
| } else { | ||
| delta = abs( y - e ); | ||
| tol = EPS * abs( e ); | ||
| t.strictEqual( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+e+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); | ||
| } | ||
| } |
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.
This block should be changed to:
for ( i = 0; i < x.length; i++ ) {
x[ i ] = f32( x[ i ] );
y = log10f( x[ i ] );
expected[ i ] = f32( expected[ i ] );
t.strictEqual( ulpdiff( y, expected[ i ] ) <= _, true, 'returns expected value' );
}_ in ulpdiff( y, expected[ i ] ) <= _ will be filled with a number like 1,2,3, etc.
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.
First try with:
for ( i = 0; i < x.length; i++ ) {
x[ i ] = f32( x[ i ] );
y = log10f( x[ i ] );
expected[ i ] = f32( expected[ i ] );
t.strictEqual( y, expected[ i ], 'returns expected value' );
}If this fails, you can use ulpdiff starting with ulpdiff( y, expected[ i ] ) <= 1 and then step up this number.
My guess is, since you are using FreeBSD as the reference implementation, this number won't exceed 1 or 2 (maybe).
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.
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.
ok on to it thanks
| var NINF = require( '@stdlib/constants/float32/ninf' ); | ||
| var EPS = require( '@stdlib/constants/float32/eps' ); | ||
| var abs = require( '@stdlib/math/base/special/abs' ); | ||
| var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); |
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.
Since this variable name is a bit long, you can refactor it to:
var f32 = require( '@stdlib/number/float64/base/to-float32' );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.
Ya, I have made the changes, please let me know if there are any changes
---
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: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- 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: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- 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
---
|
@anandkaranubc and @kgryte |
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes. report:
Progresses #649 .
Description
This pull request:
Related Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers