eDSP  0.0.1
A cross-platform DSP library written in C++.
dct.hpp
Go to the documentation of this file.
1 /*
2  * eDSP, A cross-platform Digital Signal Processing library written in modern C++.
3  * Copyright (C) 2018 Mohammed Boujemaoui Boulaghmoudi, All rights reserved.
4  *
5  * This program is free software: you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the Free
7  * Software Foundation, either version 3 of the License, or (at your option)
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along width
16  * this program. If not, see <http://www.gnu.org/licenses/>
17  *
18  * File: dct.hpp
19  * Date: 10/06/18
20  * Author: Mohammed Boujemaoui
21  */
22 
23 #ifndef EDSP_DCT_HPP
24 #define EDSP_DCT_HPP
25 
26 #include <edsp/spectral/internal/fft_impl.hpp>
27 
28 namespace edsp { inline namespace spectral {
29 
43  template <typename InputIt, typename OutputIt>
44  inline void dct(InputIt first, InputIt last, OutputIt d_first) {
45  const auto nfft =
46  static_cast<typename fft_impl<meta::value_type_t<InputIt>>::size_type>(std::distance(first, last));
47  fft_impl<meta::value_type_t<InputIt>> plan(nfft);
48  plan.dct(&(*first), &(*d_first));
49  }
50 
66  template <typename InputIt, typename OutputIt>
67  inline void idct(InputIt first, InputIt last, OutputIt d_first) {
68  const auto nfft =
69  static_cast<typename fft_impl<meta::value_type_t<InputIt>>::size_type>(std::distance(first, last));
70  fft_impl<meta::value_type_t<InputIt>> plan(nfft);
71  plan.idct(&(*first), &(*d_first));
72  plan.idct_scale(&(*d_first));
73  }
74 
75 }} // namespace edsp::spectral
76 
77 #endif // EDSP_DCT_HPP
constexpr T distance(T x, T y) noexcept
Computes the distance between x and y.
Definition: numeric.hpp:328
void dct(InputIt first, InputIt last, OutputIt d_first)
Computes the Discrete-Cosine-Transform of the range [first, last) and stores the result in another ra...
Definition: dct.hpp:44
void idct(InputIt first, InputIt last, OutputIt d_first)
Computes the Inverse-Discrete-Cosine-Transform of the range [first, last) and stores the result in an...
Definition: dct.hpp:67
Definition: amplifier.hpp:29