Changeset 5eb865 in git for kernel/kutil.cc


Ignore:
Timestamp:
Jun 9, 2009, 8:21:50 PM (14 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
e4be351ada16eebdaa1e48ce01115ffc5287dbd3
Parents:
b82abb0dc3349df20acd8231f648b8ff51bc61b6
Message:
*hannes: redtail for Z


git-svn-id: file:///usr/local/Singular/svn/trunk@11891 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/kutil.cc

    rb82abb r5eb865  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: kutil.cc,v 1.143 2009-06-04 08:42:06 Singular Exp $ */
     4/* $Id: kutil.cc,v 1.144 2009-06-09 18:21:50 Singular Exp $ */
    55/*
    66* ABSTRACT: kernel: utils for kStd
     
    45964596  return L->GetLmCurrRing();
    45974597}
     4598
     4599#ifdef HAVE_RINGS
     4600poly redtailBba_Z (LObject* L, int pos, kStrategy strat )
     4601// normalize=FALSE, withT=FALSE, coeff=Z
     4602{
     4603  strat->redTailChange=FALSE;
     4604  if (strat->noTailReduction) return L->GetLmCurrRing();
     4605  poly h, p;
     4606  p = h = L->GetLmTailRing();
     4607  if ((h==NULL) || (pNext(h)==NULL))
     4608    return L->GetLmCurrRing();
     4609
     4610  TObject* With;
     4611  // placeholder in case strat->tl < 0
     4612  TObject  With_s(strat->tailRing);
     4613
     4614  LObject Ln(pNext(h), strat->tailRing);
     4615  Ln.pLength = L->GetpLength() - 1;
     4616
     4617  pNext(h) = NULL;
     4618  if (L->p != NULL) pNext(L->p) = NULL;
     4619  L->pLength = 1;
     4620
     4621  Ln.PrepareRed(strat->use_buckets);
     4622
     4623  int cnt=REDTAIL_CANONICALIZE;
     4624  while(!Ln.IsNull())
     4625  {
     4626    loop
     4627    {
     4628      Ln.SetShortExpVector();
     4629      With = kFindDivisibleByInS(strat, pos, &Ln, &With_s);
     4630      if (With == NULL) break;
     4631      cnt--;
     4632      if (cnt==0)
     4633      {
     4634        cnt=REDTAIL_CANONICALIZE;
     4635        poly tmp=Ln.CanonicalizeP();
     4636      }
     4637      // we are in Z, do not Ccall pNorm
     4638      strat->redTailChange=TRUE;
     4639      // test divisibility of coefs:
     4640      poly p_Ln=Ln.GetLmCurrRing();
     4641      poly p_With=With->GetLmCurrRing();
     4642      number z=nIntMod(pGetCoeff(p_Ln),pGetCoeff(p_With));
     4643      if (!nIsZero(z))
     4644      {
     4645        // subtract z*Ln, add z.Ln to L
     4646        poly m=pHead(p_Ln);
     4647        pSetCoeff(m,z);
     4648        poly mm=pHead(m);
     4649        pNext(h) = m;
     4650        pIter(h);
     4651        L->pLength++;
     4652        mm=pNeg(mm);
     4653        if (Ln.bucket!=NULL)
     4654        {
     4655          int dummy=1;
     4656          kBucket_Add_q(Ln.bucket,mm,&dummy);
     4657        }
     4658        else
     4659        {
     4660          if (Ln.p!=NULL) Ln.p=pAdd(Ln.p,mm);
     4661          else if (Ln.t_p!=NULL)  Ln.t_p=p_Add_q(Ln.t_p,mm,strat->tailRing);
     4662        }
     4663      }
     4664      else
     4665        nDelete(&z);
     4666
     4667      if (ksReducePolyTail(L, With, &Ln))
     4668      {
     4669        // reducing the tail would violate the exp bound
     4670        //  set a flag and hope for a retry (in bba)
     4671        strat->completeReduce_retry=TRUE;
     4672        do
     4673        {
     4674          pNext(h) = Ln.LmExtractAndIter();
     4675          pIter(h);
     4676          L->pLength++;
     4677        } while (!Ln.IsNull());
     4678        goto all_done;
     4679      }
     4680      if (Ln.IsNull()) goto all_done;
     4681      With_s.Init(currRing);
     4682    }
     4683    pNext(h) = Ln.LmExtractAndIter();
     4684    pIter(h);
     4685    pNormalize(h);
     4686    L->pLength++;
     4687  }
     4688
     4689  all_done:
     4690  Ln.Delete();
     4691  if (L->p != NULL) pNext(L->p) = pNext(p);
     4692
     4693  if (strat->redTailChange)
     4694  {
     4695    L->last = NULL;
     4696    L->length = 0;
     4697  }
     4698
     4699  //if (TEST_OPT_PROT) { PrintS("N"); mflush(); }
     4700  //L->Normalize(); // HANNES: should have a test
     4701  kTest_L(L);
     4702  return L->GetLmCurrRing();
     4703}
     4704#endif
    45984705
    45994706/*2
Note: See TracChangeset for help on using the changeset viewer.