1 /* ========================================================================== */ 2 /* === Include/Mongoose_Debug.hpp =========================================== */ 3 /* ========================================================================== */ 4 5 /* ----------------------------------------------------------------------------- 6 * Mongoose Graph Partitioning Library Copyright (C) 2017-2018, 7 * Scott P. Kolodziej, Nuri S. Yeralan, Timothy A. Davis, William W. Hager 8 * Mongoose is licensed under Version 3 of the GNU General Public License. 9 * Mongoose is also available under other licenses; contact authors for details. 10 * -------------------------------------------------------------------------- */ 11 12 // #pragma once 13 #ifndef MONGOOSE_DEBUG_HPP 14 #define MONGOOSE_DEBUG_HPP 15 16 #include "Mongoose_CSparse.hpp" 17 #include "Mongoose_EdgeCutOptions.hpp" 18 #include "Mongoose_EdgeCutProblem.hpp" 19 #include "Mongoose_QPDelta.hpp" 20 21 #include <cassert> 22 #include <cstdio> 23 24 // Mongoose Logic Macros 25 #undef IMPLIES 26 #define IMPLIES(p, q) (!(p) || ((p) && (q))) 27 #undef IFF 28 #define IFF(p, q) (IMPLIES(p, q) && IMPLIES(q, p)) 29 30 // turn off debugging 31 #ifndef NDEBUG 32 #define NDEBUG 33 #endif 34 35 // turn off debug printing 36 #ifndef NPRINT 37 #define NPRINT 38 #endif 39 40 // Uncomment this line to enable debugging. Mongoose will be very slow. 41 // #undef NDEBUG 42 43 // Uncomment this line to enable debug printing. Mongoose will be very slow 44 // and produce massive amounts of debug output. 45 // #undef NPRINT 46 47 // ASSERT macro, example usage: ASSERT (x > 0) ; 48 // where x is required to be positive. An error occurs if x <= 0. 49 #undef ASSERT 50 #ifndef NDEBUG 51 #define ASSERT(expression) (assert(expression)) 52 #define ASSERT_TEXT(expression, text) (assert(expression &&text)) 53 #else 54 #define ASSERT(expression) 55 #define ASSERT_TEXT(expression, text) 56 #endif 57 58 // PR macro, example usage: PR (("stuff here %g %g\n", x, y)) ; 59 #undef PR 60 #undef FFLUSH 61 #ifndef NPRINT 62 #define PR(s) printf s 63 #define FFLUSH \ 64 { \ 65 fflush(stdout); \ 66 fflush(stderr); \ 67 } 68 #else 69 #define PR(s) 70 #define FFLUSH 71 #endif 72 73 // DEBUG macro, example usage: DEBUG (statement) ; 74 #undef DEBUG 75 #ifndef NDEBUG 76 #define DEBUG(s) s 77 #else 78 #define DEBUG(s) 79 #endif 80 81 #ifndef NDEBUG 82 #include <algorithm> 83 #endif 84 85 namespace Mongoose 86 { 87 88 void print(cs *G); 89 90 void print(EdgeCutProblem *G); 91 92 void QPcheckCom(EdgeCutProblem *G, const EdgeCut_Options *O, QPDelta *QP, bool check_b, 93 Int nFreeSet, double b); 94 95 void FreeSet_dump(const char *where, Int n, Int *FreeSet_list, Int nFreeSet, 96 Int *FreeSet_status, Int verbose, double *x); 97 98 } // end namespace Mongoose 99 100 #endif 101