Changeset 47a774 in git
- Timestamp:
- Aug 8, 2016, 2:14:52 PM (7 years ago)
- Branches:
- (u'spielwiese', 'f6c3dc58b0df4bd712574325fe76d0626174ad97')
- Children:
- 15813d0947d4221b8c060256fd6994a48e3c6605
- Parents:
- f73b0dba8fd582e1ebf4d2a1ed2067a19cab5a36
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gfanlib/gfanlib_zcone.cpp
rf73b0d r47a774 12 12 #include <sstream> 13 13 14 //extern "C"{ 15 #ifdef NOCDDPREFIX16 #include "setoper.h"17 #include "cdd.h"14 #include <config.h> 15 #ifdef HAVE_CDD_SETOPER_H 16 #include <cdd/setoper.h> 17 #include <cdd/cdd.h> 18 18 #else 19 #include "cdd/setoper.h" 20 #include "cdd/cdd.h" 21 #endif 22 //} 19 #ifdef HAVE_CDDLIB_SETOPER_H 20 #include <cddlib/setoper.h> 21 #include <cddlib/cdd.h> 22 #else 23 #include <setoper.h> 24 #include <cdd.h> 25 #endif //HAVE_CDDLIB_SETOPER_H 26 #endif //HAVE_CDD_SETOPER_H 27 23 28 24 29 namespace gfan{ 25 bool isCddlibRequired() 26 { 27 return true; 28 } 29 void initializeCddlibIfRequired() // calling this frequently will cause memory leaks because deinitialisation is not possible with old versions of cddlib. 30 { 31 dd_set_global_constants(); 32 } 33 void deinitializeCddlibIfRequired() 34 { 35 // dd_free_global_constants(); 36 } 30 bool isCddlibRequired() 31 { 32 return true; 33 } 34 void initializeCddlibIfRequired() // calling this frequently will cause memory leaks because deinitialisation is not possible with old versions of cddlib. 35 { 36 dd_set_global_constants(); 37 } 38 void deinitializeCddlibIfRequired() 39 { 40 #ifdef HAVE_DD_FREE_GLOBAL_CONSTANTS 41 dd_free_global_constants(); 42 #endif 43 } 37 44 static void ensureCddInitialisation() 38 45 { 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 46 // A more complicated initialisation than the following (meaning attempts to count the number of times 47 // cddlib was requested to be initialised) would require cddlib to be thread aware. 48 // The error below is implemented with an assert(0) because throwing an exception may leave the impression that 49 // it is possible to recover from this error. While that may be true, it would not work in full generality, 50 // as the following if statement cannot test whether dd_free_global_constants() has also been called. 51 // Moverover, in multithreaded environments it would be quite difficult to decide if cddlib was initialised. 52 if(!dd_one[0]._mp_num._mp_d) 53 { 54 std::cerr<<"CDDLIB HAS NOT BEEN INITIALISED!\n" 55 "\n" 56 "Fix this problem by calling the following function in your initialisation code:\n" 57 "dd_set_global_constants();\n" 58 "(after possibly setting the gmp allocators) and\n" 59 "dd_free_global_constants()\n" 60 "in your deinitialisation code (only available for cddlib version>=094d).\n" 61 "This requires the header includes:\n" 62 "#include \"cdd/setoper.h\"\n" 63 "#include \"cdd/cdd.h\"\n" 64 "\n" 65 "Alternatively, you may call gfan:initializeCddlibIfRequired() and deinitializeCddlibIfRequired()\n" 66 "if gfanlib is the only code using cddlib. If at some point cddlib is no longer required by gfanlib\n" 67 "these functions may do nothing.\n" 68 "Because deinitialisation is not possible in cddlib <094d, the functions may leak memory and should not be called often.\n" 69 "\n" 70 "This error message will never appear if the initialisation was done properly, and therefore never appear in a shipping version of your software.\n"; 71 assert(0); 72 } 73 /* 74 static bool initialized; 75 if(!initialized) 69 76 { 70 71 77 dd_set_global_constants(); 78 initialized=true; 72 79 }*/ 73 80 } … … 373 380 void removeRedundantRows(ZMatrix &inequalities, ZMatrix &equations, bool removeInequalityRedundancies) 374 381 { 375 382 ensureCddInitialisation(); 376 383 377 384 int numberOfEqualities=equations.getHeight(); … … 784 791 std::string ZCone::toString()const 785 792 { 786 787 788 793 std::stringstream f; 794 f<<*this; 795 return f.str(); 789 796 } 790 797 … … 989 996 } 990 997 */ 991 // 992 998 // ZCone dual(newGenerators,linealitySpace); 999 ZCone dual(generators,linealitySpace); 993 1000 // dual.findFacets(); 994 1001 // dual.canonicalize();
Note: See TracChangeset
for help on using the changeset viewer.