| 1 | #include "scalar_integer.hpp" |
| 2 | |
| 3 | namespace glm |
| 4 | { |
| 5 | template<length_t L, typename T, qualifier Q> |
| 6 | GLM_FUNC_QUALIFIER vec<L, bool, Q> isPowerOfTwo(vec<L, T, Q> const& Value) |
| 7 | { |
| 8 | static_assert(std::numeric_limits<T>::is_integer, "'isPowerOfTwo' only accept integer inputs"); |
| 9 | |
| 10 | vec<L, T, Q> const Result(abs(Value)); |
| 11 | return equal(Result & (Result - vec<L, T, Q>(1)), vec<L, T, Q>(0)); |
| 12 | } |
| 13 | |
| 14 | template<length_t L, typename T, qualifier Q> |
| 15 | GLM_FUNC_QUALIFIER vec<L, T, Q> nextPowerOfTwo(vec<L, T, Q> const& v) |
| 16 | { |
| 17 | static_assert(std::numeric_limits<T>::is_integer, "'nextPowerOfTwo' only accept integer inputs"); |
| 18 | |
| 19 | return detail::compute_ceilPowerOfTwo<L, T, Q, std::numeric_limits<T>::is_signed>::call(v); |
| 20 | } |
| 21 | |
| 22 | template<length_t L, typename T, qualifier Q> |
| 23 | GLM_FUNC_QUALIFIER vec<L, T, Q> prevPowerOfTwo(vec<L, T, Q> const& v) |
| 24 | { |
| 25 | static_assert(std::numeric_limits<T>::is_integer, "'prevPowerOfTwo' only accept integer inputs"); |
| 26 | |
| 27 | return detail::functor1<vec, L, T, T, Q>::call(prevPowerOfTwo, v); |
| 28 | } |
| 29 | |
| 30 | template<length_t L, typename T, qualifier Q> |
| 31 | GLM_FUNC_QUALIFIER vec<L, bool, Q> isMultiple(vec<L, T, Q> const& Value, T Multiple) |
| 32 | { |
| 33 | static_assert(std::numeric_limits<T>::is_integer, "'isMultiple' only accept integer inputs"); |
| 34 | |
| 35 | return equal(Value % Multiple, vec<L, T, Q>(0)); |
| 36 | } |
| 37 | |
| 38 | template<length_t L, typename T, qualifier Q> |
| 39 | GLM_FUNC_QUALIFIER vec<L, bool, Q> isMultiple(vec<L, T, Q> const& Value, vec<L, T, Q> const& Multiple) |
| 40 | { |
| 41 | static_assert(std::numeric_limits<T>::is_integer, "'isMultiple' only accept integer inputs"); |
| 42 | |
| 43 | return equal(Value % Multiple, vec<L, T, Q>(0)); |
| 44 | } |
| 45 | |
| 46 | template<length_t L, typename T, qualifier Q> |
| 47 | GLM_FUNC_QUALIFIER vec<L, T, Q> nextMultiple(vec<L, T, Q> const& Source, T Multiple) |
| 48 | { |
| 49 | static_assert(std::numeric_limits<T>::is_integer, "'nextMultiple' only accept integer inputs"); |
| 50 | |
| 51 | return detail::functor2<vec, L, T, Q>::call(nextMultiple, Source, vec<L, T, Q>(Multiple)); |
| 52 | } |
| 53 | |
| 54 | template<length_t L, typename T, qualifier Q> |
| 55 | GLM_FUNC_QUALIFIER vec<L, T, Q> nextMultiple(vec<L, T, Q> const& Source, vec<L, T, Q> const& Multiple) |
| 56 | { |
| 57 | static_assert(std::numeric_limits<T>::is_integer, "'nextMultiple' only accept integer inputs"); |
| 58 | |
| 59 | return detail::functor2<vec, L, T, Q>::call(nextMultiple, Source, Multiple); |
| 60 | } |
| 61 | |
| 62 | template<length_t L, typename T, qualifier Q> |
| 63 | GLM_FUNC_QUALIFIER vec<L, T, Q> prevMultiple(vec<L, T, Q> const& Source, T Multiple) |
| 64 | { |
| 65 | static_assert(std::numeric_limits<T>::is_integer, "'prevMultiple' only accept integer inputs"); |
| 66 | |
| 67 | return detail::functor2<vec, L, T, Q>::call(prevMultiple, Source, vec<L, T, Q>(Multiple)); |
| 68 | } |
| 69 | |
| 70 | template<length_t L, typename T, qualifier Q> |
| 71 | GLM_FUNC_QUALIFIER vec<L, T, Q> prevMultiple(vec<L, T, Q> const& Source, vec<L, T, Q> const& Multiple) |
| 72 | { |
| 73 | static_assert(std::numeric_limits<T>::is_integer, "'prevMultiple' only accept integer inputs"); |
| 74 | |
| 75 | return detail::functor2<vec, L, T, Q>::call(prevMultiple, Source, Multiple); |
| 76 | } |
| 77 | |
| 78 | template<length_t L, typename T, qualifier Q> |
| 79 | GLM_FUNC_QUALIFIER vec<L, int, Q> findNSB(vec<L, T, Q> const& Source, vec<L, int, Q> SignificantBitCount) |
| 80 | { |
| 81 | static_assert(std::numeric_limits<T>::is_integer, "'findNSB' only accept integer inputs"); |
| 82 | |
| 83 | return detail::functor2_vec_int<L, T, Q>::call(findNSB, Source, SignificantBitCount); |
| 84 | } |
| 85 | }//namespace glm |