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

Unable to multiply complex matrix with complex scalar from the left #1338

Open
martin-jw opened this issue Dec 24, 2023 · 2 comments
Open

Unable to multiply complex matrix with complex scalar from the left #1338

martin-jw opened this issue Dec 24, 2023 · 2 comments
Assignees

Comments

@martin-jw
Copy link

Hi there,

It is currently not possible to multiply a complex matrix with a complex scalar from the left, as illustrated here:

use nalgebra::{Complex, Matrix2};

fn main() {
    let mat = Matrix2::<Complex<f32>>::identity();
    let c = Complex::<f32>::new(1.0, -1.0);

    let product = mat * c; // This works
    let product = c * mat; // This does not compile
}

I suspect this is because Complex might be an external type. Is there a way to fix this currently or is it not possible? It is not a huge issue since you can always swap the multiplication order, but it is annoying.

@tpdickso
Copy link
Collaborator

I think historically this was the case but this might no longer be true, as it's now fine to write impl X<...> for Y as long as X contains one locally-defined type constraining it -- there is an impl for Mul<f32> for Vector2<f32> so I don't see why this wouldn't be possible. I can take a look.

@tpdickso tpdickso self-assigned this Dec 24, 2023
@tpdickso
Copy link
Collaborator

#1339

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

No branches or pull requests

2 participants