#include "minkowskidual.h" #include "field_rationals.h" #include "linalg.h" class MyCone{ public: struct Pair{ int rayIndex; vector const &rays; IntegerVector const &permutation; Pair(vector const &rays_, int rayIndex_, IntegerVector const & permutation_): rays(rays_), rayIndex(rayIndex_), permutation(permutation_) { } bool operator<(Pair const &b)const { return SymmetryGroup::compose(permutation,rays[rayIndex]) rays; void print() { for(set::const_iterator i=rays.begin();i!=rays.end();i++) { fprintf(Stderr,"--:%i ",i->rayIndex); AsciiPrinter(Stderr).printVector((i->permutation)); fprintf(Stderr,"\n"); } } }; static list computeFacets(SymmetricComplex::Cone const &theCone, IntegerMatrix const &rays, IntegerVectorList const &facetCandidates, SymmetricComplex const &theComplex/*, int linealityDim*/) { set ret; for(IntegerVectorList::const_iterator i=facetCandidates.begin();i!=facetCandidates.end();i++) { set indices; bool notAll=false; for(vector::const_iterator j=theCone.indices.begin();j!=theCone.indices.end();j++) if(dotLong(rays[*j],*i)==0) indices.insert(*j); else notAll=true; SymmetricComplex::Cone temp(indices,theCone.dimension-1,0,false,theComplex); /* temp.multiplicity=0; temp.dimension=theCone.dimension-1; temp.setIgnoreSymmetry(true); */ if(notAll)ret.insert(temp); } // fprintf(Stderr,"HEJ!!!!\n"); list ret2; for(set::const_iterator i=ret.begin();i!=ret.end();i++) { bool isMaximal=true; /* if(i->indices.size()+linealityDimdimension)//#3 isMaximal=false; else*/ for(set::const_iterator j=ret.begin();j!=ret.end();j++) if(i!=j && i->isSubsetOf(*j)) { isMaximal=false; break; } if(isMaximal) { SymmetricComplex::Cone temp(i->indexSet(),i->dimension,i->multiplicity,true,theComplex); // temp.setIgnoreSymmetry(false); ret2.push_back(temp); } } return ret2; } SymmetricComplex dualMinkowskiMixed(PolynomialSet const &g, SymmetryGroup const &sym, PolyhedralFan const &cones) { /* The set of rays of the dual fan is the vertices of the Minkowski sum after centering around zero. We only generate them up to symmetry. */ int n=cones.getAmbientDimension(); int nMaxOrbits=0; for(PolyhedralFan::coneIterator i=cones.conesBegin();i!=cones.conesEnd();i++)nMaxOrbits++; vector rays(nMaxOrbits); FieldVector translationVector(Q,n); for(PolynomialSet::const_iterator i=g.begin();i!=g.end();i++) translationVector+=Q.zHomomorphism(i->numberOfTerms()).inverse()*integerVectorToFieldVector(i->exponentsSum(),Q); { int j=0; for(PolyhedralFan::coneIterator i=cones.conesBegin();i!=cones.conesEnd();i++,j++) { FieldVector temp=integerVectorToFieldVector(i->getRelativeInteriorPoint(),Q); temp+=(Q.zHomomorphism(-1)*translationVector); rays[j]=temp.primitive(); } } fprintf(Stderr,"The new rays:\n"); for(int i=0;i newCones(primaryRays.size()); IntegerVectorList::const_iterator K=primaryRays.begin(); for(int k=0;kcontains(v)) { newCones[k].rays.insert(MyCone::Pair(rays,j,*l)); } } } } fprintf(Stderr,"Facets with their vertices:\n"); for(int k=0;k > allRaysIndices(nMaxOrbits); { int j=0; for(PolyhedralFan::coneIterator i=cones.conesBegin();i!=cones.conesEnd();i++,j++) { int k=0; for(IntegerVectorList::const_iterator l=allPrimaryRays.begin();l!=allPrimaryRays.end();l++,k++) if(i->contains(*l))allRaysIndices[j].insert(k); } } fprintf(Stderr,"Facets with their vertices (as indices):\n"); for(int k=0;k::const_iterator j=allRaysIndices[k].begin();j!=allRaysIndices[k].end();j++) fprintf(Stderr,"%i ",*j); fprintf(Stderr,"\n\n"); // newCones[k].print(); } /* We prepare the complex to return. */ SymmetricComplex ret(n,allPrimaryRays,sym); /* For every dual cone we need to compute facet normal. This is done by cddlib. Afterward we use these facet normals to add the faces of the dual cone to our collection of cones (pre-complex) - each time checking that the corresponding face is mixed. */ fprintf(Stderr,"Adding mixed faces for cones:\n"); for(int k=0;k::const_iterator i=newCones[k].rays.begin();i!=newCones[k].rays.end();i++) { a.push_back(SymmetryGroup::compose(i->permutation,rays[i->rayIndex])); } AsciiPrinter(Stderr).printVectorList(a); IntegerVectorList empty; PolyhedralCone C(a,empty,n); IntegerVectorList facetCandidates=C.extremeRays(); fprintf(Stderr,"Cone %i\nFacetNormals:\n",k); AsciiPrinter(Stderr).printVectorList(facetCandidates); /* list clist; { set indices; for(int j=0;j facets=computeFacets(theCone,rays,facetCandidates,c); clist.splice(clist.end(),facets); } clist.pop_front(); } */ } /* For every cone in the final "pre-complex" we translate it into a cone in the primary */ return ret; }