Implicitly cast "float" to "complex" in complex arithmetic #4936
goldenbergdaniel
started this conversation in
Ideas/Requests
Replies: 1 comment
-
If this is intended behavior (arithmetic operators refuse to convert up to complex/quaternion), I think it would be worth adding that functionality to the arithmetic operators. You can already convert up to complex numbers in procedure arguments as shown below. Is there a reason why this shouldn't extend to arithmetic operators?
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, in order to perform arithmetic between a numeric and a complex number, the numeric type must be explicitly cast to a complex type. This can be observed in the DFT example below, where
x
is of type[]f32
andH
is of type[]complex64
:My proposal is to implicitly cast the scalar part (which can be either real or imaginary) to a complex number. This would simplify the code into this:
In addition to providing an ergonomic benefit, this behavior would be consistent with existing behavior that allows implicitly casting a scalar type to complex type on assignment.
Beta Was this translation helpful? Give feedback.
All reactions