fir.cpp (2954B)
1 /** @addtogroup dft 2 * @{ 3 */ 4 /* 5 Copyright (C) 2016-2023 Dan Cazarin (https://www.kfrlib.com) 6 This file is part of KFR 7 8 KFR is free software: you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation, either version 2 of the License, or 11 (at your option) any later version. 12 13 KFR is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with KFR. 20 21 If GPL is not suitable for your project, you must purchase a commercial license to use KFR. 22 Buying a commercial license is mandatory as soon as you develop commercial activities without 23 disclosing the source code of your own applications. 24 See https://www.kfrlib.com for details. 25 */ 26 #include <kfr/dsp/fir.hpp> 27 #include <kfr/multiarch.h> 28 29 namespace kfr 30 { 31 32 CMT_MULTI_PROTO(namespace impl { 33 template <typename T, typename U> 34 class fir_filter : public kfr::fir_filter<T, U> 35 { 36 public: 37 using kfr::fir_filter<T, U>::fir_filter; 38 39 void process_buffer_impl(U* dest, const U* src, size_t size); 40 void process_expression_impl(U* dest, const expression_handle<U, 1>& src, size_t size); 41 }; 42 } // namespace impl 43 ) 44 45 inline namespace CMT_ARCH_NAME 46 { 47 namespace impl 48 { 49 50 template <typename T, typename U> 51 void fir_filter<T, U>::process_buffer_impl(U* dest, const U* src, size_t size) 52 { 53 make_univector(dest, size) = fir(make_univector(src, size), std::ref(this->state)); 54 } 55 template <typename T, typename U> 56 void fir_filter<T, U>::process_expression_impl(U* dest, const expression_handle<U, 1>& src, size_t size) 57 { 58 make_univector(dest, size) = fir(src, std::ref(this->state)); 59 } 60 61 template class fir_filter<float, float>; 62 template class fir_filter<double, double>; 63 template class fir_filter<float, double>; 64 template class fir_filter<double, float>; 65 template class fir_filter<float, complex<float>>; 66 template class fir_filter<double, complex<double>>; 67 68 } // namespace impl 69 } // namespace CMT_ARCH_NAME 70 71 #ifdef CMT_MULTI_NEEDS_GATE 72 73 template <typename T, typename U> 74 void fir_filter<T, U>::process_buffer(U* dest, const U* src, size_t size) 75 { 76 make_univector(dest, size) = fir(make_univector(src, size), std::ref(this->state)); 77 } 78 template <typename T, typename U> 79 void fir_filter<T, U>::process_expression(U* dest, const expression_handle<U, 1>& src, size_t size) 80 { 81 make_univector(dest, size) = fir(src, std::ref(this->state)); 82 } 83 template class fir_filter<float, float>; 84 template class fir_filter<double, double>; 85 template class fir_filter<float, double>; 86 template class fir_filter<double, float>; 87 template class fir_filter<float, complex<float>>; 88 template class fir_filter<double, complex<double>>; 89 90 #endif 91 92 } // namespace kfr