common.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef _PVFMM_COMMON_HPP_
  2. #define _PVFMM_COMMON_HPP_
  3. // Define NULL
  4. #ifndef NULL
  5. #define NULL 0
  6. #endif
  7. #include <cstddef>
  8. #include <cstdint>
  9. namespace pvfmm {
  10. typedef long Integer; // bounded numbers < 32k
  11. typedef int64_t Long; // problem size
  12. }
  13. #include <iostream>
  14. #define PVFMM_WARN(msg) \
  15. do { \
  16. std::cerr << "\n\033[1;31mWarning:\033[0m " << msg << '\n'; \
  17. } while (0)
  18. #define PVFMM_ERROR(msg) \
  19. do { \
  20. std::cerr << "\n\033[1;31mError:\033[0m " << msg << '\n'; \
  21. abort(); \
  22. } while (0)
  23. #define PVFMM_ASSERT_MSG(cond, msg) \
  24. do { \
  25. if (!(cond)) PVFMM_ERROR(msg); \
  26. } while (0)
  27. #define PVFMM_ASSERT(cond) \
  28. do { \
  29. if (!(cond)) { \
  30. fprintf(stderr, "\n%s:%d: %s: Assertion `%s' failed.\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #cond); \
  31. abort(); \
  32. } \
  33. } while (0)
  34. #define UNUSED(x) (void)(x) // to ignore unused variable warning.
  35. namespace pvfmm {
  36. #ifdef PVFMM_MEMDEBUG
  37. template <class ValueType> class ConstIterator;
  38. template <class ValueType> class Iterator;
  39. template <class ValueType, Integer DIM> class StaticArray;
  40. #else
  41. template <typename ValueType> using Iterator = ValueType*;
  42. template <typename ValueType> using ConstIterator = const ValueType*;
  43. template <typename ValueType, Integer DIM> using StaticArray = ValueType[DIM];
  44. #endif
  45. }
  46. #include <pvfmm/math_utils.hpp>
  47. #endif //_PVFMM_COMMON_HPP_