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

Is there an equivalent to numpy fft.irfft? #71

Closed
FrankHileman opened this issue Aug 1, 2023 · 2 comments · Fixed by #74
Closed

Is there an equivalent to numpy fft.irfft? #71

FrankHileman opened this issue Aug 1, 2023 · 2 comments · Fixed by #74

Comments

@FrankHileman
Copy link

FrankHileman commented Aug 1, 2023

Thank you to produce this library. Does it contain an equivalent to numpy fft.irfft? I did find the complex inverse.
https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft.html

I am a C# programmer, so I understand how to convert from in-place to generating a new array.

@swharden
Copy link
Owner

swharden commented Aug 2, 2023

Hi @FrankHileman, thank you for this question!

Presently no, FftSharp does not have an irfft function. I'd be happy to add one in though!

I would probably name it InverseReal() It could live alongside the ForwardReal() function:

/// <summary>
/// Calculate FFT and return just the real component of the spectrum
/// </summary>
public static System.Numerics.Complex[] ForwardReal(double[] samples)
{
System.Numerics.Complex[] buffer = samples.ToComplexArray();
Forward(buffer);
System.Numerics.Complex[] real = new System.Numerics.Complex[samples.Length / 2 + 1];
Array.Copy(buffer, 0, real, 0, real.Length);
return real;
}

If you wish to add this and create a pull request, I would be happy to merge it in and publish a new package with this feature

@FrankHileman
Copy link
Author

FrankHileman commented Aug 2, 2023

Hello @swharden, Thank you for the reply. I am still reading about how to convert an inverse complex method into an inverse real method, so I am not in a position to implement it immediately. From what I understand, it is not as simple as converting an array of doubles to an array of Complex.

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.

2 participants