My Project
Loading...
Searching...
No Matches
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 **/
17std::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 = kStd2(inIsAdjusted,currRing->qideal,testHomog,&nullVector,
65 NULL);
66 ideal IsAdjustedGB = lift(I,r,inIsAdjustedGB,sAdjusted);
67 id_Delete(&inIsAdjusted,sAdjusted);
68 id_Delete(&inIsAdjustedGB,sAdjusted);
69
70 ring s = rCopy0(r,FALSE,FALSE);
71 n = rVar(s);
72 s->order = (rRingOrder_t*) omAlloc0(5*sizeof(rRingOrder_t));
73 s->block0 = (int*) omAlloc0(5*sizeof(int));
74 s->block1 = (int*) omAlloc0(5*sizeof(int));
75 s->wvhdl = (int**) omAlloc0(5*sizeof(int**));
76 s->order[0] = ringorder_a;
77 s->block0[0] = 1;
78 s->block1[0] = n;
79 s->wvhdl[0] = ZVectorToIntStar(interiorPoint,ok);
80 s->order[1] = ringorder_a;
81 s->block0[1] = 1;
82 s->block1[1] = n;
83 s->wvhdl[1] = ZVectorToIntStar(facetNormal,ok);
84 s->order[2] = ringorder_lp;
85 s->block0[2] = 1;
86 s->block1[2] = n;
87 s->order[3] = ringorder_C;
88 rComplete(s);
89 rTest(s);
90 identity = n_SetMap(sAdjusted->cf,s->cf);
91 k = IDELEMS(IsAdjustedGB); ideal IsGB = idInit(k);
92 for (int i=0; i<k; i++)
93 {
94 if (IsAdjustedGB->m[i]!=NULL)
95 {
96 IsGB->m[i] = p_PermPoly(IsAdjustedGB->m[i],NULL,sAdjusted,s,identity,NULL,0);
97 }
98 }
99 id_Delete(&IsAdjustedGB,sAdjusted);
100 rDelete(sAdjusted);
101 rChangeCurrRing(origin);
102
103 /* lift the Groebner basis of the initial ideal
104 * to a Groebner basis of the original ideal,
105 * the currRingChange is solely for sake of performance */
106
107 return std::make_pair(IsGB,s);
108}
#define FALSE
Definition auxiliary.h:97
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
int i
Definition cfEzgcd.cc:132
int k
Definition cfEzgcd.cc:99
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:701
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
const CanonicalForm int s
Definition facAbsFact.cc:51
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
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
ideal kStd2(ideal F, ideal Q, tHomog h, intvec **w, bigintmat *hilb, int syzComp, int newIdeal, intvec *vw, s_poly_proc_t sp)
generic interface to GB/SB computations, large hilbert vectors
Definition kstd1.cc:2602
ideal lift(const ideal J, const ring r, const ideal inI, const ring s)
Definition lift.cc:26
#define omAlloc0(size)
#define NULL
Definition omList.c:12
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:4211
void rChangeCurrRing(ring r)
Definition polys.cc:16
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
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:3526
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition ring.cc:1426
void rDelete(ring r)
unconditionally deletes fields in r
Definition ring.cc:454
rRingOrder_t
order stuff
Definition ring.h:69
@ ringorder_lp
Definition ring.h:78
@ ringorder_a
Definition ring.h:71
@ ringorder_C
Definition ring.h:74
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
#define rTest(r)
Definition ring.h:794
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define IDELEMS(i)
@ testHomog
Definition structs.h:34