1878 mpz_t t_zaehler, t_nenner;
1879 mpz_init(t_zaehler);
1882 mpz_t s_zaehler, s_nenner, temp, MwWd;
1883 mpz_init(s_zaehler);
1890 mpz_set_si(sing_int, 2147483647);
1892 mpz_t sing_int_half;
1893 mpz_init(sing_int_half);
1894 mpz_set_si(sing_int_half, 3*(1073741824/2));
1896 mpz_t deg_w0_p1, deg_d0_p1;
1897 mpz_init(deg_w0_p1);
1898 mpz_init(deg_d0_p1);
1915 intvec* diff_weight =
MivSub(target_weight, curr_weight);
1917 intvec* diff_weight1 =
MivSub(target_weight, curr_weight);
1920 for (j=0; j<nG; j++)
1935 mpz_sub(s_zaehler, deg_w0_p1, MwWd);
1937 if(mpz_cmp(s_zaehler, t_null) != 0)
1940 mpz_sub(s_nenner, MwWd, deg_d0_p1);
1943 if( (mpz_cmp(s_zaehler,t_null) > 0 &&
1944 mpz_cmp(s_nenner, s_zaehler)>=0) ||
1945 (mpz_cmp(s_zaehler, t_null) < 0 &&
1946 mpz_cmp(s_nenner, s_zaehler)<=0))
1949 if (mpz_cmp(s_zaehler, t_null) < 0)
1951 mpz_neg(s_zaehler, s_zaehler);
1952 mpz_neg(s_nenner, s_nenner);
1956 cancel(s_zaehler, s_nenner);
1958 if(mpz_cmp(t_nenner, t_null) != 0)
1960 mpz_mul(sztn, s_zaehler, t_nenner);
1961 mpz_mul(sntz, s_nenner, t_zaehler);
1963 if(mpz_cmp(sztn,sntz) < 0)
1965 mpz_add(t_nenner, t_null, s_nenner);
1966 mpz_add(t_zaehler,t_null, s_zaehler);
1971 mpz_add(t_nenner, t_null, s_nenner);
1972 mpz_add(t_zaehler,t_null, s_zaehler);
1982 mpz_t *
vec=(mpz_t*)
omAlloc(nRing*
sizeof(mpz_t));
1986 if(mpz_cmp(t_nenner, t_null) == 0)
1989 Print(
"\n//MwalkNextWeightCC: t_nenner ist Null!");
1992 diff_weight =
ivCopy(curr_weight);
1997 if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0)
2000 diff_weight =
ivCopy(target_weight);
2009 gcd_tmp = (*curr_weight)[0];
2011 for (j=1; j<nRing; j++)
2013 gcd_tmp =
gcd(gcd_tmp, (*curr_weight)[j]);
2021 for (j=0; j<nRing; j++)
2023 gcd_tmp =
gcd(gcd_tmp, (*diff_weight)[j]);
2032 for (j=0; j<nRing; j++)
2034 (*curr_weight)[
j] = (*curr_weight)[
j]/gcd_tmp;
2035 (*diff_weight)[
j] = (*diff_weight)[
j]/gcd_tmp;
2040 for (j=0; j<nRing; j++)
2042 mpz_set_si(vec[j], (*diff_weight)[j]);
2047 #ifdef NEXT_VECTORS_CC
2048 Print(
"\n// gcd of the weight vectors (current and target) = %d", gcd_tmp);
2052 PrintS(
"\n// t_zaehler: "); mpz_out_str( stdout, 10, t_zaehler);
2053 PrintS(
", t_nenner: "); mpz_out_str( stdout, 10, t_nenner);
2059 for (j=0; j<nRing; j++)
2061 mpz_set_si(dcw, (*curr_weight)[j]);
2062 mpz_mul(s_nenner, t_nenner, dcw);
2064 if( (*diff_weight)[j]>0)
2066 mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]);
2070 mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]);
2071 mpz_neg(s_zaehler, s_zaehler);
2073 mpz_add(sntz, s_nenner, s_zaehler);
2074 mpz_init_set(vec[j], sntz);
2076 #ifdef NEXT_VECTORS_CC
2077 Print(
"\n// j = %d ==> ", j);
2079 mpz_out_str( stdout, 10, t_nenner);
2080 Print(
" * %d)", (*curr_weight)[j]);
2081 Print(
" + ("); mpz_out_str( stdout, 10, t_zaehler);
2082 Print(
" * %d) = ", (*diff_weight)[j]);
2083 mpz_out_str( stdout, 10, s_nenner);
2085 mpz_out_str( stdout, 10, s_zaehler);
2086 PrintS(
" = "); mpz_out_str( stdout, 10, sntz);
2087 Print(
" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]);
2096 if(mpz_cmp_si(ggt,1) != 0)
2098 mpz_gcd(ggt, ggt, sntz);
2103 #ifdef NEXT_VECTORS_CC
2104 PrintS(
"\n// gcd of elements of the vector: ");
2105 mpz_out_str( stdout, 10, ggt);
2116 for(j=0; j<nRing; j++)
2118 if(mpz_cmp(vec[j], sing_int_half) >= 0)
2124 for (j=0; j<nRing; j++)
2126 (*diff_weight)[
j] = mpz_get_si(vec[j]);
2131 for (j=0; j<nRing; j++)
2133 (*diff_weight)[
j] = mpz_get_si(vec[j]);
2137 for (j=0; j<nRing; j++)
2139 if(mpz_cmp_si(ggt,1)==0)
2141 (*diff_weight1)[
j] = floor(0.1*(*diff_weight)[j] + 0.5);
2146 mpz_divexact(vec[j], vec[j], ggt);
2147 (*diff_weight1)[
j] = floor(0.1*(*diff_weight)[j] + 0.5);
2170 Print(
"\n// MwalkNextWeightCC: geaenderter vector liegt in Groebnerkegel! \n");
2171 for (j=0; j<nRing; j++)
2173 (*diff_weight)[
j] = (*diff_weight1)[
j];
2190 for (j=0; j<nRing; j++)
2192 if(mpz_cmp(vec[j], sing_int)>=0)
2197 PrintS(
"\n// ** OVERFLOW in \"MwalkNextWeightCC\": ");
2198 mpz_out_str( stdout, 10, vec[j]);
2199 PrintS(
" is greater than 2147483647 (max. integer representation)\n");
2206 delete diff_weight1;
2207 mpz_clear(t_zaehler);
2208 mpz_clear(t_nenner);
2209 mpz_clear(s_zaehler);
2210 mpz_clear(s_nenner);
2215 mpz_clear(deg_w0_p1);
2216 mpz_clear(deg_d0_p1);
2219 mpz_clear(sing_int_half);
2220 mpz_clear(sing_int);
static int test_w_in_ConeCC(ideal G, intvec *iv)
static int MivAbsMax(intvec *vec)
intvec * ivCopy(const intvec *o)
static intvec * MivSub(intvec *a, intvec *b)
static long MivDotProduct(intvec *a, intvec *b)
static void cancel(mpz_t zaehler, mpz_t nenner)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
void PrintS(const char *s)
static long gcd(const long a, const long b)
static intvec * MExpPol(poly f)
static void p_Setm(poly p, const ring r)
static void ivString(intvec *iv, const char *ch)