fouriertest.frink

Download or view fouriertest.frink in plain text format

//
// Test of the functions defined in Fourier.frink
//

//use Fourier.frink

length = 64

// Testing.  Create a regular sinewave
f = new array
for j=0 to length-1
  f@j = 10 cos[4.1 j/(2 pi)] + 8 sin[17.3 j/(2 pi)]

// Test and time DFT case.
start = now[]
b = DFT[f]
//println[b]
end = now[]

println["Time in DFT is " + (end-start -> "ms")]

//scr = padAndScramble[f]
//println["Scrambled: $scr"]

//println[f]
start = now[]
bb = FFT[f]
end = now[]

println["Time in FFT is " + (end-start -> "ms")]

//println[bb]

//for [e] = bb
//   println[abs[e]]

inverse = InverseFFT[bb]

println["Ratio"]
largest = 0
for n = 0 to length-1
{
   if abs[bb@n - b@n] > largest
   {
      largest = abs[bb@n - b@n]
//      println["MISMATCH at index $n:" + (bb@n-b@n)]
   }
}
println["Largest error is " + largest]

println["Ratio Inverse"]
largest = 0
for n = 0 to length-1
{
   if abs[bb@n - b@n] > largest
   {
      largest = abs[bb@n - b@n]
//      println["MISMATCH at index $n:" + (bb@n-b@n)]
   }
}
println["Largest error is " + largest]

//println[inverse]


Download or view fouriertest.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 20162 days, 22 hours, 38 minutes ago.