public void TestReal2Complex2Real2D() { int nx = (int)System.Math.Sqrt(N); int ny = nx; _gpu.CopyToDevice(_hostInput, _devInput); FFTPlan2D planFwd = _fft.Plan2D(eFFTType.Real2Complex, eDataType.Single, nx, ny, BATCH); planFwd.Execute(_devInput, _devInterCplx); FFTPlan2D planRev = _fft.Plan2D(eFFTType.Complex2Real, eDataType.Single, nx, ny, BATCH); planRev.Execute(_devInterCplx, _devOutput); _gpu.CopyFromDevice(_devOutput, _hostOutput); for (int i = 0; i < N * BATCH; i++) { Assert.AreEqual(_hostInput[i], _hostOutput[i] / (float)N, 0.0001, "Index {0}", i); } }
public void TestComplex2Complex2Complex2D() { int nx = (int)System.Math.Sqrt(N); int ny = nx; _gpu.CopyToDevice(_hostInputCplx, _devInputCplx); FFTPlan2D planFwd = _fft.Plan2D(eFFTType.Complex2Complex, eDataType.Double, nx, ny, BATCH); planFwd.Execute(_devInputCplx, _devInterCplx); FFTPlan2D planRev = _fft.Plan2D(eFFTType.Complex2Complex, eDataType.Double, nx, ny, BATCH); planRev.Execute(_devInterCplx, _devOutputCplx, true); _gpu.CopyFromDevice(_devOutputCplx, _hostOutputCplx); for (int i = 0; i < N * BATCH; i++) { Assert.AreEqual(_hostInputCplx[i].x, _hostOutputCplx[i].x / (double)N, 0.0001, "Index {0} (x)", i); Assert.AreEqual(_hostInputCplx[i].y, _hostOutputCplx[i].y / (double)N, 0.0001, "Index {0} (y)", i); } }
public void TestReal2Complex2Real2D_2() { _gpu.CopyToDevice(_hostInput, _devInput); float[,] devInput2D = _gpu.Cast(_devInput, W, H); ComplexF[,] devInterCplx2D = _gpu.Cast(_devInterCplx, W, H); FFTPlan2D planFwd = _fft.Plan2D(eFFTType.Real2Complex, eDataType.Single, W, H, 1); planFwd.Execute(devInput2D, devInterCplx2D); FFTPlan2D planRev = _fft.Plan2D(eFFTType.Complex2Real, eDataType.Single, W, H, 1); float[,] devOutput2D = _gpu.Cast(_devOutput, W, H); planRev.Execute(devInterCplx2D, devOutput2D); _gpu.CopyFromDevice(_devOutput, _hostOutput); for (int i = 0; i < N * 1; i++) { Assert.AreEqual(_hostInput[i], _hostOutput[i] / (float)N, 0.0001, "Index {0}", i); } }