WalterSmuts / easyfft

A Rust library crate providing an easy FFT API for arrays and slices
https://docs.rs/easyfft
Apache License 2.0
32 stars 1 forks source link

Obtaining an original length in DynRealDft struct #5

Closed Ameyanagi closed 9 months ago

Ameyanagi commented 9 months ago

Hi, I wondered if there is a way to obtain an original length from DynRealDft struct. I need the information of the original length to do the ifft, but it is stored in a private variable, and I was wondering if there is a way to obtain them by api.

Right now, I can only find a way to read the length that is already halved, in which if I try to reconstruct the original length it can only be reconstructed in 50% probability.

WalterSmuts commented 9 months ago

I need the information of the original length to do the ifft, but it is stored in a private variable, and I was wondering if there is a way to obtain them by api.

Why do you need it? Can't you just call the .ifft() method?

Ameyanagi commented 9 months ago

@WalterSmuts

Thank you for the reply and sorry for the late response. I am currently working on the field of X-ray absorption spectroscopy; we need to extract parameters from a theoretical formula that resembles sin waves. However, since it is not a pure sin wave nor a periodic data, we do a lot of post-processing on the frequency spectra we obtain from FFT.

For this purpose, I am converting DynRealDft to ndalgebra or ndarray. Right now, the original length is stored in other struct prior to the FFT so that I don't lose the information, but I was wondering if I could store and retrieve it from DynRealDft struct.

I am working on analytical method that uses

WalterSmuts commented 9 months ago

I'm still trying to figure out if this post-processing is necessary and not easily expressible in the operations already exposed by DynRealDft. What operations do you perform?

I'm hesitant to expose the original length because it allows users to use RealDft::new too easily. I've purposefully feature gated it by a scary name to stop folks from using it unless it's necessary. The hope is that most applications can express their logic in terms of the safe operations exposed by DynRealDft. That way the application-write can be sure there will never be any panics.

Ameyanagi commented 9 months ago

I appreciate your consideration. Following is the code that I am working on. https://github.com/Ameyanagi/xraytsubaki/blob/main/src/xafs/xrayfft.rs#L123

I think once the serde implementation is added, I would not require information about the orginal length anymore, since can store and recover into DynRealDft.

WalterSmuts commented 9 months ago

Closing this issue in favour of #4