[SciPy-Dev] Scipy Hilbert function in C#

Subha Raj subha_rajk@yahoo....
Tue Oct 11 09:20:31 CDT 2011


> Hello All,
> I simply need to port the scipy Hilbert function in C# and
> I am looking to use an open-source library (such as
> Exocortex) for the FFT component of it. I have the following
> code snippet.
> float[] trace = new float[] { 1, 2, 3, 4};
> Fourier.FFT(trace, trace.Length/2,
> FourierDirection.Forward);
> Fourier.FFT(trace, trace.Length/2,
> FourierDirection.Forward);
> List<float> hilbert = new
> List<float>(trace.Length);
> for (int i = 0; i < trace.Length; i++)
> {
> hilbert.Add(0.0f);
> }
> for(int i=1; i<hilbert.Count/2; i++)
> {
> hilbert[i] = 2;
> }
> if(hilbert.Count/2 == 0)
> {
> hilbert[0] = hilbert[hilbert.Count/2] = 1;
> }
> List<float> hilbertResult = new List<float>();
> for (int i = 0; i < trace.Length; i++)
> {
> hilbertResult.Add(trace[i] * hilbert[i]);
> }
> float[] hilbertResult2 = hilbertResult.ToArray();
> Fourier.FFT(hilbertResult2, hilbertResult.Count/2,
> FourierDirection.Backward);
> hilbertResult2.Take(trace.Length);
> But something doesn't seem to be working right. Can someone
> help?
> Regards,
> Subha
> 


More information about the SciPy-Dev mailing list