My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
Singular
dyn_modules
gfanlib
groebnerFan.cc
Go to the documentation of this file.
1
#include "
misc/options.h
"
2
#include "
bbfan.h
"
3
4
#include "
groebnerCone.h
"
5
#include "
startingCone.h
"
6
#include "
tropicalTraversal.h
"
7
8
9
VAR
BITSET
groebnerBitsetSave1
,
groebnerBitsetSave2
;
10
11
/***
12
* sets option(redSB)
13
**/
14
static
void
setOptionRedSB
()
15
{
16
SI_SAVE_OPT
(
groebnerBitsetSave1
,
groebnerBitsetSave2
);
17
si_opt_1
|=
Sy_bit
(
OPT_REDSB
);
18
}
19
20
/***
21
* sets option(noredSB);
22
**/
23
static
void
undoSetOptionRedSB
()
24
{
25
SI_RESTORE_OPT
(
groebnerBitsetSave1
,
groebnerBitsetSave2
);
26
}
27
28
gfan::ZFan*
groebnerFan
(
const
tropicalStrategy
currentStrategy)
29
{
30
groebnerCone
startingCone =
groebnerStartingCone
(currentStrategy);
31
groebnerCones
groebnerFan
=
groebnerTraversal
(startingCone);
32
return
toFanStar
(
groebnerFan
);
33
}
34
35
36
gfan::ZFan*
groebnerFanOfPolynomial
(poly
g
, ring r,
bool
onlyLowerHalfSpace=
false
)
37
{
38
int
n =
rVar
(r);
39
40
if
(
g
==
NULL
||
g
->next==
NULL
)
41
{
42
// if g is a term or zero, return the fan consisting of the whole weight space
43
gfan::ZFan* zf =
new
gfan::ZFan(gfan::ZFan::fullFan(n));
44
return
zf;
45
}
46
else
47
{
48
gfan::ZVector lowerHalfSpaceCondition = gfan::ZVector(n);
49
lowerHalfSpaceCondition[0] = -1;
50
51
// otherwise, obtain a list of all the exponent vectors
52
int
* expv = (
int
*)
omAlloc
((n+1)*
sizeof
(
int
));
53
gfan::ZMatrix exponents = gfan::ZMatrix(0,n);
54
for
(poly
s
=
g
;
s
;
pIter
(
s
))
55
{
56
p_GetExpV
(
s
,expv,r);
57
gfan::ZVector zv =
intStar2ZVector
(n,expv);
58
exponents.appendRow(
intStar2ZVector
(n,expv));
59
}
60
omFreeSize
(expv,(n+1)*
sizeof
(
int
));
61
62
// and construct the Groebner fan
63
gfan::ZFan* zf =
new
gfan::ZFan(n);
64
int
l
= exponents.getHeight();
65
for
(
int
i
=0;
i
<
l
;
i
++)
66
{
67
// constructs the Groebner cone such that initial form is i-th term
68
gfan::ZMatrix
inequalities
= gfan::ZMatrix(0,n);
69
if
(onlyLowerHalfSpace)
70
inequalities
.appendRow(lowerHalfSpaceCondition);
71
for
(
int
j
=0;
j
<
l
;
j
++)
72
{
73
if
(
i
!=
j
)
74
inequalities
.appendRow(exponents[
i
].toVector()-exponents[
j
].toVector());
75
}
76
gfan::ZCone zc = gfan::ZCone(
inequalities
,gfan::ZMatrix(0,
inequalities
.getWidth()));
77
zc.canonicalize();
78
zf->insert(zc);
79
}
80
return
zf;
81
}
82
}
83
84
85
BOOLEAN
groebnerFan
(
leftv
res
,
leftv
args)
86
{
87
leftv
u = args;
88
if
((u!=
NULL
) && (u->
Typ
()==
IDEAL_CMD
))
89
{
90
ideal I = (ideal) u->
CopyD
();
91
leftv
v
= u->
next
;
92
93
if
(
v
==
NULL
)
94
{
95
if
((I->m[0]!=
NULL
) && (
idElem
(I)==1))
96
{
97
try
98
{
99
poly
g
= I->m[0];
100
gfan::ZFan* zf =
groebnerFanOfPolynomial
(
g
,
currRing
);
101
res
->rtyp =
fanID
;
102
res
->data = (
char
*) zf;
103
return
FALSE
;
104
}
105
catch
(
const
std::exception& ex)
106
{
107
WerrorS
(
"ERROR: "
);
WerrorS
(ex.what());
WerrorS
(
"\n"
);
108
return
TRUE
;
109
}
110
}
111
else
112
{
113
try
114
{
115
tropicalStrategy
currentStrategy(I,
currRing
);
116
setOptionRedSB
();
117
gfan::ZFan* zf =
groebnerFan
(currentStrategy);
118
undoSetOptionRedSB
();
119
res
->rtyp =
fanID
;
120
res
->data = (
char
*) zf;
121
return
FALSE
;
122
}
123
catch
(
const
std::exception& ex)
124
{
125
WerrorS
(
"ERROR: "
);
WerrorS
(ex.what());
WerrorS
(
"\n"
);
126
return
TRUE
;
127
}
128
}
129
}
130
}
131
if
((u!=
NULL
) && (u->
Typ
()==
POLY_CMD
))
132
{
133
poly
g
= (poly) u->
Data
();
134
leftv
v
= u->
next
;
135
if
(
v
==
NULL
)
136
{
137
try
138
{
139
gfan::ZFan* zf =
groebnerFanOfPolynomial
(
g
,
currRing
);
140
res
->rtyp =
fanID
;
141
res
->data = (
char
*) zf;
142
return
FALSE
;
143
}
144
catch
(
const
std::exception& ex)
145
{
146
WerrorS
(
"ERROR: "
);
WerrorS
(ex.what());
WerrorS
(
"\n"
);
147
return
TRUE
;
148
}
149
}
150
}
151
WerrorS
(
"groebnerFan: unexpected parameters"
);
152
return
TRUE
;
153
}
BITSET
#define BITSET
Definition
auxiliary.h:85
BOOLEAN
int BOOLEAN
Definition
auxiliary.h:88
TRUE
#define TRUE
Definition
auxiliary.h:101
FALSE
#define FALSE
Definition
auxiliary.h:97
inequalities
BOOLEAN inequalities(leftv res, leftv args)
Definition
bbcone.cc:560
fanID
VAR int fanID
Definition
bbfan.cc:19
bbfan.h
intStar2ZVector
gfan::ZVector intStar2ZVector(const int d, const int *i)
Definition
callgfanlib_conversion.cc:86
toFanStar
gfan::ZFan * toFanStar(std::set< gfan::ZCone > setOfCones)
Definition
callgfanlib_conversion.cc:137
l
int l
Definition
cfEzgcd.cc:100
i
int i
Definition
cfEzgcd.cc:132
g
g
Definition
cfModGcd.cc:4098
groebnerCone
Definition
groebnerCone.h:28
sleftv::CopyD
void * CopyD(int t)
Definition
subexpr.cc:714
sleftv::Typ
int Typ()
Definition
subexpr.cc:1048
sleftv::Data
void * Data()
Definition
subexpr.cc:1192
sleftv::next
leftv next
Definition
subexpr.h:86
tropicalStrategy
Definition
tropicalStrategy.h:37
s
const CanonicalForm int s
Definition
facAbsFact.cc:51
res
CanonicalForm res
Definition
facAbsFact.cc:60
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition
facBivar.h:39
j
int j
Definition
facHensel.cc:110
WerrorS
void WerrorS(const char *s)
Definition
feFopen.cc:24
VAR
#define VAR
Definition
globaldefs.h:5
IDEAL_CMD
@ IDEAL_CMD
Definition
grammar.cc:285
POLY_CMD
@ POLY_CMD
Definition
grammar.cc:290
groebnerCone.h
implementation of the class groebnerCone
groebnerCones
std::set< groebnerCone, groebnerCone_compare > groebnerCones
Definition
groebnerCone.h:24
groebnerBitsetSave2
VAR BITSET groebnerBitsetSave2
Definition
groebnerFan.cc:9
groebnerFan
gfan::ZFan * groebnerFan(const tropicalStrategy currentStrategy)
Definition
groebnerFan.cc:28
setOptionRedSB
static void setOptionRedSB()
Definition
groebnerFan.cc:14
undoSetOptionRedSB
static void undoSetOptionRedSB()
Definition
groebnerFan.cc:23
groebnerFanOfPolynomial
gfan::ZFan * groebnerFanOfPolynomial(poly g, ring r, bool onlyLowerHalfSpace=false)
Definition
groebnerFan.cc:36
groebnerBitsetSave1
VAR BITSET groebnerBitsetSave1
Definition
groebnerFan.cc:9
pIter
#define pIter(p)
Definition
monomials.h:37
omFreeSize
#define omFreeSize(addr, size)
Definition
omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition
omAllocDecl.h:210
NULL
#define NULL
Definition
omList.c:12
si_opt_1
VAR unsigned si_opt_1
Definition
options.c:5
options.h
SI_SAVE_OPT
#define SI_SAVE_OPT(A, B)
Definition
options.h:20
OPT_REDSB
#define OPT_REDSB
Definition
options.h:77
Sy_bit
#define Sy_bit(x)
Definition
options.h:31
SI_RESTORE_OPT
#define SI_RESTORE_OPT(A, B)
Definition
options.h:23
p_GetExpV
static void p_GetExpV(poly p, int *ev, const ring r)
Definition
p_polys.h:1541
currRing
VAR 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:603
idElem
static int idElem(const ideal F)
number of non-zero polys in F
Definition
simpleideals.h:69
groebnerStartingCone
groebnerCone groebnerStartingCone(const tropicalStrategy ¤tStrategy)
Definition
startingCone.cc:21
startingCone.h
leftv
sleftv * leftv
Definition
structs.h:53
groebnerTraversal
groebnerCones groebnerTraversal(const groebnerCone startingCone)
Definition
tropicalTraversal.cc:141
tropicalTraversal.h
Generated on
for My Project by
doxygen 1.17.0
for
Singular