Changeset dc42daf in git


Ignore:
Timestamp:
Feb 21, 2013, 7:13:50 PM (10 years ago)
Author:
Claus Fieker <fieker@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'cbf866d4f8c3861325311c042cb2033c053453b2')
Children:
5693d74c7e74fb28bc22148699aebb6524ded48c
Parents:
892dd80edda39f846824ca997ef834ad6d19f748
git-author:
Claus Fieker <fieker@erbsenstein.(none)>2013-02-21 19:13:50+01:00
git-committer:
Claus Fieker <fieker@erbsenstein.(none)>2013-02-22 16:40:29+01:00
Message:
an attempt to introduce better normalization for polynomials over number fields. Seems to work well in selected examples...
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/kInline.h

    r892dd8 rdc42daf  
    456456    {
    457457      if (t_p != NULL)
    458         {
    459           p_Cleardenom(t_p, tailRing);
    460           pSetCoeff0(p, pGetCoeff(t_p));
    461         }
     458        {
     459          p_ProjectiveUnique(t_p, tailRing);
     460          pSetCoeff0(p, pGetCoeff(t_p));
     461        }
    462462      else
    463         {
    464           p_Cleardenom(p, currRing);
    465         }
     463        {
     464#ifdef HAVE_RATGRING
     465          p_ProjectiveUnique(p, currRing);
     466#else
     467          p_ProjectiveUnique(p, currRing);
     468#endif
     469        }
    466470    }
    467471}
  • libpolys/polys/ext_fields/algext.cc

    r892dd8 rdc42daf  
    220220}
    221221
     222
    222223/* assumes that p and q are univariate polynomials in r,
    223224   mentioning the same variable;
     
    505506  poly aTimesB = p_Mult_q(p_Copy((poly)a, naRing),
    506507                          p_Copy((poly)b, naRing), naRing);
     508  definiteReduce(aTimesB, naMinpoly, cf);
    507509  p_Normalize(aTimesB,naRing);
    508   definiteReduce(aTimesB, naMinpoly, cf);
    509510  return (number)aTimesB;
    510511}
     
    520521    poly aDivB = p_Mult_q(p_Copy((poly)a, naRing), bInverse, naRing);
    521522    definiteReduce(aDivB, naMinpoly, cf);
     523    p_Normalize(aDivB,naRing);
    522524    return (number)aDivB;
    523525  }
     
    682684    pIter(bb);
    683685  }
     686  return h;
    684687}
    685688number naLcmContent(number a, number b, const coeffs cf)
    686689{
    687690  if (nCoeff_is_Zp(naRing->cf)) return naCopy(a,cf);
    688   else return ndGcd(a,b,cf);
    689   #if 0
     691#if 0
     692  else {
     693    number g = ndGcd(a, b, cf);
     694    return g;
     695  }
     696#else
    690697  {
    691698    a=(number)p_Copy((poly)a,naRing);
    692699    number t=napLcm(b,cf);
    693     if(!naIsOne(t,cf))
     700    if(!n_IsOne(t,naRing->cf))
    694701    {
    695702      number bt, rr;
     
    710717    return (number) a;
    711718  }
    712   #endif
     719#endif
    713720}
    714721
     
    11951202
    11961203  }
     1204
    11971205
    11981206  // part3: all coeffs = all coeffs / cand
  • libpolys/polys/monomials/p_polys.cc

    r892dd8 rdc42daf  
    24952495  if(pNext(p)==NULL)
    24962496  {
     2497    /*
    24972498    if (TEST_OPT_CONTENTSB)
    24982499    {
     
    25072508    }
    25082509    else
     2510    */
    25092511      p_SetCoeff(p,n_Init(1,r->cf),r);
    25102512
     
    25172519  assume(pNext(p)!=NULL);
    25182520
    2519 #if CLEARENUMERATORS
     2521#if 0 && CLEARENUMERATORS
     2522//CF: does not seem to work that well..
     2523 
    25202524  if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
    25212525  {
     
    28092813}
    28102814
     2815  // normalization: for poly over Q: make poly primitive, integral
     2816  //                              Qa make poly integral with leading
     2817  //                                  coefficient minimal in N
     2818  //                            Q(t) make poly primitive, integral
     2819
     2820void p_ProjectiveUnique(poly ph, const ring r)
     2821{
     2822  if( ph == NULL )
     2823    return;
     2824
     2825  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
     2826
     2827  poly start=ph;
     2828
     2829  number d, h;
     2830  poly p;
     2831
     2832#ifdef HAVE_RINGS
     2833  if (rField_is_Ring(r))
     2834  {
     2835    p_Content(ph,r);
     2836    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2837    if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
     2838    return;
     2839  }
     2840#endif
     2841
     2842  if (rField_is_Zp(r) && TEST_OPT_INTSTRATEGY)
     2843  {
     2844    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2845    if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
     2846    return;
     2847  }
     2848  p = ph;
     2849
     2850  assume(p != NULL);
     2851
     2852  if(pNext(p)==NULL) // a monomial
     2853  {
     2854    p_SetCoeff(p, n_Init(1, C), r);
     2855    return;
     2856  }
     2857
     2858  assume(pNext(p)!=NULL);
     2859
     2860  if(1)
     2861  {
     2862    h = p_GetCoeff(p, C);
     2863    number hInv = n_Invers(h, C);
     2864    pIter(p);
     2865    while (p!=NULL)
     2866    {
     2867      p_SetCoeff(p, n_Mult(p_GetCoeff(p, C), hInv, C), r);
     2868      pIter(p);
     2869    }
     2870    n_Delete(&hInv, C);
     2871    p = ph;
     2872    p_SetCoeff(p, n_Init(1, C), r);
     2873  }
     2874  p_Cleardenom(ph, r);
     2875  p_Content(ph, r);
     2876  return;
     2877}
     2878
    28112879number p_GetAllDenom(poly ph, const ring r)
    28122880{
  • libpolys/polys/monomials/p_polys.h

    r892dd8 rdc42daf  
    203203void      p_Norm(poly p1, const ring r);
    204204void      p_Normalize(poly p,const ring r);
     205void      p_ProjectiveUnique(poly p,const ring r);
    205206
    206207void      p_Content(poly p, const ring r);
Note: See TracChangeset for help on using the changeset viewer.