My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
Singular
dyn_modules
gfanlib
adjustWeights.cc
Go to the documentation of this file.
1
#include "
kernel/mod2.h
"
2
3
#include "gfanlib/gfanlib_vector.h"
4
5
#ifndef NDEBUG
6
#include "
tropicalDebug.h
"
7
#endif
//NDEBUG
8
9
/***
10
* Returns a strictly positive weight vector v with respect to whom
11
* any x-homogeneous element is homogeneous to
12
* if and only if it is homogeneous with respect to w.
13
**/
14
gfan::ZVector
nonvalued_adjustWeightForHomogeneity
(
const
gfan::ZVector &
w
)
15
{
16
/* find the smallest entry min of w */
17
gfan::Integer
min
=
w
[0];
18
for
(
unsigned
i
=1;
i
<
w
.size();
i
++)
19
if
(
w
[
i
]<
min
)
min
=
w
[
i
];
20
21
if
(
min
.sign()>0)
22
return
w
;
23
24
/* compute w+(1-min)*(1,...,1) and return it */
25
gfan::ZVector
v
=gfan::ZVector(
w
.size());
26
for
(
unsigned
i
=0;
i
<
w
.size();
i
++)
27
v
[
i
]=
w
[
i
]-
min
+1;
28
assume
(
checkForNonPositiveEntries
(
v
));
29
return
v
;
30
}
31
32
gfan::ZVector
valued_adjustWeightForHomogeneity
(
const
gfan::ZVector &
w
)
33
{
34
/* find the biggest entry max of w
35
* amongst the later entries w[1],...,w[n] */
36
gfan::Integer
max
=
w
[1];
37
for
(
unsigned
i
=2;
i
<
w
.size();
i
++)
38
if
(
max
<
w
[
i
])
max
=
w
[
i
];
39
40
/* compute -w+(1+max)*(0,1,...,1) and return it */
41
gfan::ZVector
v
=gfan::ZVector(
w
.size());
42
v
[0]=-
w
[0];
43
for
(
unsigned
i
=1;
i
<
w
.size();
i
++)
44
v
[
i
]=-
w
[
i
]+
max
+1;
45
assume
(
checkForNonPositiveLaterEntries
(
v
));
46
return
v
;
47
}
48
49
/***
50
* Returns a weight vector v which coincides with a weight vector e
51
* on any set of x-homogeneous elements that are also homogeneous with respect to w,
52
* w containing only positive weights
53
**/
54
gfan::ZVector
nonvalued_adjustWeightUnderHomogeneity
(
const
gfan::ZVector &e,
const
gfan::ZVector &
/*w*/
)
55
{
56
/* since our ideal is homogeneous, we can basically do the same as before */
57
/* find the smallest entry min of w */
58
gfan::Integer
min
=e[0];
59
for
(
unsigned
i
=1;
i
<e.size();
i
++)
60
if
(e[
i
]<
min
)
min
=e[
i
];
61
62
if
(
min
.sign()>0)
63
return
e;
64
65
/* compute w+(1-min)*(1,...,1) and return it */
66
gfan::ZVector
v
=gfan::ZVector(e.size());
67
for
(
unsigned
i
=0;
i
<e.size();
i
++)
68
v
[
i
]=e[
i
]-
min
+1;
69
assume
(
checkForNonPositiveEntries
(
v
));
70
return
v
;
71
}
72
73
gfan::ZVector
valued_adjustWeightUnderHomogeneity
(
const
gfan::ZVector &e,
const
gfan::ZVector &
w
)
74
{
75
assume
(
checkForNonPositiveLaterEntries
(
w
));
76
77
/* find k such that e+k*w is strictly positive,
78
* i.e. k such that e[i]+k*w[i] is strictly positive
79
* for all i=0,...,n */
80
gfan::Integer
k
((
long
)0);
81
if
(e[0].
sign
()<=0 &&
w
[0].
sign
()>0)
82
k
= gfan::Integer((
long
)1)-(e[0]/
w
[0]);
83
for
(
unsigned
i
=1;
i
<e.size();
i
++)
84
{
85
if
(e[
i
].
sign
()<=0)
86
{
87
gfan::Integer kk = gfan::Integer((
long
)1)-(e[
i
]/
w
[
i
]);
88
if
(
k
<kk)
89
k
= kk;
90
}
91
}
92
93
/* compute e+k*w, check it for correctness and return it */
94
gfan::ZVector
v
= e+
k
*
w
;
95
assume
(
checkForNonPositiveLaterEntries
(
v
));
96
return
v
;
97
}
nonvalued_adjustWeightForHomogeneity
gfan::ZVector nonvalued_adjustWeightForHomogeneity(const gfan::ZVector &w)
Definition
adjustWeights.cc:14
nonvalued_adjustWeightUnderHomogeneity
gfan::ZVector nonvalued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &)
Definition
adjustWeights.cc:54
valued_adjustWeightForHomogeneity
gfan::ZVector valued_adjustWeightForHomogeneity(const gfan::ZVector &w)
Definition
adjustWeights.cc:32
valued_adjustWeightUnderHomogeneity
gfan::ZVector valued_adjustWeightUnderHomogeneity(const gfan::ZVector &e, const gfan::ZVector &w)
Definition
adjustWeights.cc:73
i
int i
Definition
cfEzgcd.cc:132
k
int k
Definition
cfEzgcd.cc:99
w
const CanonicalForm & w
Definition
facAbsFact.cc:51
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition
facBivar.h:39
min
static int min(int a, int b)
Definition
fast_mult.cc:268
max
static int max(int a, int b)
Definition
fast_mult.cc:264
mod2.h
assume
#define assume(x)
Definition
mod2.h:389
sign
static int sign(int x)
Definition
ring.cc:3504
checkForNonPositiveEntries
bool checkForNonPositiveEntries(const gfan::ZVector &w)
Definition
tropicalDebug.cc:13
checkForNonPositiveLaterEntries
bool checkForNonPositiveLaterEntries(const gfan::ZVector &w)
Definition
tropicalDebug.cc:27
tropicalDebug.h
Generated on
for My Project by
doxygen 1.17.0
for
Singular