I am trying to experiment with radio concepts. From this article, I tried to implement the discrete Fourier transform of GPU-parallelism.
I'm sure I can pre-calculate the 90 degrees of sin (i) cos (i), and then just flip and repeat, not what I'm doing in this code, and that it will speed it up. But so far I don’t even think that I am getting the right answers. Entering all zeros gives the result 0, as expected, but all 0.5 gives 78.9985886f as input (in this case, I would expect 0 results). In principle, they just confuse me. I do not have good input, and I do not know what to do with the result or how to check it.
This question is related to my other post here
open Microsoft.ParallelArrays
open System
let target = new DX9Target()
ignore(target.ToArray1D(new FloatParallelArray([| 0.0f |])))
let stopwatch = new System.Diagnostics.Stopwatch()
let Hz = 50.0f
let fStep = (2.0f * float32(Math.PI)) / Hz
let shift = 0.0f
let elements = 7240
let buffer : float32[,] = Array2D.init<float32> elements elements (fun i j -> 0.5f)
let input = new FloatParallelArray(buffer)
let seqN : float32[,] = Array2D.init<float32> elements elements (fun i j -> (float32(i * elements) + float32(j)))
let steps = new FloatParallelArray(seqN)
let shiftedSteps = ParallelArrays.Add(shift, steps)
let increments = ParallelArrays.Multiply(fStep, steps)
let cos_i = ParallelArrays.Cos(increments)
let sin_i = ParallelArrays.Sin(increments)
stopwatch.Start()
let real = target.ToArray1D(ParallelArrays.Sum(ParallelArrays.Multiply(input, cos_i))).[0]
let imag = target.ToArray1D(ParallelArrays.Sum(ParallelArrays.Multiply(input, sin_i))).[0]
printf "%A in " ((real * real) + (imag * imag))
stopwatch.Stop()
printfn "%A" stopwatch.ElapsedMilliseconds
ignore (System.Console.ReadKey ())
source
share