kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit 81869ce9941e14c584326fbe235ca3ab4a6b7b3b
parent deb4387ea4d91d161d395c7154ed19908b3d06dc
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Mon, 22 Jan 2024 08:45:24 +0000

Update clang-format to 17, reformat code

Diffstat:
M.clang-format | 5+++--
Mcapi/capi.cpp | 22++++++++++------------
Minclude/kfr/base/expression.hpp | 29+++++++++++++++--------------
Minclude/kfr/base/generators.hpp | 5+----
Minclude/kfr/base/impl/static_array.hpp | 5+++--
Minclude/kfr/base/random_bits.hpp | 6+++---
Minclude/kfr/base/tensor.hpp | 2+-
Minclude/kfr/base/univector.hpp | 9+++------
Minclude/kfr/cometa/array.hpp | 4++--
Minclude/kfr/cometa/memory.hpp | 6+++---
Minclude/kfr/cometa/string.hpp | 2+-
Minclude/kfr/dft/fft.hpp | 5+----
Minclude/kfr/dft/impl/dft-impl.hpp | 4++--
Minclude/kfr/dft/impl/ft.hpp | 34+++++++++++++++++-----------------
Minclude/kfr/dft/reference_dft.hpp | 5+++--
Minclude/kfr/dsp/goertzel.hpp | 19+++++++++++--------
Minclude/kfr/dsp/sample_rate_conversion.hpp | 4++--
Minclude/kfr/graphics/geometry.hpp | 13++++++++-----
Minclude/kfr/io/audiofile.hpp | 4++--
Minclude/kfr/math/complex_math.hpp | 6+++---
Minclude/kfr/simd/complex_type.hpp | 6+++---
Minclude/kfr/simd/impl/backend_generic.hpp | 4++--
Minclude/kfr/simd/operators.hpp | 14+++++++-------
Minclude/kfr/simd/platform.hpp | 2+-
Minclude/kfr/simd/read_write.hpp | 4++--
Minclude/kfr/simd/shuffle.hpp | 2+-
Minclude/kfr/simd/types.hpp | 1-
Minclude/kfr/simd/vec.hpp | 2+-
Minclude/kfr/testo/console_colors.hpp | 2+-
Mtests/intrinsic_test.cpp | 2+-
Mtests/mpfr/mpfrplus.hpp | 8++++----
Mtests/unit/graphics/color.cpp | 2+-
Mtests/unit/math/log_exp.cpp | 2+-
Mtests/unit/simd/min_max.cpp | 1-
Mtests/unit/simd/operators.cpp | 41++++++++++++++++-------------------------
35 files changed, 135 insertions(+), 147 deletions(-)

