Functions
flip.cc File Reference
#include <utility>
#include <kernel/GBEngine/kstd1.h>
#include <gfanlib/gfanlib_vector.h>
#include <callgfanlib_conversion.h>
#include <initial.h>
#include <lift.h>
#include <tropicalStrategy.h>

Go to the source code of this file.

Functions

static void deleteOrdering (ring r)
 
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)
 

Function Documentation

§ deleteOrdering()

static void deleteOrdering ( ring  r)
static

Definition at line 10 of file flip.cc.

11 {
12  if (r->order != NULL)
13  {
14  int i=rBlocks(r);
15  assume(r->block0 != NULL && r->block1 != NULL && r->wvhdl != NULL);
16  /* delete order */
17  omFreeSize((ADDRESS)r->order,i*sizeof(int));
18  omFreeSize((ADDRESS)r->block0,i*sizeof(int));
19  omFreeSize((ADDRESS)r->block1,i*sizeof(int));
20  /* delete weights */
21  for (int j=0; j<i; j++)
22  if (r->wvhdl[j]!=NULL)
23  omFree(r->wvhdl[j]);
24  omFreeSize((ADDRESS)r->wvhdl,i*sizeof(int *));
25  }
26  else
27  assume(r->block0 == NULL && r->block1 == NULL && r->wvhdl == NULL);
28  return;
29 }
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:118
static int rBlocks(ring r)
Definition: ring.h:556
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:403
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10

§ 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 at line 40 of file flip.cc.

45 {
46  /* create a ring with weighted ordering */
47  bool ok;
48  ring sAdjusted = rCopy0(r);
49  int n = rVar(sAdjusted);
50  deleteOrdering(sAdjusted);
51  sAdjusted->order = (int*) omAlloc0(4*sizeof(int));
52  sAdjusted->block0 = (int*) omAlloc0(4*sizeof(int));
53  sAdjusted->block1 = (int*) omAlloc0(4*sizeof(int));
54  sAdjusted->wvhdl = (int**) omAlloc0(4*sizeof(int**));
55  sAdjusted->order[0] = ringorder_a;
56  sAdjusted->block0[0] = 1;
57  sAdjusted->block1[0] = n;
58  sAdjusted->wvhdl[0] = ZVectorToIntStar(adjustedInteriorPoint,ok);
59  sAdjusted->order[1] = ringorder_wp;
60  sAdjusted->block0[1] = 1;
61  sAdjusted->block1[1] = n;
62  sAdjusted->wvhdl[1] = ZVectorToIntStar(adjustedFacetNormal,ok);
63  sAdjusted->order[2] = ringorder_C;
64  rComplete(sAdjusted);
65  rTest(sAdjusted);
66  nMapFunc identity = n_SetMap(r->cf,sAdjusted->cf);
67 
68  /* compute initial ideal and map it to the new ordering */
69  ideal inIr = initial(I,r,interiorPoint);
70  int k = IDELEMS(I); ideal inIsAdjusted = idInit(k);
71  for (int i=0; i<k; i++)
72  {
73  if (inIr->m[i]!=NULL)
74  {
75  inIsAdjusted->m[i] = p_PermPoly(inIr->m[i],NULL,r,sAdjusted,identity,NULL,0);
76  }
77  }
78  id_Delete(&inIr,r);
79 
80  /* compute Groebner basis of the initial ideal */
81  intvec* nullVector = NULL;
82  ring origin = currRing;
83  rChangeCurrRing(sAdjusted);
84  ideal inIsAdjustedGB = kStd(inIsAdjusted,currRing->qideal,testHomog,&nullVector);
85  ideal IsAdjustedGB = lift(I,r,inIsAdjustedGB,sAdjusted);
86  id_Delete(&inIsAdjusted,sAdjusted);
87  id_Delete(&inIsAdjustedGB,sAdjusted);
88 
89  ring s = rCopy0(r);
90  n = rVar(s);
91  deleteOrdering(s);
92  s->order = (int*) omAlloc0(5*sizeof(int));
93  s->block0 = (int*) omAlloc0(5*sizeof(int));
94  s->block1 = (int*) omAlloc0(5*sizeof(int));
95  s->wvhdl = (int**) omAlloc0(5*sizeof(int**));
96  s->order[0] = ringorder_a;
97  s->block0[0] = 1;
98  s->block1[0] = n;
99  s->wvhdl[0] = ZVectorToIntStar(interiorPoint,ok);
100  s->order[1] = ringorder_a;
101  s->block0[1] = 1;
102  s->block1[1] = n;
103  s->wvhdl[1] = ZVectorToIntStar(facetNormal,ok);
104  s->order[2] = ringorder_dp;
105  s->block0[2] = 1;
106  s->block1[2] = n;
107  s->order[3] = ringorder_C;
108  rComplete(s);
109  rTest(s);
110  identity = n_SetMap(sAdjusted->cf,s->cf);
111  k = IDELEMS(IsAdjustedGB); ideal IsGB = idInit(k);
112  for (int i=0; i<k; i++)
113  {
114  if (IsAdjustedGB->m[i]!=NULL)
115  {
116  IsGB->m[i] = p_PermPoly(IsAdjustedGB->m[i],NULL,sAdjusted,s,identity,NULL,0);
117  }
118  }
119  id_Delete(&IsAdjustedGB,sAdjusted);
120  rDelete(sAdjusted);
121  rChangeCurrRing(origin);
122 
123  /* lift the Groebner basis of the initial ideal
124  * to a Groebner basis of the original ideal,
125  * the currRingChange is solely for sake of performance */
126 
127  return std::make_pair(IsGB,s);
128 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:580
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
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:2231
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
int k
Definition: cfEzgcd.cc:93
ideal lift(const ideal J, const ring r, const ideal inI, const ring s)
Definition: lift.cc:24
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:32
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
const ring r
Definition: syzextra.cc:208
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:3939
Definition: intvec.h:14
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:3435
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1321
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
#define rTest(r)
Definition: ring.h:775
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
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:725
void rChangeCurrRing(ring r)
Definition: polys.cc:12
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define NULL
Definition: omList.c:10
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:448
static void deleteOrdering(ring r)
Definition: flip.cc:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211