-
Notifications
You must be signed in to change notification settings - Fork 98
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
Implement inverse trigonometric functions from ratio to angle. #184
Implement inverse trigonometric functions from ratio to angle. #184
Conversation
@iliekturtles I am somewhat at a loss as to the correct usage of the
Could you give me a hint? |
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.
Thanks for the PR! Sorry for my delay in responding, it has been a busy couple days. Let me know if you get any other compile errors once the fix I noted in the diff is applied.
@iliekturtles I wonder how to handle |
I think I'm inclined towards implementing for all quantities but I'm second guessing myself as I write this sentence. Do you have any examples where the function would be used on non-length quantities? |
After some digging, I found a paper mentioning I guess this is the basic example, any field which has a spherical or cylindrical symmetry might have modes which imply usage of |
An example of using the arctangent non-length quantities which immediately comes to mind for me is the phase delay in viscoelastic solids, which is something I could see myself wanting to work with in |
Amended the generic implementation on all @iliekturtles Should be ready for review now. |
Changes look great! If you can amend the commit with tests similar to what is done for Lines 85 to 102 in 4fceafc
|
Added property-based tests for all new functions. |
Clippy doesn't like diff --git a/src/si/ratio.rs b/src/si/ratio.rs
index 8ceee33..4a3f853 100644
--- a/src/si/ratio.rs
+++ b/src/si/ratio.rs
@@ -161,33 +161,33 @@ mod tests {
use si::quantities::*;
use tests::Test;
- fn test_nan_or_eq(yl: &V, yr: &V) -> bool {
- (yl.is_nan() && yr.is_nan()) || Test::eq(yl, yr)
+ fn test_nan_or_eq(yl: V, yr: V) -> bool {
+ (yl.is_nan() && yr.is_nan()) || Test::eq(&yl, &yr)
}
quickcheck! {
fn acos(x: V) -> bool {
- test_nan_or_eq(&x.acos(), &Ratio::from(x).acos().get::<a::radian>())
+ test_nan_or_eq(x.acos(), Ratio::from(x).acos().get::<a::radian>())
}
fn acosh(x: V) -> bool {
- test_nan_or_eq(&x.acosh(), &Ratio::from(x).acosh().get::<a::radian>())
+ test_nan_or_eq(x.acosh(), Ratio::from(x).acosh().get::<a::radian>())
}
fn asin(x: V) -> bool {
- test_nan_or_eq(&x.asin(), &Ratio::from(x).asin().get::<a::radian>())
+ test_nan_or_eq(x.asin(), Ratio::from(x).asin().get::<a::radian>())
}
fn asinh(x: V) -> bool {
- test_nan_or_eq(&x.asinh(), &Ratio::from(x).asinh().get::<a::radian>())
+ test_nan_or_eq(x.asinh(), Ratio::from(x).asinh().get::<a::radian>())
}
fn atan(x: V) -> bool {
- test_nan_or_eq(&x.atan(), &Ratio::from(x).atan().get::<a::radian>())
+ test_nan_or_eq(x.atan(), Ratio::from(x).atan().get::<a::radian>())
}
fn atanh(x: V) -> bool {
- test_nan_or_eq(&x.atanh(), &Ratio::from(x).atanh().get::<a::radian>())
+ test_nan_or_eq(x.atanh(), Ratio::from(x).atanh().get::<a::radian>())
}
}
} |
Fixes #168