Changeset f41d12 in git for factory/fac_sqrfree.cc


Ignore:
Timestamp:
Dec 13, 2011, 8:02:27 PM (12 years ago)
Author:
Oleksandr Motsak <motsak@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
0943bdd5f1e662166add7c3fed483d8971bd4108
Parents:
3ef9c82a32b5b066dbd0e7b53857aa1fe70108a5f78374aba946095faa511cce5808e17088898c1a
Message:
Merge pull request #33 from mmklee/factory_sqrfree_sw

chg: more changes of squarefree decomposition according to master
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/fac_sqrfree.cc

    r3ef9c8 rf41d12  
    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.