kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.62k stars 248 forks source link

kfr::gen_sin doesn't work #175

Closed netlcod closed 1 year ago

netlcod commented 1 year ago

Hello.

    kfr::univector<kfr::fbase> x;
    float fs = 16000;
    int samps = 32;
    kfr::fbase step = kfr::c_pi<kfr::fbase>/(samps+1);
    kfr::univector<kfr::fbase> up = kfr::truncate(kfr::gen_sin<kfr::fbase>(kfr::c_pi<kfr::fbase>/2, step), samps);

OS/Compiler version: Windows 11, MinGW 8.1 Target architecture: x86_64 Compiler error message:

1) C:\Qt\Tools\mingw810_64\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\type_traits:2310: error: no type named 'type' in 'struct std::enable_if<false, kfr::avx2::vec<double, 4> >' In file included from C:/Qt/5.15.2/mingw81_64/include/QtCore/qglobal.h:45, from C:/Qt/5.15.2/mingw81_64/include/QtCore/qtimer.h:43, from C:/Qt/5.15.2/mingw81_64/include/QtCore/QTimer:1, from F:/Programming/SignalStudio/src/devices/input/generator.h:4, from F:/Programming/SignalStudio/src/devices/input/generator.cpp:1: C:/Qt/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/type_traits: In substitution of 'template<bool _Cond, class _Tp> using enable_if_t = typename std::enable_if::type [with bool _Cond = std::is_same_v<double, kfr::avx2::vec<double, 2> >; _Tp = kfr::avx2::vec<double, 4>]': F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:105:81: required from 'struct kfr::avx2::generator<double, 4, kfr::avx2::generator_sin<double, 4>, kfr::avx2::vec<double, 2> >' F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:224:8: required from 'struct kfr::avx2::generator_sin<double, 4>' F:/Programming/SignalStudio/src/devices/input/generator.cpp:88:105: required from here C:/Qt/Tools/mingw810_64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/type_traits:2310:61: error: no type named 'type' in 'struct std::enable_if<false, kfr::avx2::vec<double, 4> >' using enable_if_t = typename enable_if<_Cond, _Tp>::type; ^

2) F:\Programming\SignalStudio\lib\kfr\include\kfr\base\generators.hpp:103: error: 'const struct kfr::avx2::generator_sin<double, 4>' has no member named 'get_value'; did you mean 'get_shape'? In file included from F:/Programming/SignalStudio/lib/kfr/include/kfr/base.hpp:32, from F:/Programming/SignalStudio/src/devices/input/generator.h:8, from F:/Programming/SignalStudio/src/devices/input/generator.cpp:1: F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp: In instantiation of 'kfr::avx2::vec<T, width> kfr::avx2::generator<T, VecWidth, Class, Twork>::call_get_value() const [with T = double; long long unsigned int VecWidth = 4; Class = kfr::avx2::generator_sin<double, 4>; Twork = kfr::avx2::vec<double, 2>]': F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:86:38: required from 'kfr::avx2::vec<T, N> kfr::avx2::generator<T, VecWidth, Class, Twork>::generate() const [with long long unsigned int N = 4; T = double; long long unsigned int VecWidth = 4; Class = kfr::avx2::generator_sin<double, 4>; Twork = kfr::avx2::vec<double, 2>]' F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:97:42: required from 'kfr::avx2::vec<T, N> kfr::avx2::get_elements(const kfr::avx2::generator<T, VecWidth, Class, Twork>&, const kfr::shape<1>&, const kfr::axis_params<0, N>&) [with long long unsigned int N = 4; T = double; long long unsigned int VecWidth = 4; Class = kfr::avx2::generator_sin<double, 4>; Twork = kfr::avx2::vec<double, 2>]' F:/Programming/SignalStudio/lib/kfr/include/kfr/base/basic_expressions.hpp:195:47: required from 'kfr::avx2::vec<SubType, N> kfr::avx2::get_elements(const kfr::expression_slice&, const kfr::shape&, const kfr::axis_params<VecAxis, N>&) [with Arg = kfr::avx2::generator_sin<double, 4>; long long unsigned int NDims = 1; long long unsigned int Axis = 0; long long unsigned int N = 4; T = double]' F:/Programming/SignalStudio/lib/kfr/include/kfr/base/expression.hpp:646:47: required from 'void kfr::avx2::tprocess_body(Out&&, In&&, std::size_t, std::size_t, std::size_t, kfr::shape, kfr::shape) [with Out = kfr::univector&; In = kfr::expression_slice<kfr::avx2::generator_sin<double, 4> >; long long unsigned int OutAxis = 0; long long unsigned int w = 4; long long unsigned int gw = 1; Tin = double; long long unsigned int outdims = 1; long long unsigned int indims = 1; std::size_t = long long unsigned int]' F:/Programming/SignalStudio/lib/kfr/include/kfr/base/expression.hpp:768:70: required from 'kfr::shape kfr::avx2::process(Out&&, In&&, kfr::shape, kfr::shape, cometa::csize_t) [with long long unsigned int width = 0; long long unsigned int Axis = 18446744073709551615; Out = kfr::univector&; In = kfr::expression_slice<kfr::avx2::generator_sin<double, 4> >; long long unsigned int gw = 1; long long unsigned int outdims = 1; typename std::enable_if<(expression_dims > 0), cometa::details::unique_enum_impl<721>::type>::type = (cometa::details::unique_enum_impl<721>::type)721; cometa::csize_t = cometa::cval_t<long long unsigned int, 1>]' F:/Programming/SignalStudio/lib/kfr/include/kfr/base/univector.hpp:246:16: required from 'void kfr::univector_base<T, Class, true>::assign_expr(Input&&) [with Input = kfr::expression_slice<kfr::avx2::generator_sin<double, 4> >; T = double; Class = kfr::univector]' F:/Programming/SignalStudio/lib/kfr/include/kfr/base/univector.hpp:417:9: required from 'kfr::univector<T, 18446744073709551615>::univector(Input&&) [with Input = kfr::expression_slice<kfr::avx2::generator_sin<double, 4> >; kfr::internal_generic::expressions_check* = 0; T = double]' F:/Programming/SignalStudio/src/devices/input/generator.cpp:88:113: required from here F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:103:92: error: 'const struct kfr::avx2::generator_sin<double, 4>' has no member named 'get_value'; did you mean 'get_shape'? KFR_MEM_INTRINSIC vec<T, width> call_get_value() const { return ptr_cast(this)->get_value(); }


                                                                     get_shape

