Click or drag to resize

Complex

Performs 1-dimensional discrete Fourier transform of complex forward domain.

This topic contains the following sections:

Constructor

Constructor

Description

Performance

set the length of sequences to be used

Initializes an instance of ComplexDFT1D class that allows to compute forward and backward (inverse) DFT of given length.

methodComplexDFT1D(Int32)

Methods
Properties

Property

Description

Performance

forward scale factor

A scale factor for forward transform.

PropertyForwardScaleFactor

backward scale factor

A scale factor for backward transform.

PropertyBackwardScaleFactor

Code Sample

Computation of forward and backward transform:

C#
 1using System;
 2using FinMath.SignalProcessing;
 3using FinMath.Statistics;
 4
 5namespace FinMath.Samples
 6{
 7    class FourierTransformComplex
 8    {
 9        static void Main()
10        {
11            // Create random generator.
12            RandomGenerator random = new RandomGenerator();
13
14            // Create arrays.
15            Complex[] input = new Complex[7];
16            Complex[] output = new Complex[7];
17            Complex[] result = new Complex[7];
18
19            // Generate random series of numbers.
20            for (Int32 i = 0; i < 7; i += 1)
21            {
22                input[i] = new Complex(random.NextDouble(), random.NextDouble());
23            }
24            Console.WriteLine("Input = ");
25            Console.Write(input[0].ToString("0.000"));
26            for (Int32 i = 1; i < input.Length; ++i)
27                Console.Write(", " + input[i].ToString("0.000"));
28            Console.WriteLine(Environment.NewLine);
29
30            // Create a new instance of RealDFT1D.
31            ComplexDFT1D dft = new ComplexDFT1D(7);
32
33            // Set forward and backward scale factors.
34            dft.ForwardScaleFactor = 1.0 / 7;
35            dft.BackwardScaleFactor = 1.0;
36
37            // Compute forward transform.
38            dft.ComputeForward(input, output);
39            Console.WriteLine("Output = ");
40            Console.Write(output[0].ToString("0.000"));
41            for (Int32 i = 1; i < output.Length; ++i)
42                Console.Write(", " + output[i].ToString("0.000"));
43            Console.WriteLine(Environment.NewLine);
44
45            // Compute backward transform.
46            dft.ComputeBackward(output, result);
47            Console.WriteLine("Result = ");
48            Console.Write(result[0].ToString("0.000"));
49            for (Int32 i = 1; i < result.Length; ++i)
50                Console.Write(", " + result[i].ToString("0.000"));
51            Console.WriteLine(Environment.NewLine);
52        }
53    }
54}

See Also

Other Resources