Ignore:
Timestamp:
Feb 11, 2013, 4:55:42 PM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
066b2f73d6d0f598eb063fc56982fb77c0db67b2
Parents:
c462b60ab56fe1781c7f591d40ccd2799acd6c92
Message:
opt: avoid pAdd, use pReverse in chinrem

from master
File:
1 edited

Legend:

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

    rc462b60 r0366c4  
    136136    else
    137137    {
     138      //Print("new mon:");pWrite(h);
    138139      p_SetCoeff(h,n,R);
    139       //Print("new mon:");pWrite(h);
    140       res_p=p_Add_q(res_p,h,R);
    141     }
    142   }
     140      pNext(h)=res_p;
     141      res_p=h; // building res_p in reverse order!
     142    }
     143  }
     144  res_p=pReverse(res_p);
     145  pTest(res_p);
    143146  return res_p;
    144147}
     
    234237
    235238          const short len_gen= o->data.am.len_gen;
    236          
     239
    237240          if ((c > 0) && (c <= len_gen))
    238241          {
     
    241244            ord += w[c];
    242245          }
    243          
     246
    244247          p->exp[o->data.am.place] = ord;
    245248          break;
     
    436439
    437440            assume( c < IDELEMS(F) ); // What about others???
    438            
     441
    439442            const poly pp = F->m[c]; // get reference monomial!!!
    440443
    441444            if(pp == NULL)
    442445              break;
    443            
     446
    444447            assume(pp != NULL);
    445448
     
    15711574  for (int i=rVar(r); i; --i)
    15721575    p_SetExp(m,i, si_max( p_GetExp(a,i,r), p_GetExp(b,i,r)),r);
    1573  
     1576
    15741577  p_SetComp(m, si_max(p_GetComp(a,r), p_GetComp(b,r)),r);
    15751578  /* Don't do a pSetm here, otherwise hres/lres chockes */
     
    19982001  assume( ph != NULL );
    19992002
    2000   assume( r != NULL ); assume( r->cf != NULL ); 
     2003  assume( r != NULL ); assume( r->cf != NULL );
    20012004
    20022005
     
    20162019  }
    20172020#endif
    2018  
    2019  
     2021
     2022
    20202023#ifdef HAVE_RINGS
    20212024  if (rField_is_Ring(r))
     
    20642067      p_Test(ph, r); n_Test(pGetCoeff(ph), r->cf);
    20652068      assume(n_GreaterZero(pGetCoeff(ph), r->cf)); // ??
    2066      
     2069
    20672070      // if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
    20682071      return;
    20692072    }
    20702073#endif
    2071    
     2074
    20722075    n_Normalize(pGetCoeff(ph),r->cf);
    20732076    if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
     
    21222125//    }
    21232126#endif
    2124     if (rField_is_Q_a(r)) 
     2127    if (rField_is_Q_a(r))
    21252128    {
    21262129      // we only need special handling for alg. ext.
     
    24462449
    24472450  assume( r != NULL ); assume( r->cf != NULL ); const coeffs C = r->cf;
    2448  
     2451
    24492452#if CLEARENUMERATORS
    24502453  if( 0 )
     
    24882491
    24892492  assume(p != NULL);
    2490  
     2493
    24912494  if(pNext(p)==NULL)
    24922495  {
     
    25072510    assume( n_GreaterZero(pGetCoeff(ph),C) );
    25082511    if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
    2509    
     2512
    25102513    return start;
    25112514  }
     
    25252528    assume(n_GreaterZero(pGetCoeff(ph), C)); // ??
    25262529//    if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
    2527    
     2530
    25282531    return start;
    25292532  }
     
    26242627  assume( n_GreaterZero(pGetCoeff(ph),C) );
    26252628  if(!n_GreaterZero(pGetCoeff(ph),C)) ph = p_Neg(ph,r);
    2626  
     2629
    26272630  return start;
    26282631}
     
    26432646
    26442647    n_ClearDenominators(itr, d, C); // multiply with common denom. d
    2645     n_ClearContent(itr, h, C); // divide by the content h 
    2646 
    2647     c = n_Div(d, h, C); // d/h 
     2648    n_ClearContent(itr, h, C); // divide by the content h
     2649
     2650    c = n_Div(d, h, C); // d/h
    26482651
    26492652    n_Delete(&d, C);
     
    26642667  }
    26652668#endif
    2666  
    2667  
     2669
     2670
    26682671  if( pNext(p) == NULL )
    26692672  {
     
    26772680      c = n_Neg(c, C);
    26782681    }
    2679    
     2682
    26802683    return;
    26812684  }
    26822685
    26832686  assume( pNext(p) != NULL );
    2684  
     2687
    26852688#if CLEARENUMERATORS
    26862689  if( nCoeff_is_Q(C) || nCoeff_is_Q_a(C) )
    26872690  {
    26882691    CPolyCoeffsEnumerator itr(ph);
    2689    
     2692
    26902693    n_ClearDenominators(itr, d, C); // multiply with common denom. d
    2691     n_ClearContent(itr, h, C); // divide by the content h 
    2692 
    2693     c = n_Div(d, h, C); // d/h 
     2694    n_ClearContent(itr, h, C); // divide by the content h
     2695
     2696    c = n_Div(d, h, C); // d/h
    26942697
    26952698    n_Delete(&d, C);
     
    27112714#endif
    27122715
    2713  
    2714  
     2716
     2717
    27152718
    27162719  if(1)
     
    28022805    c = n_Neg(c, C);
    28032806  }
    2804  
     2807
    28052808}
    28062809
     
    36193622  assume(dst != NULL);
    36203623  assume(dst->cf != NULL);
    3621  
     3624
    36223625  while (p != NULL)
    36233626  {
     
    36333636
    36343637      p_GetCoeff(qq, dst) = n;// Note: n can be a ZERO!!!
    3635       // coef may be zero: 
     3638      // coef may be zero:
    36363639//      p_Test(qq, dst);
    36373640    }
     
    36483651      if ( nCoeff_is_algExt(dst->cf) )
    36493652        p_Normalize(aq,dst);
    3650      
     3653
    36513654      if (aq == NULL)
    36523655        p_SetCoeff(qq, n_Init(0, dst->cf),dst); // Very dirty trick!!!
     
    40384041  assume( r1 == r2 || rSamePolyRep(r1, r2) ); // will be used in rEqual!
    40394042  assume( r1->cf == r2->cf );
    4040  
     4043
    40414044  while ((p1 != NULL) && (p2 != NULL))
    40424045  {
     
    40464049    if (! p_ExpVectorEqual(p1, p2, r1, r2))
    40474050      return FALSE;
    4048    
     4051
    40494052    if (! n_Equal(p_GetCoeff(p1,r1), p_GetCoeff(p2,r2), r1->cf ))
    40504053      return FALSE;
    4051    
     4054
    40524055    pIter(p1);
    40534056    pIter(p2);
     
    41204123    {
    41214124      a = next;
    4122       next = pNext(a);     
     4125      next = pNext(a);
    41234126      l++;
    41244127    }
Note: See TracChangeset for help on using the changeset viewer.