Changeset 8d341e in git


Ignore:
Timestamp:
Sep 10, 2012, 2:31:22 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'fc741b6502fd8a97288eaa3eba6e5220f3c3df87')
Children:
fff61504bea4abfcad24fecfcec903e476caa188
Parents:
9952bd4644408a55960f0436312937dc4ea343e8
Message:
Switchable use of n_ClearContent&n_ClearDenominators for p_Content&p_Cleardenom (/Q!)

chg: p_Cleardenom(_n) should call clear content after clearing denominators, i.e. n_ClearContent is to be called after n_ClearDenominators
chg: old handling of a single term: clear the coeff.
add: assume positive leading coeff for results of p_Content&p_Cleardenom


NOTE: CLEARENUMERATORS is false here!
File:
1 edited

Legend:

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

    r9952bd r8d341e  
    20232023static number p_InitContent(poly ph, const ring r);
    20242024
     2025#define CLEARENUMERATORS 0
     2026
    20252027void p_Content(poly ph, const ring r)
    20262028{
    2027 #if 0
    2028   if( ph != NULL )
     2029#if CLEARENUMERATORS
     2030  if( (ph != NULL) && nCoeff_is_Q(r->cf) )
    20292031  {
    20302032    CPolyCoeffsEnumerator itr(ph);
    20312033    n_ClearContent(itr, r->cf);
    2032 //    return;
    2033   }
    2034 #endif
    2035 
    2036  
     2034
     2035    assume( n_GreaterZero(pGetCoeff(ph),r->cf) );
     2036   
     2037    return;
     2038  }
     2039#endif
     2040
    20372041#ifdef HAVE_RINGS
    20382042  if (rField_is_Ring(r))
     
    20532057          pIter(h);
    20542058        }
     2059        assume( n_GreaterZero(pGetCoeff(ph),r->cf) );
    20552060      }
    20562061      n_Delete(&k,r->cf);
     
    20692074  else
    20702075  {
     2076#if CLEARENUMERATORS
     2077    if( (ph != NULL) && nCoeff_is_Q(r->cf) )
     2078    {
     2079      CPolyCoeffsEnumerator itr(ph);
     2080      n_ClearContent(itr, r->cf);
     2081      assume( n_GreaterZero(pGetCoeff(ph),r->cf) );
     2082      return;
     2083    }
     2084#endif
     2085   
    20712086    n_Normalize(pGetCoeff(ph),r->cf);
    20722087    if(!n_GreaterZero(pGetCoeff(ph),r->cf)) ph = p_Neg(ph,r);
     
    24412456poly p_Cleardenom(poly ph, const ring r)
    24422457{
     2458  const coeffs C = r->cf;
     2459
    24432460  poly start=ph;
    24442461
    2445 #if 0
    2446   if( ph != NULL )
     2462#if CLEARENUMERATORS
     2463  if( (ph != NULL) && nCoeff_is_Q(C) )
    24472464  {
    24482465    CPolyCoeffsEnumerator itr(ph);
    2449     n_ClearDenominators(itr, r->cf);
    2450     //  return start;
    2451   }
    2452 #endif
    2453 
     2466    n_ClearDenominators(itr, C);
     2467    n_ClearContent(itr, C); // divide out the content
     2468
     2469    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2470   
     2471    return start;
     2472  }
     2473#endif
     2474 
    24542475  number d, h;
    24552476  poly p;
     
    24592480  {
    24602481    p_Content(ph,r);
     2482    assume( n_GreaterZero(pGetCoeff(ph),C) );
    24612483    return start;
    24622484  }
    24632485#endif
    2464   if (rField_is_Zp(r) && TEST_OPT_INTSTRATEGY) return start;
     2486
     2487  if (rField_is_Zp(r) && TEST_OPT_INTSTRATEGY)
     2488  {
     2489    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2490    return start;
     2491  }
    24652492  p = ph;
     2493
     2494  assume(p != NULL);
     2495 
    24662496  if(pNext(p)==NULL)
    24672497  {
     
    24792509    else
    24802510      p_SetCoeff(p,n_Init(1,r->cf),r);
    2481   }
    2482   else
     2511
     2512    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2513   
     2514    return start;
     2515  }
     2516
     2517#if CLEARENUMERATORS
     2518  if( (ph != NULL) && nCoeff_is_Q(C) )
     2519  {
     2520    CPolyCoeffsEnumerator itr(ph);
     2521    n_ClearDenominators(itr, C);
     2522    n_ClearContent(itr, C); // divide out the content
     2523
     2524    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2525   
     2526    return start;
     2527  }
     2528#endif
     2529
     2530  if(1)
    24832531  {
    24842532    h = n_Init(1,r->cf);
     
    25712619#endif
    25722620  }
     2621
     2622  assume( n_GreaterZero(pGetCoeff(ph),C) );
     2623 
    25732624  return start;
    25742625}
     
    25762627void p_Cleardenom_n(poly ph,const ring r,number &c)
    25772628{
    2578 #if 0
    2579   if( ph != NULL )
    2580   {
    2581     CPolyCoeffsEnumerator itr(ph);
    2582     n_ClearDenominators(itr, c, r->cf);
    2583 //    return;
    2584   }
    2585 #endif
    2586  
     2629  const coeffs C = r->cf;
    25872630  number d, h;
    25882631  poly p;
    25892632
    25902633  p = ph;
     2634
     2635  assume(ph != NULL);
     2636
     2637
     2638
     2639#if CLEARENUMERATORS
     2640  if( (ph != NULL) && nCoeff_is_Q(C) )
     2641  {
     2642    CPolyCoeffsEnumerator itr(ph);
     2643    n_ClearDenominators(itr, d, C); // multiply with common denom. d
     2644    n_ClearContent(itr, h, C); // divide by the content h
     2645
     2646    c = n_Div(d, h, C); // d/h
     2647
     2648    n_Delete(&d, C);
     2649    n_Delete(&h, C);
     2650
     2651    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2652   
     2653    return;
     2654  }
     2655#endif
     2656 
    25912657  if(pNext(p)==NULL)
    25922658  {
    2593     c=n_Invers(pGetCoeff(p),r->cf);
    2594     p_SetCoeff(p,n_Init(1,r->cf),r);
    2595   }
    2596   else
     2659    c=n_Invers(pGetCoeff(p), C);
     2660    p_SetCoeff(p, n_Init(1, C), r);
     2661
     2662    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2663   
     2664    return;
     2665  }
     2666
     2667#if CLEARENUMERATORS
     2668  if( (ph != NULL) && nCoeff_is_Q(C) )
     2669  {
     2670    CPolyCoeffsEnumerator itr(ph);
     2671    n_ClearDenominators(itr, d, C); // multiply with common denom. d
     2672    n_ClearContent(itr, h, C); // divide by the content h
     2673
     2674    c = n_Div(d, h, C); // d/h
     2675
     2676    n_Delete(&d, C);
     2677    n_Delete(&h, C);
     2678
     2679    assume( n_GreaterZero(pGetCoeff(ph),C) );
     2680   
     2681    return;
     2682  }
     2683#endif
     2684
     2685 
     2686 
     2687
     2688  if(1)
    25972689  {
    25982690    h = n_Init(1,r->cf);
     
    26762768    }
    26772769  }
     2770
     2771  assume( n_GreaterZero(pGetCoeff(ph),C) );
    26782772}
    26792773
Note: See TracChangeset for help on using the changeset viewer.