-
Notifications
You must be signed in to change notification settings - Fork 706
feat(frontend): Hyperbolic trigonometric functions #8918
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
Conversation
xiangjinwu
left a comment
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.
btw we can remove the leading --@ of the following tests now:
risingwave/src/tests/regress/data/sql/float8.sql
Lines 200 to 219 in 3091f16
| -- test Inf/NaN cases for hyperbolic functions | |
| --@ SELECT sinh(double precision 'infinity'); | |
| --@ SELECT sinh(double precision '-infinity'); | |
| --@ SELECT sinh(double precision 'nan'); | |
| --@ SELECT cosh(double precision 'infinity'); | |
| --@ SELECT cosh(double precision '-infinity'); | |
| --@ SELECT cosh(double precision 'nan'); | |
| --@ SELECT tanh(double precision 'infinity'); | |
| --@ SELECT tanh(double precision '-infinity'); | |
| --@ SELECT tanh(double precision 'nan'); | |
| --@ SELECT asinh(double precision 'infinity'); | |
| --@ SELECT asinh(double precision '-infinity'); | |
| --@ SELECT asinh(double precision 'nan'); | |
| -- acosh(Inf) should be Inf, but some mingw versions produce NaN, so skip test | |
| -- SELECT acosh(double precision 'infinity'); | |
| --@ SELECT acosh(double precision '-infinity'); | |
| --@ SELECT acosh(double precision 'nan'); | |
| --@ SELECT atanh(double precision 'infinity'); | |
| --@ SELECT atanh(double precision '-infinity'); | |
| --@ SELECT atanh(double precision 'nan'); |
proto/expr.proto
Outdated
| SINH = 261; | ||
| COSH = 262; | ||
| TANH = 263; | ||
| COTH = 264; |
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.
| t | ||
|
|
||
| query R | ||
| SELECT abs(sinh(1) - 1.1752011936438014) < 0.000000000000001 |
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.
Equality of imprecise float is inherently hard 😢 FYI postgres regress test only test for 15 significant decimal digits for double precision, using the extra_float_digits config we do not support yet.
risingwave/src/tests/regress/data/expected/float8.out
Lines 640 to 647 in 3091f16
| -- hyperbolic functions | |
| -- we run these with extra_float_digits = 0 too, since different platforms | |
| -- tend to produce results that vary in the last place. | |
| SELECT sinh(double precision '1'); | |
| sinh | |
| ----------------- | |
| 1.1752011936438 | |
| (1 row) |
But we can manually adjust the precision requirement here, and we have no intention to do better than rust builtin f64::sinh...
What about
SELECT abs(sinh(1) - 1.17520119364380) < 1e-15;
-- or even 1e-14 if the ci machine is less capable
btw it is also a bit clearer to use the 1e-15 syntax rather than counting the zeros.
|
Sorry for not coming back to this earlier. I updated the PR according to your suggestions. Thank you very much for your comments @xiangjinwu. |
Codecov Report
@@ Coverage Diff @@
## main #8918 +/- ##
=======================================
Coverage 71.12% 71.12%
=======================================
Files 1250 1250
Lines 209294 209371 +77
=======================================
+ Hits 148850 148924 +74
- Misses 60444 60447 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 7 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
xiangjinwu
left a comment
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.
As mentioned in earlier comments, could you turn on the applicable regress tests?
proto/expr.proto
Outdated
| SINH = 253; | ||
| COSH = 254; | ||
| TANH = 255; | ||
| COTH = 256; | ||
| ASINH = 257; | ||
| ACOSH = 258; | ||
| ATANH = 259; |
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.
FYI it would not be backward compatible when we change the mapping of an existing enum value.
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Implement the following functions:
sinh/cosh/tanh/asinh/acosh/atanhThere is no
atan2hAFAIK.tracking issue: #8806 #9675
Checklist For Contributors
./risedev check(or alias,./risedev c)Checklist For Reviewers
Documentation
Documents are here: #9675
Types of user-facing changes
Please keep the types that apply to your changes, and remove the others.
Release note
Implement hyperbolic trigonometric functions.