Changeset 182ac7 in git


Ignore:
Timestamp:
May 4, 2021, 3:32:47 PM (21 months ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '2234726c50d679d6664181a5c72f75a6fd64a787')
Children:
502859fe5faa956d714f45c2e56bd4bd4736e1ad
Parents:
d56a028f6c210ff9d0a22ef03869531f6ea14743
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2021-05-04 15:32:47+02:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2021-05-04 15:33:55+02:00
Message:
moved kutil.cc -> kstd2.cc: ind2, ind_fact_2, removed VANIDEAL RING2TOM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    rd56a028 r182ac7  
    28472847       else
    28482848  #endif
    2849 
    2850 
    2851   /*==================== DLL =================*/
    2852   #ifdef __CYGWIN__
    2853   #ifdef HAVE_DL
    2854   /* testing the DLL functionality under Win32 */
    2855         if (strcmp(sys_cmd, "DLL") == 0)
    2856         {
    2857           typedef void  (*Void_Func)();
    2858           typedef int  (*Int_Func)(int);
    2859           void *hh=dynl_open("WinDllTest.dll");
    2860           if ((h!=NULL) && (h->Typ()==INT_CMD))
    2861           {
    2862             int (*f)(int);
    2863             if (hh!=NULL)
    2864             {
    2865               int (*f)(int);
    2866               f=(Int_Func)dynl_sym(hh,"PlusDll");
    2867               int i=10;
    2868               if (f!=NULL) printf("%d\n",f(i));
    2869               else PrintS("cannot find PlusDll\n");
    2870             }
    2871           }
    2872           else
    2873           {
    2874             void (*f)();
    2875             f= (Void_Func)dynl_sym(hh,"TestDll");
    2876             if (f!=NULL) f();
    2877             else PrintS("cannot find TestDll\n");
    2878           }
    2879           return FALSE;
    2880         }
    2881         else
    2882   #endif
    2883   #endif
    2884   #ifdef HAVE_RING2TOM
    2885   /*==================== ring-GB ==================================*/
    2886       if (strcmp(sys_cmd, "findZeroPoly")==0)
    2887       {
    2888         ring r = currRing;
    2889         poly f = (poly) h->Data();
    2890         res->rtyp=POLY_CMD;
    2891         res->data=(poly) kFindZeroPoly(f, r, r);
    2892         return(FALSE);
    2893       }
    2894       else
    2895   /*==================== Creating zero polynomials =================*/
    2896   #ifdef HAVE_VANIDEAL
    2897       if (strcmp(sys_cmd, "createG0")==0)
    2898       {
    2899         /* long exp[50];
    2900         int N = 0;
    2901         while (h != NULL)
    2902         {
    2903           N += 1;
    2904           exp[N] = (long) h->Data();
    2905           // if (exp[i] % 2 != 0) exp[i] -= 1;
    2906           h = h->next;
    2907         }
    2908         for (int k = 1; N + k <= currRing->N; k++) exp[k] = 0;
    2909 
    2910         poly t_p;
    2911         res->rtyp=POLY_CMD;
    2912         res->data= (poly) kCreateZeroPoly(exp, -1, &t_p, currRing, currRing);
    2913         return(FALSE); */
    2914 
    2915         res->rtyp = IDEAL_CMD;
    2916         res->data = (ideal) createG0();
    2917         return(FALSE);
    2918       }
    2919       else
    2920   #endif
    29212849  /*==================== redNF_ring =================*/
     2850  #ifdef HAVE_RINGS
    29222851      if (strcmp(sys_cmd, "redNF_ring")==0)
    29232852      {
  • dox/Doxyfile.in

    rd56a028 r182ac7  
    20252025HAVE_PYTHON \
    20262026HAVE_RATGRING \
    2027 HAVE_RING2TOM \
    20282027HAVE_SBRK \
    20292028HAVE_SDB \
     
    20352034HAVE_TAIL_BIN \
    20362035HAVE_TAIL_RING \
    2037 HAVE_VANIDEAL \
    20382036HAVE_WALK \
    20392037HAVE_ZERODIVISORS \
  • kernel/GBEngine/kstd2.cc

    rd56a028 r182ac7  
    522522  }
    523523}
     524
     525#ifdef HAVE_RINGS
     526static long ind2(long arg)
     527{
     528  if (arg <= 0) return 0;
     529  long ind = 0;
     530  while (arg%2 == 0)
     531  {
     532    arg = arg / 2;
     533    ind++;
     534  }
     535  return ind;
     536}
     537
     538static long ind_fact_2(long arg)
     539{
     540  if (arg <= 0) return 0;
     541  long ind = 0;
     542  if (arg%2 == 1) { arg--; }
     543  while (arg > 0)
     544  {
     545    ind += ind2(arg);
     546    arg = arg - 2;
     547  }
     548  return ind;
     549}
     550#endif
    524551
    525552#ifdef HAVE_RINGS
  • kernel/GBEngine/kutil.cc

    rd56a028 r182ac7  
    41764176    j--;
    41774177  }
    4178 }
    4179 #endif
    4180 
    4181 #ifdef HAVE_RINGS
    4182 long ind2(long arg)
    4183 {
    4184   if (arg <= 0) return 0;
    4185   long ind = 0;
    4186   while (arg%2 == 0)
    4187   {
    4188     arg = arg / 2;
    4189     ind++;
    4190   }
    4191   return ind;
    4192 }
    4193 
    4194 long ind_fact_2(long arg)
    4195 {
    4196   if (arg <= 0) return 0;
    4197   long ind = 0;
    4198   if (arg%2 == 1) { arg--; }
    4199   while (arg > 0)
    4200   {
    4201     ind += ind2(arg);
    4202     arg = arg - 2;
    4203   }
    4204   return ind;
    4205 }
    4206 #endif
    4207 
    4208 #ifdef HAVE_VANIDEAL
    4209 static long twoPow(long arg)
    4210 {
    4211   return 1L << arg;
    4212 }
    4213 
    4214 /*2
    4215 * put the pair (p, f) in B and f in T
    4216 */
    4217 static void enterOneZeroPairRing (poly f, poly t_p, poly p, int ecart, kStrategy strat, int atR = -1)
    4218 {
    4219   int      l,j,compare,compareCoeff;
    4220   LObject  Lp;
    4221 
    4222 #ifdef KDEBUG
    4223   Lp.ecart=0; Lp.length=0;
    4224 #endif
    4225   /*- computes the lcm(s[i],p) -*/
    4226   Lp.lcm = p_Lcm(p,f,Lp.lcm,currRing);
    4227   pSetCoeff(Lp.lcm, nLcm(pGetCoeff(p), pGetCoeff(f), currRing));
    4228   assume(!strat->sugarCrit);
    4229   assume(!strat->fromT);
    4230   /*
    4231   *the set B collects the pairs of type (S[j],p)
    4232   *suppose (r,p) is in B and (s,p) is the new pair and lcm(s,p) != lcm(r,p)
    4233   *if the leading term of s divides lcm(r,p) then (r,p) will be canceled
    4234   *if the leading term of r divides lcm(s,p) then (s,p) will not enter B
    4235   */
    4236   for(j = strat->Bl;j>=0;j--)
    4237   {
    4238     compare=pDivCompRing(strat->B[j].lcm,Lp.lcm);
    4239     compareCoeff = nDivComp(pGetCoeff(strat->B[j].lcm), pGetCoeff(Lp.lcm));
    4240     if (compareCoeff == 0 || compare == compareCoeff)
    4241     {
    4242       if (compare == 1)
    4243       {
    4244         strat->c3++;
    4245         pLmDelete(Lp.lcm);
    4246         return;
    4247       }
    4248       else
    4249       if (compare == -1)
    4250       {
    4251         deleteInL(strat->B,&strat->Bl,j,strat);
    4252         strat->c3++;
    4253       }
    4254     }
    4255     if (compare == pDivComp_EQUAL)
    4256     {
    4257       // Add hint for same LM and direction of LC (later) (TODO Oliver)
    4258       if (compareCoeff == 1)
    4259       {
    4260         strat->c3++;
    4261         pLmDelete(Lp.lcm);
    4262         return;
    4263       }
    4264       else
    4265       if (compareCoeff == -1)
    4266       {
    4267         deleteInL(strat->B,&strat->Bl,j,strat);
    4268         strat->c3++;
    4269       }
    4270     }
    4271   }
    4272   /*
    4273   *the pair (S[i],p) enters B if the spoly != 0
    4274   */
    4275   /*-  compute the short s-polynomial -*/
    4276   if ((f==NULL) || (p==NULL)) return;
    4277   pNorm(p);
    4278   {
    4279     Lp.p = ksCreateShortSpoly(f, p, strat->tailRing);
    4280   }
    4281   if (Lp.p == NULL) //deactivated, as we are adding pairs with zeropoly and not from S
    4282   {
    4283     /*- the case that the s-poly is 0 -*/
    4284 //    if (strat->pairtest==NULL) initPairtest(strat);
    4285 //    strat->pairtest[i] = TRUE;/*- hint for spoly(S^[i],p)=0 -*/
    4286 //    strat->pairtest[strat->sl+1] = TRUE;
    4287     /*hint for spoly(S[i],p) == 0 for some i,0 <= i <= sl*/
    4288     /*
    4289     *suppose we have (s,r),(r,p),(s,p) and spoly(s,p) == 0 and (r,p) is
    4290     *still in B (i.e. lcm(r,p) == lcm(s,p) or the leading term of s does not
    4291     *divide lcm(r,p)). In the last case (s,r) can be canceled if the leading
    4292     *term of p divides the lcm(s,r)
    4293     *(this canceling should be done here because
    4294     *the case lcm(s,p) == lcm(s,r) is not covered in chainCrit)
    4295     *the first case is handeled in chainCrit
    4296     */
    4297     if (Lp.lcm!=NULL) pLmDelete(Lp.lcm);
    4298   }
    4299   else
    4300   {
    4301     /*- the pair (S[i],p) enters B -*/
    4302     Lp.p1 = f;
    4303     Lp.p2 = p;
    4304 
    4305     pNext(Lp.p) = strat->tail;
    4306 
    4307     LObject tmp_h(f, currRing, strat->tailRing);
    4308     tmp_h.SetShortExpVector();
    4309     strat->initEcart(&tmp_h);
    4310     tmp_h.sev = pGetShortExpVector(tmp_h.p);
    4311     tmp_h.t_p = t_p;
    4312 
    4313     enterT(tmp_h, strat, strat->tl + 1);
    4314 
    4315     if (atR >= 0)
    4316     {
    4317       Lp.i_r2 = atR;
    4318       Lp.i_r1 = strat->tl;
    4319     }
    4320 
    4321     strat->initEcartPair(&Lp,f,p,0/*strat->ecartS[i]*/,ecart);     // Attention: TODO: break ecart
    4322     l = strat->posInL(strat->B,strat->Bl,&Lp,strat);
    4323     enterL(&strat->B, &strat->Bl, &strat->Bmax, Lp, l);
    4324   }
    4325 }
    4326 
    4327 /* Helper for kCreateZeroPoly
    4328  * enumerating the exponents
    4329 ring r = 2^2, (a, b, c), lp; ideal G0 = system("createG0"); ideal G = interred(G0); ncols(G0); ncols(G);
    4330  */
    4331 
    4332 static int nextZeroSimplexExponent (long exp[], long ind[], long cexp[], long cind[], long* cabsind, long step[], long bound, long N)
    4333 /* gives the next exponent from the set H_1 */
    4334 {
    4335   long add = ind2(cexp[1] + 2);
    4336   if ((*cabsind < bound) && (*cabsind - step[1] + add < bound))
    4337   {
    4338     cexp[1] += 2;
    4339     cind[1] += add;
    4340     *cabsind += add;
    4341   }
    4342   else
    4343   {
    4344     // cabsind >= habsind
    4345     if (N == 1) return 0;
    4346     int i = 1;
    4347     while (exp[i] == cexp[i] && i <= N) i++;
    4348     cexp[i] = exp[i];
    4349     *cabsind -= cind[i];
    4350     cind[i] = ind[i];
    4351     step[i] = 500000;
    4352     *cabsind += cind[i];
    4353     // Print("in: %d\n", *cabsind);
    4354     i += 1;
    4355     if (i > N) return 0;
    4356     do
    4357     {
    4358       step[1] = 500000;
    4359       for (int j = i + 1; j <= N; j++)
    4360       {
    4361         if (step[1] > step[j]) step[1] = step[j];
    4362       }
    4363       add = ind2(cexp[i] + 2);
    4364       if (*cabsind - step[1] + add >= bound)
    4365       {
    4366         cexp[i] = exp[i];
    4367         *cabsind -= cind[i];
    4368         cind[i] = ind[i];
    4369         *cabsind += cind[i];
    4370         step[i] = 500000;
    4371         i += 1;
    4372         if (i > N) return 0;
    4373       }
    4374       else step[1] = -1;
    4375     } while (step[1] != -1);
    4376     step[1] = 500000;
    4377     cexp[i] += 2;
    4378     cind[i] += add;
    4379     *cabsind += add;
    4380     if (add < step[i]) step[i] = add;
    4381     for (i = 2; i <= N; i++)
    4382     {
    4383       if (step[1] > step[i]) step[1] = step[i];
    4384     }
    4385   }
    4386   return 1;
    4387 }
    4388 
    4389 /*
    4390  * Creates the zero Polynomial on position exp
    4391  * long exp[] : exponent of leading term
    4392  * cabsind    : total 2-ind of exp (if -1 will be computed)
    4393  * poly* t_p  : will hold the LT in tailRing
    4394  * leadRing   : ring for the LT
    4395  * tailRing   : ring for the tail
    4396  */
    4397 
    4398 poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing)
    4399 {
    4400 
    4401   poly zeroPoly = NULL;
    4402 
    4403   number tmp1;
    4404   poly tmp2, tmp3;
    4405 
    4406   if (cabsind == -1)
    4407   {
    4408     cabsind = 0;
    4409     for (int i = 1; i <= leadRing->N; i++)
    4410     {
    4411       cabsind += ind_fact_2(exp[i]);
    4412     }
    4413 //    Print("cabsind: %d\n", cabsind);
    4414   }
    4415   if (cabsind < leadRing->ch)
    4416   {
    4417     zeroPoly = p_ISet(twoPow(leadRing->ch - cabsind), tailRing);
    4418   }
    4419   else
    4420   {
    4421     zeroPoly = p_ISet(1, tailRing);
    4422   }
    4423   for (int i = 1; i <= leadRing->N; i++)
    4424   {
    4425     for (long j = 1; j <= exp[i]; j++)
    4426     {
    4427       tmp1 = nInit(j);
    4428       tmp2 = p_ISet(1, tailRing);
    4429       p_SetExp(tmp2, i, 1, tailRing);
    4430       p_Setm(tmp2, tailRing);
    4431       if (nIsZero(tmp1))
    4432       { // should nowbe obsolet, test ! TODO OLIVER
    4433         zeroPoly = p_Mult_q(zeroPoly, tmp2, tailRing);
    4434       }
    4435       else
    4436       {
    4437         tmp3 = p_NSet(nCopy(tmp1), tailRing);
    4438         zeroPoly = p_Mult_q(zeroPoly, p_Add_q(tmp3, tmp2, tailRing), tailRing);
    4439       }
    4440     }
    4441   }
    4442   tmp2 = p_NSet(nCopy(pGetCoeff(zeroPoly)), leadRing);
    4443   for (int i = 1; i <= leadRing->N; i++)
    4444   {
    4445     pSetExp(tmp2, i, p_GetExp(zeroPoly, i, tailRing));
    4446   }
    4447   p_Setm(tmp2, leadRing);
    4448   *t_p = zeroPoly;
    4449   zeroPoly = pNext(zeroPoly);
    4450   pNext(*t_p) = NULL;
    4451   pNext(tmp2) = zeroPoly;
    4452   return tmp2;
    4453 }
    4454 
    4455 // #define OLI_DEBUG
    4456 #if 0
    4457 /*
    4458  * Generate the s-polynomial for the virtual set of zero-polynomials
    4459  */
    4460 
    4461 void initenterzeropairsRing (poly p, int ecart, kStrategy strat, int atR)
    4462 {
    4463   // Initialize
    4464   long exp[50];            // The exponent of \hat{X} (basepoint)
    4465   long cexp[50];           // The current exponent for iterating over all
    4466   long ind[50];            // The power of 2 in the i-th component of exp
    4467   long cind[50];           // analog for cexp
    4468   long mult[50];           // How to multiply the elements of G
    4469   long cabsind = 0;        // The abs. index of cexp, i.e. the sum of cind
    4470   long habsind = 0;        // The abs. index of the coefficient of h
    4471   long step[50];           // The last increases
    4472   for (int i = 1; i <= currRing->N; i++)
    4473   {
    4474     exp[i] = p_GetExp(p, i, currRing);
    4475     if (exp[i] & 1 != 0)
    4476     {
    4477       exp[i] = exp[i] - 1;
    4478       mult[i] = 1;
    4479     }
    4480     cexp[i] = exp[i];
    4481     ind[i] = ind_fact_2(exp[i]);
    4482     cabsind += ind[i];
    4483     cind[i] = ind[i];
    4484     step[i] = 500000;
    4485   }
    4486   step[1] = 500000;
    4487   habsind = ind2(n_Int(pGetCoeff(p), currRing->cf);
    4488   long bound = currRing->ch - habsind;
    4489 #ifdef OLI_DEBUG
    4490   PrintS("-------------\npoly  :");
    4491   wrp(p);
    4492   Print("\nexp   : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]);
    4493   Print("cexp  : (%d, %d)\n", cexp[1], cexp[2]);
    4494   Print("cind  : (%d, %d)\n", cind[1], cind[2]);
    4495   Print("bound : %d\n", bound);
    4496   Print("cind  : %d\n", cabsind);
    4497 #endif
    4498   if (cabsind == 0)
    4499   {
    4500     if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N)))
    4501     {
    4502       return;
    4503     }
    4504   }
    4505   // Now the whole simplex
    4506   do
    4507   {
    4508     // Build s-polynomial
    4509     // 2**ind-def * mult * g - exp-def * h
    4510     poly t_p;
    4511     poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, strat->tailRing);
    4512 #ifdef OLI_DEBUG
    4513     Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]);
    4514     PrintS("zPoly : ");
    4515     wrp(zeroPoly);
    4516     PrintLn();
    4517 #endif
    4518     enterOneZeroPairRing(zeroPoly, t_p, p, ecart, strat, atR);
    4519   }
    4520   while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N) );
    4521 }
    4522 #endif
    4523 
    4524 /*
    4525  * Create the Groebner basis of the vanishing polynomials.
    4526  */
    4527 
    4528 ideal createG0()
    4529 {
    4530   // Initialize
    4531   long exp[50];            // The exponent of \hat{X} (basepoint)
    4532   long cexp[50];           // The current exponent for iterating over all
    4533   long ind[50];            // The power of 2 in the i-th component of exp
    4534   long cind[50];           // analog for cexp
    4535   long mult[50];           // How to multiply the elements of G
    4536   long cabsind = 0;        // The abs. index of cexp, i.e. the sum of cind
    4537   long habsind = 0;        // The abs. index of the coefficient of h
    4538   long step[50];           // The last increases
    4539   for (int i = 1; i <= currRing->N; i++)
    4540   {
    4541     exp[i] = 0;
    4542     cexp[i] = exp[i];
    4543     ind[i] = 0;
    4544     step[i] = 500000;
    4545     cind[i] = ind[i];
    4546   }
    4547   long bound = currRing->ch;
    4548   step[1] = 500000;
    4549 #ifdef OLI_DEBUG
    4550   PrintS("-------------\npoly  :");
    4551 //  wrp(p);
    4552   Print("\nexp   : (%d, %d)\n", exp[1] + mult[1], exp[2] + mult[1]);
    4553   Print("cexp  : (%d, %d)\n", cexp[1], cexp[2]);
    4554   Print("cind  : (%d, %d)\n", cind[1], cind[2]);
    4555   Print("bound : %d\n", bound);
    4556   Print("cind  : %d\n", cabsind);
    4557 #endif
    4558   if (cabsind == 0)
    4559   {
    4560     if (!(nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N)))
    4561     {
    4562       return idInit(1, 1);
    4563     }
    4564   }
    4565   ideal G0 = idInit(1, 1);
    4566   // Now the whole simplex
    4567   do
    4568   {
    4569     // Build s-polynomial
    4570     // 2**ind-def * mult * g - exp-def * h
    4571     poly t_p;
    4572     poly zeroPoly = kCreateZeroPoly(cexp, cabsind, &t_p, currRing, currRing);
    4573 #ifdef OLI_DEBUG
    4574     Print("%d, (%d, %d), ind = (%d, %d)\n", cabsind, cexp[1], cexp[2], cind[1], cind[2]);
    4575     PrintS("zPoly : ");
    4576     wrp(zeroPoly);
    4577     PrintLn();
    4578 #endif
    4579     // Add to ideal
    4580     pEnlargeSet(&(G0->m), IDELEMS(G0), 1);
    4581     IDELEMS(G0) += 1;
    4582     G0->m[IDELEMS(G0) - 1] = zeroPoly;
    4583   }
    4584   while ( nextZeroSimplexExponent(exp, ind, cexp, cind, &cabsind, step, bound, currRing->N) );
    4585   idSkipZeroes(G0);
    4586   return G0;
    45874178}
    45884179#endif
  • kernel/GBEngine/kutil.h

    rd56a028 r182ac7  
    520520void superenterpairs (poly h,int k,int ecart,int pos,kStrategy strat, int atR = -1);
    521521void superenterpairsSig (poly h,poly hSig,int hFrom,int k,int ecart,int pos,kStrategy strat, int atR = -1);
    522 poly kCreateZeroPoly(long exp[], long cabsind, poly* t_p, ring leadRing, ring tailRing);
    523 long ind2(long arg);
    524 
    525 long ind_fact_2(long arg);
    526 ideal createG0();
    527522#endif
    528523int redLazy (LObject* h,kStrategy strat);
Note: See TracChangeset for help on using the changeset viewer.