From 289b76e4a2177e320fe906fdbbbe3b20a2f11942 Mon Sep 17 00:00:00 2001 From: ancarola Date: Mon, 1 Jul 2019 00:00:56 +0200 Subject: The matrix library is compiling and all tested operations work fine. Next goals: - Implement optimisations for multiplication in K-diagonal - Add adjoint operation for complex matrices - Determinant - Algorithms: Gauss Jordan --- include/mm/debug.hpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 include/mm/debug.hpp (limited to 'include/mm/debug.hpp') diff --git a/include/mm/debug.hpp b/include/mm/debug.hpp new file mode 100644 index 0000000..0254744 --- /dev/null +++ b/include/mm/debug.hpp @@ -0,0 +1,78 @@ +#pragma once + +#ifndef __NPDEBUG__ +#define __NPDEBUG__ + +#include +#include + +#ifndef NDEBUG + #define __FILENAME__ (\ + __builtin_strrchr(__FILE__, '/') ? \ + __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) + + #define npdebug_prep(); { \ + std::cerr << "[" << __FILENAME__ \ + << ":" << __LINE__ \ + << ", " << __func__ \ + << "] " ; \ + } + + #define npdebug(...); { \ + npdebug_prep(); \ + np::va_debug(__VA_ARGS__); \ + } + + namespace np { + template + inline void va_debug(Args&&... args) { + (std::cerr << ... << args) << std::endl; + } + + template + void range_debug(const T& t) { + range_debug("", t); + } + + template + void range_debug(const std::string& msg, const T& t) { + std::string out; + for (auto elem : t) + out += elem += ", "; + + npdebug(msg, out); + } + + template + T inspect(const T& t) { + npdebug(t); + return t; + } + + template + T inspect(const std::string& msg, const T& t) { + npdebug(msg, t); + return t; + } + } +#else + #define npdebug(...) {} + + namespace np { + template + inline void va_debug(Args&... args) {} + + template + inline void range_debug(const T& t) {} + + template + inline void range_debug(const std::string& msg, const T& t) {} + + template + T inspect(const T& t) { return t; } + + template + T inspect(const std::string& msg, const T& t) { return t; } + } +#endif // NDEBUG +#endif // __NPDEBUG__ -- cgit v1.2.1