-
Notifications
You must be signed in to change notification settings - Fork 41
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
Complexes #350
Complexes #350
Conversation
extendr-api/src/scalar/rcplx.rs
Outdated
use std::ops::{AddAssign, DivAssign, MulAssign, SubAssign}; | ||
|
||
// #[cfg(feature="num-complex")] | ||
pub type C64 = num_complex::Complex<f64>; |
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.
I know it is against the naming convention, but shouldn't it be c64
inline with f64
and i64
/u64
?
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.
Rust likes types to start with a capital letter. But we can override this with a #[allow()]
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.
I know, I am just curious and asking for opininons. I am ok with either options.
extendr-api/src/wrapper/mod.rs
Outdated
@@ -197,6 +199,7 @@ make_conversions!(S4, ExpectedS4, is_s4, "Not a S4 type"); | |||
make_conversions!(Integers, ExpectedInteger, is_integer, "Not an integer type"); | |||
make_conversions!(Logicals, ExpectedLogical, is_logical, "Not a logical type"); | |||
make_conversions!(Doubles, ExpectedReal, is_real, "Not a floating point type"); | |||
make_conversions!(Complexes, ExpectedComplex, is_complex, "Not a complex type"); |
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.
Maybe 'complex number'? 'Complex type' can be misleading.
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.
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.
Also, next step is to ditch FromRobj
Are you good with this @clauswilke @yutannihilation @Ilia-Kosenkov ? |
I gave this a quick look and it generally seems fine to me. One issue that caught my eye is If there is a good reason for having these two types, then I think this should be documented somewhere. Also, users should be told which one to use when. |
Currently, we either wrap num_complex or a simple struct with the same layout in Rcplx. num_complex gives us complex arithmetic, functions, nan tests and more but We could have implemented arithmetic for Rcomplex, but it would have been a lot |
That's fine, and I have no concerns with the technical aspects, but I think this should be stated clearly in the docs somewhere. If I understand correctly, endusers would never normally use
|
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.
I'm not very familiar with complex math, but this generally looks good to me.
This PR implements the Complexes type and provides complex number support via num_complex.
Rcplx
wrapsnum_complex::Complex<f64>
the same way thatRfloat
wraps f64.This PR provides only basic support.