Archived
1
Fork 0
This repository has been archived on 2025-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
mozaic/lib/wvlt/wavelet_utilities.hpp
2014-09-05 17:49:21 +02:00

19 lines
383 B
C++

#pragma once
template <typename Int>
bool is_pow_of_two(Int n){
return n && !(n & (n - 1));
}
template <typename Int>
bool is_even(Int n){
return (n & 1) == 0;
}
// calculates integer 2-log such that:
// 2^(two_log(x)) >= x > 2^(two_log(x) - 1)
inline unsigned int two_log(unsigned int x){
if(x <= 1) return 0;
return 8*sizeof(unsigned int) - unsigned(__builtin_clz(x-1));
}