10 #include "Tools/Exception/exception.hpp"
16 template <
typename R>
inline R div2(
R val) {
return val * (
R)0.500; }
17 template <>
inline int32_t
div2(int32_t val) {
return val >> 1; }
18 template <>
inline int16_t
div2(int16_t val) {
return val >> 1; }
19 template <>
inline int8_t
div2(int8_t val) {
return val >> 1; }
21 template <
typename R>
inline R div4(
R val) {
return val * (
R)0.250; }
22 template <>
inline int32_t
div4(int32_t val) {
return val >> 2; }
23 template <>
inline int16_t
div4(int16_t val) {
return val >> 2; }
24 template <>
inline int8_t
div4(int8_t val) {
return val >> 2; }
26 template <
typename R>
inline R div8(
R val) {
return val * (
R)0.125; }
27 template <>
inline int32_t
div8(int32_t val) {
return val >> 3; }
28 template <>
inline int16_t
div8(int16_t val) {
return val >> 3; }
29 template <>
inline int8_t
div8(int8_t val) {
return val >> 3; }
40 constexpr
R sat_val() {
return std::numeric_limits<R>::infinity(); }
42 template <> constexpr
double sat_val<double >() {
return std::numeric_limits<double>::infinity(); }
43 template <> constexpr
float sat_val<float >() {
return std::numeric_limits<float >::infinity(); }
49 constexpr std::pair<R, R>
sat_vals() {
return std::make_pair(-sat_val<R>(), sat_val<R>()); }
53 constexpr
B bit_init() {
return (
B)(((
B)1) << (
sizeof(
B) * 8 -1)); }
60 template <
typename T,
class A = std::allocator<T>>
63 const auto loop_size = (int)array.size();
64 for (
auto i = 0; i < loop_size; i++)
65 array[i] = saturate<T>(array[i], min, max);
68 template <
typename B,
typename R>
69 B sgn(
R val) {
return (
B)((
R(0) < val) - (val <
R(0))); }
75 return (x > 0) && !(x & (x - 1));
78 template <
typename R,
typename function_type>
83 std::stringstream message;
84 message <<
"'max' has to be equal or greater than 'min' ('max' = " << max <<
", 'min' = " << min <<
").";
85 throw invalid_argument(__FILE__, __LINE__, __func__, message.str());
88 if (number_steps <= 0)
90 std::stringstream message;
91 message <<
"'number_steps' has to be greater than 0 ('number_steps' = " << number_steps <<
").";
92 throw invalid_argument(__FILE__, __LINE__, __func__, message.str());
95 R step = (max -
min) / number_steps;
98 for (
auto i = 0; i < number_steps; i++)
99 area += func(min + ((
R)i + (
R)0.5) * step) * step;
reg min(const reg, const reg)
Definition: mipp.h:643
reg max(const reg, const reg)
Definition: mipp.h:644
R_32 R
Definition: types.h:51
B_32 B
Definition: types.h:50