round.cpp (1459B)
1 /** 2 * KFR (https://www.kfrlib.com) 3 * Copyright (C) 2016-2023 Dan Cazarin 4 * See LICENSE.txt for details 5 */ 6 7 #include <kfr/simd/round.hpp> 8 9 namespace kfr 10 { 11 inline namespace CMT_ARCH_NAME 12 { 13 TEST(floor) 14 { 15 test_function1( 16 test_catogories::all, [](auto x) { return kfr::floor(x); }, 17 [](auto x) -> decltype(x) 18 { return std::is_integral<decltype(x)>::value ? x : static_cast<decltype(x)>(std::floor(x)); }); 19 } 20 21 TEST(ceil) 22 { 23 test_function1( 24 test_catogories::all, [](auto x) { return kfr::ceil(x); }, 25 [](auto x) -> decltype(x) 26 { return std::is_integral<decltype(x)>::value ? x : static_cast<decltype(x)>(std::ceil(x)); }); 27 } 28 29 TEST(trunc) 30 { 31 test_function1( 32 test_catogories::all, [](auto x) { return kfr::trunc(x); }, 33 [](auto x) -> decltype(x) 34 { return std::is_integral<decltype(x)>::value ? x : static_cast<decltype(x)>(std::trunc(x)); }); 35 } 36 37 TEST(round) 38 { 39 test_function1( 40 test_catogories::all, [](auto x) { return kfr::round(x); }, 41 [](auto x) -> decltype(x) 42 { return std::is_integral<decltype(x)>::value ? x : static_cast<decltype(x)>(std::round(x)); }); 43 } 44 45 TEST(fract) 46 { 47 test_function1( 48 test_catogories::all, [](auto x) { return kfr::fract(x); }, 49 [](auto x) -> decltype(x) 50 { return std::is_integral<decltype(x)>::value ? 0 : static_cast<decltype(x)>(x - std::floor(x)); }); 51 } 52 } // namespace CMT_ARCH_NAME 53 } // namespace kfr