-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Add core::num::Complex
#158885
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: main
Are you sure you want to change the base?
Add core::num::Complex
#158885
Changes from all commits
5b66cc1
d7ec103
592e138
3512f08
3238bbf
2567434
130ae0b
534309d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /// A complex number. | ||
| #[derive(Clone, Copy, Debug, PartialEq)] | ||
| #[unstable(feature = "complex_numbers", issue = "154023")] | ||
| #[repr(C)] | ||
| #[lang = "complex"] | ||
| pub struct Complex<T> { | ||
| /// The real component. | ||
| pub re: T, | ||
| /// The imaginary component. | ||
| pub im: T, | ||
|
Comment on lines
+8
to
+10
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh, odd. I kind of would expect
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There might be some value in matching the C function names
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just following the RFC here, libs can re-litigate it later |
||
| } | ||
|
Comment on lines
+6
to
+11
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unsure if public fields is desirable here.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having to call a method just to get the real or imaginary part seems annoying
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again this is just per the RFC #154023
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, OK, I didn't notice that on my scan.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. leaving this open so I see it if I revisit this PR for some reason, but considering it nonblocking. |
||
|
|
||
| #[unstable(feature = "complex_numbers", issue = "154023")] | ||
| impl<T> Complex<T> { | ||
| /// Create a new complex number from a real and imaginary component. | ||
| #[must_use] | ||
| pub fn new(re: T, im: T) -> Complex<T> { | ||
| Complex { re, im } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.