Changeset 6caa2a6 in git for factory


Ignore:
Timestamp:
Mar 22, 2012, 2:12:44 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
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
Location:
factory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • factory/facFqSquarefree.cc

    r9ebec2 r6caa2a6  
    8787  {
    8888    g= gcd (w, u);
    89     if (degree(g) > 0)
     89    if (!g.inCoeffDomain())
    9090      result.append (CFFactor (g, j));
    9191    w= w/g;
     
    9595    j++;
    9696  }
    97   if (degree(w) > 0)
     97  if (!w.inCoeffDomain())
    9898    result.append (CFFactor (w, j));
    9999  return result;
     
    132132        found= false;
    133133        CFFListIterator k= tmp2;
    134         if (!k.hasItem()) tmp2.append (j.getItem());
     134        if (!k.hasItem() && !j.getItem().factor().inCoeffDomain()) tmp2.append (j.getItem());
    135135        else
    136136        {
     
    144144            }
    145145          }
    146           if (found == false)
     146          if (found == false && !j.getItem().factor().inCoeffDomain())
    147147            tmp2.append(j.getItem());
    148148        }
     
    172172      i.getItem()= CFFactor (i.getItem().factor()/tmp, i.getItem().exp());
    173173      j.getItem()= CFFactor (j.getItem().factor()/tmp, j.getItem().exp());
    174       if (degree (tmp) > 0 && tmp.level() > 0)
     174      if (!tmp.inCoeffDomain())
    175175      {
    176176        tmp= M (tmp);
     
    182182  for (CFFListIterator i= tmp2; i.hasItem(); i++)
    183183  {
    184     if (degree (i.getItem().factor()) > 0 && i.getItem().factor().level() >= 0)
     184    if (!i.getItem().factor().inCoeffDomain())
    185185    {
    186186      tmp= M (i.getItem().factor());
     
    190190  for (CFFListIterator j= tmp1; j.hasItem(); j++)
    191191  {
    192     if (degree (j.getItem().factor()) > 0 && j.getItem().factor().level() >= 0)
     192    if (!j.getItem().factor().inCoeffDomain())
    193193    {
    194194      tmp= M (j.getItem().factor());
  • 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.