Skip to content
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

impl Mul<Array<Complex<T>>> for T #1260

Open
cavemanloverboy opened this issue Jan 19, 2023 · 5 comments · May be fixed by #782
Open

impl Mul<Array<Complex<T>>> for T #1260

cavemanloverboy opened this issue Jan 19, 2023 · 5 comments · May be fixed by #782

Comments

@cavemanloverboy
Copy link

cavemanloverboy commented Jan 19, 2023

I did a quick scan of the issues and didn't see this. For an array: Array<Complex<f64>> (for example), i think it's perfectly reasonable to expect

let output: Array<Complex<f64>> = 2.0_f64 * array;

to work. I've only ever gotten a rhs mul e.g. array * 2.0 to work. (see example, non-working example). Is there a reason this hasn't been done, e.g. orphan rules?

@cavemanloverboy
Copy link
Author

I think it should be possible, actually, here's an example

@cavemanloverboy
Copy link
Author

The implementation can also be done for Complex<f32> and Complex<f64> for Array<Complex<f32>> and Array<Complex<f64>>

@cavemanloverboy cavemanloverboy changed the title impl Mul<Array<T>> for T impl Mul<Array<Complex<T>>> for T Jan 19, 2023
@cavemanloverboy
Copy link
Author

Also, doing this for Div will allow for things like 1.0 / array for a complex array.

@bluss
Copy link
Member

bluss commented Jan 21, 2023

Please see this for doc on scalars on the left hand side: https://docs.rs/ndarray/latest/ndarray/trait.ScalarOperand.html

Just for baseline/background. I don't know if this is a good idea, don't know if there are any drawbacks. Since complex implements mixed float-complex operations, we have the necessary precedent to consider it.

@akern40
Copy link
Collaborator

akern40 commented Dec 23, 2024

I believe this would be closed by #782? The next-gen compiler will enable that PR and seems to be close to stabilization, as it is a Rust goal for 2024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants