Changeset fff1bf in git for libpolys


Ignore:
Timestamp:
Mar 31, 2022, 2:19:28 PM (2 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
03e31554a5f308d79b80ade9e36dd826ddb61c08
Parents:
c808198eb3569c6fecf1ebaacef81b08e8aea4ff
Message:
opt: p_Norm for Zp
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/monomials/p_polys.cc

    rc808198 rfff1bf  
    37973797void p_Norm(poly p1, const ring r)
    37983798{
    3799   if (rField_is_Ring(r))
     3799  if (LIKELY(rField_is_Ring(r)))
    38003800  {
    38013801    if(!n_GreaterZero(pGetCoeff(p1),r->cf)) p1 = p_Neg(p1,r);
     
    38033803    // Werror("p_Norm not possible in the case of coefficient rings.");
    38043804  }
    3805   else if (p1!=NULL)
    3806   {
    3807     if (pNext(p1)==NULL)
     3805  else if (LIKELY(p1!=NULL))
     3806  {
     3807    if (UNLIKELY(pNext(p1)==NULL))
    38083808    {
    38093809      p_SetCoeff(p1,n_Init(1,r->cf),r);
     
    38123812    if (!n_IsOne(pGetCoeff(p1),r->cf))
    38133813    {
    3814       number k, c;
    3815       n_Normalize(pGetCoeff(p1),r->cf);
    3816       k = pGetCoeff(p1);
    3817       c = n_Init(1,r->cf);
    3818       pSetCoeff0(p1,c);
     3814      number k = pGetCoeff(p1);
     3815      pSetCoeff0(p1,n_Init(1,r->cf));
    38193816      poly h = pNext(p1);
    3820       if (rField_is_Zp(r))
     3817      if (LIKELY(rField_is_Zp(r)))
    38213818      {
    38223819        if (r->cf->ch>32003)
     
    38253822          while (h!=NULL)
    38263823          {
    3827             c=n_Mult(pGetCoeff(h),inv,r->cf);
     3824            number c=n_Mult(pGetCoeff(h),inv,r->cf);
    38283825            // no need to normalize
    38293826            p_SetCoeff(h,c,r);
     
    38363833          while (h!=NULL)
    38373834          {
    3838             c=n_Div(pGetCoeff(h),k,r->cf);
     3835            number c=n_Div(pGetCoeff(h),k,r->cf);
    38393836            // no need to normalize
    38403837            p_SetCoeff(h,c,r);
     
    38453842      else if(getCoeffType(r->cf)==n_algExt)
    38463843      {
     3844        n_Normalize(k,r->cf);
    38473845        number inv=n_Invers(k,r->cf);
    38483846        while (h!=NULL)
    38493847        {
    3850           c=n_Mult(pGetCoeff(h),inv,r->cf);
     3848          number c=n_Mult(pGetCoeff(h),inv,r->cf);
    38513849          // no need to normalize
    3852           // normalize already in nMult: Zp_a
     3850          // normalize already in nMult: Zp_a, Q_a
    38533851          p_SetCoeff(h,c,r);
    38543852          pIter(h);
    38553853        }
    38563854        n_Delete(&inv,r->cf);
     3855        n_Delete(&k,r->cf);
    38573856      }
    38583857      else
    38593858      {
     3859        n_Normalize(k,r->cf);
    38603860        while (h!=NULL)
    38613861        {
    3862           c=n_Div(pGetCoeff(h),k,r->cf);
     3862          number c=n_Div(pGetCoeff(h),k,r->cf);
    38633863          // no need to normalize: Z/p, R
    3864           // normalize already in nDiv: Q_a
    38653864          // remains: Q
    3866           if (rField_is_Q(r) && (!n_IsOne(c,r->cf))) n_Normalize(c,r->cf);
     3865          if (rField_is_Q(r)) n_Normalize(c,r->cf);
    38673866          p_SetCoeff(h,c,r);
    38683867          pIter(h);
    38693868        }
    3870       }
    3871       n_Delete(&k,r->cf);
     3869        n_Delete(&k,r->cf);
     3870      }
    38723871    }
    38733872    else
Note: See TracChangeset for help on using the changeset viewer.