My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
Singular
dyn_modules
gfanlib
tropicalVariety.cc
Go to the documentation of this file.
1
#include "
callgfanlib_conversion.h
"
2
#include "
std_wrapper.h
"
3
#include "
bbfan.h
"
4
#include "
groebnerCone.h
"
5
#include "
tropicalVarietyOfPolynomials.h
"
6
#include "
tropicalVarietyOfIdeals.h
"
7
#include "
coeffs/numbers.h
"
8
#include "
misc/options.h
"
9
#include "
kernel/structs.h
"
10
11
#include "gfanlib/gfanlib_zfan.h"
12
13
VAR
BITSET
bitsetSave1
,
bitsetSave2
;
14
15
16
/***
17
* sets option(redSB)
18
**/
19
static
void
setOptionRedSB
()
20
{
21
SI_SAVE_OPT
(
bitsetSave1
,
bitsetSave2
);
22
si_opt_1
|=
Sy_bit
(
OPT_REDSB
);
23
}
24
25
26
/***
27
* sets option(noredSB);
28
**/
29
static
void
undoSetOptionRedSB
()
30
{
31
SI_RESTORE_OPT
(
bitsetSave1
,
bitsetSave2
);
32
}
33
34
static
gfan::ZFan*
toZFan
(std::set<gfan::ZCone> maxCones,
int
d)
35
{
36
gfan::ZFan* zf =
new
gfan::ZFan(d);
37
for
(std::set<gfan::ZCone>::iterator sigma = maxCones.begin(); sigma!=maxCones.end(); sigma++)
38
zf->insert(*sigma);
39
return
zf;
40
}
41
42
43
BOOLEAN
tropicalVariety
(
leftv
res
,
leftv
args)
44
{
45
leftv
u = args;
46
if
((u!=
NULL
) && (u->
Typ
()==
POLY_CMD
))
47
{
48
poly
g
= (poly) u->
Data
();
49
leftv
v
= u->
next
;
50
if
(
v
==
NULL
)
51
{
52
try
53
{
54
ideal I =
idInit
(1);
55
I->m[0] =
g
;
56
tropicalStrategy
currentStrategy(I,
currRing
);
57
std::set<gfan::ZCone> maxCones =
tropicalVariety
(
g
,
currRing
,¤tStrategy);
58
res
->rtyp =
fanID
;
59
res
->data = (
char
*)
toZFan
(maxCones,currentStrategy.
getExpectedAmbientDimension
());
60
I->m[0] =
NULL
;
61
id_Delete
(&I,
currRing
);
62
return
FALSE
;
63
}
64
catch
(
const
std::exception& ex)
65
{
66
Werror
(
"ERROR: %s"
,ex.what());
67
return
TRUE
;
68
}
69
}
70
if
((
v
!=
NULL
) && (
v
->Typ()==
NUMBER_CMD
))
71
{
72
try
73
{
74
ideal I =
idInit
(1);
75
I->m[0] =
g
;
76
number
p
= (number)
v
->Data();
77
tropicalStrategy
currentStrategy(I,
p
,
currRing
);
78
ideal startingIdeal = currentStrategy.
getStartingIdeal
();
79
ring startingRing = currentStrategy.
getStartingRing
();
80
poly gStart = startingIdeal->m[0];
81
std::set<gfan::ZCone> maxCones =
tropicalVariety
(gStart,startingRing,¤tStrategy);
82
res
->rtyp =
fanID
;
83
res
->data = (
char
*)
toZFan
(maxCones,currentStrategy.
getExpectedAmbientDimension
());
84
I->m[0] =
NULL
;
85
id_Delete
(&I,
currRing
);
86
return
FALSE
;
87
}
88
catch
(
const
std::exception& ex)
89
{
90
Werror
(
"ERROR: %s"
,ex.what());
91
return
TRUE
;
92
}
93
94
}
95
}
96
if
((u!=
NULL
) && (u->
Typ
()==
IDEAL_CMD
))
97
{
98
ideal I = (ideal) u->
Data
();
99
leftv
v
= u->
next
;
100
101
if
((I->m[0]!=
NULL
) && (
idElem
(I)==1))
102
{
103
poly
g
= I->m[0];
104
if
(
v
==
NULL
)
105
{
106
try
107
{
108
tropicalStrategy
currentStrategy(I,
currRing
);
109
std::set<gfan::ZCone> maxCones =
tropicalVariety
(
g
,
currRing
,¤tStrategy);
110
res
->rtyp =
fanID
;
111
res
->data = (
char
*)
toZFan
(maxCones,currentStrategy.
getExpectedAmbientDimension
());
112
return
FALSE
;
113
}
114
catch
(
const
std::exception& ex)
115
{
116
Werror
(
"ERROR: %s"
,ex.what());
117
return
TRUE
;
118
}
119
}
120
if
((
v
!=
NULL
) && (
v
->Typ()==
NUMBER_CMD
))
121
{
122
try
123
{
124
number
p
= (number)
v
->Data();
125
tropicalStrategy
currentStrategy(I,
p
,
currRing
);
126
ideal startingIdeal = currentStrategy.
getStartingIdeal
();
127
ring startingRing = currentStrategy.
getStartingRing
();
128
poly gStart = startingIdeal->m[0];
129
std::set<gfan::ZCone> maxCones =
tropicalVariety
(gStart,startingRing,¤tStrategy);
130
res
->rtyp =
fanID
;
131
res
->data = (
char
*)
toZFan
(maxCones,currentStrategy.
getExpectedAmbientDimension
());
132
return
FALSE
;
133
}
134
catch
(
const
std::exception& ex)
135
{
136
Werror
(
"ERROR: %s"
,ex.what());
137
return
TRUE
;
138
}
139
}
140
}
141
142
if
(
v
==
NULL
)
143
{
144
try
145
{
146
setOptionRedSB
();
147
ideal stdI;
148
if
(!
hasFlag
(u,
FLAG_STD
))
149
stdI =
gfanlib_kStd_wrapper
(I,
currRing
);
150
else
151
stdI =
id_Copy
(I,
currRing
);
152
tropicalStrategy
currentStrategy(stdI,
currRing
);
153
gfan::ZFan* tropI =
tropicalVariety
(currentStrategy);
154
res
->rtyp =
fanID
;
155
res
->data = (
char
*) tropI;
156
undoSetOptionRedSB
();
157
id_Delete
(&stdI,
currRing
);
158
return
FALSE
;
159
}
160
catch
(
const
std::exception& ex)
161
{
162
Werror
(
"ERROR: %s"
,ex.what());
163
return
TRUE
;
164
}
165
}
166
if
((
v
!=
NULL
) && (
v
->Typ()==
NUMBER_CMD
))
167
{
168
try
169
{
170
number
p
= (number)
v
->Data();
171
ideal stdI;
172
if
(!
hasFlag
(u,
FLAG_STD
))
173
stdI =
gfanlib_kStd_wrapper
(I,
currRing
);
174
else
175
stdI =
id_Copy
(I,
currRing
);
176
tropicalStrategy
currentStrategy(stdI,
p
,
currRing
);
177
gfan::ZFan* tropI =
tropicalVariety
(currentStrategy);
178
res
->rtyp =
fanID
;
179
res
->data = (
char
*) tropI;
180
id_Delete
(&stdI,
currRing
);
181
return
FALSE
;
182
}
183
catch
(
const
std::exception& ex)
184
{
185
Werror
(
"ERROR: %s"
,ex.what());
186
return
TRUE
;
187
}
188
}
189
return
FALSE
;
190
}
191
WerrorS
(
"tropicalVariety: unexpected parameters"
);
192
return
TRUE
;
193
}
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
fanID
VAR int fanID
Definition
bbfan.cc:19
bbfan.h
callgfanlib_conversion.h
p
int p
Definition
cfModGcd.cc:4086
g
g
Definition
cfModGcd.cc:4098
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
tropicalStrategy::getStartingRing
ring getStartingRing() const
returns the polynomial ring over the valuation ring
Definition
tropicalStrategy.h:176
tropicalStrategy::getStartingIdeal
ideal getStartingIdeal() const
returns the input ideal
Definition
tropicalStrategy.h:185
tropicalStrategy::getExpectedAmbientDimension
int getExpectedAmbientDimension() const
Definition
tropicalStrategy.h:191
res
CanonicalForm res
Definition
facAbsFact.cc:60
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition
facBivar.h:39
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
NUMBER_CMD
@ NUMBER_CMD
Definition
grammar.cc:289
POLY_CMD
@ POLY_CMD
Definition
grammar.cc:290
groebnerCone.h
implementation of the class groebnerCone
id_Copy
ideal id_Copy(ideal h1, const ring r)
copy an ideal
Definition
simpleideals.cc:542
hasFlag
#define hasFlag(A, F)
Definition
ipid.h:112
FLAG_STD
#define FLAG_STD
Definition
ipid.h:106
numbers.h
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
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition
polys.cc:13
Werror
void Werror(const char *fmt,...)
Definition
reporter.cc:189
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition
simpleideals.cc:35
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition
simpleideals.cc:123
idElem
static int idElem(const ideal F)
number of non-zero polys in F
Definition
simpleideals.h:69
gfanlib_kStd_wrapper
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition
std_wrapper.cc:6
std_wrapper.h
structs.h
leftv
sleftv * leftv
Definition
structs.h:53
tropicalVarietyOfIdeals.h
tropicalVarietyOfPolynomials.h
bitsetSave2
VAR BITSET bitsetSave2
Definition
tropicalVariety.cc:13
setOptionRedSB
static void setOptionRedSB()
Definition
tropicalVariety.cc:19
tropicalVariety
BOOLEAN tropicalVariety(leftv res, leftv args)
Definition
tropicalVariety.cc:43
bitsetSave1
VAR BITSET bitsetSave1
Definition
tropicalVariety.cc:13
undoSetOptionRedSB
static void undoSetOptionRedSB()
Definition
tropicalVariety.cc:29
toZFan
static gfan::ZFan * toZFan(std::set< gfan::ZCone > maxCones, int d)
Definition
tropicalVariety.cc:34
Generated on
for My Project by
doxygen 1.17.0
for
Singular