fft_impl4.c 1.35 KB
//
// fft_impl4.c: this file is part of the SL program suite.
//
// Copyright (C) 2009 The SL project.
// Copyright (C) 2020 daiteq.
//
//

enum { MAX_M = TABLE_SIZE, MAX_N = 1 << MAX_M };

static const cpx_t sc_table[ MAX_N ] = {
#define HEADERNAME MAKENAME(2, TABLE_SIZE)
#define HEADER STRINGIFY(HEADERNAME)

#include HEADER
};
const void* sc_table_ptr = sc_table;

void FFT_2(unsigned p, unsigned long LE2, const cpx_t* restrict cos_sin, cpx_t* restrict X, unsigned long Z)
{
    unsigned i = p;

    const unsigned long w  = i & ((LE2) - 1);
    const unsigned long j  = (i - w) * 2 + w;
    const unsigned long ip = j + (LE2);
    cpx_t* restrict x = (X);

    const cpx_t U = (cos_sin)[w * (Z)];

    cpx_t T; // const cpx_t
    dcmul(U,x[ip], T);

    const cpx_t xj = x[j];
    dcsub(xj, T, x[ip]);
    dcadd(xj, T, x[j]);
}
void FFT_1_mt(unsigned p, cpx_t* restrict X, unsigned long N2, const void* t)
{
  int i;
    unsigned k = p+1;
    
    
    const cpx_t*restrict cos_sin = (const cpx_t*restrict)(const void*)(t);
    unsigned long Z  = (MAX_N >> k);
    unsigned long LE = (1 << k);
    for (i=0;i<N2;i++)
      FFT_2(i, LE/2, cos_sin, X, Z);
}

static
void FFT_1(unsigned long M, cpx_t*restrict X, unsigned long N2, const void* t, unsigned blocksize)
{
  int i;
    for (i=0;i<M;i++) {
//       printf("M %lu,i %u\n",M,i);
      FFT_1_mt(i, X, N2, t);
    }
}