1
#include "singularconversion.h"
3
#include "polynomialring.h"
4
#include "polynomial.h"
5
#include "field_rationals.h"
6
#include "buchberger.h"
13
void singularBuchberger(PolynomialSet *g, TermOrder const &termOrder)
15
ring R=singularRing(g->getRing());
17
ideal i=singularPolynomialSet(*g);
19
// ideal j=kStd(i,NULL,testHomog,NULL);
20
// test|=(Sy_bit(OPT_REDSB)|Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_INTSTRATEGY));
21
test|=(Sy_bit(OPT_REDSB)|Sy_bit(OPT_REDTAIL));
23
ideal j=kStd(i,NULL,testHomog,NULL);
27
PolynomialSet ret=fromSingularIdeal(g->getRing(),j);
37
/**************************************************************************************************************************/
39
#include "groebnerengine.h"
41
static ring mySingularRingDegRevLex(PolynomialRing const &r, IntegerVector const &weight)
43
// FieldRationalsImplementation *q=dynamic_cast<FieldRationalsImplementation>r.getField().implementingObject;
45
ring ret=(ring)omAlloc0(sizeof(sip_sring));
47
if(r.getField().isRationals())
57
ret->N=r.getNumberOfVariables();
59
ret->names=(char**) omAlloc(ret->N*sizeof(char*));
60
for(int i=0;i<ret->N;i++)
61
ret->names[i]=omStrDup(r.getVariableName(i).c_str());
63
ret->order=(int*)omAlloc0(3*sizeof(int));
64
ret->block0=(int*)omAlloc0(3*sizeof(int));
65
ret->block1=(int*)omAlloc0(3*sizeof(int));
67
ret->order[0]=ringorder_wp;//degree revlex
68
// ret->order[0]=ringorder_Wp;//degree lex
69
ret->block0[0]=1;ret->block1[0]=ret->N;
70
ret->order[1]=ringorder_C;
72
ret->wvhdl=(int**)omAlloc0(3*sizeof(int*));
73
ret->wvhdl[0]=(int*)omAlloc(ret->N*sizeof(int));
75
IntegerVector weight2=weight+(1-weight.min())*IntegerVector::allOnes(weight.size());
76
//debug<<"WEIGHT FOR SINGULAR"<<weight2<<"\n";
77
for(int i=0;i<ret->N;i++)
78
ret->wvhdl[0][i]=weight2[i];//FIXMEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
81
// ret->options|=(Sy_bit(OPT_REDSB)|Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_INTSTRATEGY)|Sy_bit(OPT_REDTHROUGH));
82
// cerr<<"ringoptions"<<int(ret->options)<<"\n";
84
// cerr<<"test"<<int(test)<<"\n";
86
// cerr<<"test"<<int(test)<<"\n";
92
class GroebnerEngineSingular : public GroebnerEngine
94
virtual PolynomialSet groebnerBasis(bool &success, PolynomialSet const &idealGenerators, TermOrder const &termOrder, bool autoreduce)
96
PolynomialSet ret(idealGenerators.getRing());
97
if(!ret.getRing().getField().isRationals())
102
if(!idealGenerators.isHomogeneous())
107
if(dynamic_cast<const WeightReverseLexicographicTermOrder*> (&termOrder))
109
const WeightReverseLexicographicTermOrder *T=dynamic_cast<const WeightReverseLexicographicTermOrder*> (&termOrder);
111
ring R=mySingularRingDegRevLex(idealGenerators.getRing(),T->getWeight());
112
ideal i=singularPolynomialSet(idealGenerators);
113
test|=(Sy_bit(OPT_REDSB)|Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_INTSTRATEGY));
114
test|=(Sy_bit(OPT_REDTHROUGH));
116
log2 cerr<<"calling singular\n";
117
// debug<<"test"<<int(test)<<"\n";
118
ideal j=kStd(i,NULL,testHomog,NULL);
119
log2 cerr<<"returning from singular\n";
122
ret=fromSingularIdeal(ret.getRing(),j);
126
ret.markAndScale(termOrder);
127
minimize(&ret);//<---- This is needed for test case 1000 in the suite. Of course it would be nicer if Singular could compute the reduced GB itself.
128
autoReduce_(&ret,termOrder);//------------------------------------------REMOVE AND TRUST SINGULAR
132
* This test fails on the example
133
* gfan _tropicaltraverse --symmetry --log2 <hannah.cone
134
* The monomial d^3*e*f^3*g^8*h^4*i^2 appears as a leading term, but also in a tail.
137
debug<<idealGenerators;
139
autoReduce_(&ret,termOrder);
143
assert(isMinimal(ret));
144
assert(isReduced(ret));
147
autoReduce_(&ret,termOrder);
155
virtual PolynomialSet autoReduce(bool &success, PolynomialSet const &idealGenerators)
157
PolynomialSet ret(idealGenerators.getRing());
158
if(!ret.getRing().getField().isRationals())
163
if(!idealGenerators.isHomogeneous())
169
IntegerVector weight=termorderWeight(idealGenerators);
171
ring R=mySingularRingDegRevLex(idealGenerators.getRing(),weight);
172
ideal i=singularPolynomialSet(idealGenerators);
173
test|=(Sy_bit(OPT_REDSB)|Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_INTSTRATEGY));
175
log2 cerr<<"calling singular\n";
176
ideal j=kStd(i,NULL,testHomog,NULL);
177
// ideal j=kInterRed(i);
178
log2 cerr<<"returning from singular\n";
181
ret=fromSingularIdeal(ret.getRing(),j);
185
ret.markAndScale(WeightTermOrder(weight));
186
assert(isReduced(ret));
191
virtual const char* name()
197
static GroebnerEngineSingular groebnerEngineSingular;