Changeset 6caa2a6 in git for factory/facFqSquarefree.h


Ignore:
Timestamp:
Mar 22, 2012, 2:12:44 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
8baf483af507d28dd83b7b3ad71d29b53b7cab06
Parents:
9ebec2d49d73d2930aed03c7b76f347cbf7537fa
git-author:
Martin Lee <martinlee84@web.de>2012-03-22 14:12:44+01:00
git-committer:
Martin Lee <martinlee84@web.de>2012-04-04 14:42:27+02:00
Message:
chg: avoid adding of constant factors to squarefree factorization
chg: divide out contents first in squarefree factorization
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/facFqSquarefree.h

    r9ebec2 r6caa2a6  
    1919#include "cf_assert.h"
    2020#include "cf_factory.h"
    21 
     21#include "fac_sqrfree.h"
    2222
    2323/// squarefree factorization over a finite field
     
    3737/// @return a list of squarefree factors with multiplicity
    3838inline
    39 CFFList FpSqrf (const CanonicalForm& F ///< [in] a poly
     39CFFList FpSqrf (const CanonicalForm& F, ///< [in] a poly
     40                bool sort= true         ///< [in] sort factors by exponent?
    4041               )
    4142{
    4243  Variable a= 1;
    43   CFFList result= squarefreeFactorization (F, a);
     44  int n= F.level();
     45  CanonicalForm cont, bufF= F;
     46  CFFList bufResult;
     47
     48  CFFList result;
     49  for (int i= n; i >= 1; i++)
     50  {
     51    cont= content (bufF, i);
     52    bufResult= squarefreeFactorization (cont, a);
     53    if (bufResult.getFirst().factor().inCoeffDomain())
     54      bufResult.removeFirst();
     55    result= Union (result, bufResult);
     56    bufF /= cont;
     57    if (bufF.inCoeffDomain())
     58      break;
     59  }
     60  if (!bufF.inCoeffDomain())
     61  {
     62    bufResult= squarefreeFactorization (bufF, a);
     63    if (bufResult.getFirst().factor().inCoeffDomain())
     64      bufResult.removeFirst();
     65    result= Union (result, bufResult);
     66  }
     67  if (sort)
     68    result= sortCFFList (result);
    4469  result.insert (CFFactor (Lc(F), 1));
    4570  return result;
     
    5277inline
    5378CFFList FqSqrf (const CanonicalForm& F, ///< [in] a poly
    54                 const Variable& alpha   ///< [in] algebraic variable
     79                const Variable& alpha,  ///< [in] algebraic variable
     80                bool sort= true         ///< [in] sort factors by exponent?
    5581               )
    5682{
    57   CFFList result= squarefreeFactorization (F, alpha);
     83  int n= F.level();
     84  CanonicalForm cont, bufF= F;
     85  CFFList bufResult;
     86
     87  CFFList result;
     88  for (int i= n; i >= 1; i++)
     89  {
     90    cont= content (bufF, i);
     91    bufResult= squarefreeFactorization (cont, alpha);
     92    if (bufResult.getFirst().factor().inCoeffDomain())
     93      bufResult.removeFirst();
     94    result= Union (result, bufResult);
     95    bufF /= cont;
     96    if (bufF.inCoeffDomain())
     97      break;
     98  }
     99  if (!bufF.inCoeffDomain())
     100  {
     101    bufResult= squarefreeFactorization (bufF, alpha);
     102    if (bufResult.getFirst().factor().inCoeffDomain())
     103      bufResult.removeFirst();
     104    result= Union (result, bufResult);
     105  }
     106  if (sort)
     107    result= sortCFFList (result);
    58108  result.insert (CFFactor (Lc(F), 1));
    59109  return result;
     
    65115/// @return a list of squarefree factors with multiplicity
    66116inline
    67 CFFList GFSqrf (const CanonicalForm& F ///< [in] a poly
     117CFFList GFSqrf (const CanonicalForm& F, ///< [in] a poly
     118                bool sort= true         ///< [in] sort factors by exponent?
    68119               )
    69120{
    70121  ASSERT (CFFactory::gettype() == GaloisFieldDomain,
    71122          "GF as base field expected");
    72   Variable a= 1;
    73   CFFList result= squarefreeFactorization (F, a);
    74   result.insert (CFFactor (Lc(F), 1));
    75   return result;
     123  return FpSqrf (F, sort);
    76124}
    77125
Note: See TracChangeset for help on using the changeset viewer.