Changeset 2a4231 in git for libpolys


Ignore:
Timestamp:
Jun 29, 2015, 4:40:07 PM (9 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
74dcead93fa7d8032514e5919362facbb50b1c0e
Parents:
8e18ccc9b499f7dc190d8295d0c3f12184a9f764
Message:
fix: tr. #723
Location:
libpolys/polys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/ext_fields/transext.cc

    r8e18cc r2a4231  
    193193  {
    194194    p_Test(den, ntRing);
    195 
    196195    if(p_IsConstant(den, ntRing) && (n_IsOne(pGetCoeff(den), ntCoeffs)))
    197196    {
     
    199198      return FALSE;
    200199    }
    201 
    202200    if( !n_GreaterZero(pGetCoeff(den), ntCoeffs) )
    203201    {
     
    205203      return FALSE;
    206204    }
    207 
    208205    // test that den is over integers!?
    209 
    210   } else
     206  }
     207  else
    211208  {  // num != NULL // den == NULL
    212 
    213209//    if( COM(t) != 0 )
    214210//    {
     
    343339  if (IS0(a)) return NULL;
    344340  fraction f = (fraction)a;
    345   poly g = p_Copy(NUM(f), ntRing);
    346   poly h = NULL; if (!DENIS1(f)) h = p_Copy(DEN(f), ntRing);
    347   fraction result = (fraction)omAllocBin(fractionObjectBin);
    348   NUM(result) = g;
    349   DEN(result) = h;
     341  poly g = NUM(f);
     342  poly h = NULL;
     343  h =DEN(f);
     344  fraction result = (fraction)omAlloc0Bin(fractionObjectBin);
     345  NUM(result) = p_Copy(g,cf->extRing);
     346  DEN(result) = p_Copy(h,cf->extRing);
    350347  COM(result) = COM(f);
    351348  ntTest((number)result);
     
    384381    if( !n_GreaterZero(g, ntCoeffs) )
    385382    {
    386       NUM (f) = p_Neg(NUM (f), ntRing); // Ugly :(((
     383      NUM (f) = p_Neg(NUM (f), ntRing);
    387384      g = n_InpNeg(g, ntCoeffs);
    388385    }
     
    393390    if( !n_IsOne(g, ntCoeffs) )
    394391    {
    395       DEN (f) = p_NSet(g, ntRing); // update COM(f)???
     392      DEN (f) = p_NSet(g, ntRing);
    396393      COM (f) ++;
    397394      assume( DEN (f) != NULL );
     
    12501247
    12511248  if (IS0(a)) return;
     1249  if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
    12521250  if (!simpleTestsHaveAlreadyBeenPerformed)
    12531251  {
    1254     if (DENIS1(f) || NUMIS1(f)) { COM(f) = 0; return; }
    12551252
    12561253    /* check whether NUM(f) = DEN(f), and - if so - replace 'a' by 1 */
     
    12601257      p_Delete(&DEN(f), ntRing); DEN(f) = NULL;
    12611258      COM(f) = 0;
    1262       ntTest(a); // !!!!
     1259      ntTest(a);
    12631260      return;
    12641261    }
     
    14551452    //PrintS(" den=");p_wrp(DEN(a),ntRing);PrintLn();
    14561453    definiteGcdCancellation(a, cf, FALSE);
    1457     fraction f=(fraction)a;
    1458     if ((DEN(f)!=NULL)
    1459     &&(!n_GreaterZero(pGetCoeff(DEN(f)),ntCoeffs)))
    1460     {
    1461       NUM(f)=p_Neg(NUM(f),ntRing);
    1462       DEN(f)=p_Neg(DEN(f),ntRing);
    1463       a=(number)f;
     1454    if ((DEN((fraction)a)!=NULL)
     1455    &&(!n_GreaterZero(pGetCoeff(DEN((fraction)a)),ntCoeffs)))
     1456    {
     1457      NUM((fraction)a)=p_Neg(NUM((fraction)a),ntRing);
     1458      DEN((fraction)a)=p_Neg(DEN((fraction)a),ntRing);
    14641459    }
    14651460  }
     
    18431838  fraction f = (fraction)a;
    18441839  poly g = prMapR(NUM(f), nMap, rSrc, rDst);
     1840  /* g may contain summands with coeff 0 */
     1841  poly hh=g;
     1842  poly prev=NULL;
     1843  while(hh!=NULL)
     1844  {
     1845    if (n_IsZero(pGetCoeff(hh),rDst->cf))
     1846    {
     1847      if (prev==NULL)
     1848      {
     1849        g=p_LmFreeAndNext(g,rDst);
     1850        hh=g;
     1851      }
     1852      else
     1853      {
     1854        prev->next=p_LmFreeAndNext(prev->next,rDst);
     1855        hh=prev->next;
     1856      }
     1857    }
     1858    else
     1859    {
     1860      prev=hh;
     1861      pIter(hh);
     1862    }
     1863  }
     1864  if (g==NULL) return NULL;
    18451865
    18461866  poly h = NULL;
    18471867
    18481868  if (!DENIS1(f))
     1869  {
    18491870     h = prMapR(DEN(f), nMap, rSrc, rDst);
     1871     /* h may contain summands with coeff 0 */
     1872    hh=h;
     1873    prev=NULL;
     1874    while(hh!=NULL)
     1875    {
     1876      if (n_IsZero(pGetCoeff(hh),rDst->cf))
     1877      {
     1878        if (prev==NULL)
     1879        {
     1880          h=p_LmFreeAndNext(h,rDst);
     1881          hh=h;
     1882        }
     1883        else
     1884        {
     1885          prev->next=p_LmFreeAndNext(prev->next,rDst);
     1886          hh=prev->next;
     1887        }
     1888      }
     1889      else
     1890      {
     1891        prev=hh;
     1892        pIter(hh);
     1893      }
     1894    }
     1895    if (h==NULL) WerrorS("mapping to */0");
     1896  }
    18501897
    18511898  fraction result = (fraction)omAllocBin(fractionObjectBin);
  • libpolys/polys/monomials/p_polys.cc

    r8e18cc r2a4231  
    39053905    PrintS("\np_PermPoly::p: "); p_Write(p, oldRing, oldRing); PrintLn();
    39063906#endif
    3907 
    39083907  const int OldpVariables = rVar(oldRing);
    39093908  poly result = NULL;
     
    39113910  poly aq = NULL; /* the map coefficient */
    39123911  poly qq; /* the mapped monomial */
    3913 
    39143912  assume(dst != NULL);
    39153913  assume(dst->cf != NULL);
    3916 
    39173914  while (p != NULL)
    39183915  {
     
    39223919      qq = p_Init(dst);
    39233920      assume( nMap != NULL );
    3924 
    39253921      number n = nMap(p_GetCoeff(p, oldRing), oldRing->cf, dst->cf);
    3926 
    39273922      n_Test (n,dst->cf);
    3928 
    39293923      if ( nCoeff_is_algExt(dst->cf) )
    39303924        n_Normalize(n, dst->cf);
    3931 
    39323925      p_GetCoeff(qq, dst) = n;// Note: n can be a ZERO!!!
    3933       // coef may be zero:
    3934 //      p_Test(qq, dst);
    39353926    }
    39363927    else
    39373928    {
    39383929      qq = p_One(dst);
    3939 
    39403930//      aq = naPermNumber(p_GetCoeff(p, oldRing), par_perm, OldPar, oldRing); // no dst???
    39413931//      poly    n_PermNumber(const number z, const int *par_perm, const int P, const ring src, const ring dst)
    39423932      aq = n_PermNumber(p_GetCoeff(p, oldRing), par_perm, OldPar, oldRing, dst);
    3943 
    39443933      p_Test(aq, dst);
    3945 
    39463934      if ( nCoeff_is_algExt(dst->cf) )
    39473935        p_Normalize(aq,dst);
    3948 
    39493936      if (aq == NULL)
    39503937        p_SetCoeff(qq, n_Init(0, dst->cf),dst); // Very dirty trick!!!
    3951 
    39523938      p_Test(aq, dst);
    39533939    }
    3954 
    39553940    if (rRing_has_Comp(dst))
    39563941       p_SetComp(qq, p_GetComp(p, oldRing), dst);
    3957 
    39583942    if ( n_IsZero(pGetCoeff(qq), dst->cf) )
    39593943    {
     
    39813965              assume( dst->cf->extRing == NULL );
    39823966              number ee = n_Param(1, dst);
    3983 
    39843967              number eee;
    39853968              n_Power(ee, e, &eee, dst->cf); //nfDelete(ee,dst);
    3986 
    39873969              ee = n_Mult(c, eee, dst->cf);
    39883970              //nfDelete(c,dst);nfDelete(eee,dst);
     
    39933975              const int par = -perm[i];
    39943976              assume( par > 0 );
    3995 
    39963977//              WarnS("longalg missing 3");
    39973978#if 1
    39983979              const coeffs C = dst->cf;
    39993980              assume( C != NULL );
    4000 
    40013981              const ring R = C->extRing;
    40023982              assume( R != NULL );
    4003 
    40043983              assume( par <= rVar(R) );
    4005 
    40063984              poly pcn; // = (number)c
    4007 
    40083985              assume( !n_IsZero(c, C) );
    4009 
    40103986              if( nCoeff_is_algExt(C) )
    40113987                 pcn = (poly) c;
    40123988               else //            nCoeff_is_transExt(C)
    40133989                 pcn = NUM((fraction)c);
    4014 
    40153990              if (pNext(pcn) == NULL) // c->z
    40163991                p_AddExp(pcn, -perm[i], e, R);
     
    40203995                p_SetExp(mmc, -perm[i], e, R);
    40213996                p_Setm(mmc, R);
    4022 
    40233997                number nnc;
    40243998                // convert back to a number: number nnc = mmc;
     
    40274001                else //            nCoeff_is_transExt(C)
    40284002                  nnc = ntInit(mmc, C);
    4029 
    40304003                p_GetCoeff(qq, dst) = n_Mult((number)c, nnc, C);
    40314004                n_Delete((number *)&c, C);
    40324005                n_Delete((number *)&nnc, C);
    40334006              }
    4034 
    40354007              mapped_to_par=1;
    40364008#endif
     
    40754047      if (aq!=NULL)
    40764048         qq=p_Mult_q(aq,qq,dst);
    4077 
    40784049      aq = qq;
    4079 
    40804050      while (pNext(aq) != NULL) pIter(aq);
    4081 
    40824051      if (result_last==NULL)
    40834052      {
     
    40964065    }
    40974066  }
    4098 
    40994067  result=p_SortAdd(result,dst);
    41004068#else
     
    41274095#endif
    41284096  p_Test(result,dst);
    4129 
    41304097#if 0
    41314098  p_Test(result,dst);
Note: See TracChangeset for help on using the changeset viewer.