From f1f3b93bb939eaf58bba31d82e443efc2c673aae Mon Sep 17 00:00:00 2001 From: Christoph Ruegg Date: Fri, 28 Oct 2016 09:16:06 +0200 Subject: [PATCH] FFT-MKL: real packed transformation support --- src/NativeProviders/MKL/fft.cpp | 30 +++++++++++++++++++ .../Providers/Common/Mkl/SafeNativeMethods.cs | 18 +++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/NativeProviders/MKL/fft.cpp b/src/NativeProviders/MKL/fft.cpp index fccf5ce2..b8c160e1 100644 --- a/src/NativeProviders/MKL/fft.cpp +++ b/src/NativeProviders/MKL/fft.cpp @@ -47,6 +47,16 @@ extern "C" { return fft_create_1d(handle, n, forward_scale, backward_scale, DFTI_SINGLE, DFTI_COMPLEX); } + DLLEXPORT MKL_LONG d_fft_create(DFTI_DESCRIPTOR_HANDLE* handle, const MKL_LONG n, const double forward_scale, const double backward_scale) + { + return fft_create_1d(handle, n, forward_scale, backward_scale, DFTI_DOUBLE, DFTI_REAL); + } + + DLLEXPORT MKL_LONG s_fft_create(DFTI_DESCRIPTOR_HANDLE* handle, const MKL_LONG n, const float forward_scale, const float backward_scale) + { + return fft_create_1d(handle, n, forward_scale, backward_scale, DFTI_SINGLE, DFTI_REAL); + } + DLLEXPORT MKL_LONG z_fft_create_multidim(DFTI_DESCRIPTOR_HANDLE* handle, MKL_LONG dimensions, MKL_LONG n[], const double forward_scale, const double backward_scale) { return fft_create_md(handle, dimensions, n, forward_scale, backward_scale, DFTI_DOUBLE, DFTI_COMPLEX); @@ -67,6 +77,16 @@ extern "C" { return DftiComputeForward(handle, x); } + DLLEXPORT MKL_LONG d_fft_forward(const DFTI_DESCRIPTOR_HANDLE handle, double x[]) + { + return DftiComputeForward(handle, x); + } + + DLLEXPORT MKL_LONG s_fft_forward(const DFTI_DESCRIPTOR_HANDLE handle, float x[]) + { + return DftiComputeForward(handle, x); + } + DLLEXPORT MKL_LONG z_fft_backward(const DFTI_DESCRIPTOR_HANDLE handle, MKL_Complex16 x[]) { return DftiComputeBackward(handle, x); @@ -76,4 +96,14 @@ extern "C" { { return DftiComputeBackward(handle, x); } + + DLLEXPORT MKL_LONG d_fft_backward(const DFTI_DESCRIPTOR_HANDLE handle, double x[]) + { + return DftiComputeBackward(handle, x); + } + + DLLEXPORT MKL_LONG s_fft_backward(const DFTI_DESCRIPTOR_HANDLE handle, float x[]) + { + return DftiComputeBackward(handle, x); + } } diff --git a/src/Numerics/Providers/Common/Mkl/SafeNativeMethods.cs b/src/Numerics/Providers/Common/Mkl/SafeNativeMethods.cs index bab628ca..fe50ec8a 100644 --- a/src/Numerics/Providers/Common/Mkl/SafeNativeMethods.cs +++ b/src/Numerics/Providers/Common/Mkl/SafeNativeMethods.cs @@ -392,6 +392,12 @@ namespace MathNet.Numerics.Providers.Common.Mkl [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_fft_create([Out] out IntPtr handle, int n, float forward_scale, float backward_scale); + [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern int d_fft_create([Out] out IntPtr handle, int n, double forward_scale, double backward_scale); + + [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern int s_fft_create([Out] out IntPtr handle, int n, float forward_scale, float backward_scale); + [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_fft_create_multidim([Out] out IntPtr handle, int dimensions, [In] int[] n, double forward_scale, double backward_scale); @@ -404,12 +410,24 @@ namespace MathNet.Numerics.Providers.Common.Mkl [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_fft_forward([In] IntPtr handle, [In, Out] Complex32[] x); + [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern int d_fft_forward([In] IntPtr handle, [In, Out] double[] x); + + [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern int s_fft_forward([In] IntPtr handle, [In, Out] float[] x); + [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int z_fft_backward([In] IntPtr handle, [In, Out] Complex[] x); [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] internal static extern int c_fft_backward([In] IntPtr handle, [In, Out] Complex32[] x); + [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern int d_fft_backward([In] IntPtr handle, [In, Out] double[] x); + + [DllImport(_DllName, ExactSpelling = true, SetLastError = false, CallingConvention = CallingConvention.Cdecl)] + internal static extern int s_fft_backward([In] IntPtr handle, [In, Out] float[] x); + #endregion FFT // ReSharper restore InconsistentNaming