Changeset 4f6d99 in git for factory/facAlgExt.cc


Ignore:
Timestamp:
Nov 14, 2012, 4:21:35 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
Children:
70c40f240ce667ca18d03028aae0c90552755245
Parents:
f6237dd32a31b0c8c58f56d6a808bda992e743fa
git-author:
Martin Lee <martinlee84@web.de>2012-11-14 16:21:35+01:00
git-committer:
Martin Lee <martinlee84@web.de>2012-11-16 13:23:04+01:00
Message:
chg: better recovery of factors in univariate factorization over Q(a)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facAlgExt.cc

    rf6237dd r4f6d99  
    3535TIMING_DEFINE_PRINT(fac_alg_sqrf)
    3636TIMING_DEFINE_PRINT(fac_alg_factor_sqrf)
     37TIMING_DEFINE_PRINT(fac_alg_time_shift)
    3738
    3839// squarefree part of F
     
    126127  ASSERT (degree (norm, alpha) <= 0, "wrong norm computed");
    127128  TIMING_START (fac_alg_factor_norm);
     129  bool save_sort= !isOn (SW_USE_NTL_SORT);
     130  On (SW_USE_NTL_SORT);
    128131  CFFList normFactors= factorize (norm);
     132  if (save_sort)
     133    Off (SW_USE_NTL_SORT);
    129134  TIMING_END_AND_PRINT (fac_alg_factor_norm, "time to factor norm: ");
    130135  CFList factors;
     
    136141
    137142  normFactors.removeFirst();
     143  CFFListIterator i= normFactors;
    138144  CanonicalForm buf;
    139   buf= f;
     145  bool shiftBuf= false;
     146  if (!(normFactors.length() == 2 && degree (i.getItem().factor()) <= degree (f)))
     147  {
     148    TIMING_START (fac_alg_time_shift);
     149    if (shift != 0)
     150      buf= f (f.mvar() - shift*alpha, f.mvar());
     151    else
     152      buf= f;
     153    shiftBuf= true;
     154    TIMING_END_AND_PRINT (fac_alg_time_shift, "time to shift: ");
     155  }
     156  else
     157    buf= f;
    140158  CanonicalForm factor;
    141159  int count= 0;
    142   for (CFFListIterator i= normFactors; i.hasItem(); i++)
     160  for (; i.hasItem(); i++)
    143161  {
    144162    ASSERT (i.getItem().exp() == 1, "norm not squarefree");
    145163    TIMING_START (fac_alg_gcd);
    146     if (shift == 0)
     164    if (shiftBuf)
    147165      factor= gcd (buf, i.getItem().factor());
    148166    else
    149       factor= gcd (buf, i.getItem().factor() (f.mvar() + shift*alpha, f.mvar()));
     167    {
     168      if (shift == 0)
     169        factor= gcd (buf, i.getItem().factor());
     170      else
     171        factor= gcd (buf, i.getItem().factor() (f.mvar() + shift*alpha, f.mvar()));
     172    }
    150173    buf /= factor;
     174    if (shiftBuf)
     175    {
     176      if (shift != 0)
     177        factor= factor (f.mvar() + shift*alpha, f.mvar());
     178    }
    151179    TIMING_END_AND_PRINT (fac_alg_gcd, "time to recover factors: ");
    152180    factors.append (factor);
     
    154182    if (normFactors.length() - 1 == count)
    155183    {
    156       factors.append (buf);
     184      if (shiftBuf)
     185        factors.append (buf (f.mvar() + shift*alpha, f.mvar()));
     186      else
     187        factors.append (buf);
    157188      buf= 1;
    158189      break;
Note: See TracChangeset for help on using the changeset viewer.