3) F:\Programming\SignalStudio\lib\kfr\include\kfr\base\generators.hpp:241: error: passing 'const kfr::avx2::vec<double, 8>' as 'this' argument discards qualifiers [-fpermissive]
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:101:48:   required from 'void kfr::avx2::generator<T, VecWidth, Class, Twork>::call_next() const [with T = double; long long unsigned int VecWidth = 4; Class = kfr::avx2::generator_sin<double, 4>; Twork = kfr::avx2::vec<double, 2>]'
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:87:13:   required from 'kfr::avx2::vec<T, N> kfr::avx2::generator<T, VecWidth, Class, Twork>::generate() const [with long long unsigned int N = 4; T = double; long long unsigned int VecWidth = 4; Class = kfr::avx2::generator_sin<double, 4>; Twork = kfr::avx2::vec<double, 2>]'
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:97:42:   required from 'kfr::avx2::vec<T, N> kfr::avx2::get_elements(const kfr::avx2::generator<T, VecWidth, Class, Twork>&, const kfr::shape<1>&, const kfr::axis_params<0, N>&) [with long long unsigned int N = 4; T = double; long long unsigned int VecWidth = 4; Class = kfr::avx2::generator_sin<double, 4>; Twork = kfr::avx2::vec<double, 2>]'
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/basic_expressions.hpp:195:47:   required from 'kfr::avx2::vec<SubType, N> kfr::avx2::get_elements(const kfr::expression_slice<Arg>&, const kfr::shape<indims>&, const kfr::axis_params<VecAxis, N>&) [with Arg = kfr::avx2::generator_sin<double, 4>; long long unsigned int NDims = 1; long long unsigned int Axis = 0; long long unsigned int N = 4; T = double]'
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/expression.hpp:646:47:   required from 'void kfr::avx2::tprocess_body(Out&&, In&&, std::size_t, std::size_t, std::size_t, kfr::shape<outdims>, kfr::shape<indims>) [with Out = kfr::univector<double>&; In = kfr::expression_slice<kfr::avx2::generator_sin<double, 4> >; long long unsigned int OutAxis = 0; long long unsigned int w = 4; long long unsigned int gw = 1; Tin = double; long long unsigned int outdims = 1; long long unsigned int indims = 1; std::size_t = long long unsigned int]'
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/expression.hpp:768:70:   required from 'kfr::shape<Dims> kfr::avx2::process(Out&&, In&&, kfr::shape<Dims>, kfr::shape<Dims>, cometa::csize_t<count>) [with long long unsigned int width = 0; long long unsigned int Axis = 18446744073709551615; Out = kfr::univector<double>&; In = kfr::expression_slice<kfr::avx2::generator_sin<double, 4> >; long long unsigned int gw = 1; long long unsigned int outdims = 1; typename std::enable_if<(expression_dims<Out> > 0), cometa::details::unique_enum_impl<721>::type>::type <anonymous> = (cometa::details::unique_enum_impl<721>::type)721; cometa::csize_t<count> = cometa::cval_t<long long unsigned int, 1>]'
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/univector.hpp:246:16:   required from 'void kfr::univector_base<T, Class, true>::assign_expr(Input&&) [with Input = kfr::expression_slice<kfr::avx2::generator_sin<double, 4> >; T = double; Class = kfr::univector<double>]'
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/univector.hpp:417:9:   required from 'kfr::univector<T, 18446744073709551615>::univector(Input&&) [with Input = kfr::expression_slice<kfr::avx2::generator_sin<double, 4> >; kfr::internal_generic::expressions_check<Input>* <anonymous> = 0; T = double]'
F:/Programming/SignalStudio/src/devices/input/generator.cpp:88:113:   required from here
F:/Programming/SignalStudio/lib/kfr/include/kfr/base/generators.hpp:241:12: error: passing 'const kfr::avx2::vec<double, 8>' as 'this' argument discards qualifiers [-fpermissive]
         cs = cs - addsub(alpha * cs, beta * swap<2>(cs));
         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dancazarin commented 1 year ago

Hello. Fixed in dev branch

dancazarin commented 1 year ago

Merged into master