Changeset 98474f in git for libpolys/coeffs/numbers.cc


Ignore:
Timestamp:
Jul 17, 2012, 9:09:26 PM (11 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '2234726c50d679d6664181a5c72f75a6fd64a787')
Children:
975db1808b2b0917d858a9096710abc55c256aec
Parents:
805d0b10ffd62e7ff079f116851129cc4ae8f89d
git-author:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-07-17 21:09:26+02:00
git-committer:
Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-07-17 21:33:55+02:00
Message:
Abstract iterator/enumerator interfaces + dummies for ClearContent and ClearDenominators
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/numbers.cc

    r805d0b1 r98474f  
    123123
    124124int ndSize(number a, const coeffs r) { return (int)n_IsZero(a,r)==FALSE; }
     125
     126/// divide by the first (leading) number and return it, i.e. make monic
     127static void ndClearContent(ICoeffsEnumerator& numberCollectionEnumerator, number& c, const coeffs r)
     128{
     129  assume(r != NULL);
     130
     131  // no fractions
     132  assume(!(  nCoeff_is_Q(r) || nCoeff_is_Q_a(r) ));
     133  // all coeffs are given by integers!!!
     134  assume( nCoeff_is_Ring(r) || nCoeff_is_Zp(r) || nCoeff_is_numeric(r) || nCoeff_is_GF(r) || nCoeff_is_Zp_a(r) );
     135
     136  numberCollectionEnumerator.Reset();
     137 
     138#ifdef HAVE_RINGS
     139  /// TODO: move to a separate implementation
     140  if (nCoeff_is_Ring(r))
     141  {
     142    if (nCoeff_has_Units(r))
     143    {
     144      c = n_GetUnit(numberCollectionEnumerator.Current(), r);
     145     
     146      if (!n_IsOne(c, r))
     147      {
     148        number inv = n_Invers(c, r);
     149
     150        do
     151        {
     152          n_InpMult(numberCollectionEnumerator.Current(), inv, r);
     153        }
     154        while( numberCollectionEnumerator.MoveNext() );
     155
     156        n_Delete(&inv, r);       
     157      }     
     158    } else c = n_Init(1, r);
     159   
     160    return;
     161  }
     162#endif
     163
     164  assume(!nCoeff_is_Ring(r));
     165
     166  c = numberCollectionEnumerator.Current();
     167 
     168  n_Normalize(c, r);
     169
     170  if (!n_IsOne(c, r))
     171  {   
     172    numberCollectionEnumerator.Current() = n_Init(1, r); // ???
     173   
     174    number inv = n_Invers(c, r);
     175   
     176    while( numberCollectionEnumerator.MoveNext() )
     177    {
     178      number &n = numberCollectionEnumerator.Current();
     179      n_Normalize(n, r); // ?
     180      n_InpMult(n, inv, r);
     181    }
     182   
     183    n_Delete(&inv, r);
     184  }
     185}
     186
     187/// does nothing (just returns a dummy one number)
     188static void ndClearDenominators(ICoeffsEnumerator& /*numberCollectionEnumerator*/, number& d, const coeffs r)
     189{
     190  assume( r != NULL );
     191  assume( !(nCoeff_is_Q(r) || nCoeff_is_transExt(r)) );
     192  assume( nCoeff_is_Ring(r) || nCoeff_is_Zp(r) || nCoeff_is_numeric(r) || nCoeff_is_GF(r) || (getCoeffType(r)==n_algExt) );
     193
     194  d = n_Init(1, r);
     195}
    125196
    126197number ndCopy(number a, const coeffs) { return a; }
     
    262333    n->cfParameter = ndParameter;
    263334
     335    n->cfClearContent = ndClearContent;
     336    n->cfClearDenominators = ndClearDenominators;
     337
    264338#ifdef HAVE_RINGS
    265339    n->cfDivComp = ndDivComp;
     
    352426//    assume(n->cfInit_bigint!=NULL);
    353427    assume(n->cfCoeffWrite != NULL);
     428
     429    assume(n->cfClearContent != NULL);
     430    assume(n->cfClearDenominators != NULL);
     431   
    354432#ifdef LDEBUG
    355433    assume(n->cfDBTest!=NULL);
Note: See TracChangeset for help on using the changeset viewer.