ChillFish8 / cfavml

An unopinionated SIMD vector operation library for Rust, supporting no_std and no-alloc workloads.
Apache License 2.0
3 stars 1 forks source link

Complex Number Support? #4

Open abstractqqq opened 3 months ago

abstractqqq commented 3 months ago

I am trying this in my package and it has significantly sped up higher dimension vector math for me.. I am wondering if complex number support is planned? Thank you

ChillFish8 commented 3 months ago

Good to hear it is useful to you :)

I would say probably not in the near future as I'm not very familiar with complex number operations and they likely require some more specialized handling to do the standard arithmetic operations on most hardware.

Happy to accept PRs for it, I think most of the work would be around implementing the SimdRegister<T> trait on the various CPU flags and everything else should 'just work' but I am going to be sticking with non-complex types for now.

skewballfox commented 4 weeks ago

Happy to accept PRs for it, I think most of the work would be around implementing the SimdRegister trait on the various CPU flags and everything else should 'just work' but I am going to be sticking with non-complex types for now.

If you are interested, I can start a PR, though I'm not sure how fast I'll be able to complete it. Something that might be useful to reference for whoever does implement it is the AvxVector trait for rustfft and its implementations (one is on 827)

ChillFish8 commented 3 weeks ago

Any contribution is welcome :smiley: I think implementation-wise, it may come down to how to represent the complex types themselves. For ergonomics, it might be that we use an existing lib for the repr (or at least provide bytemuck support for it) which probably means having the complex number impls in a separate crate may be beneficial.

skewballfox commented 3 weeks ago

I think implementation-wise, it may come down to how to represent the complex types themselves. For ergonomics, it might be that we use an existing lib for the repr (or at least provide bytemuck support for it) which probably means having the complex number impls in a separate crate may be beneficial.

so a separate cfavml-complex crate that implements SimdRegister<num_comple::Complex<F>> (among other traits)? Also, I'm guessing we only care about floating point types. Is there a situation where you need complex ints?

ChillFish8 commented 3 weeks ago

I suspect floats are going to be the main application for most people although personally I don't work with complex numbers much so I can't say concretely.

Targeting floats first would probably be a good initial step

abstractqqq commented 3 weeks ago

When I opened this issue, I was looking at complex vector multiplication which is a step in convolution (by FFT).

I think it's ok to build for floats first and then if someone request, add ints