#ifndef EIGEN_CORE_UTIL_ASSERT_H
#define EIGEN_CORE_UTIL_ASSERT_H
#if !defined(EIGEN_NO_DEBUG) && (!defined(EIGEN_GPU_COMPILE_PHASE) || !defined(EIGEN_NO_DEBUG_GPU))
#include <cassert>
#ifndef EIGEN_USE_CUSTOM_PLAIN_ASSERT
#define EIGEN_USE_CUSTOM_PLAIN_ASSERT 0
#endif
#if EIGEN_USE_CUSTOM_PLAIN_ASSERT
#ifndef EIGEN_HAS_BUILTIN_FILE
#if (EIGEN_HAS_BUILTIN(__builtin_FILE) && (EIGEN_COMP_CLANG || !defined(EIGEN_CUDA_ARCH))) || \
(EIGEN_GNUC_STRICT_AT_LEAST(5, 0, 0) && (EIGEN_COMP_NVCC >= 110000 || !defined(EIGEN_CUDA_ARCH))) || \
(EIGEN_COMP_MSVC >= 1926 && (!EIGEN_COMP_NVCC || EIGEN_COMP_NVCC >= 110000))
#define EIGEN_HAS_BUILTIN_FILE 1
#else
#define EIGEN_HAS_BUILTIN_FILE 0
#endif
#endif
#if EIGEN_HAS_BUILTIN_FILE
#define EIGEN_BUILTIN_FILE __builtin_FILE()
#define EIGEN_BUILTIN_LINE __builtin_LINE()
#else
#define EIGEN_BUILTIN_FILE __FILE__
#define EIGEN_BUILTIN_LINE __LINE__
#endif
#if EIGEN_COMP_MSVC
#define EIGEN_BUILTIN_FUNCTION __FUNCSIG__
#elif EIGEN_COMP_GNUC
#define EIGEN_BUILTIN_FUNCTION __PRETTY_FUNCTION__
#else
#define EIGEN_BUILTIN_FUNCTION __func__
#endif
namespace Eigen {
namespace internal {
template <typename EnableIf = void, typename... EmptyArgs>
struct assert_handler_impl {
EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE static inline void run(const char* expression, const char* file, unsigned line,
const char* function) {
#ifdef EIGEN_GPU_COMPILE_PHASE
#ifndef EIGEN_NO_IO
printf("Assertion failed at %s:%u in %s: %s\n", file == nullptr ? "<file>" : file, line,
function == nullptr ? "<function>" : function, expression);
#endif
__trap();
#else
#ifndef EIGEN_NO_IO
fprintf(stderr, "Assertion failed at %s:%u in %s: %s\n", file == nullptr ? "<file>" : file, line,
function == nullptr ? "<function>" : function, expression);
#endif
std::abort();
#endif }
};
template <typename... EmptyArgs>
struct assert_handler_impl<void_t<decltype(__assert_fail((const char*)nullptr, (const char*)nullptr, 0, (const char*)nullptr, std::declval<EmptyArgs>()... ))>,
EmptyArgs...> {
EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE static inline void run(const char* expression, const char* file, unsigned line,
const char* function) {
__assert_fail(expression, file, line, function, std::declval<EmptyArgs>()...);
}
};
EIGEN_DEVICE_FUNC EIGEN_DONT_INLINE inline void __assert_handler(const char* expression, const char* file,
unsigned line, const char* function) {
assert_handler_impl<>::run(expression, file, line, function);
}
} }
#define eigen_plain_assert(expression) \
(EIGEN_PREDICT_FALSE(!(expression)) ? Eigen::internal::__assert_handler(#expression, EIGEN_BUILTIN_FILE, \
EIGEN_BUILTIN_LINE, EIGEN_BUILTIN_FUNCTION) \
: (void)0)
#else
#define eigen_plain_assert(condition) assert(condition)
#endif
#else
#define eigen_plain_assert(condition) ((void)0)
#endif
#endif