My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
Singular
dyn_modules
gfanlib
std_wrapper.cc
Go to the documentation of this file.
1
#include <vector>
2
3
#include "
Singular/libsingular.h
"
4
5
std::vector<int>
gitfan_satstdSaturatingVariables
;
6
ideal
gfanlib_kStd_wrapper
(ideal I, ring r,
tHomog
h
=
testHomog
)
7
{
8
ring origin =
currRing
;
9
if
(origin != r)
10
rChangeCurrRing
(r);
11
12
intvec
* nullVector =
NULL
;
13
ideal stdI =
kStd2
(I,
currRing
->qideal,
h
,&nullVector,(
bigintmat
*)
NULL
);
// there is still a memory leak here!!!
14
id_DelDiv
(stdI,
currRing
);
15
idSkipZeroes
(stdI);
16
if
(nullVector!=
NULL
)
delete
nullVector;
17
18
if
(origin != r)
19
rChangeCurrRing
(origin);
20
21
return
stdI;
22
}
23
24
//------------------------------------------------------------------------
25
// routine that simplifies the new element by dividing it with the maximal possible
26
// partially saturating the ideal with respect to all variables doing so
27
static
BOOLEAN
sat_vars_sp
(
kStrategy
strat)
28
{
29
BOOLEAN
b
=
FALSE
;
// set b to TRUE, if spoly was changed,
30
// let it remain FALSE otherwise
31
if
(strat->
P
.t_p==
NULL
)
32
{
33
poly
p
=strat->
P
.p;
34
35
// iterate over all terms of p and
36
// compute the minimum mm of all exponent vectors
37
int
*mm=(
int
*)
omAlloc
((1+rVar(
currRing
))*
sizeof
(
int
));
38
int
*m0=(
int
*)
omAlloc
((1+rVar(
currRing
))*
sizeof
(
int
));
39
p_GetExpV(
p
,mm,
currRing
);
40
bool
nonTrivialSaturationToBeDone=
true
;
41
for
(
p
=
pNext
(
p
);
p
!=
NULL
;
pIter
(
p
))
42
{
43
nonTrivialSaturationToBeDone=
false
;
44
p_GetExpV(
p
,m0,
currRing
);
45
for
(
int
i
=
gitfan_satstdSaturatingVariables
.size()-1;
i
>=0;
i
--)
46
{
47
int
li =
gitfan_satstdSaturatingVariables
[
i
];
48
mm[li]=si_min(mm[li],m0[li]);
49
if
(mm[li]>0) nonTrivialSaturationToBeDone=
true
;
50
}
51
// abort if the minimum is zero in each component
52
if
(nonTrivialSaturationToBeDone==
false
)
break
;
53
}
54
if
(nonTrivialSaturationToBeDone==
true
)
55
{
56
// std::cout << "simplifying!" << std::endl;
57
p
=p_Copy(strat->
P
.p,
currRing
);
58
strat->
P
.Init();
59
strat->
P
.tailRing = strat->
tailRing
;
60
strat->
P
.p=
p
;
61
while
(
p
!=
NULL
)
62
{
63
for
(
int
i
=
gitfan_satstdSaturatingVariables
.size()-1;
i
>=0;
i
--)
64
{
65
int
li =
gitfan_satstdSaturatingVariables
[
i
];
66
p_SubExp(
p
,li,mm[li],
currRing
);
67
}
68
p_Setm(
p
,
currRing
);
69
pIter
(
p
);
70
}
71
b
=
TRUE
;
72
}
73
omFree
(mm);
74
omFree
(m0);
75
}
76
else
77
{
78
poly
p
=strat->
P
.t_p;
79
80
// iterate over all terms of p and
81
// compute the minimum mm of all exponent vectors
82
int
*mm=(
int
*)
omAlloc
((1+rVar(
currRing
))*
sizeof
(
int
));
83
int
*m0=(
int
*)
omAlloc
((1+rVar(
currRing
))*
sizeof
(
int
));
84
p_GetExpV(
p
,mm,strat->
tailRing
);
85
bool
nonTrivialSaturationToBeDone=
true
;
86
for
(
p
=
pNext
(
p
);
p
!=
NULL
;
pIter
(
p
))
87
{
88
nonTrivialSaturationToBeDone=
false
;
89
p_GetExpV(
p
,m0,strat->
tailRing
);
90
for
(
int
i
=
gitfan_satstdSaturatingVariables
.size()-1;
i
>=0;
i
--)
91
{
92
int
li =
gitfan_satstdSaturatingVariables
[
i
];
93
mm[li]=si_min(mm[li],m0[li]);
94
if
(mm[li]>0) nonTrivialSaturationToBeDone =
true
;
95
}
96
// abort if the minimum is zero in each component
97
if
(!nonTrivialSaturationToBeDone)
break
;
98
}
99
if
(nonTrivialSaturationToBeDone)
100
{
101
p
=p_Copy(strat->
P
.t_p,strat->
tailRing
);
102
strat->
P
.Init();
103
strat->
P
.tailRing = strat->
tailRing
;
104
strat->
P
.t_p=
p
;
105
while
(
p
!=
NULL
)
106
{
107
for
(
int
i
=
gitfan_satstdSaturatingVariables
.size()-1;
i
>=0;
i
--)
108
{
109
int
li =
gitfan_satstdSaturatingVariables
[
i
];
110
p_SubExp(
p
,li,mm[li],strat->
tailRing
);
111
}
112
p_Setm(
p
,strat->
tailRing
);
113
pIter
(
p
);
114
}
115
strat->
P
.GetP();
116
b
=
TRUE
;
117
}
118
omFree
(mm);
119
omFree
(m0);
120
}
121
return
b
;
// return TRUE if sp was changed, FALSE if not
122
}
123
124
ideal
gfanlib_satStd_wrapper
(ideal I, ring r,
tHomog
h
=
testHomog
)
125
{
126
ring origin =
currRing
;
127
if
(origin != r)
128
rChangeCurrRing
(r);
129
130
int
n = rVar(
currRing
);
131
gitfan_satstdSaturatingVariables
= std::vector<int>(n);
132
for
(
int
i
=n-1;
i
>=0;
i
--)
133
gitfan_satstdSaturatingVariables
[
i
] =
i
+1;
134
135
ideal stdI =
kStd2
(I,
currRing
->qideal,
h
,
NULL
,(
bigintmat
*)
NULL
,0,0,
NULL
,
sat_vars_sp
);
136
id_DelDiv
(stdI,
currRing
);
137
idSkipZeroes
(stdI);
138
139
if
(origin != r)
140
rChangeCurrRing
(origin);
141
142
return
stdI;
143
}
144
145
static
BOOLEAN
abort_if_monomial_sp
(
kStrategy
strat)
146
{
147
BOOLEAN
b
=
FALSE
;
// set b to TRUE, if spoly was changed,
148
// let it remain FALSE otherwise
149
if
(strat->
P
.t_p==
NULL
)
150
{
151
poly
p
=strat->
P
.p;
152
if
(
pNext
(
p
)==
NULL
)
153
{
154
while
((strat->
Ll
>= 0))
155
deleteInL
(strat->
L
,&strat->
Ll
,strat->
Ll
,strat);
156
return
FALSE
;
157
}
158
}
159
else
160
{
161
poly
p
=strat->
P
.t_p;
162
if
(
pNext
(
p
)==
NULL
)
163
{
164
while
((strat->
Ll
>= 0))
165
deleteInL
(strat->
L
,&strat->
Ll
,strat->
Ll
,strat);
166
return
FALSE
;
167
}
168
}
169
return
b
;
// return TRUE if sp was changed, FALSE if not
170
}
171
172
ideal
gfanlib_monomialabortStd_wrapper
(ideal I, ring r,
tHomog
h
=
testHomog
)
173
{
174
ring origin =
currRing
;
175
if
(origin != r)
176
rChangeCurrRing
(r);
177
178
ideal stdI =
kStd2
(I,
currRing
->qideal,
h
,
NULL
,(
bigintmat
*)
NULL
,0,0,
NULL
,
abort_if_monomial_sp
);
179
id_DelDiv
(stdI,
currRing
);
180
idSkipZeroes
(stdI);
181
182
if
(origin != r)
183
rChangeCurrRing
(origin);
184
185
return
stdI;
186
}
BOOLEAN
int BOOLEAN
Definition
auxiliary.h:88
TRUE
#define TRUE
Definition
auxiliary.h:101
FALSE
#define FALSE
Definition
auxiliary.h:97
i
int i
Definition
cfEzgcd.cc:132
p
int p
Definition
cfModGcd.cc:4086
b
CanonicalForm b
Definition
cfModGcd.cc:4111
bigintmat
Matrices of numbers.
Definition
bigintmat.h:51
intvec
Definition
intvec.h:24
skStrategy::tailRing
ring tailRing
Definition
kutil.h:342
skStrategy::Ll
int Ll
Definition
kutil.h:350
skStrategy::P
LObject P
Definition
kutil.h:301
skStrategy::L
LSet L
Definition
kutil.h:326
abort_if_monomial_sp
static BOOLEAN abort_if_monomial_sp(kStrategy strat)
Definition
customstd.cc:92
h
STATIC_VAR Poly * h
Definition
janet.cc:971
kStd2
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:2607
deleteInL
void deleteInL(LSet set, int *length, int j, kStrategy strat)
Definition
kutil.cc:1208
libsingular.h
pIter
#define pIter(p)
Definition
monomials.h:37
pNext
#define pNext(p)
Definition
monomials.h:36
omAlloc
#define omAlloc(size)
Definition
omAllocDecl.h:210
omFree
#define omFree(addr)
Definition
omAllocDecl.h:261
NULL
#define NULL
Definition
omList.c:12
rChangeCurrRing
void rChangeCurrRing(ring r)
Definition
polys.cc:16
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition
polys.cc:13
id_DelDiv
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
Definition
simpleideals.cc:463
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition
simpleideals.cc:201
gitfan_satstdSaturatingVariables
std::vector< int > gitfan_satstdSaturatingVariables
Definition
std_wrapper.cc:5
gfanlib_satStd_wrapper
ideal gfanlib_satStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition
std_wrapper.cc:124
gfanlib_kStd_wrapper
ideal gfanlib_kStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition
std_wrapper.cc:6
gfanlib_monomialabortStd_wrapper
ideal gfanlib_monomialabortStd_wrapper(ideal I, ring r, tHomog h=testHomog)
Definition
std_wrapper.cc:172
sat_vars_sp
static BOOLEAN sat_vars_sp(kStrategy strat)
Definition
std_wrapper.cc:27
tHomog
tHomog
Definition
structs.h:31
testHomog
@ testHomog
Definition
structs.h:34
kStrategy
skStrategy * kStrategy
Definition
structs.h:54
Generated on
for My Project by
doxygen 1.18.0
for
Singular