diff --git a/.clang-format b/.clang-format @@ -14,8 +14,7 @@ Cpp11BracedListStyle: false AllowShortIfStatementsOnASingleLine: false AllowShortFunctionsOnASingleLine : true AlignOperands: true -Standard: Cpp11 -IndentCaseLabels: false +Standard: c++17 AlignTrailingComments : false ConstructorInitializerAllOnOneLineOrOnePerLine : false ColumnLimit: 110 @@ -25,3 +24,5 @@ AlwaysBreakTemplateDeclarations : true AlignConsecutiveAssignments : true PenaltyReturnTypeOnItsOwnLine: 50000 CommentPragmas: '^ >' +IndentExternBlock: NoIndent +SortIncludes: false diff --git a/capi/capi.cpp b/capi/capi.cpp @@ -291,8 +291,7 @@ extern "C" KFR_FILTER_F32* kfr_filter_create_fir_plan_f32(const kfr_f32* taps, size_t size) { #ifndef CMT_MULTI - return reinterpret_cast<KFR_FILTER_F32*>( - make_fir_filter<float>(make_univector(taps, size))); + return reinterpret_cast<KFR_FILTER_F32*>(make_fir_filter<float>(make_univector(taps, size))); #else return reinterpret_cast<KFR_FILTER_F32*>( make_fir_filter<float>(cpu_t::runtime, make_univector(taps, size))); @@ -301,8 +300,7 @@ extern "C" KFR_FILTER_F64* kfr_filter_create_fir_plan_f64(const kfr_f64* taps, size_t size) { #ifndef CMT_MULTI - return reinterpret_cast<KFR_FILTER_F64*>( - make_fir_filter<double>(make_univector(taps, size))); + return reinterpret_cast<KFR_FILTER_F64*>(make_fir_filter<double>(make_univector(taps, size))); #else return reinterpret_cast<KFR_FILTER_F64*>( make_fir_filter<double>(cpu_t::runtime, make_univector(taps, size))); @@ -313,8 +311,8 @@ extern "C" size_t block_size) { #ifndef CMT_MULTI - return reinterpret_cast<KFR_FILTER_F32*>(make_convolve_filter<float>( - make_univector(taps, size), block_size ? block_size : 1024)); + return reinterpret_cast<KFR_FILTER_F32*>( + make_convolve_filter<float>(make_univector(taps, size), block_size ? block_size : 1024)); #else return reinterpret_cast<KFR_FILTER_F32*>(make_convolve_filter<float>( cpu_t::runtime, make_univector(taps, size), block_size ? block_size : 1024)); @@ -324,8 +322,8 @@ extern "C" size_t block_size) { #ifndef CMT_MULTI - return reinterpret_cast<KFR_FILTER_F64*>(make_convolve_filter<double>( - make_univector(taps, size), block_size ? block_size : 1024)); + return reinterpret_cast<KFR_FILTER_F64*>( + make_convolve_filter<double>(make_univector(taps, size), block_size ? block_size : 1024)); #else return reinterpret_cast<KFR_FILTER_F64*>(make_convolve_filter<double>( cpu_t::runtime, make_univector(taps, size), block_size ? block_size : 1024)); @@ -338,8 +336,8 @@ extern "C" return nullptr; #ifndef CMT_MULTI - return reinterpret_cast<KFR_FILTER_F32*>(make_biquad_filter<float, 64>( - reinterpret_cast<const biquad_params<float>*>(sos), sos_count)); + return reinterpret_cast<KFR_FILTER_F32*>( + make_biquad_filter<float, 64>(reinterpret_cast<const biquad_params<float>*>(sos), sos_count)); #else return reinterpret_cast<KFR_FILTER_F32*>(make_biquad_filter<float, 64>( cpu_t::runtime, reinterpret_cast<const biquad_params<float>*>(sos), sos_count)); @@ -351,8 +349,8 @@ extern "C" return nullptr; #ifndef CMT_MULTI - return reinterpret_cast<KFR_FILTER_F64*>(make_biquad_filter<double, 64>( - reinterpret_cast<const biquad_params<double>*>(sos), sos_count)); + return reinterpret_cast<KFR_FILTER_F64*>( + make_biquad_filter<double, 64>(reinterpret_cast<const biquad_params<double>*>(sos), sos_count)); #else return reinterpret_cast<KFR_FILTER_F64*>(make_biquad_filter<double, 64>( cpu_t::runtime, reinterpret_cast<const biquad_params<double>*>(sos), sos_count)); diff --git a/include/kfr/base/expression.hpp b/include/kfr/base/expression.hpp @@ -187,7 +187,7 @@ constexpr inline bool is_input_output_expression<E, enable_if_input_output_expre KFR_ENABLE_IF(is_input_output_expression<E1>&& is_input_expression<E2>) template <typename T> -constexpr inline bool is_expr_element = std::is_same_v<std::remove_cv_t<T>, T>&& is_vec_element<T>; +constexpr inline bool is_expr_element = std::is_same_v<std::remove_cv_t<T>, T> && is_vec_element<T>; template <typename E> constexpr inline bool is_infinite = expression_traits<E>::get_shape().has_infinity(); @@ -470,18 +470,21 @@ struct expression_function : expression_with_arguments<Args...>, expression_trai #else constexpr static shape<dims> get_shape(const expression_function& self) { - return self.fold([&](auto&&... args) CMT_INLINE_LAMBDA constexpr->auto { - return internal_generic::common_shape<true>( - expression_traits<decltype(args)>::get_shape(args)...); - }); + return self.fold( + [&](auto&&... args) CMT_INLINE_LAMBDA constexpr -> auto { + return internal_generic::common_shape<true>( + expression_traits<decltype(args)>::get_shape(args)...); + }); } constexpr static shape<dims> get_shape() { - return expression_function::fold_idx([&](auto... args) CMT_INLINE_LAMBDA constexpr->auto { - return internal_generic::common_shape( - expression_traits< - typename expression_function::template nth<val_of(decltype(args)())>>::get_shape()...); - }); + return expression_function::fold_idx( + [&](auto... args) CMT_INLINE_LAMBDA constexpr -> auto + { + return internal_generic::common_shape( + expression_traits<typename expression_function::template nth<val_of(decltype(args)())>>:: + get_shape()...); + }); } #endif @@ -597,10 +600,8 @@ template <typename Fn, typename... Args, index_t Axis, size_t N, index_t Dims, KFR_INTRINSIC vec<T, N> get_elements(const expression_function<Fn, Args...>& self, const shape<Dims>& index, const axis_params<Axis, N>& sh) { - return self.fold_idx( - [&](auto... idx) CMT_INLINE_LAMBDA -> vec<T, N> { - return self.fn(internal::get_arg<Tr::dims>(self, index, sh, idx)...); - }); + return self.fold_idx([&](auto... idx) CMT_INLINE_LAMBDA -> vec<T, N> + { return self.fn(internal::get_arg<Tr::dims>(self, index, sh, idx)...); }); } template <typename Out, typename In, index_t OutAxis, size_t w, size_t gw, typename Tin, index_t outdims, diff --git a/include/kfr/base/generators.hpp b/include/kfr/base/generators.hpp @@ -243,10 +243,7 @@ struct generator_sin : public generator<T, VecWidth, generator_sin<T, VecWidth>, this->value = vec<vec<T, 2>, VecWidth>::from_flatten(cs); } - KFR_MEM_INTRINSIC vec<T, VecWidth> get_value() const - { - return odd(flatten(this->value)); - } + KFR_MEM_INTRINSIC vec<T, VecWidth> get_value() const { return odd(flatten(this->value)); } protected: T step; diff --git a/include/kfr/base/impl/static_array.hpp b/include/kfr/base/impl/static_array.hpp @@ -98,10 +98,11 @@ struct static_array_base<T, csizes_t<indices...>> } constexpr static_array_base& operator=(const static_array_base&) = default; - constexpr static_array_base& operator=(static_array_base&&) = default; + constexpr static_array_base& operator=(static_array_base&&) = default; template <size_t index> - constexpr static value_type just_value(value_type value) { + constexpr static value_type just_value(value_type value) + { // Workaround for MSVC2019 Internal compiler error return value; } diff --git a/include/kfr/base/random_bits.hpp b/include/kfr/base/random_bits.hpp @@ -50,9 +50,9 @@ constexpr seed_from_rdtsc_t seed_from_rdtsc{}; struct random_state { constexpr random_state() : v{ 0, 0, 0, 0 } {} - constexpr random_state(random_state&&) = default; - constexpr random_state(const random_state&) = default; - constexpr random_state& operator=(random_state&&) = default; + constexpr random_state(random_state&&) = default; + constexpr random_state(const random_state&) = default; + constexpr random_state& operator=(random_state&&) = default; constexpr random_state& operator=(const random_state&) = default; // internal field portable_vec<u32, 4> v; diff --git a/include/kfr/base/tensor.hpp b/include/kfr/base/tensor.hpp @@ -352,7 +352,7 @@ public: tensor(const tensor&& other) : tensor(static_cast<const tensor&>(other)) {} #else tensor(const tensor&) = default; - tensor(tensor&&) = default; + tensor(tensor&&) = default; tensor(tensor& other) : tensor(const_cast<const tensor&>(other)) {} tensor(const tensor&& other) : tensor(static_cast<const tensor&>(other)) {} #endif diff --git a/include/kfr/base/univector.hpp b/include/kfr/base/univector.hpp @@ -455,7 +455,7 @@ struct univector<T, tag_dynamic_vector> new (this) univector(other); return *this; } - univector& operator=(univector&& other) + univector& operator=(univector&& other) { this->~univector(); new (this) univector(std::move(other)); @@ -463,12 +463,9 @@ struct univector<T, tag_dynamic_vector> } #else univector& operator=(const univector&) = default; - univector& operator=(univector&&) = default; + univector& operator=(univector&&) = default; #endif - KFR_MEM_INTRINSIC univector& operator=(univector& other) - { - return operator=(std::as_const(other)); - } + KFR_MEM_INTRINSIC univector& operator=(univector& other) { return operator=(std::as_const(other)); } template <typename Input, KFR_ACCEPT_EXPRESSIONS(Input)> KFR_MEM_INTRINSIC univector& operator=(Input&& input) { diff --git a/include/kfr/cometa/array.hpp b/include/kfr/cometa/array.hpp @@ -33,10 +33,10 @@ public: constexpr array_ref(array_ref&&) CMT_NOEXCEPT = default; #ifdef CMT_COMPILER_GNU constexpr array_ref& operator=(const array_ref&) CMT_NOEXCEPT = default; - constexpr array_ref& operator=(array_ref&&) CMT_NOEXCEPT = default; + constexpr array_ref& operator=(array_ref&&) CMT_NOEXCEPT = default; #else array_ref& operator=(const array_ref&) = default; - array_ref& operator=(array_ref&&) = default; + array_ref& operator=(array_ref&&) = default; #endif template <size_t N> diff --git a/include/kfr/cometa/memory.hpp b/include/kfr/cometa/memory.hpp @@ -164,9 +164,9 @@ struct autofree { CMT_MEM_INTRINSIC autofree() {} explicit CMT_MEM_INTRINSIC autofree(size_t size) : ptr(aligned_allocate<T>(size)) {} - autofree(const autofree&) = delete; - autofree& operator=(const autofree&) = delete; - autofree(autofree&&) CMT_NOEXCEPT = default; + autofree(const autofree&) = delete; + autofree& operator=(const autofree&) = delete; + autofree(autofree&&) CMT_NOEXCEPT = default; autofree& operator=(autofree&&) CMT_NOEXCEPT = default; CMT_MEM_INTRINSIC T& operator[](size_t index) CMT_NOEXCEPT { return ptr[index]; } CMT_MEM_INTRINSIC const T& operator[](size_t index) const CMT_NOEXCEPT { return ptr[index]; } diff --git a/include/kfr/cometa/string.hpp b/include/kfr/cometa/string.hpp @@ -655,7 +655,7 @@ std::string array_to_string(size_t size, Getter&& getter, int max_columns = 16, std::string_view close = "}") { return array_to_string<Fmt>(std::array<size_t, 1>{ size }, std::forward<Getter>(getter), max_columns, - max_dimensions, std::move(separator), std::move(open), std::move(close)); + max_dimensions, std::move(separator), std::move(open), std::move(close)); } template <typename Fmt = void, typename T> std::string array_to_string(size_t size, T* data, int max_columns = 16, int max_dimensions = INT_MAX, diff --git a/include/kfr/dft/fft.hpp b/include/kfr/dft/fft.hpp @@ -402,10 +402,7 @@ struct dft_plan_real : dft_plan<T> size_t size; dft_pack_format fmt; - dft_plan_real() - : size(0), fmt(dft_pack_format::CCs) - { - } + dft_plan_real() : size(0), fmt(dft_pack_format::CCs) {} dft_plan_real(const dft_plan_real&) = delete; dft_plan_real(dft_plan_real&&) = default; diff --git a/include/kfr/dft/impl/dft-impl.hpp b/include/kfr/dft/impl/dft-impl.hpp @@ -94,7 +94,7 @@ struct dft_stage_fixed_impl : dft_stage<T> this->recursion = false; // true; this->stage_size = fixed_radix * iterations * blocks; this->data_size = align_up((this->repeats * (fixed_radix - 1)) * sizeof(complex<T>), - platform<>::native_cache_alignment); + platform<>::native_cache_alignment); } constexpr static size_t rradix = fixed_radix; @@ -254,7 +254,7 @@ struct dft_arblen_stage_impl : dft_stage<T> univector<complex<T>> xp_fft; }; -template <typename T, size_t radix1, size_t radix2, size_t size = radix1* radix2> +template <typename T, size_t radix1, size_t radix2, size_t size = radix1 * radix2> struct dft_special_stage_impl : dft_stage<T> { dft_special_stage_impl() : stage1(radix1, size / radix1, 1), stage2(radix2, 1, size / radix2) diff --git a/include/kfr/dft/impl/ft.hpp b/include/kfr/dft/impl/ft.hpp @@ -1069,17 +1069,17 @@ KFR_INTRINSIC void butterfly6(const cvec<T, N>& a0, const cvec<T, N>& a1, const cvec<T, N>& w0, cvec<T, N>& w1, cvec<T, N>& w2, cvec<T, N>& w3, cvec<T, N>& w4, cvec<T, N>& w5) { - cvec<T, N* 2> a03 = concat(a0, a3); - cvec<T, N* 2> a25 = concat(a2, a5); - cvec<T, N* 2> a41 = concat(a4, a1); + cvec<T, N * 2> a03 = concat(a0, a3); + cvec<T, N * 2> a25 = concat(a2, a5); + cvec<T, N * 2> a41 = concat(a4, a1); butterfly3<N * 2, inverse>(a03, a25, a41, a03, a25, a41); cvec<T, N> t0, t1, t2, t3, t4, t5; split(a03, t0, t1); split(a25, t2, t3); split(a41, t4, t5); - t3 = -t3; - cvec<T, N* 2> a04 = concat(t0, t4); - cvec<T, N* 2> a15 = concat(t1, t5); + t3 = -t3; + cvec<T, N * 2> a04 = concat(t0, t4); + cvec<T, N * 2> a15 = concat(t1, t5); cvec<T, N * 2> w02, w35; butterfly2<N * 2>(a04, a15, w02, w35); split(w02, w0, w2); @@ -1121,9 +1121,9 @@ KFR_INTRINSIC void butterfly9(const cvec<T, N>& a0, const cvec<T, N>& a1, const cvec<T, N>& w0, cvec<T, N>& w1, cvec<T, N>& w2, cvec<T, N>& w3, cvec<T, N>& w4, cvec<T, N>& w5, cvec<T, N>& w6, cvec<T, N>& w7, cvec<T, N>& w8) { - cvec<T, N* 3> a012 = concat(a0, a1, a2); - cvec<T, N* 3> a345 = concat(a3, a4, a5); - cvec<T, N* 3> a678 = concat(a6, a7, a8); + cvec<T, N * 3> a012 = concat(a0, a1, a2); + cvec<T, N * 3> a345 = concat(a3, a4, a5); + cvec<T, N * 3> a678 = concat(a6, a7, a8); butterfly3<N * 3, inverse>(a012, a345, a678, a012, a345, a678); cvec<T, N> t0, t1, t2, t3, t4, t5, t6, t7, t8; split(a012, t0, t1, t2); @@ -1135,9 +1135,9 @@ KFR_INTRINSIC void butterfly9(const cvec<T, N>& a0, const cvec<T, N>& a1, const t7 = cmul(t7, tw9_2<T, inverse>()); t8 = cmul(t8, tw9_4<T, inverse>()); - cvec<T, N* 3> t036 = concat(t0, t3, t6); - cvec<T, N* 3> t147 = concat(t1, t4, t7); - cvec<T, N* 3> t258 = concat(t2, t5, t8); + cvec<T, N * 3> t036 = concat(t0, t3, t6); + cvec<T, N * 3> t147 = concat(t1, t4, t7); + cvec<T, N * 3> t258 = concat(t2, t5, t8); butterfly3<N * 3, inverse>(t036, t147, t258, t036, t147, t258); split(t036, w0, w1, w2); @@ -1381,11 +1381,11 @@ KFR_INTRINSIC void butterfly10(const cvec<T, N>& a0, const cvec<T, N>& a1, const cvec<T, N>& w3, cvec<T, N>& w4, cvec<T, N>& w5, cvec<T, N>& w6, cvec<T, N>& w7, cvec<T, N>& w8, cvec<T, N>& w9) { - cvec<T, N* 2> a05 = concat(a0, a5); - cvec<T, N* 2> a27 = concat(a2, a7); - cvec<T, N* 2> a49 = concat(a4, a9); - cvec<T, N* 2> a61 = concat(a6, a1); - cvec<T, N* 2> a83 = concat(a8, a3); + cvec<T, N * 2> a05 = concat(a0, a5); + cvec<T, N * 2> a27 = concat(a2, a7); + cvec<T, N * 2> a49 = concat(a4, a9); + cvec<T, N * 2> a61 = concat(a6, a1); + cvec<T, N * 2> a83 = concat(a8, a3); butterfly5<N * 2, inverse>(a05, a27, a49, a61, a83, a05, a27, a49, a61, a83); cvec<T, N> t0, t1, t2, t3, t4, t5, t6, t7, t8, t9; split(a05, t0, t1); diff --git a/include/kfr/dft/reference_dft.hpp b/include/kfr/dft/reference_dft.hpp @@ -87,7 +87,8 @@ void reference_fft(complex<T>* out, const complex<T>* in, size_t size, bool inve using Tcmplx = Tnumber(*)[2]; if (size < 1) return; - if (size == 1) { + if (size == 1) + { out[0] = in[0]; return; } @@ -169,7 +170,7 @@ void reference_dft(T* out, const complex<T>* in, size_t size) if (size < 1) return; std::vector<complex<T>> dataout(size); - reference_dft(dataout.data(), in, size, true); + reference_dft(dataout.data(), in, size, true); for (size_t i = 0; i < size; i++) out[i] = dataout[i].real(); } diff --git a/include/kfr/dsp/goertzel.hpp b/include/kfr/dsp/goertzel.hpp @@ -38,10 +38,10 @@ inline namespace CMT_ARCH_NAME template <typename T> struct expression_goertzel : expression_traits_defaults { - constexpr static size_t dims = 1; + constexpr static size_t dims = 1; using value_type = T; - + constexpr static shape<1> get_shape(const expression_goertzel&) { return shape<1>(infinite_size); } constexpr static shape<1> get_shape() { return shape<1>(infinite_size); } @@ -54,7 +54,7 @@ struct expression_goertzel : expression_traits_defaults result.real(q1 - q2 * cos(omega)); result.imag(q2 * sin(omega)); } - + template <size_t N, index_t VecAxis> friend KFR_INTRINSIC void set_elements(expression_goertzel& self, shape<1>, axis_params<VecAxis, N>, const identity<vec<T, N>>& x) @@ -79,11 +79,14 @@ struct expression_goertzel : expression_traits_defaults template <typename T, size_t width> struct expression_parallel_goertzel : expression_traits_defaults { - constexpr static size_t dims = 1; + constexpr static size_t dims = 1; using value_type = T; - - constexpr static shape<1> get_shape(const expression_parallel_goertzel&) { return shape<1>(infinite_size); } + + constexpr static shape<1> get_shape(const expression_parallel_goertzel&) + { + return shape<1>(infinite_size); + } constexpr static shape<1> get_shape() { return shape<1>(infinite_size); } expression_parallel_goertzel(complex<T> result[], vec<T, width> omega) @@ -101,8 +104,8 @@ struct expression_parallel_goertzel : expression_traits_defaults } } template <size_t N, index_t VecAxis> - friend KFR_INTRINSIC void set_elements(expression_parallel_goertzel& self, shape<1>, axis_params<VecAxis, N>, - const identity<vec<T, N>>& x) + friend KFR_INTRINSIC void set_elements(expression_parallel_goertzel& self, shape<1>, + axis_params<VecAxis, N>, const identity<vec<T, N>>& x) { const vec<T, N> in = x; CMT_LOOP_UNROLL diff --git a/include/kfr/dsp/sample_rate_conversion.hpp b/include/kfr/dsp/sample_rate_conversion.hpp @@ -339,7 +339,7 @@ struct expression_downsample<2, offset, E> : expression_with_arguments<E> KFR_INTRINSIC friend vec<T, N> get_elements(const expression_downsample& self, size_t index, axis_params<0, N>) CMT_NOEXCEPT { - const vec<T, N* 2> x = get_elements(self.first(), index * 2, axis_params<0, N * 2>()); + const vec<T, N * 2> x = get_elements(self.first(), index * 2, axis_params<0, N * 2>()); return x.shuffle(csizeseq<N, offset, 2>); } }; @@ -357,7 +357,7 @@ struct expression_downsample<4, offset, E> : expression_with_arguments<E> KFR_INTRINSIC friend vec<T, N> get_elements(const expression_downsample& self, index_t index, axis_params<0, N>) CMT_NOEXCEPT { - const vec<T, N* 4> x = get_elements(self.first(), index * 4, axis_params<0, N * 4>()); + const vec<T, N * 4> x = get_elements(self.first(), index * 4, axis_params<0, N * 4>()); return x.shuffle(csizeseq<N, offset, 4>); } }; diff --git a/include/kfr/graphics/geometry.hpp b/include/kfr/graphics/geometry.hpp @@ -64,7 +64,7 @@ struct point constexpr point(T x, T y) noexcept : v(x, y) {} constexpr point(const size<T>& sz) noexcept : v(sz.v) {} #if CMT_COMPILER_IS_MSVC - constexpr point(const point& p) noexcept: v(p.v) {} + constexpr point(const point& p) noexcept : v(p.v) {} #else constexpr point(const point& p) noexcept = default; #endif @@ -150,7 +150,7 @@ struct size constexpr explicit size(T xy) noexcept : v(xy, xy) {} constexpr size(const vec<T, 2>& v) noexcept : v(v) {} #if CMT_COMPILER_IS_MSVC - constexpr size(const size& p) noexcept: v(p.v) {} + constexpr size(const size& p) noexcept : v(p.v) {} #else constexpr size(const size& p) noexcept = default; #endif @@ -227,7 +227,7 @@ struct border constexpr border(T x1, T y1, T x2, T y2) noexcept : v(x1, y1, x2, y2) {} constexpr explicit border(const vec<T, 4>& v) : v(v) {} #if CMT_COMPILER_IS_MSVC - constexpr border(const border& p) noexcept: v(p.v) {} + constexpr border(const border& p) noexcept : v(p.v) {} #else constexpr border(const border& p) noexcept = default; #endif @@ -297,7 +297,7 @@ struct rectangle constexpr rectangle(T x1, T y1, T x2, T y2) : v(x1, y1, x2, y2) {} constexpr explicit rectangle(const vec<T, 4>& v) : v(v) {} #if CMT_COMPILER_IS_MSVC - constexpr rectangle(const rectangle& p) noexcept: v(p.v) {} + constexpr rectangle(const rectangle& p) noexcept : v(p.v) {} #else constexpr rectangle(const rectangle& p) noexcept = default; #endif @@ -342,7 +342,10 @@ struct rectangle return rectangle( concat(cast<T>(p1.v + this->size().v * point1.v), cast<T>(p1.v + this->size().v * point2))); } - rectangle split(Tfloat x, Tfloat y, Tfloat w, Tfloat h) const noexcept { return split({ x, y }, { w, h }); } + rectangle split(Tfloat x, Tfloat y, Tfloat w, Tfloat h) const noexcept + { + return split({ x, y }, { w, h }); + } rectangle cut_h_start(T width, bool partial = false) { diff --git a/include/kfr/io/audiofile.hpp b/include/kfr/io/audiofile.hpp @@ -363,8 +363,8 @@ struct audio_reader_flac : audio_reader<T> audio_reader_flac(std::shared_ptr<abstract_reader<>>&& reader) : reader(std::move(reader)) { f = drflac_open((drflac_read_proc)&internal_generic::drflac_reader_read_proc, - (drflac_seek_proc)&internal_generic::drflac_reader_seek_proc, this->reader.get(), - nullptr); + (drflac_seek_proc)&internal_generic::drflac_reader_seek_proc, this->reader.get(), + nullptr); fmt.channels = f->channels; fmt.samplerate = f->sampleRate; fmt.length = static_cast<imax>(f->totalPCMFrameCount); diff --git a/include/kfr/math/complex_math.hpp b/include/kfr/math/complex_math.hpp @@ -66,19 +66,19 @@ KFR_INTRINSIC vec<complex<T>, N> ccosh(const vec<complex<T>, N>& x) template <typename T, size_t N> KFR_INTRINSIC vec<T, N> cabssqr(const vec<complex<T>, N>& x) { - const vec<T, N* 2> xx = sqr(cdecom(x)); + const vec<T, N * 2> xx = sqr(cdecom(x)); return even(xx) + odd(xx); } template <typename T, size_t N> KFR_INTRINSIC vec<T, N> cabs(const vec<complex<T>, N>& x) { - const vec<T, N* 2> xx = sqr(cdecom(x)); + const vec<T, N * 2> xx = sqr(cdecom(x)); return sqrt(even(xx) + odd(xx)); } template <typename T, size_t N> KFR_INTRINSIC vec<T, N> carg(const vec<complex<T>, N>& x) { - const vec<T, N* 2> xx = cdecom(x); + const vec<T, N * 2> xx = cdecom(x); return atan2(odd(xx), even(xx)); } diff --git a/include/kfr/simd/complex_type.hpp b/include/kfr/simd/complex_type.hpp @@ -50,7 +50,7 @@ template <typename T> struct complex { static_assert(is_simd_type<T>, "Incorrect type for complex"); - constexpr complex() CMT_NOEXCEPT = default; + constexpr complex() CMT_NOEXCEPT = default; KFR_MEM_INTRINSIC constexpr complex(T re) CMT_NOEXCEPT : re(re), im(0) {} KFR_MEM_INTRINSIC constexpr complex(T re, T im) CMT_NOEXCEPT : re(re), im(im) {} constexpr complex(const complex&) CMT_NOEXCEPT = default; @@ -68,10 +68,10 @@ struct complex } #ifdef CMT_COMPILER_GNU constexpr complex& operator=(const complex&) CMT_NOEXCEPT = default; - constexpr complex& operator=(complex&&) CMT_NOEXCEPT = default; + constexpr complex& operator=(complex&&) CMT_NOEXCEPT = default; #else complex& operator=(const complex&) = default; - complex& operator=(complex&&) = default; + complex& operator=(complex&&) = default; #endif KFR_MEM_INTRINSIC constexpr const T& real() const CMT_NOEXCEPT { return re; } KFR_MEM_INTRINSIC constexpr const T& imag() const CMT_NOEXCEPT { return im; } diff --git a/include/kfr/simd/impl/backend_generic.hpp b/include/kfr/simd/impl/backend_generic.hpp @@ -306,11 +306,11 @@ KFR_SIMD_TYPE(f64, 2, float64x2_t); #define KFR_i8sse_INDEX(x, i) bitcast_anything<simd_array<i8, 16>>(x).val[i] #define KFR_i16sse_INDEX(x, i) bitcast_anything<simd_array<i16, 8>>(x).val[i] #define KFR_i32sse_INDEX(x, i) _mm_cvtsi128_si32(_mm_shuffle_epi32(x, _MM_SHUFFLE(3, 2, 1, i))) -#define KFR_i64sse_INDEX(x, i) _mm_cvtsi128_si64(_mm_shuffle_epi32(x, _MM_SHUFFLE(3, 2, (i)*2 + 1, i * 2))) +#define KFR_i64sse_INDEX(x, i) _mm_cvtsi128_si64(_mm_shuffle_epi32(x, _MM_SHUFFLE(3, 2, (i) * 2 + 1, i * 2))) #define KFR_u8sse_INDEX(x, i) bitcast_anything<simd_array<u8, 16>>(x).val[i] #define KFR_u16sse_INDEX(x, i) bitcast_anything<simd_array<u16, 8>>(x).val[i] #define KFR_u32sse_INDEX(x, i) _mm_cvtsi128_si32(_mm_shuffle_epi32(x, _MM_SHUFFLE(3, 2, 1, i))) -#define KFR_u64sse_INDEX(x, i) _mm_cvtsi128_si64(_mm_shuffle_epi32(x, _MM_SHUFFLE(3, 2, (i)*2 + 1, i * 2))) +#define KFR_u64sse_INDEX(x, i) _mm_cvtsi128_si64(_mm_shuffle_epi32(x, _MM_SHUFFLE(3, 2, (i) * 2 + 1, i * 2))) #define KFR_f32sse_INDEX(x, i) _mm_cvtss_f32(_mm_shuffle_ps(x, x, _MM_SHUFFLE(3, 2, 1, i))) #define KFR_f64sse_INDEX(x, i) _mm_cvtsd_f64(_mm_shuffle_pd(x, x, _MM_SHUFFLE2(1, i))) #endif diff --git a/include/kfr/simd/operators.hpp b/include/kfr/simd/operators.hpp @@ -53,20 +53,20 @@ inline namespace CMT_ARCH_NAME return x; \ } \ template <typename T1, typename T2, size_t N, KFR_ENABLE_IF(1 + vec_rank<T1> > vec_rank<T2>)> \ - constexpr KFR_INTRINSIC vec<T1, N>& operator asgnop(vec<T1, N>& x, const T2& y) \ + constexpr KFR_INTRINSIC vec<T1, N>& operator asgnop(vec<T1, N>& x, const T2 & y) \ { \ x = intrinsics::fn(x, T1(y)); \ return x; \ } \ template <typename T1, typename T2, size_t N, typename C = std::common_type_t<T1, T2>, \ KFR_ENABLE_IF(1 + vec_rank<T1> > vec_rank<T2>)> \ - constexpr KFR_INTRINSIC vec<C, N> operator op(const vec<T1, N>& x, const T2& y) \ + constexpr KFR_INTRINSIC vec<C, N> operator op(const vec<T1, N>& x, const T2 & y) \ { \ return intrinsics::fn(promoteto<C>(x), C(y)); \ } \ template <typename T1, typename T2, size_t N, typename C = std::common_type_t<T1, T2>, \ KFR_ENABLE_IF(vec_rank<T1> < 1 + vec_rank<T2>)> \ - constexpr KFR_INTRINSIC vec<C, N> operator op(const T1& x, const vec<T2, N>& y) \ + constexpr KFR_INTRINSIC vec<C, N> operator op(const T1 & x, const vec<T2, N>& y) \ { \ return intrinsics::fn(C(x), promoteto<C>(y)); \ } \ @@ -96,7 +96,7 @@ inline namespace CMT_ARCH_NAME return intrinsics::fn(x, y); \ } \ template <typename T1, typename T2, size_t N, KFR_ENABLE_IF(vec_rank<T1> < 1 + vec_rank<T2>)> \ - constexpr KFR_INTRINSIC vec<T1, N> operator op(const T1& x, const vec<T2, N>& y) \ + constexpr KFR_INTRINSIC vec<T1, N> operator op(const T1 & x, const vec<T2, N>& y) \ { \ return intrinsics::fn(broadcastto<T1>(x), promoteto<utype<T1>>(y)); \ } \ @@ -109,13 +109,13 @@ inline namespace CMT_ARCH_NAME #define KFR_VEC_CMP_OPERATOR(op, fn) \ template <typename T1, typename T2, size_t N, typename C = std::common_type_t<T1, T2>, \ KFR_ENABLE_IF(1 + vec_rank<T1> > vec_rank<T2>)> \ - constexpr KFR_INTRINSIC mask<C, N> operator op(const vec<T1, N>& x, const T2& y) \ + constexpr KFR_INTRINSIC mask<C, N> operator op(const vec<T1, N>& x, const T2 & y) \ { \ return intrinsics::fn(promoteto<C>(x), vec<C, N>(y)).asmask(); \ } \ template <typename T1, typename T2, size_t N, typename C = std::common_type_t<T1, T2>, \ KFR_ENABLE_IF(vec_rank<T1> < 1 + vec_rank<T2>)> \ - constexpr KFR_INTRINSIC mask<C, N> operator op(const T1& x, const vec<T2, N>& y) \ + constexpr KFR_INTRINSIC mask<C, N> operator op(const T1 & x, const vec<T2, N>& y) \ { \ return intrinsics::fn(vec<C, N>(x), promoteto<C>(y)).asmask(); \ } \ @@ -631,7 +631,7 @@ KFR_INTRINSIC vec<T, N> negodd(const vec<T, N>& x) template <typename T, size_t N1, size_t... Ns> vec<vec<T, sizeof...(Ns) + 1>, N1> packtranspose(const vec<T, N1>& x, const vec<T, Ns>&... rest) { - const vec<T, N1*(sizeof...(Ns) + 1)> t = transpose<N1>(concat(x, rest...)); + const vec<T, N1 * (sizeof...(Ns) + 1)> t = transpose<N1>(concat(x, rest...)); return t.v; } diff --git a/include/kfr/simd/platform.hpp b/include/kfr/simd/platform.hpp @@ -270,7 +270,7 @@ constexpr static size_t minimum_vector_width = : platform<>::minimum_int_vector_size / sizeof(T))); template <typename T> -constexpr static size_t vector_capacity = platform<>::simd_register_count* vector_width<T>; +constexpr static size_t vector_capacity = platform<>::simd_register_count * vector_width<T>; #ifdef CMT_COMPILER_IS_MSVC template <typename T> diff --git a/include/kfr/simd/read_write.hpp b/include/kfr/simd/read_write.hpp @@ -127,7 +127,7 @@ KFR_INTRINSIC vec<T, N * groupsize> gather(const T* base, const vec<IT, N>& offs namespace internal { -template <size_t groupsize, typename T, size_t N, size_t Nout = N* groupsize, typename IT, size_t... Indices> +template <size_t groupsize, typename T, size_t N, size_t Nout = N * groupsize, typename IT, size_t... Indices> KFR_INTRINSIC void scatter_helper(T* base, const vec<IT, N>& offset, const vec<T, Nout>& value, csizes_t<Indices...>) { @@ -142,7 +142,7 @@ KFR_INTRINSIC void scatter_helper_s(T* base, size_t stride, const vec<T, N>& val } } // namespace internal -template <size_t groupsize = 1, typename T, size_t N, size_t Nout = N* groupsize, typename IT> +template <size_t groupsize = 1, typename T, size_t N, size_t Nout = N * groupsize, typename IT> KFR_INTRINSIC void scatter(T* base, const vec<IT, N>& offset, const vec<T, Nout>& value) { return internal::scatter_helper<groupsize>(base, offset, value, csizeseq<N>); diff --git a/include/kfr/simd/shuffle.hpp b/include/kfr/simd/shuffle.hpp @@ -117,7 +117,7 @@ KFR_INTRINSIC vec<T, N * 4> concat4(const vec<T, N>& a, const vec<T, N>& b, cons vec<T, N>::scalar_size()>(c.v, d.v)); } -template <size_t count, typename T, size_t N, size_t Nout = N* count> +template <size_t count, typename T, size_t N, size_t Nout = N * count> KFR_INTRINSIC vec<T, Nout> repeat(const vec<T, N>& x) { return x.shuffle(csizeseq<Nout> % csize<N>); diff --git a/include/kfr/simd/types.hpp b/include/kfr/simd/types.hpp @@ -263,7 +263,6 @@ struct unwrap_bit<bit<T>> template <typename T> using unwrap_bit = typename internal_generic::unwrap_bit<T>::type; - template <typename T> constexpr inline bool is_bit = false; template <typename T> diff --git a/include/kfr/simd/vec.hpp b/include/kfr/simd/vec.hpp @@ -680,7 +680,7 @@ constexpr size_t size_of() CMT_NOEXCEPT } template <typename From, size_t N, typename Tsub = deep_subtype<From>, - size_t Nout = N* size_of<From>() / size_of<Tsub>()> + size_t Nout = N * size_of<From>() / size_of<Tsub>()> constexpr KFR_INTRINSIC vec<Tsub, Nout> flatten(const vec<From, N>& x) CMT_NOEXCEPT { return x.flatten(); diff --git a/include/kfr/testo/console_colors.hpp b/include/kfr/testo/console_colors.hpp @@ -2,7 +2,7 @@ #include <cstdint> #include <cstdio> -//#define CONSOLE_COLORS_FORCE_ASCII +// #define CONSOLE_COLORS_FORCE_ASCII #if defined _WIN32 && !defined PRINT_COLORED_FORCE_ASCII #define USE_WIN32_API diff --git a/tests/intrinsic_test.cpp b/tests/intrinsic_test.cpp @@ -74,7 +74,7 @@ bool builtin_sub_overflow<i64>(i64 x, i64 y, i64* r) return ((x ^ y) & 0x8000000000000000ull) && ((*r ^ x) & 0x8000000000000000ull); #endif } -//#endif +// #endif template <typename T> inline T ref_satadd(T x, T y) { diff --git a/tests/mpfr/mpfrplus.hpp b/tests/mpfr/mpfrplus.hpp @@ -583,11 +583,11 @@ inline number horner(number x, number c0, number c1, Ts... values) struct complex { - inline complex() noexcept = default; - inline complex(const complex&) noexcept = default; - inline complex(complex&&) noexcept = default; + inline complex() noexcept = default; + inline complex(const complex&) noexcept = default; + inline complex(complex&&) noexcept = default; inline complex& operator=(const complex&) noexcept = default; - inline complex& operator=(complex&&) noexcept = default; + inline complex& operator=(complex&&) noexcept = default; inline complex(const number& real) noexcept : real(real), imag(zero()) {} inline complex(const number& real, const number& imag) noexcept : real(real), imag(imag) {} inline bool isreal() const { return imag.iszero(); } diff --git a/tests/unit/graphics/color.cpp b/tests/unit/graphics/color.cpp @@ -64,7 +64,7 @@ TEST(color) CHECK(c6.g == 0.213161f); #endif CHECK(c6.b == 1.f); - + f32color c7 = u16color(0, 32767, 65535); CHECK(c7.r == 0.f); CHECK(c7.g == 0.499992370489f); diff --git a/tests/unit/math/log_exp.cpp b/tests/unit/math/log_exp.cpp @@ -24,7 +24,7 @@ TEST(cbrt) { CHECK(kfr::cbrt(27.f) == 3.f); CHECK(kfr::cbrt(-27.f) == -3.f); - + CHECK(kfr::root(32.f, 5.f) == 2.f); CHECK(kfr::root(-32.f, 5.f) == -2.f); CHECK(std::isnan(kfr::root(-32.f, 5.001f))); diff --git a/tests/unit/simd/min_max.cpp b/tests/unit/simd/min_max.cpp @@ -72,5 +72,4 @@ TEST(absmax) } // namespace CMT_ARCH_NAME } // namespace kfr - CMT_PRAGMA_MSVC(warning(pop)) diff --git a/tests/unit/simd/operators.cpp b/tests/unit/simd/operators.cpp @@ -66,9 +66,8 @@ TEST(div) test_catogories::vectors, [](auto x, auto y) { return is_safe_division<subtype<decltype(x)>>(x.front(), y.front()) ? x / y : 0; }, - [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> { - return is_safe_division(x, y) ? x / y : 0; - }); + [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> + { return is_safe_division(x, y) ? x / y : 0; }); } struct not_f { @@ -84,9 +83,8 @@ TEST(mod) test_catogories::vectors, [](auto x, auto y) { return is_safe_division<subtype<decltype(x)>>(x.front(), y.front()) ? x % y : 0; }, - [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> { - return is_safe_division(x, y) ? x % y : 0; - }, + [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> + { return is_safe_division(x, y) ? x % y : 0; }, fn_return_constant<bool, true>{}, not_f{}); } @@ -185,54 +183,48 @@ TEST(eq) { test_function2( test_catogories::vectors, [](auto x, auto y) { return (x == y).asvec(); }, - [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> { - return maskbits<subtype<decltype(x)>>(x == y); - }); + [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> + { return maskbits<subtype<decltype(x)>>(x == y); }); } TEST(ne) { test_function2( test_catogories::vectors, [](auto x, auto y) { return (x != y).asvec(); }, - [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> { - return maskbits<subtype<decltype(x)>>(x != y); - }); + [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> + { return maskbits<subtype<decltype(x)>>(x != y); }); } TEST(ge) { test_function2( test_catogories::vectors, [](auto x, auto y) { return (x >= y).asvec(); }, - [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> { - return maskbits<subtype<decltype(x)>>(x >= y); - }); + [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> + { return maskbits<subtype<decltype(x)>>(x >= y); }); } TEST(le) { test_function2( test_catogories::vectors, [](auto x, auto y) { return (x <= y).asvec(); }, - [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> { - return maskbits<subtype<decltype(x)>>(x <= y); - }); + [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> + { return maskbits<subtype<decltype(x)>>(x <= y); }); } TEST(gt) { test_function2( test_catogories::vectors, [](auto x, auto y) { return (x > y).asvec(); }, - [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> { - return maskbits<subtype<decltype(x)>>(x > y); - }); + [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> + { return maskbits<subtype<decltype(x)>>(x > y); }); } TEST(lt) { test_function2( test_catogories::vectors, [](auto x, auto y) { return (x < y).asvec(); }, - [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> { - return maskbits<subtype<decltype(x)>>(x < y); - }); + [](auto x, auto y) -> std::common_type_t<decltype(x), decltype(y)> + { return maskbits<subtype<decltype(x)>>(x < y); }); } TEST(horner) @@ -272,5 +264,4 @@ TEST(apply) } // namespace CMT_ARCH_NAME } // namespace kfr - CMT_PRAGMA_MSVC(warning(pop))