// Copyright Naoki Shibata and contributors 2010 - 2021. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include #include #include #include "sleef.h" #include "sleefdft.h" #include #ifndef MODE #define MODE SLEEF_MODE_DEBUG #endif #if BASETYPEID == 1 #define THRES 1e-30 #define SleefDFT_init2d SleefDFT_double_init2d #define SleefDFT_execute SleefDFT_double_execute typedef double real; #elif BASETYPEID == 2 #define THRES 1e-13 #define SleefDFT_init2d SleefDFT_float_init2d #define SleefDFT_execute SleefDFT_float_execute typedef float real; #else #error BASETYPEID not set #endif static double squ(double x) { return x * x; } // complex forward double check_cf(int n, int m) { fftw_complex *in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n * m); fftw_complex *out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n * m); fftw_plan w = fftw_plan_dft_2d(n, m, in, out, FFTW_FORWARD, FFTW_ESTIMATE); real *sx = (real *)Sleef_malloc(n*m*2*sizeof(real)); real *sy = (real *)Sleef_malloc(n*m*2*sizeof(real)); struct SleefDFT *p = SleefDFT_init2d(n, m, sx, sy, MODE); for(int i=0;i \n", argv[0]); exit(-1); } const int n = 1 << atoi(argv[1]); const int m = 1 << atoi(argv[2]); srand((unsigned int)time(NULL)); SleefDFT_setPlanFilePath(NULL, NULL, SLEEF_PLAN_RESET | SLEEF_PLAN_READONLY); // int success = 1; double e; e = check_cf(n, m); success = success && e < THRES; printf("complex forward : %s (%g)\n", e < THRES ? "OK" : "NG", e); e = check_cb(n, m); success = success && e < THRES; printf("complex backward : %s (%g)\n", e < THRES ? "OK" : "NG", e); exit(success ? 0 : -1); }