Changeset f78374 in git for factory/fac_sqrfree.cc


Ignore:
Timestamp:
Dec 13, 2011, 1:49:48 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
f41d12e69588befe7fc3383e41747d4ac6575de4
Parents:
3ef9c82a32b5b066dbd0e7b53857aa1fe70108a5
Message:
chg: more changes of squarefree decomposition according to master
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/fac_sqrfree.cc

    r3ef9c8 rf78374  
    99#include "canonicalform.h"
    1010#include "cf_map.h"
     11#include "cf_algorithm.h"
    1112
    1213static int divexp = 1;
     
    140141    if ( a.inCoeffDomain() )
    141142        return CFFactor( a, 1 );
    142     CanonicalForm cont = content( a );
    143     CanonicalForm aa = a / cont;
     143    CanonicalForm aa, LcA;
     144    if (isOn (SW_RATIONAL))
     145    {
     146      LcA= bCommonDen (a);
     147      aa= a*LcA;
     148    }
     149    else
     150    {
     151      LcA= icontent (a);
     152      if (lc (a).sign() < 0)
     153        LcA= -LcA;
     154      aa= a/LcA;
     155    }
     156    CanonicalForm cont = content( aa );
     157    aa /= cont;
    144158    CanonicalForm b = aa.deriv(), c = gcd( aa, b );
    145159    CanonicalForm y, z, w = aa / c;
     
    152166        if ( degree( z, v ) > 0 )
    153167        {
    154             if ( lc( z ).sign() < 0 )
    155                 F.append( CFFactor( -z, i ) );
    156             else
    157                 F.append( CFFactor( z, i ) );
     168          if (isOn (SW_RATIONAL))
     169          {
     170            z /= Lc (z);
     171            z *= bCommonDen (z);
     172          }
     173          if (lc (z).sign() < 0)
     174            z= -z;
     175          F.append( CFFactor( z, i ) );
    158176        }
    159177        i++;
     
    162180    if ( degree( w,v ) > 0 )
    163181    {
    164         if ( lc( w ).sign() < 0 )
    165             F.append( CFFactor( -w, i ) );
    166         else
    167             F.append( CFFactor( w, i ) );
     182      if (isOn (SW_RATIONAL))
     183      {
     184        w /= Lc (w);
     185        w *= bCommonDen (w);
     186      }
     187      if (lc (w).sign() < 0)
     188        w= -w;
     189      F.append( CFFactor( w, i ) );
    168190    }
    169191    if ( ! cont.isOne() )
    170         F = Union( F, sqrFreeZ( cont ) );
    171     if ( lc( a ).sign() < 0 )
    172     {
    173         if ( F.getFirst().exp() == 1 )
    174         {
    175             CanonicalForm f = F.getFirst().factor();
    176             CFFListIterator(F).getItem() = CFFactor( -f, 1 );
    177         }
    178         else
    179             F.insert( CFFactor( -1, 1 ) );
    180     }
     192    {
     193        CFFList buf= sqrFreeZ (cont);
     194        buf.removeFirst();
     195        F = Union( F, buf );
     196    }
     197    F.insert (CFFactor (LcA, 1));
    181198    return F;
    182199}
Note: See TracChangeset for help on using the changeset viewer.