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

Issues with complex support #151

Open
liss-h opened this issue Sep 6, 2024 · 5 comments
Open

Issues with complex support #151

liss-h opened this issue Sep 6, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@liss-h
Copy link

liss-h commented Sep 6, 2024

Describe the bug
Hi :), I was fiddling around with faer and found the support around complex numbers really confusing & slightly buggy.

  1. Stack overflow on windows. The following code causes a stack overflow on windows (only in dev builds, release works)

    use num_complex::Complex;
    
    let m = Mat::<Complex<f64>>::zeros(4, 3);
    let v = Mat::<Complex<f64>>::zeros(3, 1);
    let r = m * v;
    
    println!("{r:?}");
  2. Additionally, for an unknown (to me) reason there is apparently no way to index a Mat<Complex<f64>>. The following code does not compile:

    let m = Mat::<Complex<f64>>::zeros(4, 3);
    let x = m[(0, 0)]; // trait error here

    At least to me it is not at all apparent why this doesn't work. I haven't found anything in the documentation about it.

  3. It took me a very long time to figure out that you are supposed to use c64 instead of Complex<f64>. Adding an example or some more documentation how to use complex numbers would be appreciated.

Thx :)

@liss-h liss-h added the bug Something isn't working label Sep 6, 2024
@sarah-quinones
Copy link
Owner

@liss-h
Copy link
Author

liss-h commented Sep 8, 2024

Yeah, I saw that page. It took me quite a while to find it so I think it would be good to feature it more prominently.
That page also doesn't really explain 1 & 2

@sarah-quinones
Copy link
Owner

the stack overflow is due to the stack size on windows being relatively small. faer uses a lot of abstraction layers which ends up being quite costly in non optimized builds. i recommend setting opt-level = 3 in your Cargo.toml if you still want debug assertions

as for 2, i can't return a reference to Complex<_> because the real and imaginary parts are stored separately, which native rust references don't really support

@liss-h
Copy link
Author

liss-h commented Sep 8, 2024

the stack overflow is due to the stack size on windows being relatively small. faer uses a lot of abstraction layers which ends up being quite costly in non optimized builds. i recommend setting opt-level = 3 in your Cargo.toml if you still want debug assertions

ok thx

as for 2, i can't return a reference to Complex<_> because the real and imaginary parts are stored separately, which native rust references don't really support

Ah, right sorry, I totally forgot that Index has to return a reference

Could you still document (some of) these things? I think it would be beneficial for new users of faer if they don't have to figure this out on their own. Mainly talking about the limitations on windows and featuring the complex_native page more prominently or maybe adding an example for complex numbers in the repo (which links to the page). I think that would be very helpful

@sarah-quinones
Copy link
Owner

sure, im currently in the middle of a refactor/possible redesign phase, so this might take a while

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants