Changeset 2de7b0 in git for libpolys/polys


Ignore:
Timestamp:
Sep 13, 2013, 10:38:22 AM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
57f6787143191ee820fea3fb30b759d7708dc7fc
Parents:
7627f67da8dc2c135f659c4e3f2ef25e3de4f00e
Message:
chg: improve definiteGcdCancellation by using singclap_gcd_and_divide
Location:
libpolys/polys
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/clapsing.cc

    r7627f6 r2de7b0  
    147147}
    148148
    149 void singclap_gcd_and_divide ( poly& f, poly& g, const ring r)
     149poly singclap_gcd_and_divide ( poly& f, poly& g, const ring r)
    150150{
    151151  poly res=NULL;
    152152
    153   if (f!=NULL) p_Cleardenom(f, r);
    154   if (g!=NULL) p_Cleardenom(g, r);
    155   else         return; // g==0 => but do a p_Cleardenom(f)
    156   if (f==NULL) return; // f==0 => but do a p_Cleardenom(g)
     153  if (g == NULL)
     154  {
     155    res= p_Copy (f,r);
     156    p_Delete (&f, r);
     157    f=p_One (r);
     158    return res;
     159  }
     160  if (f==NULL)
     161  {
     162    res= p_Copy (g,r);
     163    p_Delete (&g, r);
     164    g=p_One (r);
     165    return res;
     166  }
    157167
    158168  Off(SW_RATIONAL);
     
    169179      p_Delete(&f,r);
    170180      p_Delete(&g,r);
     181      if (getCharacteristic() == 0)
     182        On (SW_RATIONAL);
    171183      f=convFactoryPSingP( F/GCD, r);
    172184      g=convFactoryPSingP( G/GCD, r);
    173185    }
     186    res=convFactoryPSingP( GCD , r);
    174187    if (!b1) Off (SW_USE_EZGCD_P);
    175188  }
     
    193206        p_Delete(&f,r);
    194207        p_Delete(&g,r);
     208        if (getCharacteristic() == 0)
     209          On (SW_RATIONAL);
    195210        f= convFactoryAPSingAP( F/GCD,r );
    196211        g= convFactoryAPSingAP( G/GCD,r );
    197212      }
     213      res= convFactoryAPSingAP( GCD,r );
    198214      if (!b1) Off(SW_USE_QGCD);
    199215    }
     
    207223        p_Delete(&f,r);
    208224        p_Delete(&g,r);
     225        if (getCharacteristic() == 0)
     226          On (SW_RATIONAL);
    209227        f= convFactoryPSingTrP( F/GCD,r );
    210228        g= convFactoryPSingTrP( G/GCD,r );
    211229      }
     230      res= convFactoryPSingTrP( GCD,r );
    212231    }
    213232  }
     
    215234    WerrorS( feNotImplemented );
    216235  Off(SW_RATIONAL);
     236  return res;
    217237}
    218238
  • libpolys/polys/clapsing.h

    r7627f6 r2de7b0  
    3333
    3434/// clears denominators of f and g, divides by gcd(f,g)
    35 void singclap_gcd_and_divide ( poly& f, poly& g, const ring r);
     35poly singclap_gcd_and_divide ( poly& f, poly& g, const ring r);
    3636
    3737// commented out!
  • libpolys/polys/ext_fields/transext.cc

    r7627f6 r2de7b0  
    13771377
    13781378#ifdef HAVE_FACTORY
    1379   poly pGcd;
    13801379  /* here we assume: NUM(f), DEN(f) !=NULL, in Z_a reqp. Z/p_a */
    1381     pGcd = singclap_gcd_r(NUM(f), DEN(f), ntRing);
     1380  poly pGcd = singclap_gcd_and_divide(NUM(f), DEN(f), ntRing);
    13821381  if (p_IsConstant(pGcd, ntRing)
    13831382  && n_IsOne(p_GetCoeff(pGcd, ntRing), ntCoeffs)
     
    13911390    {
    13921391      NUM (f) = p_Div_nn (NUM (f), p_GetCoeff (DEN(f),ntRing), ntRing);
    1393       //poly newNum= singclap_pdivide (NUM(f), DEN (f), ntRing);
    1394       //p_Delete(&NUM (f), ntRing);
    1395       //NUM (f)= newNum;
    13961392      p_Delete(&DEN (f), ntRing);
    13971393      DEN (f) = NULL;
     
    14021398  { /* We divide both NUM(f) and DEN(f) by the gcd which is known
    14031399       to be != 1. */
    1404     poly newNum = singclap_pdivide(NUM(f), pGcd, ntRing);
    1405     p_Delete(&NUM(f), ntRing);
    1406     NUM(f) = newNum;
    1407     poly newDen = singclap_pdivide(DEN(f), pGcd, ntRing);
    1408     p_Delete(&DEN(f), ntRing);
    1409     DEN(f) = newDen;
    14101400    if (p_IsConstant(DEN(f), ntRing) &&
    14111401        n_IsOne(p_GetCoeff(DEN(f), ntRing), ntCoeffs))
     
    14131403      /* DEN(f) = 1 needs to be represented by NULL! */
    14141404      p_Delete(&DEN(f), ntRing);
    1415       newDen = NULL;
     1405      DEN(f) = NULL;
    14161406    }
    14171407    else
     
    14201410         call will remove those nested fractions, in case there are
    14211411         any. */
    1422       if (nCoeff_is_Q(ntCoeffs)) handleNestedFractionsOverQ(f, cf);
     1412      if (nCoeff_is_Zp(ntCoeffs) && p_IsConstant (DEN (f), ntRing))
     1413      {
     1414        NUM (f) = p_Div_nn (NUM (f), p_GetCoeff (DEN(f),ntRing), ntRing);
     1415        p_Delete(&DEN (f), ntRing);
     1416        DEN (f) = NULL;
     1417        COM (f) = 0;
     1418      } else if (nCoeff_is_Q(ntCoeffs)) handleNestedFractionsOverQ(f, cf);
    14231419    }
    14241420  }
Note: See TracChangeset for help on using the changeset viewer.