swharden/FftSharp

Is there an equivalent to numpy fft.irfft?

Closed this issue · 2 comments

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.

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

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.