aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/utils/math.hpp
blob: b7f06ea2468ca63ab1b41595b3d3c4210b3176cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//
// Copyright 2018 Ettus Research, a National Instruments Company
//
// SPDX-License-Identifier: GPL-3.0-or-later
//

// 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 */