My Project  debian-1:4.1.1-p2+ds-4build3
flip.cc
Go to the documentation of this file.
2 #include "gfanlib/gfanlib_vector.h"
4 #include "singularWishlist.h"
5 #include "initial.h"
6 #include "lift.h"
7 
8 /***
9  * Given a Groebner basis I of an ideal in r, an interior Point
10  * on a face of the maximal Groebner cone associated to the ordering on r,
11  * and a vector pointing outwards from it,
12  * returns a pair (Is,s) such that:
13  * (1) s is the same mathematical ring as r, but with a new ordering such that
14  * the interior point lies on the intersection of both maximal Groebner cones
15  * (2) Is is a Groebner basis of the same ideal with respect to the ordering on s
16  **/
17 std::pair<ideal,ring> flip(const ideal I, const ring r,
18  const gfan::ZVector interiorPoint,
19  const gfan::ZVector facetNormal,
20  const gfan::ZVector adjustedInteriorPoint,
21  const gfan::ZVector adjustedFacetNormal)
22 {
23  /* create a ring with weighted ordering */
24  bool ok;
25  ring sAdjusted = rCopy0(r,FALSE,FALSE);
26  int n = rVar(sAdjusted);
27  sAdjusted->order = (rRingOrder_t*) omAlloc0(5*sizeof(rRingOrder_t));
28  sAdjusted->block0 = (int*) omAlloc0(5*sizeof(int));
29  sAdjusted->block1 = (int*) omAlloc0(5*sizeof(int));
30  sAdjusted->wvhdl = (int**) omAlloc0(5*sizeof(int**));
31  sAdjusted->order[0] = ringorder_a;
32  sAdjusted->block0[0] = 1;
33  sAdjusted->block1[0] = n;
34  sAdjusted->wvhdl[0] = ZVectorToIntStar(adjustedInteriorPoint,ok);
35  sAdjusted->order[1] = ringorder_a;
36  sAdjusted->block0[1] = 1;
37  sAdjusted->block1[1] = n;
38  sAdjusted->wvhdl[1] = ZVectorToIntStar(adjustedFacetNormal,ok);
39  sAdjusted->order[2] = ringorder_lp;
40  sAdjusted->block0[2] = 1;
41  sAdjusted->block1[2] = n;
42  sAdjusted->wvhdl[2] = ZVectorToIntStar(adjustedFacetNormal,ok);
43  sAdjusted->order[3] = ringorder_C;
44  rComplete(sAdjusted);
45  rTest(sAdjusted);
46  nMapFunc identity = n_SetMap(r->cf,sAdjusted->cf);
47 
48  /* compute initial ideal and map it to the new ordering */
49  ideal inIr = initial(I,r,interiorPoint);
50  int k = IDELEMS(I); ideal inIsAdjusted = idInit(k);
51  for (int i=0; i<k; i++)
52  {
53  if (inIr->m[i]!=NULL)
54  {
55  inIsAdjusted->m[i] = p_PermPoly(inIr->m[i],NULL,r,sAdjusted,identity,NULL,0);
56  }
57  }
58  id_Delete(&inIr,r);
59 
60  /* compute Groebner basis of the initial ideal */
61  intvec* nullVector = NULL;
62  ring origin = currRing;
63  rChangeCurrRing(sAdjusted);
64  ideal inIsAdjustedGB = kStd(inIsAdjusted,currRing->qideal,testHomog,&nullVector);
65  ideal IsAdjustedGB = lift(I,r,inIsAdjustedGB,sAdjusted);
66  id_Delete(&inIsAdjusted,sAdjusted);
67  id_Delete(&inIsAdjustedGB,sAdjusted);
68 
69  ring s = rCopy0(r,FALSE,FALSE);
70  n = rVar(s);
71  s->order = (rRingOrder_t*) omAlloc0(5*sizeof(rRingOrder_t));
72  s->block0 = (int*) omAlloc0(5*sizeof(int));
73  s->block1 = (int*) omAlloc0(5*sizeof(int));
74  s->wvhdl = (int**) omAlloc0(5*sizeof(int**));
75  s->order[0] = ringorder_a;
76  s->block0[0] = 1;
77  s->block1[0] = n;
78  s->wvhdl[0] = ZVectorToIntStar(interiorPoint,ok);
79  s->order[1] = ringorder_a;
80  s->block0[1] = 1;
81  s->block1[1] = n;
82  s->wvhdl[1] = ZVectorToIntStar(facetNormal,ok);
83  s->order[2] = ringorder_lp;
84  s->block0[2] = 1;
85  s->block1[2] = n;
86  s->order[3] = ringorder_C;
87  rComplete(s);
88  rTest(s);
89  identity = n_SetMap(sAdjusted->cf,s->cf);
90  k = IDELEMS(IsAdjustedGB); ideal IsGB = idInit(k);
91  for (int i=0; i<k; i++)
92  {
93  if (IsAdjustedGB->m[i]!=NULL)
94  {
95  IsGB->m[i] = p_PermPoly(IsAdjustedGB->m[i],NULL,sAdjusted,s,identity,NULL,0);
96  }
97  }
98  id_Delete(&IsAdjustedGB,sAdjusted);
99  rDelete(sAdjusted);
100  rChangeCurrRing(origin);
101 
102  /* lift the Groebner basis of the initial ideal
103  * to a Groebner basis of the original ideal,
104  * the currRingChange is solely for sake of performance */
105 
106  return std::make_pair(IsGB,s);
107 }
FALSE
#define FALSE
Definition: auxiliary.h:94
callgfanlib_conversion.h
k
int k
Definition: cfEzgcd.cc:92
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition: polys.cc:15
lift
ideal lift(const ideal J, const ring r, const ideal inI, const ring s)
Definition: lift.cc:26
lift.h
rTest
#define rTest(r)
Definition: ring.h:777
initial
poly initial(const poly p, const ring r, const gfan::ZVector &w)
Returns the initial form of p with respect to w.
Definition: initial.cc:30
testHomog
@ testHomog
Definition: structs.h:41
flip
std::pair< ideal, ring > flip(const ideal I, const ring r, const gfan::ZVector interiorPoint, const gfan::ZVector facetNormal, const gfan::ZVector adjustedInteriorPoint, const gfan::ZVector adjustedFacetNormal)
Definition: flip.cc:17
ringorder_C
@ ringorder_C
Definition: ring.h:80
rCopy0
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1325
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
rVar
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
i
int i
Definition: cfEzgcd.cc:125
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: simpleideals.cc:114
p_PermPoly
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:4014
nMapFunc
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
ZVectorToIntStar
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
Definition: callgfanlib_conversion.cc:110
intvec
Definition: intvec.h:21
singularWishlist.h
initial.h
ringorder_lp
@ ringorder_lp
Definition: ring.h:84
rDelete
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:439
kstd1.h
ringorder_a
@ ringorder_a
Definition: ring.h:77
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
NULL
#define NULL
Definition: omList.c:10
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
n_SetMap
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:722
IDELEMS
#define IDELEMS(i)
Definition: simpleideals.h:26
kStd
ideal kStd(ideal F, ideal Q, tHomog h, intvec **w, intvec *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
Definition: kstd1.cc:2096
rRingOrder_t
rRingOrder_t
order stuff
Definition: ring.h:75
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
rComplete
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3351