Changeset f41d12 in git


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

chg: more changes of squarefree decomposition according to master
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_algorithm.h

    r3ef9c8 rf41d12  
    7070CFFList factorize ( const CanonicalForm & f, const Variable & alpha );
    7171
    72 CFFList sqrFree ( const CanonicalForm & f );
     72CFFList sqrFree ( const CanonicalForm & f, bool sort= false );
    7373
    7474bool isSqrFree ( const CanonicalForm & f );
  • factory/cf_factor.cc

    r3ef9c8 rf41d12  
    2626#include "cf_algorithm.h"
    2727#include "facFqFactorize.h"
     28#include "facFqSquarefree.h"
    2829#include "cf_map.h"
    2930#include "algext.h"
     
    829830}
    830831
    831 CFFList sqrFree ( const CanonicalForm & f )
     832CFFList sqrFree ( const CanonicalForm & f, bool sort )
    832833{
    833834//    ASSERT( f.isUnivariate(), "multivariate factorization not implemented" );
     
    837838        result = sqrFreeZ( f );
    838839    else
    839         result = sqrFreeFp( f );
    840 
    841     //return ( sort ? sortCFFList( result ) : result );
     840    {
     841        Variable alpha;
     842        if (hasFirstAlgVar (f, alpha))
     843          result = FqSqrf( f, alpha );
     844        else
     845          result= FpSqrf (f);
     846    }
     847    if (sort)
     848    {
     849      CFFactor buf= result.getFirst();
     850      result.removeFirst();
     851      result= sortCFFList (result);
     852      result.insert (buf);
     853    }
    842854    return result;
    843855}
  • factory/fac_multivar.cc

    r3ef9c8 rf41d12  
    361361    {
    362362        if ( i.getItem().factor().inCoeffDomain() )
    363         {
    364             if ( ! i.getItem().factor().isOne() )
    365                 R.append( CFFactor( i.getItem().factor(), i.getItem().exp() ) );
    366         }
     363            R.append( CFFactor( i.getItem().factor(), i.getItem().exp() ) );
    367364        else
    368365        {
  • 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}
  • libpolys/polys/clapsing.cc

    r3ef9c8 rf41d12  
    10351035  number N=NULL;
    10361036  number NN=NULL;
     1037  number old_lead_coeff=n_Copy(pGetCoeff(f), r->cf);
    10371038
    10381039  if (!rField_is_Zp(r) && !rField_is_Zp_a(r)) /* Q, Q(a) */
     
    11541155      res->m[0]=p_One(r);
    11551156    }
    1156   }
     1157    if (N!=NULL)
     1158    {
     1159      p_Mult_nn(res->m[0],N,r);
     1160      n_Delete(&N,r->cf);
     1161      N=NULL;
     1162    }
     1163  }
     1164  if (rField_is_Q_a(r) && (r->cf->extRing->minideal!=NULL))
     1165  {
     1166    int i=IDELEMS(res)-1;
     1167    int stop=1;
     1168    if (with_exps!=0) stop=0;
     1169    for(;i>=stop;i--)
     1170    {
     1171      p_Norm(res->m[i],r);
     1172    }
     1173    if (with_exps==0) p_SetCoeff(res->m[0],old_lead_coeff,r);
     1174    else n_Delete(&old_lead_coeff,r->cf);
     1175  }
     1176  else
     1177    n_Delete(&old_lead_coeff,r->cf);
    11571178  p_Delete(&f,r);
    11581179  errorreported=save_errorreported;
     
    11601181  if (res==NULL)
    11611182    WerrorS( feNotImplemented );
     1183  if (NN!=NULL)
     1184  {
     1185    n_Delete(&NN,r->cf);
     1186  }
     1187  if (N!=NULL)
     1188  {
     1189    n_Delete(&N,r->cf);
     1190  }
    11621191  return res;
    11631192}
Note: See TracChangeset for help on using the changeset viewer.