1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
#include "groebnerengine.h"
#include "printer.h"
GroebnerEngine *GroebnerEngine::list;
static GroebnerEngine *gfan,*singular,*default_;
static bool initialized;
GroebnerEngine::GroebnerEngine()
{
next=list;
list=this;
}
GroebnerEngine *GroebnerEngine::find(const char *name)
{
GroebnerEngine *l=list;
while(l)
{
if(std::string(l->name())==std::string(name))break;
l=l->next;
}
return l;
}
static inline void GE_Init()
{
if(!initialized)
{
GE_SetEngine("");
}
}
bool GE_SetEngine(const char *name)
{
singular=GroebnerEngine::find("singular");
gfan=GroebnerEngine::find("gfan");
GroebnerEngine *selected=GroebnerEngine::find(name);
default_=gfan;
if(singular)default_=singular;
if(selected)default_=selected;
initialized=true;
assert(default_);
fprintf(stderr,"Groebner basis Engine being used: \"%s\".\n",default_->name());
return selected;
}
PolynomialSet GE_groebnerBasis(PolynomialSet const &idealGenerators, TermOrder const &termOrder, bool autoreduce)
{
GE_Init();
PolynomialSet ret(idealGenerators.getRing());
bool success=true;
//Should be put into a list instead
if(default_)
{
ret=default_->groebnerBasis(success,idealGenerators,termOrder,autoreduce);
if(success)
return ret;
}
if(singular)
{
ret=singular->groebnerBasis(success,idealGenerators,termOrder,autoreduce);
if(success)
return ret;
}
if(gfan)
{
ret=gfan->groebnerBasis(success,idealGenerators,termOrder,autoreduce);
if(success)
return ret;
}
assert(0);
return ret;
}
PolynomialSet GE_autoReduce(PolynomialSet const &idealGenerators)
{
GE_Init();
PolynomialSet ret(idealGenerators.getRing());
bool success=true;
if(default_)
{
ret=default_->autoReduce(success,idealGenerators);
if(success)
return ret;
}
if(singular)
{
ret=singular->autoReduce(success,idealGenerators);
if(success)
return ret;
}
if(gfan)
{
ret=gfan->autoReduce(success,idealGenerators);
if(success)
return ret;
}
assert(0);
return ret;
}
|