diff options
Diffstat (limited to 'host/lib/include/uhdlib/utils/math.hpp')
-rw-r--r-- | host/lib/include/uhdlib/utils/math.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/utils/math.hpp b/host/lib/include/uhdlib/utils/math.hpp new file mode 100644 index 000000000..eeb420727 --- /dev/null +++ b/host/lib/include/uhdlib/utils/math.hpp @@ -0,0 +1,25 @@ +// +// Copyright 2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0 +// + +// More math, but not meant for public API + +#ifndef INCLUDED_UHDLIB_UTILS_MATH_HPP +#define INCLUDED_UHDLIB_UTILS_MATH_HPP + +#include <cmath> + +namespace uhd { namespace math { + +/*! log2(num), rounded up to the nearest integer. + */ +template <class T> +T ceil_log2(T num){ + return std::ceil(std::log(num)/std::log(T(2))); +} + +}} /* namespace uhd::math */ + +#endif /* INCLUDED_UHDLIB_UTILS_MATH_HPP */ |