Changeset 9abcc6 in git
- Timestamp:
- Mar 12, 2014, 9:08:50 AM (10 years ago)
- Branches:
- (u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
- Children:
- 7aa26b206f76709abff0bab4adaac2dfc4ddb4ef
- Parents:
- c890142d6921b9d30b396af149a3df2fbc57981a
- git-author:
- Yue Ren <ren@mathematik.uni-kl.de>2014-03-12 10:08:50+02:00
- git-committer:
- Yue Ren <ren@mathematik.uni-kl.de>2015-02-06 13:47:03+01:00
- Files:
-
- 5 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/dyn_modules/gfanlib/Makefile.am
rc89014 r9abcc6 1 1 ACLOCAL_AMFLAGS = -I ../../m4 2 2 3 SOURCES = gfanlib_exceptions.h callgfanlib_conversion.cc callgfanlib_conversion.h bbcone.cc bbcone.h bbfan.cc bbfan.h bbpolytope.cc bbpolytope.h gfan.h gitfan.cc gitfan.h tropicalVarietyOfPolynomials.h tropicalVarietyOfPolynomials.cc ppinitialReduction.cc ppinitialReduction.h ttinitialReduction.cc ttinitialReduction.h containsMonomial.cc containsMonomial.h adjustWeights.cc adjustWeights.h tropicalStrategy.cc tropicalStrategy.h initial.cc initial.h witness.cc witness.h tropicalCurves.cc tropicalCurves.h groebnerCone.cc groebnerCone.h neighbours.cc neighbours.h startingCone.cc startingCone.h tropical.cc tropical.h gfanlib.cc 3 SOURCES = gfanlib_exceptions.h callgfanlib_conversion.cc callgfanlib_conversion.h bbcone.cc bbcone.h bbfan.cc bbfan.h bbpolytope.cc bbpolytope.h gfan.h gitfan.cc gitfan.h tropicalVarietyOfPolynomials.h tropicalVarietyOfPolynomials.cc ppinitialReduction.cc ppinitialReduction.h ttinitialReduction.cc ttinitialReduction.h containsMonomial.cc containsMonomial.h adjustWeights.cc adjustWeights.h tropicalStrategy.cc tropicalStrategy.h initial.cc initial.h witness.cc witness.h tropicalCurves.cc tropicalCurves.h groebnerCone.cc groebnerCone.h neighbours.cc neighbours.h startingCone.cc startingCone.h tropicalVarietyOfIdeals.cc tropicalVarietyOfIdeals.h tropicalVariety.cc tropicalVariety.h tropical.cc tropical.h gfanlib.cc 4 4 5 5 6 MY_CPPFLAGS = -I${top_srcdir} -I${top_builddir} \ -
Singular/dyn_modules/gfanlib/bbfan.cc
rc89014 r9abcc6 40 40 std::string s = zf->toString(2+4+8+128); 41 41 return omStrDup(s.c_str()); 42 // ======= 43 // std::stringstream s; 44 // std::string raysAndCones = zf->toStringJustRaysAndMaximalCones(); 45 // s << raysAndCones; 46 // if (zf->getDimension() >= 0) // <=> zf is not empty 47 // { 48 // assert(zf->numberOfConesOfDimension(zf->getDimension()-zf->getLinealityDimension(),0,0)); 49 // gfan::ZCone zc = zf->getCone(zf->getDimension()-zf->getLinealityDimension(),0,0,0); 50 // gfan::ZMatrix genLinSpace = zc.generatorsOfLinealitySpace(); 51 // char* gens = toString(genLinSpace); 52 // s << std::endl << "GENERATORS_LINEALITY_SPACE:" << std::endl; 53 // s << gens; 54 // } 55 // std::string sstring = s.str(); 56 // return omStrDup(sstring.c_str()); 57 // >>>>>>> status updated 11.03. 42 58 } 43 59 } … … 858 874 859 875 860 BOOLEAN tropicalVariety(leftv res, leftv args)861 {862 leftv u=args;863 if ((u != NULL) && (u->Typ() == POLY_CMD))864 {865 int n = rVar(currRing);866 gfan::ZFan* zf = new gfan::ZFan(n);867 int* expv1 = (int*)omAlloc((n+1)*sizeof(int));868 int* expv2 = (int*)omAlloc((n+1)*sizeof(int));869 int* expvr = (int*)omAlloc((n+1)*sizeof(int));870 gfan::ZVector expw1 = gfan::ZVector(n);871 gfan::ZVector expw2 = gfan::ZVector(n);872 gfan::ZVector expwr = gfan::ZVector(n);873 gfan::ZMatrix eq, ineq;874 for (poly s1=(poly)u->Data(); s1!=NULL; pIter(s1))875 {876 pGetExpV(s1,expv1);877 expw1 = intStar2ZVector(n,expv1);878 for (poly s2=pNext(s1); s2!=NULL; pIter(s2))879 {880 pGetExpV(s2,expv2);881 expw2 = intStar2ZVector(n,expv2);882 eq = gfan::ZMatrix(0,n);883 eq.appendRow(expw1-expw2);884 ineq = gfan::ZMatrix(0,n);885 for (poly r=(poly)u->Data(); r!=NULL; pIter(r))886 {887 pGetExpV(r,expvr);888 expwr = intStar2ZVector(n,expvr);889 if ((r!=s1) && (r!=s2))890 {891 ineq.appendRow(expw1-expwr);892 }893 }894 gfan::ZCone zc = gfan::ZCone(ineq,eq);895 zf->insert(zc);896 }897 }898 omFreeSize(expv1,(n+1)*sizeof(int));899 omFreeSize(expv2,(n+1)*sizeof(int));900 omFreeSize(expvr,(n+1)*sizeof(int));901 res->rtyp = fanID;902 res->data = (void*) zf;903 return FALSE;904 }905 WerrorS("tropicalVariety: unexpected parameters");906 return TRUE;907 }876 // BOOLEAN tropicalVariety(leftv res, leftv args) 877 // { 878 // leftv u=args; 879 // if ((u != NULL) && (u->Typ() == POLY_CMD)) 880 // { 881 // int n = rVar(currRing); 882 // gfan::ZFan* zf = new gfan::ZFan(n); 883 // int* expv1 = (int*)omAlloc((n+1)*sizeof(int)); 884 // int* expv2 = (int*)omAlloc((n+1)*sizeof(int)); 885 // int* expvr = (int*)omAlloc((n+1)*sizeof(int)); 886 // gfan::ZVector expw1 = gfan::ZVector(n); 887 // gfan::ZVector expw2 = gfan::ZVector(n); 888 // gfan::ZVector expwr = gfan::ZVector(n); 889 // gfan::ZMatrix eq, ineq; 890 // for (poly s1=(poly)u->Data(); s1!=NULL; pIter(s1)) 891 // { 892 // pGetExpV(s1,expv1); 893 // expw1 = intStar2ZVector(n,expv1); 894 // for (poly s2=pNext(s1); s2!=NULL; pIter(s2)) 895 // { 896 // pGetExpV(s2,expv2); 897 // expw2 = intStar2ZVector(n,expv2); 898 // eq = gfan::ZMatrix(0,n); 899 // eq.appendRow(expw1-expw2); 900 // ineq = gfan::ZMatrix(0,n); 901 // for (poly r=(poly)u->Data(); r!=NULL; pIter(r)) 902 // { 903 // pGetExpV(r,expvr); 904 // expwr = intStar2ZVector(n,expvr); 905 // if ((r!=s1) && (r!=s2)) 906 // { 907 // ineq.appendRow(expw1-expwr); 908 // } 909 // } 910 // gfan::ZCone zc = gfan::ZCone(ineq,eq); 911 // zf->insert(zc); 912 // } 913 // } 914 // omFreeSize(expv1,(n+1)*sizeof(int)); 915 // omFreeSize(expv2,(n+1)*sizeof(int)); 916 // omFreeSize(expvr,(n+1)*sizeof(int)); 917 // res->rtyp = fanID; 918 // res->data = (void*) zf; 919 // return FALSE; 920 // } 921 // WerrorS("tropicalVariety: unexpected parameters"); 922 // return TRUE; 923 // } 908 924 909 925 gfan::ZFan commonRefinement(gfan::ZFan zf, gfan::ZFan zg) … … 1038 1054 p->iiAddCproc("","fVector",FALSE,fVector); 1039 1055 p->iiAddCproc("","containsInCollection",FALSE,containsInCollection); 1040 p->iiAddCproc("","tropicalVariety",FALSE,tropicalVariety);1056 // p->iiAddCproc("","tropicalVariety",FALSE,tropicalVariety); 1041 1057 p->iiAddCproc("","commonRefinement",FALSE,commonRefinement); 1042 1058 // iiAddCproc("","grFan",FALSE,grFan); -
Singular/dyn_modules/gfanlib/groebnerCone.cc
rc89014 r9abcc6 1 #include <kernel/polys.h> 1 #include <kernel/kstd1.h> 2 #include <kernel/ideals.h> 2 3 #include <Singular/ipid.h> 3 4 5 #include <libpolys/polys/monomials/p_polys.h> 4 6 #include <libpolys/polys/monomials/ring.h> 5 #include <kernel/ideals.h> 7 #include <libpolys/polys/prCopy.h> 8 6 9 #include <gfanlib/gfanlib.h> 7 10 … … 95 98 } 96 99 97 groebnerConeData::groebnerConeData(): 98 I(NULL), 99 r(NULL), 100 c(gfan::ZCone(0)), 101 p(gfan::ZVector(0)) 102 { 103 } 104 105 groebnerConeData::groebnerConeData(const groebnerConeData &sigma): 106 I(id_Copy(sigma.getIdeal(),sigma.getRing())), 107 r(rCopy(sigma.getRing())), 108 c(gfan::ZCone(sigma.getCone())), 109 p(gfan::ZVector(sigma.getInteriorPoint())) 110 { 111 } 112 113 groebnerConeData::groebnerConeData(const ideal &J, const ring &s, const gfan::ZCone &d, const gfan::ZVector &q): 114 I(J), 115 r(s), 116 c(d), 117 p(q) 118 { 119 } 120 121 groebnerConeData::groebnerConeData(const ideal &J, const ring &s): 122 I(J), 123 r(s) 124 { 125 } 126 127 groebnerConeData::~groebnerConeData() 128 { 129 id_Delete(&I,r); 130 rDelete(r); 131 } 132 133 134 groebnerConeData maximalGroebnerConeData(ideal I, const ring r) 100 gfan::ZCone fullGroebnerCone(const ideal &I, const ring &r) 135 101 { 136 102 int n = rVar(r); … … 156 122 omFreeSize(leadexpv,(n+1)*sizeof(int)); 157 123 omFreeSize(tailexpv,(n+1)*sizeof(int)); 124 return gfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth())); 125 } 126 127 groebnerConeData::groebnerConeData(): 128 I(NULL), 129 r(NULL), 130 c(gfan::ZCone(0)), 131 p(gfan::ZVector(0)) 132 { 133 } 134 135 groebnerConeData::groebnerConeData(const groebnerConeData &sigma): 136 I(id_Copy(sigma.getIdeal(),sigma.getRing())), 137 r(rCopy(sigma.getRing())), 138 c(gfan::ZCone(sigma.getCone())), 139 p(gfan::ZVector(sigma.getInteriorPoint())) 140 { 141 } 142 143 groebnerConeData::groebnerConeData(const ideal &J, const ring &s, const gfan::ZCone &d, const gfan::ZVector &q): 144 I(J), 145 r(s), 146 c(d), 147 p(q) 148 { 149 } 150 151 groebnerConeData::~groebnerConeData() 152 { 153 // if (I!=NULL) id_Delete(&I,r); 154 // if (r!=NULL) rDelete(r); 155 } 156 157 158 groebnerConeData maximalGroebnerConeData(ideal I, const ring r) 159 { 160 int n = rVar(r); 161 poly g = NULL; 162 int* leadexpv = (int*) omAlloc((n+1)*sizeof(int)); 163 int* tailexpv = (int*) omAlloc((n+1)*sizeof(int)); 164 gfan::ZVector leadexpw = gfan::ZVector(n); 165 gfan::ZVector tailexpw = gfan::ZVector(n); 166 gfan::ZMatrix inequalities = gfan::ZMatrix(0,n); 167 for (int i=0; i<IDELEMS(I); i++) 168 { 169 g = (poly) I->m[i]; pGetExpV(g,leadexpv); 170 leadexpw = intStar2ZVector(n, leadexpv); 171 pIter(g); 172 while (g != NULL) 173 { 174 pGetExpV(g,tailexpv); 175 tailexpw = intStar2ZVector(n, tailexpv); 176 inequalities.appendRow(leadexpw-tailexpw); 177 pIter(g); 178 } 179 } 180 omFreeSize(leadexpv,(n+1)*sizeof(int)); 181 omFreeSize(tailexpv,(n+1)*sizeof(int)); 158 182 gfan::ZCone zc = gfan::ZCone(inequalities,gfan::ZMatrix(0, inequalities.getWidth())); 159 183 gfan::ZVector p = zc.getRelativeInteriorPoint(); 160 184 return groebnerConeData(I,r,zc,p); 161 185 } 186 187 /*** 188 * Given a general ring r with any ordering, changes the ordering to wp(-w) 189 **/ 190 void changeOrderingTo_wp(ring r, const gfan::ZVector w) 191 { 192 omFree(r->order); 193 r->order = (int*) omAlloc0(3*sizeof(int)); 194 omFree(r->block0); 195 r->block0 = (int*) omAlloc0(3*sizeof(int)); 196 omFree(r->block1); 197 r->block1 = (int*) omAlloc0(3*sizeof(int)); 198 for (int i=0; r->wvhdl[i]; i++) omFree(r->wvhdl[i]); 199 omFree(r->wvhdl); 200 r->wvhdl = (int**) omAlloc0(3*sizeof(int*)); 201 202 bool ok = false; 203 r->order[0] = ringorder_wp; 204 r->block0[0] = 1; 205 r->block1[0] = r->N; 206 r->wvhdl[0] = ZVectorToIntStar(w,ok); 207 r->order[1] = ringorder_C; 208 rComplete(r,1); 209 } 210 211 groebnerConeData::groebnerConeData(const ideal J, const ring s, const gfan::ZVector w) 212 { 213 r = rCopy(s); 214 changeOrderingTo_wp(r,w); 215 rChangeCurrRing(r); 216 217 int k = idSize(J); I = idInit(k); 218 nMapFunc identityMap = n_SetMap(s->cf,r->cf); 219 for (int i=0; i<k; i++) 220 I->m[i] = p_PermPoly(J->m[i],NULL,s,r,identityMap,NULL,0); 221 intvec* nullVector = NULL; 222 I = kStd(I,currQuotient,testHomog,&nullVector); 223 224 c = sloppyGroebnerCone(I,r,w); 225 p = c.getRelativeInteriorPoint(); 226 } 227 228 groebnerConeData::groebnerConeData(const ideal J, const ring s, const gfan::ZCone d) 229 { 230 c = d; 231 p = d.getRelativeInteriorPoint(); 232 233 r = rCopy(s); 234 changeOrderingTo_wp(r,p); 235 rChangeCurrRing(r); 236 237 int k = idSize(J); I = idInit(k); 238 nMapFunc identityMap = n_SetMap(s->cf,r->cf); 239 for (int i=0; i<k; i++) 240 I->m[i] = p_PermPoly(J->m[i],NULL,s,r,identityMap,NULL,0); 241 intvec* nullVector = NULL; 242 I = kStd(I,currQuotient,testHomog,&nullVector); 243 } 244 245 // /*** 246 // * Given a general ring r with any ordering, changes the ordering to a(v),ws(-w) 247 // **/ 248 // bool changetoAWSRing(ring r, const gfan::ZVector v, const gfan::ZVector w) 249 // { 250 // omFree(r->order); 251 // r->order = (int*) omAlloc0(4*sizeof(int)); 252 // omFree(r->block0); 253 // r->block0 = (int*) omAlloc0(4*sizeof(int)); 254 // omFree(r->block1); 255 // r->block1 = (int*) omAlloc0(4*sizeof(int)); 256 // for (int i=0; r->wvhdl[i]; i++) 257 // { omFree(r->wvhdl[i]); } 258 // omFree(r->wvhdl); 259 // r->wvhdl = (int**) omAlloc0(4*sizeof(int*)); 260 261 // bool ok = false; 262 // r->order[0] = ringorder_a; 263 // r->block0[0] = 1; 264 // r->block1[0] = r->N; 265 // r->wvhdl[0] = ZVectorToIntStar(v,ok); 266 // r->order[1] = ringorder_ws; 267 // r->block0[1] = 1; 268 // r->block1[1] = r->N; 269 // r->wvhdl[1] = ZVectorToIntStar(w,ok); 270 // r->order[2] = ringorder_C; 271 // return ok; 272 // } 273 274 // groebnerConeData::groebnerConeData(const ideal J, const ring s, const gfan::ZVector w) 275 // { 276 // r = rCopy(s); 277 // changeOrderingTo_wp(r,w); 278 // rChangeCurrRing(r); 279 280 // int k = idSize(J); I = idInit(k); 281 // nMapFunc identityMap = n_SetMap(s->cf,r->cf); 282 // for (int i=0; i<k; i++) 283 // I->m[i] = p_PermPoly(J->m[i],NULL,s,r,nMap,NULL,0); 284 // intvec* nullVector = NULL; 285 // I = kStd(I,currQuotient,testHomog,&nullVector); 286 287 // c = sloppyGroebnerCone(I,r,w); 288 // p = c.getRelativeInteriorPoint(); 289 // } 290 291 gfan::ZFan* toFanStar(setOfGroebnerConeData setOfCones) 292 { 293 if (setOfCones.size() > 0) 294 { 295 setOfGroebnerConeData::iterator cone = setOfCones.begin(); 296 gfan::ZFan* zf = new gfan::ZFan(cone->getCone().ambientDimension()); 297 for (; cone!=setOfCones.end(); cone++) 298 zf->insert(cone->getCone()); 299 return zf; 300 } 301 else 302 return new gfan::ZFan(gfan::ZFan::fullFan(currRing->N)); 303 } -
Singular/dyn_modules/gfanlib/groebnerCone.h
rc89014 r9abcc6 8 8 #include <libpolys/polys/simpleideals.h> 9 9 #include <kernel/ideals.h> 10 #include <gfanlib/gfanlib_vector.h> 11 #include <gfanlib/gfanlib_zcone.h> 10 #include <gfanlib/gfanlib.h> 12 11 #include <set> 13 12 13 gfan::ZCone sloppyGroebnerCone(const poly g, const ring r, const gfan::ZVector w); 14 gfan::ZCone sloppyGroebnerCone(const ideal I, const ring r, const gfan::ZVector w); 14 15 gfan::ZCone groebnerCone(const poly g, const ring r, const gfan::ZVector w); 15 16 gfan::ZCone groebnerCone(const ideal I, const ring r, const gfan::ZVector w); 16 17 gfan::ZCone fullGroebnerCone(const ideal &I, const ring &r); 17 18 18 19 class groebnerConeData … … 31 32 groebnerConeData(const groebnerConeData &sigma); 32 33 groebnerConeData(const ideal &J, const ring &s, const gfan::ZCone &d, const gfan::ZVector &q); 33 groebnerConeData(const ideal &J, const ring &s); 34 groebnerConeData(const ideal J, const ring s, const gfan::ZVector w); 35 groebnerConeData(const ideal J, const ring s, const gfan::ZCone d); 34 36 ~groebnerConeData(); 35 37 … … 58 60 typedef std::set<groebnerConeData,groebnerConeData_compare> setOfGroebnerConeData; 59 61 62 gfan::ZFan* toFanStar(setOfGroebnerConeData setOfCones); 63 60 64 #endif -
Singular/dyn_modules/gfanlib/neighbours.cc
rc89014 r9abcc6 20 20 int r = inequalities.getHeight(); 21 21 int c = inequalities.getWidth(); 22 if (r==0) return gfan::ZMatrix(0,c); 22 23 23 24 gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c); … … 44 45 newInequalities = inequalities.submatrix(0,0,r-1,c); 45 46 newEquations = equations; 46 newEquations.appendRow(inequalities[r ]);47 newEquations.appendRow(inequalities[r-1]); 47 48 facet = gfan::ZCone(newInequalities,newEquations); 48 49 relativeInteriorPoints.appendRow(facet.getRelativeInteriorPoint()); … … 63 64 gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c); 64 65 gfan::ZMatrix outerFacetNormals = gfan::ZMatrix(0,c); 66 if (r<=1) 67 return std::make_pair(relativeInteriorPoints,outerFacetNormals); 65 68 // next we iterate over each of the r facets, build the respective cone and add it to the list 66 69 // this is the i=0 case … … 97 100 setOfGroebnerConeData groebnerNeighbours(const groebnerConeData sigma, const tropicalStrategy currentCase) 98 101 { 99 bool (*red )(ideal I, ring r);100 red = currentCase.reduce;102 bool (*reduce)(ideal I, ring r); 103 reduce = currentCase.reduce; 101 104 102 105 gfan::ZCone zc = sigma.getCone(); … … 108 111 for (int i=0; i<interiorPoints.getHeight(); i++) 109 112 { 110 std::pair<ideal,ring> flipped = flip(sigma.getIdeal(),sigma.getRing(),interiorPoints[i],facetNormals[i] );113 std::pair<ideal,ring> flipped = flip(sigma.getIdeal(),sigma.getRing(),interiorPoints[i],facetNormals[i],currentCase); 111 114 ideal I = flipped.first; 112 115 ring r = flipped.second; 113 red(I,r); 114 neighbours.insert(groebnerConeData(I,r)); 116 reduce(I,r); 117 gfan::ZCone c = sloppyGroebnerCone(I,r,facetNormals[i]); 118 gfan::ZVector p = c.getRelativeInteriorPoint(); 119 neighbours.insert(groebnerConeData(I,r,c,p)); 115 120 } 116 121 … … 118 123 } 119 124 120 setOfGroebnerConeData tropicalNeighbo rs(const groebnerConeData sigma, const tropicalStrategy currentCase)125 setOfGroebnerConeData tropicalNeighbours(const groebnerConeData sigma, const tropicalStrategy currentCase) 121 126 { 122 127 gfan::ZCone zc = sigma.getCone(); … … 138 143 for (std::set<gfan::ZVector>::iterator ray = setOfRays.begin(); ray!=setOfRays.end(); ray++) 139 144 { 140 std::pair<ideal,ring> flipped = flip(I,r,w,*ray );145 std::pair<ideal,ring> flipped = flip(I,r,w,*ray,currentCase); 141 146 ideal I = flipped.first; 142 147 ring r = flipped.second; 143 148 red(I,r); 144 neighbours.insert(groebnerConeData(I,r)); 149 gfan::ZCone c = sloppyGroebnerCone(I,r,*ray); 150 gfan::ZVector p = c.getRelativeInteriorPoint(); 151 neighbours.insert(groebnerConeData(I,r,c,p)); 145 152 } 146 153 } -
Singular/dyn_modules/gfanlib/neighbours.h
rc89014 r9abcc6 6 6 7 7 setOfGroebnerConeData groebnerNeighbours(const groebnerConeData sigma, const tropicalStrategy currentCase); 8 setOfGroebnerConeData tropicalNeighbours(const groebnerConeData sigma, const tropicalStrategy currentCase); 8 9 BOOLEAN tropicalNeighbours(leftv res, leftv args); 9 10 -
Singular/dyn_modules/gfanlib/startingCone.cc
rc89014 r9abcc6 6 6 #include <neighbours.h> 7 7 #include <tropicalStrategy.h> 8 9 /*** 10 * Given a general ring r with any ordering, 11 * changes the ordering to a(v),ws(-w) 12 **/ 13 bool changetoAWSRing(ring r, gfan::ZVector v, gfan::ZVector w) 14 { 15 omFree(r->order); 16 r->order = (int*) omAlloc0(4*sizeof(int)); 17 omFree(r->block0); 18 r->block0 = (int*) omAlloc0(4*sizeof(int)); 19 omFree(r->block1); 20 r->block1 = (int*) omAlloc0(4*sizeof(int)); 21 for (int i=0; r->wvhdl[i]; i++) 22 { omFree(r->wvhdl[i]); } 23 omFree(r->wvhdl); 24 r->wvhdl = (int**) omAlloc0(4*sizeof(int*)); 25 26 bool ok = false; 27 r->order[0] = ringorder_a; 28 r->block0[0] = 1; 29 r->block1[0] = r->N; 30 r->wvhdl[0] = ZVectorToIntStar(v,ok); 31 r->order[1] = ringorder_ws; 32 r->block0[1] = 1; 33 r->block1[1] = r->N; 34 r->wvhdl[1] = ZVectorToIntStar(w,ok); 35 r->order[2] = ringorder_C; 36 return ok; 37 } 8 #include <tropicalCurves.h> 9 #include <bbcone.h> 10 #include <tropicalVariety.h> 38 11 39 12 40 / ***41 * Given a ring with ordering a(v'),ws(w'),42 * changes the weights to v,w43 **/44 bool changeAWSWeights(ring r, gfan::ZVector v, gfan::ZVector w)45 {46 omFree(r->wvhdl[0]);47 omFree(r->wvhdl[1]);48 bool ok = false;49 r->wvhdl[0] = ZVectorToIntStar(v,ok);50 r->wvhdl[1] = ZVectorToIntStar(w,ok);51 return ok;52 }13 // /*** 14 // * Given a ring with ordering a(v'),ws(w'), 15 // * changes the weights to v,w 16 // **/ 17 // bool changeAWSWeights(ring r, gfan::ZVector v, gfan::ZVector w) 18 // { 19 // omFree(r->wvhdl[0]); 20 // omFree(r->wvhdl[1]); 21 // bool ok = false; 22 // r->wvhdl[0] = ZVectorToIntStar(v,ok); 23 // r->wvhdl[1] = ZVectorToIntStar(w,ok); 24 // return ok; 25 // } 53 26 54 27 … … 67 40 if (s == NULL) 68 41 { 69 // std::cout << "found no monomial in initial ideal!" << std::endl;70 42 p_Delete(&s,r); 71 43 return R[i]; 72 }73 p_Delete(&s,r);74 }75 gfan::ZMatrix L = zc.generatorsOfLinealitySpace();76 for (int i=0; i<L.getHeight(); i++)77 {78 ideal inI = initial(I,r,L[i]);79 poly s = checkForMonomialViaSuddenSaturation(inI,r);80 id_Delete(&inI,r);81 if (s == NULL)82 {83 // std::cout << "found no monomial in initial ideal!" << std::endl;84 p_Delete(&s,r);85 return L[i];86 44 } 87 45 p_Delete(&s,r); … … 93 51 gfan::ZVector tropicalStartingPoint(const ideal I, const ring r, const tropicalStrategy currentCase) 94 52 { 53 bool (*red)(ideal I, ring r); 54 red = currentCase.reduce; red(I,r); 55 95 56 groebnerConeData sigma = maximalGroebnerConeData(id_Copy(I,r),rCopy(r)); 96 57 gfan::ZVector startingPoint = findTropicalPoint(sigma); 97 while (startingPoint.size()==0) 58 if (startingPoint.size() > 0) 59 return startingPoint; 60 setOfGroebnerConeData groebnerFan; 61 setOfGroebnerConeData workingList; 62 workingList.insert(sigma); 63 64 while (!workingList.empty()) 98 65 { 66 sigma = *(workingList.begin()); 99 67 setOfGroebnerConeData neighbours = groebnerNeighbours(sigma,currentCase); 100 setOfGroebnerConeData::iterator tau = neighbours.begin(); 101 for (; tau!=neighbours.end(); tau++) 68 for (setOfGroebnerConeData::iterator tau = neighbours.begin(); tau!=neighbours.end(); tau++) 102 69 { 103 startingPoint = findTropicalPoint(*tau); 104 if (startingPoint.size() > 0) break; 70 if (groebnerFan.count(*tau) == 0) 71 { 72 if (workingList.count(*tau) == 0) 73 { 74 startingPoint = findTropicalPoint(*tau); 75 if (startingPoint.size() > 0) 76 return startingPoint; 77 } 78 workingList.insert(*tau); 79 } 105 80 } 106 tau = neighbours.begin();107 sigma = *tau;81 groebnerFan.insert(groebnerConeData(sigma)); 82 workingList.erase(sigma); 108 83 } 109 84 return startingPoint; 110 85 } 111 112 86 113 87 BOOLEAN tropicalStartingPoint0(leftv res, leftv args) … … 133 107 } 134 108 109 gfan::ZCone tropicalStartingCone(const ideal I, const ring r, const tropicalStrategy currentCase) 110 { 111 // groebnerConeData sigma = maximalGroebnerConeData(I,r); 112 // gfan::ZCone zc = sigma.getCone(); 113 // if (zc.dimensionOfLinealitySpace == d) 114 // return zc.linealitySpace(); 115 // gfan::ZVector w = tropicalStartingPoint(I,r,currentCase); 116 // ideal inI = initial(I,w,r); 117 // gfan::ZCone zd = 135 118 136 // gfan::ZCone* tropicalStartingCone(const ideal &I, ring r) 137 // { 138 // gfan::ZVector* w = tropicalStartingPoint(I,r); 139 // return groebnerCone(I,r,w); 140 // } 119 gfan::ZVector w = tropicalStartingPoint(I,r,currentCase); 120 if (w.size() == 0) 121 { 122 gfan::ZCone zc = fullGroebnerCone(I,r); 123 return zc.linealitySpace(); 124 } 125 ideal inI = initial(I,r,w); 126 std::set<gfan::ZCone> T = tropicalCurve(inI,r,0,currentCase); 127 return *T.begin(); 128 } 129 130 BOOLEAN tropicalStartingCone0(leftv res, leftv args) 131 { 132 leftv u = args; 133 ideal I = (ideal) u->CopyD(); 134 gfan::ZCone startingCone = tropicalStartingCone(I,currRing,nonValuedCase); 135 id_Delete(&I, currRing); 136 res->rtyp = coneID; 137 res->data = (char*) new gfan::ZCone(startingCone); 138 return FALSE; 139 } 140 141 BOOLEAN tropicalStartingCone1(leftv res, leftv args) 142 { 143 leftv u = args; 144 ideal I = (ideal) u->CopyD(); 145 gfan::ZCone startingCone = tropicalStartingCone(I,currRing,valuedCase); 146 id_Delete(&I, currRing); 147 res->rtyp = coneID; 148 res->data = (char*) new gfan::ZCone(startingCone); 149 return FALSE; 150 } -
Singular/dyn_modules/gfanlib/startingCone.h
rc89014 r9abcc6 3 3 4 4 #include <groebnerCone.h> 5 /* namespace tropical */ 6 /* { */ 7 8 /* class facet */ 9 /* { */ 10 /* gfan::ZVector interiorPoint; */ 11 /* gfan::ZVector facetNormal; */ 12 13 /* public: */ 14 15 /* facet(); */ 16 /* facet(const facet &f); */ 17 /* facet(const gfan::ZCone &c, const gfan::ZVector &v, const gfan::ZVector &w); */ 18 /* ~facet(); */ 19 20 /* gfan::ZCone getEta() { return this->eta; }; */ 21 /* gfan::ZVector getInteriorPoint() { return this->interiorPoint; }; */ 22 /* gfan::ZVector getFacetNormal() { return this->facetNormal; }; */ 23 24 /* friend struct facet_compare; */ 25 /* }; */ 26 27 /* struct facet_compare */ 28 /* { */ 29 /* bool operator()(const facet &f, const facet &g) const */ 30 /* { */ 31 /* const gfan::ZVector v1 = f.interiorPoint; */ 32 /* const gfan::ZVector v2 = g.interiorPoint; */ 33 /* #ifndef NDEBUG */ 34 /* assume(v1.size() == v2.size()); */ 35 /* #endif */ 36 /* return v1 < v2; */ 37 /* } */ 38 /* }; */ 39 40 /* typedef std::set<facet,facet_compare> facets; */ 41 42 /* void mergeFacets(facets &F, const facets &newFacets); */ 43 44 /* } */ 5 #include <tropicalStrategy.h> 45 6 46 7 gfan::ZVector containsTropicalPoint(const groebnerConeData sigma); 47 8 gfan::ZVector tropicalStartingPoint(ideal I, ring r); 9 gfan::ZCone tropicalStartingCone(const ideal I, const ring r, const tropicalStrategy currentCase); 48 10 49 11 BOOLEAN tropicalStartingPoint0(leftv res, leftv args); 50 12 BOOLEAN tropicalStartingPoint1(leftv res, leftv args); 51 13 14 BOOLEAN tropicalStartingCone0(leftv res, leftv args); 15 BOOLEAN tropicalStartingCone1(leftv res, leftv args); 16 52 17 #endif -
Singular/dyn_modules/gfanlib/tropical.cc
rc89014 r9abcc6 14 14 #include <tropicalStrategy.h> 15 15 #include <startingCone.h> 16 #include <tropicalVariety.h> 16 17 17 18 BOOLEAN homogeneitySpace(leftv res, leftv args) … … 207 208 p->iiAddCproc("","tropicalStartingPoint0",FALSE,tropicalStartingPoint0); 208 209 p->iiAddCproc("","tropicalStartingPoint1",FALSE,tropicalStartingPoint1); 210 p->iiAddCproc("","tropicalStartingCone0",FALSE,tropicalStartingCone0); 211 p->iiAddCproc("","tropicalStartingCone1",FALSE,tropicalStartingCone1); 212 p->iiAddCproc("","tropicalVariety",FALSE,tropicalVariety); 209 213 #endif //NDEBUG 210 214 p->iiAddCproc("","ppreduceInitially",FALSE,ppreduceInitially); -
Singular/dyn_modules/gfanlib/tropicalCurves.cc
rc89014 r9abcc6 89 89 90 90 /*** 91 * Computes the tropical curve of an x-homogeneous ideal I 92 * which is weighted homogeneous with respect to weight w in ring r 91 * Computes the tropical curve of an x-homogeneous ideal I in ring r 93 92 **/ 94 93 std::set<gfan::ZCone> tropicalCurve(const ideal I, const ring r, const int d, -
Singular/dyn_modules/gfanlib/witness.cc
rc89014 r9abcc6 4 4 #include <callgfanlib_conversion.h> 5 5 #include <initial.h> 6 #include <tropicalStrategy.h> 6 7 #include <utility> 7 8 … … 134 135 } 135 136 136 std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal )137 std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal, const tropicalStrategy currentCase) 137 138 { 139 gfan::ZVector (*adjustWeight0)(gfan::ZVector w); 140 adjustWeight0 = currentCase.adjustWeightForHomogeneity; 141 gfan::ZVector (*adjustWeight1)(gfan::ZVector v, gfan::ZVector w); 142 adjustWeight1 = currentCase.adjustWeightUnderHomogeneity; 143 144 gfan::ZVector adjustedInteriorPoint = adjustWeight0(interiorPoint); 145 gfan::ZVector adjustedFacetNormal = adjustWeight1(facetNormal,adjustedInteriorPoint); 146 138 147 ring origin = currRing; 139 148 ideal inIr = initial(I,r,interiorPoint); … … 143 152 int n = rVar(s); 144 153 deleteOrdering(s); 145 // for (i=0; s->order[i]; i++)146 // omFree(s->wvhdl[i]);147 // i++; omFreeSize(s->order, i*sizeof(int));148 // omFreeSize(s->block0, i*sizeof(int));149 // omFreeSize(s->block1, i*sizeof(int));150 // omFreeSize(s->wvhdl, i*sizeof(int));151 154 s->order = (int*) omAlloc0(4*sizeof(int)); 152 155 s->block0 = (int*) omAlloc0(4*sizeof(int)); … … 156 159 s->block0[0] = 1; 157 160 s->block1[0] = n; 158 s->wvhdl[0] = ZVectorToIntStar( interiorPoint,ok);161 s->wvhdl[0] = ZVectorToIntStar(adjustedInteriorPoint,ok); 159 162 s->order[1] = ringorder_wp; 160 163 s->block0[1] = 1; 161 164 s->block1[1] = n; 162 s->wvhdl[1] = ZVectorToIntStar( facetNormal,ok);165 s->wvhdl[1] = ZVectorToIntStar(adjustedFacetNormal,ok); 163 166 s->order[2] = ringorder_C; 164 167 rComplete(s,1); -
Singular/dyn_modules/gfanlib/witness.h
rc89014 r9abcc6 6 6 #include <Singular/ipid.h> 7 7 #include <gfanlib/gfanlib_vector.h> 8 #include <tropicalStrategy.h> 8 9 9 10 poly witness(const poly m, const ideal I, const ideal inI, const ring r); 10 std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal );11 std::pair<ideal,ring> flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal, const tropicalStrategy currentCase); 11 12 12 13 #ifndef NDEBUG
Note: See TracChangeset
for help on using the changeset viewer.