-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
math.Complex: genericize arithmetics with reals, replace mulbyi with comptime-generic i-shifted arithmetic #19202
Conversation
add/sub/mul/div
with reals
add/sub/mul/div
with realsThere 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.
provide alternate functions for operating on scalars rather than abusing anytype
Disagree. This is in preparation for #16278 according what this link says wrt C99 spec:
Until #16278 is implemented, the arithmetic methods serve as stand-ins for the arithmetic operators. I can make them more strict with additional comptime type constraints, but the anytype argument is the entire premise. c.c. @Snektron |
I feel that Andrew is right here. Maybe an alternative solution would be to add a constructor that initializes a Complex from just a real value? Together with #9938, this would form a relatively concise way to write complex operations on reals:
|
But this way they don't get lowered to scalar operations at compile time though? The intent is to generalize permutation operations like And they are not just for operations with scalars. Consider expressions like |
closed in favor of #20346 |
uses
anytype
to enable binary arithmetic operations (add/sub/mul/div) with real argumentsalso added iadd, isub, imul, and idiv, and removed
mulbyi
which can be achieved withz.imul(1)
that lowers to the equivalent data shuffle ops at comptime.