Loading...
Searching...
No Matches
adjustWeights.h File Reference
`#include "gfanlib/gfanlib_vector.h"`

Go to the source code of this file.

## Functions

gfan::ZVector | nonvalued_adjustWeightForHomogeneity (const gfan::ZVector &w)
gfan::ZVector | valued_adjustWeightForHomogeneity (const gfan::ZVector &w)
gfan::ZVector | nonvalued_adjustWeightUnderHomogeneity (const gfan::ZVector &e, const gfan::ZVector &w)
gfan::ZVector | valued_adjustWeightUnderHomogeneity (const gfan::ZVector &e, const gfan::ZVector &w)

## Function Documentation

## nonvalued_adjustWeightForHomogeneity()

gfan::ZVector nonvalued_adjustWeightForHomogeneity | ( | const gfan::ZVector & | w | ) |

Definition at line 14 of file adjustWeights.cc.

{
/* find the smallest entry min of w */
gfan::Integer min=w[0];
for (unsigned i=1; i<w.size(); i++)
if (w[i]<min) min=w[i];
if (min.sign()>0)
return w;
/* compute w+(1-min)*(1,...,1) and return it */
gfan::ZVector v=gfan::ZVector(w.size());
for (unsigned i=0; i<w.size(); i++)
v[i]=w[i]-min+1;
assume(checkForNonPositiveEntries(v));
return v;
}
i
int i
Definition cfEzgcd.cc:132
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
assume
#define assume(x)
Definition mod2.h:389
checkForNonPositiveEntries
bool checkForNonPositiveEntries(const gfan::ZVector &w)
Definition tropicalDebug.cc:13

## nonvalued_adjustWeightUnderHomogeneity()

gfan::ZVector nonvalued_adjustWeightUnderHomogeneity | ( | const gfan::ZVector & | e,
|  | const gfan::ZVector & | w )

Definition at line 54 of file adjustWeights.cc.

{
/* since our ideal is homogeneous, we can basically do the same as before */
/* find the smallest entry min of w */
gfan::Integer min=e[0];
for (unsigned i=1; i<e.size(); i++)
if (e[i]<min) min=e[i];
if (min.sign()>0)
return e;
/* compute w+(1-min)*(1,...,1) and return it */
gfan::ZVector v=gfan::ZVector(e.size());
for (unsigned i=0; i<e.size(); i++)
v[i]=e[i]-min+1;
assume(checkForNonPositiveEntries(v));
return v;
}

## valued_adjustWeightForHomogeneity()

gfan::ZVector valued_adjustWeightForHomogeneity | ( | const gfan::ZVector & | w | ) |

Definition at line 32 of file adjustWeights.cc.

{
/* find the biggest entry max of w
* amongst the later entries w[1],...,w[n] */
gfan::Integer max=w[1];
for (unsigned i=2; i<w.size(); i++)
if (max<w[i]) max=w[i];
/* compute -w+(1+max)*(0,1,...,1) and return it */
gfan::ZVector v=gfan::ZVector(w.size());
v[0]=-w[0];
for (unsigned i=1; i<w.size(); i++)
v[i]=-w[i]+max+1;
assume(checkForNonPositiveLaterEntries(v));
return v;
}
max
static int max(int a, int b)
Definition fast_mult.cc:264
checkForNonPositiveLaterEntries
bool checkForNonPositiveLaterEntries(const gfan::ZVector &w)
Definition tropicalDebug.cc:27

## valued_adjustWeightUnderHomogeneity()

gfan::ZVector valued_adjustWeightUnderHomogeneity | ( | const gfan::ZVector & | e,
|  | const gfan::ZVector & | w )

Definition at line 73 of file adjustWeights.cc.

{
assume(checkForNonPositiveLaterEntries(w));
/* find k such that e+k*w is strictly positive,
* i.e. k such that e[i]+k*w[i] is strictly positive
* for all i=0,...,n */
gfan::Integer k((long)0);
if (e[0].sign()<=0 && w[0].sign()>0)
k = gfan::Integer((long)1)-(e[0]/w[0]);
for (unsigned i=1; i<e.size(); i++)
{
if (e[i].sign()<=0)
{
gfan::Integer kk = gfan::Integer((long)1)-(e[i]/w[i]);
if (k<kk)
k = kk;
}
}
/* compute e+k*w, check it for correctness and return it */
gfan::ZVector v = e+k*w;
assume(checkForNonPositiveLaterEntries(v));
return v;
}
k
int k
Definition cfEzgcd.cc:99
sign
static int sign(int x)
Definition ring.cc:3504