| 1902 | typedef struct fftblue_plan_i * fftblue_plan; |
| 1903 | |
| 1904 | NOINLINE static fftblue_plan make_fftblue_plan (size_t length) |
| 1905 | { |
| 1906 | fftblue_plan plan = RALLOC(fftblue_plan_i,1); |
| 1907 | if (!plan) return NULL; |
| 1908 | plan->n = length; |
| 1909 | plan->n2 = good_size(plan->n*2-1); |
| 1910 | plan->mem = RALLOC(double, 2*plan->n+2*plan->n2); |
| 1911 | if (!plan->mem) { DEALLOC(plan); return NULL; } |
| 1912 | plan->bk = plan->mem; |
| 1913 | plan->bkf = plan->bk+2*plan->n; |
| 1914 | |
| 1915 | /* initialize b_k */ |
| 1916 | double *tmp = RALLOC(double,4*plan->n); |
| 1917 | if (!tmp) { DEALLOC(plan->mem); DEALLOC(plan); return NULL; } |
| 1918 | sincos_2pibyn(2*plan->n,tmp); |
| 1919 | plan->bk[0] = 1; |
| 1920 | plan->bk[1] = 0; |
| 1921 | |
| 1922 | size_t coeff=0; |
| 1923 | for (size_t m=1; m<plan->n; ++m) |
| 1924 | { |
| 1925 | coeff+=2*m-1; |
| 1926 | if (coeff>=2*plan->n) coeff-=2*plan->n; |
| 1927 | plan->bk[2*m ] = tmp[2*coeff ]; |
| 1928 | plan->bk[2*m+1] = tmp[2*coeff+1]; |
| 1929 | } |
| 1930 | |
| 1931 | /* initialize the zero-padded, Fourier transformed b_k. Add normalisation. */ |
| 1932 | double xn2 = 1./plan->n2; |
| 1933 | plan->bkf[0] = plan->bk[0]*xn2; |
| 1934 | plan->bkf[1] = plan->bk[1]*xn2; |
| 1935 | for (size_t m=2; m<2*plan->n; m+=2) |
| 1936 | { |
| 1937 | plan->bkf[m] = plan->bkf[2*plan->n2-m] = plan->bk[m] *xn2; |
| 1938 | plan->bkf[m+1] = plan->bkf[2*plan->n2-m+1] = plan->bk[m+1] *xn2; |
| 1939 | } |
| 1940 | for (size_t m=2*plan->n;m<=(2*plan->n2-2*plan->n+1);++m) |
| 1941 | plan->bkf[m]=0.; |
| 1942 | plan->plan=make_cfftp_plan(plan->n2); |
| 1943 | if (!plan->plan) |
| 1944 | { DEALLOC(tmp); DEALLOC(plan->mem); DEALLOC(plan); return NULL; } |
| 1945 | if (cfftp_forward(plan->plan,plan->bkf,1.)!=0) |
| 1946 | { DEALLOC(tmp); DEALLOC(plan->mem); DEALLOC(plan); return NULL; } |
| 1947 | DEALLOC(tmp); |
| 1948 | |
| 1949 | return plan; |
| 1950 | } |
| 1951 | |
| 1952 | NOINLINE static void destroy_fftblue_plan (fftblue_plan plan) |
| 1953 | { |
no test coverage detected