Example: Complex FFT

The Fourier coefficients of a complex periodic sequence are computed. Then the coefficients are used to try to reproduce the periodic sequence.
using System;
using Imsl.Math;

public class ComplexFFTEx1
{
	public static void  Main(String[] args)
	{
		Complex[] x = new Complex[]{
            new Complex(1, 8), new Complex(2, 7), new Complex(3, 6), 
            new Complex(4, 5), new Complex(5, 4), new Complex(6, 3), 
            new Complex(7, 2), new Complex(8, 1)
        };
		ComplexFFT fft = new ComplexFFT(x.Length);
		
		Complex[] y = fft.Forward(x);
		Complex[] z = fft.Backward(y);
		for (int i = 0; i < x.Length; i++)
		{
			z[i] /= x.Length;
		}
		
		new PrintMatrix("x").Print(x);
		new PrintMatrix("y").Print(y);
		new PrintMatrix("z").Print(z);
	}
}

Output

    x
    0    
0  1+8i  
1  2+7i  
2  3+6i  
3  4+5i  
4  5+4i  
5  6+3i  
6  7+2i  
7  8+1i  

                   y
                    0                   
0                 36+36i                
1   5.65685424949238+13.6568542494924i  
2                   +8i                 
3  -2.34314575050762+5.65685424949238i  
4                 -4+4i                 
5  -5.65685424949238+2.34314575050762i  
6                 -8                    
7  -13.6568542494924-5.65685424949238i  

    z
    0    
0  1+8i  
1  2+7i  
2  3+6i  
3  4+5i  
4  5+4i  
5  6+3i  
6  7+2i  
7  8+1i  


Link to C# source.