VB FFT Example

← All NMath Code Examples

 

Imports System
Imports System.Globalization
Imports System.Threading
Imports System.Text

Imports CenterSpace.NMath.Core

Namespace CenterSpace.NMath.Examples.VisualBasic

  A .NET example in Visual Basic showing how to use the basic Fast Fourier Transform (FFT) modules.
  Module FFTExample

    Sub Main()

      Simple example to compute a forward 1D real 1024 point FFT
      Console.WriteLine()

      Create some random signal data.
      Dim Rand As RandomNumberGenerator = New RandGenMTwist(4230987)
      Dim Data As New DoubleVector(1024, Rand)

      Compute the FFT
      This will create a complex conjugate symmetric packed result.
      Dim fft1024 As New DoubleForward1DFFT(1024)
      Dim FFTResult As DoubleVector = fft1024.FFT(Data)

      Ask the FFT instance for the correct reader, to unpacked the result.
      Dim Reader As DoubleSymmetricSignalReader = fft1024.GetSignalReader(Data)

      The reader provides random access to any element in the pack fft result.
      Dim ThirdElement As DoubleComplex = Reader(2)

      Console.WriteLine()
      Console.WriteLine("1D real forward 1024 point FFT computed.")
      Console.WriteLine("-----------------------------------" + Environment.NewLine)

      
      Simple example to compute a backward 1D complex 1000 point FFT
      

      Create some new random signal data.
      Dim CData As New DoubleComplexVector(1000, Rand)

      Create the 1D backward complex FFT instance
      Dim fft1000 As New DoubleComplexBackward1DFFT(1000)

      Compute the FFT
      Complex FFTs generated unpacked results.
      fft1000.FFTInPlace(CData)

      Console.WriteLine("1D complex backward 1000 point FFT computed.")
      Console.WriteLine("-----------------------------------" + Environment.NewLine)


      Console.WriteLine()
      Console.WriteLine("Finished. Press Enter Key.")
      Console.Read()

    End Sub
  End Module
End Namespace


← All NMath Code Examples
Top