Changeset 6d09f28 in git


Ignore:
Timestamp:
Aug 14, 2006, 7:08:37 PM (18 years ago)
Author:
Oliver Wienand <wienand@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
d39ce40a2e8c985712a746d769cc723fe80f080f
Parents:
2a5c2f4b88044ea4f445da171e3d11679bd20548
Message:
introduced def HAVE_VANGB
--> compute GB in the ring of function rather than polynomials

kstd2.cc:
* moved ind2 and ind_fact_2 to kutil.h/cc
* bba: enterpairs changes size of T in VANGB case

kutil.h/cc:
* ind2/ind_fact_2 see above
* kCreateZeroPoly: create a zero polynomial with given exponent
* createG0: creates the groebner basis of the vanishing polynomials


git-svn-id: file:///usr/local/Singular/svn/trunk@9404 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/kstd2.cc

    r2a5c2f4 r6d09f28  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kstd2.cc,v 1.17 2006-06-07 18:44:23 wienand Exp $ */
     4/* $Id: kstd2.cc,v 1.18 2006-08-14 17:08:36 wienand Exp $ */
    55/*
    66*  ABSTRACT -  Kernel: alg. of Buchberger
     
    186186}
    187187
    188 long ind2(long arg)
    189 {
    190   long ind = 0;
    191   if (arg <= 0) return 0;
    192   while (arg%2 == 0)
    193   {
    194     arg = arg / 2;
    195     ind++;
    196   }
    197   return ind;
    198 }
    199 
    200 long ind_fact_2(long arg)
    201 {
    202   long ind = 0;
    203   if (arg <= 0) return 0;
    204   if (arg%2 == 1) { arg--; }
    205   while (arg > 0)
    206   {
    207     ind += ind2(arg);
    208     arg = arg - 2;
    209   }
    210   return ind;
    211 }
    212 
    213188poly kFindZeroPoly(poly input_p, ring leadRing, ring tailRing)
    214189{
     
    225200
    226201  long k = 1;
    227   // of interest is only k_ind2, special routine for improvement ... TOTO OLIVER
     202  // of interest is only k_ind2, special routine for improvement ... TODO OLIVER
    228203  for (int i = 1; i <= leadRing->N; i++)
    229204  {
     
    282257    return tmp2;
    283258  }
    284   long alpha_k = twoPow(leadRing->ch - k_ind2);
     259/*  long alpha_k = twoPow(leadRing->ch - k_ind2);
    285260  if (1 == 0 && alpha_k <= a) {  // Temporarly disabled, reducing coefficients not compatible with std TODO Oliver
    286261    zeroPoly = p_ISet((a / alpha_k)*alpha_k, tailRing);
     
    308283    pNext(tmp2) = zeroPoly;
    309284    return tmp2;
    310   }
     285  } */
    311286  return NULL;
    312287}
     
    343318  loop
    344319  {
    345     zeroPoly = NULL; //kFindDivisibleByZeroPoly(h);
     320#ifdef HAVE_VANGB
     321    zeroPoly = kFindDivisibleByZeroPoly(h);
    346322    if (zeroPoly != NULL)
    347323    {
     
    366342    }
    367343    else
     344#endif
    368345    {
    369346      j = kFindDivisibleByInT(strat->T, strat->sevT, strat->tl, h);
     
    994971      enterT(strat->P, strat);
    995972#ifdef HAVE_RING2TOM
     973#ifdef HAVE_VANGB
     974      int at_R = strat->tl;
     975#endif
    996976      if (currRing->cring == 1)
    997977        superenterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
     
    1000980        enterpairs(strat->P.p,strat->sl,strat->P.ecart,pos,strat, strat->tl);
    1001981      // posInS only depends on the leading term
     982#ifdef HAVE_VANGB
     983      strat->enterS(strat->P, pos, strat, at_R);
     984#else
    1002985      strat->enterS(strat->P, pos, strat, strat->tl);
     986#endif
    1003987      if (hilb!=NULL) khCheck(Q,w,hilb,hilbeledeg,hilbcount,strat);
    1004988//      Print("[%d]",hilbeledeg);
  • kernel/kutil.cc

    r2a5c2f4 r6d09f28  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.29 2006-06-20 21:44:18 wienand Exp $ */
     4/* $Id: kutil.cc,v 1.30 2006-08-14 17:08:36 wienand Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    2323#undef KDEBUG
    2424#define KDEBUG 2
     25#endif
     26
     27#ifdef HAVE_RING2TOM
     28#include "ideals.h"
    2529#endif
    2630
     
    10181022  (*Lp).length = 0;
    10191023}
    1020 
     1024         
    10211025void initEcartPairMora (LObject* Lp,poly f,poly g,int ecartF,int ecartG)
    10221026{
     
    11561160  else
    11571161  {
    1158     Lp.p = ksCreateShortSpoly(strat->S[i],p, strat->tailRing);
     1162    Lp.p = ksCreateShortSpoly(strat->S[i], p, strat->tailRing);
    11591163  }
    11601164  if (Lp.p == NULL)
     
    19421946}
    19431947
     1948long ind2(long arg)
     1949{
     1950  long ind = 0;
     1951  if (arg <= 0) return 0;
     1952  while (arg%2 == 0)
     1953  {
     1954    arg = arg / 2;
     1955    ind++;
     1956  }
     1957  return ind;
     1958}
     1959
     1960long ind_fact_2(long arg)
     1961{
     1962  long ind = 0;
     1963  if (arg <= 0) return 0;
     1964  if (arg%2 == 1) { arg--; }
     1965  while (arg > 0)
     1966  {
     1967    ind += ind2(arg);
     1968    arg = arg - 2;
     1969  }
     1970  return ind;
     1971}
     1972
     1973/*2
     1974* put the pair (p, f) in B and f in T
     1975*/
     1976void enterOneZeroPairRing (poly f, poly t_p, poly p, int ecart, kStrategy strat, int atR = -1)
     1977{
     1978  int      l,j,compare,compareCoeff;
     1979  LObject  Lp;
     1980
     1981  if (strat->interred_flag) return;
     1982#ifdef KDEBUG
     1983  Lp.ecart=0; Lp.length=0;
     1984#endif
     1985  /*- computes the lcm(s[i],p) -*/
     1986  Lp.lcm = pInit();
     1987
     1988  pLcm(p,f,Lp.lcm);
     1989  pSetm(Lp.lcm);
     1990  pSetCoeff(Lp.lcm, nLcm(pGetCoeff(p), pGetCoeff(f), currRing));
     1991  assume(!strat->sugarCrit);
     1992  assume(!strat->fromT);
     1993  /*
     1994  *the set B collects the pairs of type (S[j],p)
     1995  *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p)
     1996  *if the leading term of s devides lcm(r,p) then (r,p) will be canceled
     1997  *if the leading term of r devides lcm(s,p) then (s,p) will not enter B
     1998  */
     1999  for(j = strat->Bl;j>=0;j--)
     2000  {
     2001    compare=pDivCompRing(strat->B[j].lcm,Lp.lcm);
     2002    compareCoeff = nComp((long) pGetCoeff(strat->B[j].lcm), (long) pGetCoeff(Lp.lcm));
     2003    if (compareCoeff == 0 || compare == compareCoeff)
     2004    {
     2005      if (compare == 1)
     2006      {
     2007        strat->c3++;
     2008        pLmFree(Lp.lcm);
     2009        return;
     2010      }
     2011      else
     2012      if (compare == -1)
     2013      {
     2014        deleteInL(strat->B,&strat->Bl,j,strat);
     2015        strat->c3++;
     2016      }
     2017    }
     2018    if (compare == pDivComp_EQUAL)
     2019    {
     2020      // Add hint for same LM and direction of LC (later) (TODO Oliver)
     2021      if (compareCoeff == 1)
     2022      {
     2023        strat->c3++;
     2024        pLmFree(Lp.lcm);
     2025        return;
     2026      }
     2027      else
     2028      if (compareCoeff == -1)
     2029      {
     2030        deleteInL(strat->B,&strat->Bl,j,strat);
     2031        strat->c3++;
     2032      }
     2033    }
     2034  }
     2035  /*
     2036  *the pair (S[i],p) enters B if the spoly != 0
     2037  */
     2038  /*-  compute the short s-polynomial -*/
     2039  if ((f==NULL) || (p==NULL)) return;
     2040  pNorm(p);
     2041  {
     2042    Lp.p = ksCreateShortSpoly(f, p, strat->tailRing);
     2043  }
     2044  if (Lp.p == NULL) //deactivated, as we are adding pairs with zeropoly and not from S
     2045  {
     2046    /*- the case that the s-poly is 0 -*/
     2047//    if (strat->pairtest==NULL) initPairtest(strat);
     2048//    strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
     2049//    strat->pairtest[strat->sl+1] = TRUE;
     2050    /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
     2051    /*
     2052    *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
     2053    *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
     2054    *devide lcm(r,p)). In the last case (s,r) can be canceled if the leading
     2055    *term of p devides the lcm(s,r)
     2056    *(this canceling should be done here because
     2057    *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
     2058    *the first case is handeled in chainCrit
     2059    */
     2060    if (Lp.lcm!=NULL) pLmFree(Lp.lcm);
     2061  }
     2062  else
     2063  {
     2064    /*- the pair (S[i],p) enters B -*/
     2065    Lp.p1 = f;
     2066    Lp.p2 = p;
     2067
     2068    pNext(Lp.p) = strat->tail;
     2069
     2070    LObject tmp_h(f, currRing, strat->tailRing);
     2071    tmp_h.SetShortExpVector();
     2072    strat->initEcart(&tmp_h);
     2073    tmp_h.sev = pGetShortExpVector(tmp_h.p);
     2074    tmp_h.SetpFDeg();
     2075    tmp_h.t_p = t_p;
     2076
     2077    enterT(tmp_h, strat, strat->tl + 1);
     2078
     2079    if (atR >= 0)
     2080    {
     2081      Lp.i_r2 = atR;
     2082      Lp.i_r1 = strat->tl;
     2083    }
     2084
     2085    strat->initEcartPair(&Lp,f,p,0/*strat->ecartS[i]*/,ecart);     // Attention: TODO: break ecart
     2086    l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
     2087    // enterL(&strat->B, &strat->Bl, &strat->Bmax, Lp, l);
     2088  }
     2089}
     2090
     2091/* Helper for kCreateZeroPoly
     2092 * enumerating the exponents
     2093 */
     2094
     2095int nextZeroSimplexExponent (long exp[], long ind[], long cexp[], long cind[], long* cabsind, long bound, long N)
     2096/* gives the next exponent from the set H_1 */
     2097{
     2098  if (*cabsind < bound)
     2099  {
     2100    cexp[1] += 2;
     2101    long add = ind2(cexp[1]);
     2102    cind[1] += add;
     2103    *cabsind += add;
     2104  }
     2105  else
     2106  {
     2107    // cabsind >= habsind
     2108    if (N == 1) return 0;
     2109    int i = 1;
     2110    while (exp[i] == cexp[i] && i <= N) i++;
     2111    cexp[i] = exp[i];
     2112    *cabsind -= cind[i];
     2113    cind[i] = ind[i];
     2114    *cabsind += cind[i];
     2115    // Print("in: %d\n", *cabsind);
     2116    i += 1;
     2117    if (i > N) return 0;
     2118    cexp[i] += 2;
     2119    long add = ind2(cexp[i]);
     2120    cind[i] += add;
     2121    *cabsind += add;
     2122  }
     2123  return 1;
     2124}
     2125
     2126/*
     2127 * Creates the zero Polynomial on position exp
     2128 * long exp[] : exponent of leading term
     2129 * cabsind    : total 2-ind of exp (if -1 will be computed)
     2130 * poly* t_p  : will hold the LT in tailRing
     2131 * leadRing   : ring for the LT
     2132 * tailRing   : ring for the tail
     2133 */
     2134
     2135poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing)
     2136{
     2137
     2138  poly zeroPoly = NULL;
     2139
     2140  number tmp1;
     2141  poly tmp2, tmp3;
     2142
     2143  if (cabsind == -1)
     2144  {
     2145    cabsind = 0;
     2146    for (int i = 1; i <= leadRing->N; i++)
     2147    {
     2148      cabsind += ind_fact_2(exp[i]);
     2149    }
     2150//    Print("cabsind: %d\n", cabsind);
     2151  }
     2152  if (cabsind < leadRing->ch)
     2153  {
     2154    zeroPoly = p_ISet(twoPow(leadRing->ch - cabsind), tailRing);
     2155  }
     2156  else
     2157  {
     2158    zeroPoly = p_ISet(1, tailRing);
     2159  }
     2160  for (int i = 1; i <= leadRing->N; i++)
     2161  {
     2162    for (long j = 1; j <= exp[i]; j++)
     2163    {
     2164      tmp1 = nInit(j);
     2165      tmp2 = p_ISet(1, tailRing);
     2166      p_SetExp(tmp2, i, 1, tailRing);
     2167      p_Setm(tmp2, tailRing);
     2168      if (nIsZero(tmp1))
     2169      { // should nowbe obsolet, test ! TODO OLIVER
     2170        zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
     2171      }
     2172      else
     2173      {
     2174        tmp3 = p_NSet(nCopy(tmp1), tailRing);
     2175        zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
     2176      }
     2177    }
     2178  }
     2179  tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
     2180  for (int i = 1; i <= leadRing->N; i++) {
     2181    pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
     2182  }
     2183  p_Setm(tmp2, leadRing);
     2184  *t_p = zeroPoly;
     2185  zeroPoly = pNext(zeroPoly);
     2186  pNext(*t_p) = NULL;
     2187  pNext(tmp2) = zeroPoly;
     2188  return tmp2;
     2189}
     2190
     2191// #define OLI_DEBUG
     2192
     2193/*
     2194 * Generate the s-polynomial for the virtual set of zero-polynomials
     2195 */
     2196
     2197void initenterzeropairsRing (poly p, int ecart, kStrategy strat, int atR)
     2198{
     2199  // Initialize
     2200  long exp[50];            // The exponent of \hat{X} (basepoint)
     2201  long cexp[50];           // The current exponent for iterating over all
     2202  long ind[50];            // The power of 2 in the i-th component of exp
     2203  long cind[50];           // analog for cexp
     2204  long mult[50];           // How to multiply the elements of G
     2205  long cabsind = 0;        // The abs. index of cexp, i.e. the sum of cind
     2206  long habsind = 0;        // The abs. index of the coefficient of h
     2207  for (int i = 1; i <= currRing->N; i++)
     2208  {
     2209    exp[i] = p_GetExp(p, i, currRing);
     2210    if (exp[i] & 1 != 0)
     2211    {
     2212      exp[i] = exp[i] - 1;
     2213      mult[i] = 1;
     2214    }
     2215    cexp[i] = exp[i];
     2216    ind[i] = ind_fact_2(exp[i]);
     2217    cabsind += ind[i];
     2218    cind[i] = ind[i];
     2219  }
     2220  habsind = ind2((long) p_GetCoeff(p, currRing));
     2221  long bound = currRing->ch - habsind;
     2222#ifdef OLI_DEBUG
     2223  PrintS("-------------\npoly  :");
     2224  wrp(p);
     2225  Print("\nexp   : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]);
     2226  Print("cexp  : (%d, %d)\n", cexp[1], cexp[2]);
     2227  Print("cind  : (%d, %d)\n", cind[1], cind[2]);
     2228  Print("bound : %d\n", bound);
     2229  Print("cind  : %d\n", cabsind);
     2230#endif
     2231  if (cabsind == 0)
     2232  {
     2233    if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, bound, currRing->N)))
     2234    {
     2235      return;
     2236    }
     2237  }
     2238  // Now the whole simplex
     2239  do
     2240  {
     2241    // Build s-polynomial
     2242    // 2**ind-def * mult * g - exp-def * h
     2243    poly t_p;
     2244    poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, strat->tailRing);
     2245#ifdef OLI_DEBUG
     2246    Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]);
     2247    Print("zPoly : ");
     2248    wrp(zeroPoly);
     2249    Print("\n");
     2250#endif
     2251    enterOneZeroPairRing(zeroPoly, t_p, p, ecart, strat, atR);
     2252  }
     2253  while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, bound, currRing->N) );
     2254}
     2255
     2256/*
     2257 * Create the Groebner basis of the vanishing polynomials.
     2258 */
     2259
     2260ideal createG0()
     2261{
     2262  // Initialize
     2263  long exp[50];            // The exponent of \hat{X} (basepoint)
     2264  long cexp[50];           // The current exponent for iterating over all
     2265  long ind[50];            // The power of 2 in the i-th component of exp
     2266  long cind[50];           // analog for cexp
     2267  long mult[50];           // How to multiply the elements of G
     2268  long cabsind = 0;        // The abs. index of cexp, i.e. the sum of cind
     2269  long habsind = 0;        // The abs. index of the coefficient of h
     2270  for (int i = 1; i <= currRing->N; i++)
     2271  {
     2272    exp[i] = 0;
     2273    cexp[i] = exp[i];
     2274    ind[i] = 0;
     2275    cind[i] = ind[i];
     2276  }
     2277  long bound = currRing->ch;
     2278#ifdef OLI_DEBUG
     2279  PrintS("-------------\npoly  :");
     2280  wrp(p);
     2281  Print("\nexp   : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]);
     2282  Print("cexp  : (%d, %d)\n", cexp[1], cexp[2]);
     2283  Print("cind  : (%d, %d)\n", cind[1], cind[2]);
     2284  Print("bound : %d\n", bound);
     2285  Print("cind  : %d\n", cabsind);
     2286#endif
     2287  if (cabsind == 0)
     2288  {
     2289    if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, bound, currRing->N)))
     2290    {
     2291      return idInit(1, 1);
     2292    }
     2293  }
     2294  ideal G0 = idInit(1, 1);
     2295  // Now the whole simplex
     2296  do
     2297  {
     2298    // Build s-polynomial
     2299    // 2**ind-def * mult * g - exp-def * h
     2300    poly t_p;
     2301    poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, currRing);
     2302#ifdef OLI_DEBUG
     2303    Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]);
     2304    Print("zPoly : ");
     2305    wrp(zeroPoly);
     2306    Print("\n");
     2307#endif
     2308    // Add to ideal
     2309    pEnlargeSet(&(G0->m), IDELEMS(G0), 1);
     2310    IDELEMS(G0) += 1;
     2311    G0->m[IDELEMS(G0) - 1] = zeroPoly;
     2312  }
     2313  while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, bound, currRing->N) );
     2314  idSkipZeroes(G0);
     2315  return G0;
     2316}
     2317
    19442318/*2
    19452319*(s[0],h),...,(s[k],h) will be put to the pairset L
     
    19902364      }
    19912365    }
     2366
     2367#ifdef HAVE_VANGB
     2368    initenterzeropairsRing(h, ecart, strat, atR);
     2369#endif
    19922370
    19932371    if (new_pair) chainCritRing(h,ecart,strat);
  • kernel/kutil.h

    r2a5c2f4 r6d09f28  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: kutil.h,v 1.17 2006-06-12 17:40:10 wienand Exp $ */
     6/* $Id: kutil.h,v 1.18 2006-08-14 17:08:37 wienand Exp $ */
    77/*
    88* ABSTRACT: kernel: utils for kStd
     
    397397#ifdef HAVE_RING2TOM
    398398int redRing2toM (LObject* h,kStrategy strat);
     399long ind2(long arg);
     400long ind_fact_2(long arg);
    399401long twoPow(long arg);
    400402void enterExtendedSpoly(poly h,kStrategy strat);
    401403void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);
     404poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing);
     405ideal createG0();
    402406#endif
    403407int redLazy (LObject* h,kStrategy strat);
Note: See TracChangeset for help on using the changeset viewer.