General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
729 B

  1. #pragma once
  2. namespace gp {
  3. namespace math {
  4. template<typename T>
  5. constexpr T pi;
  6. template<typename T>
  7. T abs(T);
  8. template<typename word_t>
  9. word_t log2(word_t v);
  10. /**
  11. * @brief Returns \f$n\f$ so that it is the smallest value that matches for \f$v\leq{}log2(2^n)\f$
  12. *
  13. * @tparam word_t
  14. * @param v
  15. * @return constexpr word_t
  16. */
  17. template<typename word_t>
  18. constexpr word_t msb(word_t v);
  19. /**
  20. * @brief Reads the sign of a value
  21. *
  22. * @tparam T
  23. * @return -1 if the value is negative
  24. * @return 0 if the value is 0 or not a number
  25. * @return 1 if the value is positive
  26. */
  27. template<typename T>
  28. T sign(T);
  29. }
  30. }