common.hpp 2.1 KB

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