vector_integer.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /// @ref ext_vector_integer
  2. /// @file glm/ext/vector_integer.hpp
  3. ///
  4. /// @see core (dependence)
  5. /// @see ext_vector_integer (dependence)
  6. ///
  7. /// @defgroup ext_vector_integer GLM_EXT_vector_integer
  8. /// @ingroup ext
  9. ///
  10. /// Include <glm/ext/vector_integer.hpp> to use the features of this extension.
  11. #pragma once
  12. // Dependencies
  13. #include "../detail/setup.hpp"
  14. #include "../detail/qualifier.hpp"
  15. #include "../detail/_vectorize.hpp"
  16. #include "../vector_relational.hpp"
  17. #include "../common.hpp"
  18. #include <limits>
  19. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  20. # pragma message("GLM: GLM_EXT_vector_integer extension included")
  21. #endif
  22. namespace glm
  23. {
  24. /// @addtogroup ext_vector_integer
  25. /// @{
  26. /// Return true if the value is a power of two number.
  27. ///
  28. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  29. /// @tparam T Signed or unsigned integer scalar types.
  30. /// @tparam Q Value from qualifier enum
  31. ///
  32. /// @see ext_vector_integer
  33. template<length_t L, typename T, qualifier Q>
  34. GLM_FUNC_DECL vec<L, bool, Q> isPowerOfTwo(vec<L, T, Q> const& v);
  35. /// Return the power of two number which value is just higher the input value,
  36. /// round up to a power of two.
  37. ///
  38. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  39. /// @tparam T Signed or unsigned integer scalar types.
  40. /// @tparam Q Value from qualifier enum
  41. ///
  42. /// @see ext_vector_integer
  43. template<length_t L, typename T, qualifier Q>
  44. GLM_FUNC_DECL vec<L, T, Q> nextPowerOfTwo(vec<L, T, Q> const& v);
  45. /// Return the power of two number which value is just lower the input value,
  46. /// round down to a power of two.
  47. ///
  48. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  49. /// @tparam T Signed or unsigned integer scalar types.
  50. /// @tparam Q Value from qualifier enum
  51. ///
  52. /// @see ext_vector_integer
  53. template<length_t L, typename T, qualifier Q>
  54. GLM_FUNC_DECL vec<L, T, Q> prevPowerOfTwo(vec<L, T, Q> const& v);
  55. /// Return true if the 'Value' is a multiple of 'Multiple'.
  56. ///
  57. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  58. /// @tparam T Signed or unsigned integer scalar types.
  59. /// @tparam Q Value from qualifier enum
  60. ///
  61. /// @see ext_vector_integer
  62. template<length_t L, typename T, qualifier Q>
  63. GLM_FUNC_DECL vec<L, bool, Q> isMultiple(vec<L, T, Q> const& v, T Multiple);
  64. /// Return true if the 'Value' is a multiple of 'Multiple'.
  65. ///
  66. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  67. /// @tparam T Signed or unsigned integer scalar types.
  68. /// @tparam Q Value from qualifier enum
  69. ///
  70. /// @see ext_vector_integer
  71. template<length_t L, typename T, qualifier Q>
  72. GLM_FUNC_DECL vec<L, bool, Q> isMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
  73. /// Higher multiple number of Source.
  74. ///
  75. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  76. /// @tparam T Signed or unsigned integer scalar types.
  77. /// @tparam Q Value from qualifier enum
  78. ///
  79. /// @param v Source values to which is applied the function
  80. /// @param Multiple Must be a null or positive value
  81. ///
  82. /// @see ext_vector_integer
  83. template<length_t L, typename T, qualifier Q>
  84. GLM_FUNC_DECL vec<L, T, Q> nextMultiple(vec<L, T, Q> const& v, T Multiple);
  85. /// Higher multiple number of Source.
  86. ///
  87. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  88. /// @tparam T Signed or unsigned integer scalar types.
  89. /// @tparam Q Value from qualifier enum
  90. ///
  91. /// @param v Source values to which is applied the function
  92. /// @param Multiple Must be a null or positive value
  93. ///
  94. /// @see ext_vector_integer
  95. template<length_t L, typename T, qualifier Q>
  96. GLM_FUNC_DECL vec<L, T, Q> nextMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
  97. /// Lower multiple number of Source.
  98. ///
  99. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  100. /// @tparam T Signed or unsigned integer scalar types.
  101. /// @tparam Q Value from qualifier enum
  102. ///
  103. /// @param v Source values to which is applied the function
  104. /// @param Multiple Must be a null or positive value
  105. ///
  106. /// @see ext_vector_integer
  107. template<length_t L, typename T, qualifier Q>
  108. GLM_FUNC_DECL vec<L, T, Q> prevMultiple(vec<L, T, Q> const& v, T Multiple);
  109. /// Lower multiple number of Source.
  110. ///
  111. /// @tparam L Integer between 1 and 4 included that qualify the dimension of the vector
  112. /// @tparam T Signed or unsigned integer scalar types.
  113. /// @tparam Q Value from qualifier enum
  114. ///
  115. /// @param v Source values to which is applied the function
  116. /// @param Multiple Must be a null or positive value
  117. ///
  118. /// @see ext_vector_integer
  119. template<length_t L, typename T, qualifier Q>
  120. GLM_FUNC_DECL vec<L, T, Q> prevMultiple(vec<L, T, Q> const& v, vec<L, T, Q> const& Multiple);
  121. /// Returns the bit number of the Nth significant bit set to
  122. /// 1 in the binary representation of value.
  123. /// If value bitcount is less than the Nth significant bit, -1 will be returned.
  124. ///
  125. /// @tparam L An integer between 1 and 4 included that qualify the dimension of the vector.
  126. /// @tparam T Signed or unsigned integer scalar types.
  127. ///
  128. /// @see ext_vector_integer
  129. template<length_t L, typename T, qualifier Q>
  130. GLM_FUNC_DECL vec<L, int, Q> findNSB(vec<L, T, Q> const& Source, vec<L, int, Q> SignificantBitCount);
  131. /// @}
  132. } //namespace glm
  133. #include "vector_integer.inl"