27#ifndef quantlib_fast_fourier_transform_hpp
28#define quantlib_fast_fourier_transform_hpp
42 static std::size_t
min_order(std::size_t inputSize) {
43 return static_cast<std::size_t
>(
44 std::ceil(std::log(
static_cast<Real>(inputSize)) /
M_LN2));
49 std::size_t m =
static_cast<std::size_t
>(1) << order;
50 cs_[order - 1] = std::cos (2 *
M_PI / m);
51 sn_[order - 1] = std::sin (2 *
M_PI / m);
52 for (std::size_t i = order - 1; i > 0; --i) {
60 return (
static_cast<std::size_t
>(1) <<
cs_.size());
65 template<
typename InputIterator,
typename RandomAccessIterator>
66 void transform(InputIterator inBegin, InputIterator inEnd,
67 RandomAccessIterator out)
const {
73 template<
typename InputIterator,
typename RandomAccessIterator>
75 RandomAccessIterator out)
const {
82 template<
typename InputIterator,
typename RandomAccessIterator>
84 RandomAccessIterator out,
87 typename std::iterator_traits<RandomAccessIterator>::value_type
89 const std::size_t order =
cs_.size();
90 const auto N = std::size_t(
static_cast<std::size_t
>(1) << order);
92 for (; inBegin != inEnd; ++i, ++inBegin) {
96 for (std::size_t
s = 1;
s <= order; ++
s) {
97 std::size_t m =
static_cast<std::size_t
>(1) <<
s;
100 for (std::size_t j = 0; j < m/2; ++j) {
101 for (std::size_t k = j; k < N; k += m) {
102 complex
t = w * (*(out + k + m/2));
103 complex u = *(out + k);
105 *(out + k + m/2) = u -
t;
112 static std::size_t
bit_reverse(std::size_t x, std::size_t order) {
114 for (std::size_t i = 0; i < order; ++i) {
Classes and functions for error handling.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Matrix inverse(const Matrix &m)