-
Notifications
You must be signed in to change notification settings - Fork 3
/
cfft.cpp
39 lines (31 loc) · 937 Bytes
/
cfft.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Main program to calculate at compile-time the fast fourier transform (FFT).
Copyright Paul Keir 2012-2016
Distributed under the Boost Software License, Version 1.0.
(See accompanying file license.txt or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <iostream>
#ifdef RECARR
#include "cfft_recarr.hpp"
#else
#include "cfft.hpp"
#endif
constexpr size_t n = SZ;
typedef double fptype;
typedef cxns::cx<fptype> cxtype;
int main(int argc, char *argv[])
{
constexpr auto si = cxns::sin<fptype>;
constexpr auto in = Init<cxtype>(n);
constexpr auto ca = StaticCast<cxtype,size_t>();
#ifdef CONSTMATH
constexpr auto x = map( compose( si, in, ca ), iota<n>() );
constexpr auto res = fft(x);
#else
auto x = map( compose( si, in, ca ), iota<n>() );
auto res = fft(x);
#endif
std::cout << x << std::endl;
std::cout << map( in, res ) << std::endl;
return 0;
}