-
-
Notifications
You must be signed in to change notification settings - Fork 701
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
feat: add math/base/special/powf
#5739
base: develop
Are you sure you want to change the base?
Conversation
Hello! 👋 I've noticed that your commit doesn't contain the expected YAML metadata blocks. This typically happens when your development environment isn't properly set up with the stdlib git hooks. Here's how to fix this:
If you're still having issues, please check our development guide for more information. Thank you for your contribution! |
var polyvalL = require( './polyval_l.js' ); | ||
|
||
|
||
// VARIABLES // |
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.
these values have been based on upstream implementation of powf
in msun.
@kgryte @gunjjoshi what do you guys think of the JS implementation so far!! |
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.
have kept this empty as of now thinking of generating fixtures first and get back to this.
Updates so far cc: @kgryte @gunjjoshi
Upcoming updates
|
if ( sn === 1 ) { | ||
// Signal overflow... | ||
return sn * HUGE * HUGE; | ||
} | ||
// Signal underflow... | ||
return sn * TINY * TINY; |
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.
@gunjjoshi was a little confused about handling Over and underflow when x
is not close to unity
Had to rebase a branch as an unwanted change was added Ik it's unethical to do this but it was messing the purpose of this big-PR everything is running clean now working on more features. |
* | ||
* ## Notice | ||
* | ||
* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/9.3.0/lib/msun/src/e_powf.c}. The implementation follows the original, but has been modified for JavaScript. |
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.
We can update this 9.3.0
version to use the latest implementation.
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.
We can use this: https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_powf.c
/** | ||
* Evaluates the exponential function for single-precision values. | ||
* | ||
* ## Method |
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.
Method
is not required here. We can remove this, as it is not present in the reference implementation.
* x^y = 2^n e^{y^\prime \cdot \mathrm{log2}} | ||
* ``` | ||
* | ||
* ## Special Cases |
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.
Similarly, this and the Notes
section below can be removed too.
hx = fromWordf( x ); | ||
hy = fromWordf( y ); |
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.
@Neerajpathak07 hx
and hy
are words, which we are getting from the numbers x
and y
. So, we should be using toWordf
here, instead of fromWordf
.
@Neerajpathak07 Let's follow https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_powf.c?revision=367086&view=markup here. The current implementation in |
} | ||
|
||
// Special cases `x`... | ||
if ( lx === 0 ) { |
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.
Where is this lx
coming from?
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.
Seems like you've done a port of the double-precision implementation. Ideally, we must be independently following the single-precision reference, as the implementations may vary significantly.
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.
@gunjjoshi I haven't started refactoring the main.js
yet was working on log2ax
, logx
and pow2
to get them in line with single-precision implementation and wanted to get approvals on the var names and hexadecimal values first.
What I have changed in main.js
is:-
- Removed the logic for high and low words.
- Align the var with correct package convention.
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.
@Neerajpathak07 I would have started the implementation from main.js
, referring to the freeBSD implementation, rather than first working on log2ax
, logx
and pow2
.
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.
Noted I'll keep that in mind.
Progresses #649.
Description
This pull request:
math/base/special/powf
which is the single-precision version ofpow
Related Issues
This pull request:
Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers