Changeset cae0b6 in git


Ignore:
Timestamp:
Oct 10, 2002, 7:43:40 PM (21 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
Children:
7724a3281f0baa9aa017ab10865fcac877d85684
Parents:
cbe9af8559b8f0a37f140c253c032b29f7d4103a
Message:
* hannes: NTL and multivar. poly in char 0


git-svn-id: file:///usr/local/Singular/svn/trunk@6261 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
factory
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • factory/NTLconvert.cc

    rcbe9af8 rcae0b6  
    1 /* $Id: NTLconvert.cc,v 1.3 2002-08-19 11:10:41 Singular Exp $ */
     1/* $Id: NTLconvert.cc,v 1.4 2002-10-10 17:43:38 Singular Exp $ */
    22#include <config.h>
    33
     
    586586  // Start by appending the multiplicity
    587587
    588   if (!IsOne(multi))
     588  //if (!IsOne(multi))
    589589    rueckgabe.append(CFFactor(convertZZ2CF(multi),1));
    590590
  • factory/cf_factor.cc

    rcbe9af8 rcae0b6  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_factor.cc,v 1.15 2002-09-24 11:28:29 Singular Exp $ */
     2/* $Id: cf_factor.cc,v 1.16 2002-10-10 17:43:39 Singular Exp $ */
    33
    44//{{{ docu
     
    174174  if ( f.inCoeffDomain() )
    175175        return CFFList( f );
     176  //out_cf("factorize:",f,"==================================\n");
    176177  int mv=f.level();
     178  int org_v=mv;
    177179  if (! f.isUnivariate() )
    178180  {
    179181    mv=find_mvar(f);
    180     if (mv!=f.level())
    181     {
    182       swapvar(f,Variable(mv),f.mvar());
    183     }
    184     if ( getCharacteristic() == 0 ) Off(SW_USE_NTL);
     182    if ( getCharacteristic() > 0 )
     183    {
     184      if (mv!=f.level())
     185      {
     186        swapvar(f,Variable(mv),f.mvar());
     187      }
     188    }
     189    else
     190    {
     191      if (mv!=1)
     192      {
     193        swapvar(f,Variable(mv),Variable(1));
     194        org_v=1;
     195      }
     196    }
    185197  }
    186198  CFFList F;
     
    274286            F.insert( CFFactor( ic ) );
    275287        }
    276         if ( F.getFirst().factor().isOne() )
    277         {
    278           F.removeFirst();
    279         }
     288        else
     289        {
     290          if ( !F.getFirst().factor().inCoeffDomain() )
     291          {
     292            CFFactor new_first( 1 );
     293            F.insert( new_first );
     294          }
     295        }
     296        //if ( F.getFirst().factor().isOne() )
     297        //{
     298        //  F.removeFirst();
     299        //}
    280300      }
    281301      else
     
    306326  }
    307327
    308   if ((mv!=f.level()) && (! f.isUnivariate() ))
     328  if ((mv!=org_v) && (! f.isUnivariate() ))
    309329  {
    310330    CFFListIterator J=F;
    311331    for ( ; J.hasItem(); J++)
    312332    {
    313       swapvar(J.getItem().factor(),Variable(mv),f.mvar());
    314     }
    315     swapvar(f,Variable(mv),f.mvar());
    316   }
     333      swapvar(J.getItem().factor(),Variable(mv),Variable(org_v));
     334    }
     335    swapvar(f,Variable(mv),Variable(org_v));
     336  }
     337  //out_cff(F);
    317338  return F;
    318339}
     340
    319341#ifdef HAVE_NTL
    320342CanonicalForm fntl ( const CanonicalForm & f, int j )
  • factory/fac_distrib.cc

    rcbe9af8 rcae0b6  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fac_distrib.cc,v 1.6 1997-10-09 14:47:17 schmidt Exp $ */
     2/* $Id: fac_distrib.cc,v 1.7 2002-10-10 17:43:40 Singular Exp $ */
    33
    44#include <config.h>
     
    2222    d[0] = delta * omega;
    2323    for ( int i = 1; i <= k; i++ ) {
    24         q = abs(F[i]);
    25         for ( int j = i-1; j >= 0; j-- ) {
    26             r = d[j];
    27             do {
    28                 r = gcd( r, q );
    29                 q = q / r;
    30             } while ( r != 1 );
    31             if ( q == 1 ) {
    32                 DEBDECLEVEL( cerr, "nonDivisors" );
    33                 return false;
    34             }
    35         }
    36         d[i] = q;
     24        q = abs(F[i]);
     25        for ( int j = i-1; j >= 0; j-- ) {
     26            r = d[j];
     27            do {
     28                r = gcd( r, q );
     29                q = q / r;
     30            } while ( r != 1 );
     31            if ( q == 1 ) {
     32                DEBDECLEVEL( cerr, "nonDivisors" );
     33                return false;
     34            }
     35        }
     36        d[i] = q;
    3737    }
    3838    DEBDECLEVEL( cerr, "nonDivisors" );
     
    5050    Vn = A( lcU );
    5151    if ( Vn.isZero() )
    52         return false;
     52        return false;
    5353    delta = content( U0 );
    5454    for ( I = F, j = 1; I.hasItem(); I++, j++ )
    55         FF[j] = A( I.getItem().factor() );
     55        FF[j] = A( I.getItem().factor() );
    5656    return nonDivisors( omega, delta, FF, D );
    5757}
     
    6767    lcG = CFArray( 1, r );
    6868    for ( j = 1; j <= r; j ++ )
    69         lcG[j] = 1;
     69        lcG[j] = 1;
    7070
    7171    for ( I = F, i = 1; I.hasItem(); I++, i++ ) {
    72         ft = I.getItem().factor();
    73         m = I.getItem().exp();
    74         DEBOUTLN( cerr, "trying to distribute " << ft );
    75         DEBOUTLN( cerr, "which is tested with " << D[i] );
    76         DEBOUTLN( cerr, "and contained to the power of " << m );
    77         j = 1;
    78         while ( m > 0 && j <= r ) {
    79             ut = lc( G[j] );
    80             DEBOUTLN( cerr, "checking with " << ut );
    81             while ( m > 0 && divides( D[i], ut ) ) {
    82                 DEBOUTLN( cerr, "match found" );
    83                 m--; ut /= D[i];
    84                 lcG[j] *= ft;
    85             }
    86             j++;
    87         }
    88         if (m != 0) {
    89             DEBDECLEVEL( cerr, "distributeLeadingCoeffs" );
    90             return false;
    91         }
     72        ft = I.getItem().factor();
     73        m = I.getItem().exp();
     74        DEBOUTLN( cerr, "trying to distribute " << ft );
     75        DEBOUTLN( cerr, "which is tested with " << D[i] );
     76        DEBOUTLN( cerr, "and contained to the power of " << m );
     77        j = 1;
     78        while ( m > 0 && j <= r ) {
     79            ut = lc( G[j] );
     80            DEBOUTLN( cerr, "checking with " << ut );
     81            while ( m > 0 && divides( D[i], ut ) ) {
     82                DEBOUTLN( cerr, "match found" );
     83                m--; ut /= D[i];
     84                lcG[j] *= ft;
     85            }
     86            j++;
     87        }
     88        if (m != 0) {
     89            DEBDECLEVEL( cerr, "distributeLeadingCoeffs" );
     90            return false;
     91        }
    9292    }
    9393    DEBOUTLN( cerr, "the leading coeffs before omega and delta correction: " << lcG );
    9494    if ( omega != 1 ) {
    95         for ( j = 1; j <= r; j++ ) {
    96 //          G[j] *= omega;
    97             lcG[j] *= omega;
    98             G[j] = G[j] * ( A( lcG[j] ) / lc( G[j] ) );
    99         }
    100         U *= power( omega, r-1 );
     95        for ( j = 1; j <= r; j++ ) {
     96//            G[j] *= omega;
     97            lcG[j] *= omega;
     98            G[j] = G[j] * ( A( lcG[j] ) / lc( G[j] ) );
     99        }
     100        U *= power( omega, r-1 );
    101101    }
    102102    if ( delta != 1 ) {
    103         for ( j = 1; j <= r; j++ ) {
    104             lcG[j] *= delta;
    105             G[j] = G[j] * ( A( lcG[j] ) / lc( G[j] ) );
    106         }
    107         U *= power( delta, r );
     103        for ( j = 1; j <= r; j++ ) {
     104            lcG[j] *= delta;
     105            G[j] = G[j] * ( A( lcG[j] ) / lc( G[j] ) );
     106        }
     107        U *= power( delta, r );
    108108    }
    109109    DEBDECLEVEL( cerr, "distributeLeadingCoeffs" );
     
    116116{
    117117    if ( F.isOne() )
    118         return;
     118        return;
    119119    if ( L.isEmpty() ) {
    120         L.append( F );
    121         return;
     120        L.append( F );
     121        return;
    122122    }
    123123    CanonicalForm h, f = F;
    124124    CFListIterator i, j;
    125125    for ( i = L; i.hasItem() && ! f.isOne(); ) {
    126         h = gcd( f, i.getItem() );
    127         if ( h.isOne() ) {
    128             i++;
    129             continue;
    130         }
    131         while ( divides( h, f ) )
    132             f /= h;
    133         CFList D( h );
    134         gfbAdjoin( i.getItem() / h, D );
    135         for ( j = D; j.hasItem(); j++ )
    136             i.append( j.getItem() );
    137         i.remove( true );
     126        h = gcd( f, i.getItem() );
     127        if ( h.isOne() ) {
     128            i++;
     129            continue;
     130        }
     131        while ( divides( h, f ) )
     132            f /= h;
     133        CFList D( h );
     134        gfbAdjoin( i.getItem() / h, D );
     135        for ( j = D; j.hasItem(); j++ )
     136            i.append( j.getItem() );
     137        i.remove( true );
    138138    }
    139139    if ( ! f.isOne() )
    140         L.append( f );
     140        L.append( f );
    141141}
    142142
     
    148148    CFList R;
    149149    for ( i = L; i.hasItem(); i++ )
    150         gfbAdjoin( i.getItem(), R );
     150        gfbAdjoin( i.getItem(), R );
    151151    return R;
    152152}
     
    159159    CFArray lcG(1,n);
    160160    for ( int i = 1; i <= n; i++ ) {
    161         G[i] *= A(l)/lc(G[i]);
    162         lcG[i] = l;
     161        G[i] *= A(l)/lc(G[i]);
     162        lcG[i] = l;
    163163    }
    164164    return Hensel( U * power( l, n-1 ), G, lcG, A, bound, x );
     
    171171    CFArray TrueLcs(1, n);
    172172    for (i=1; i <= n; i++)
    173         TrueLcs[i] = 1;
     173        TrueLcs[i] = 1;
    174174    Variable y;
    175175    CanonicalForm lcU = LC ( U, Variable(1) );
    176176    while (! lcU.inCoeffDomain())
    177177    {
    178         y = lcU.mvar(); // should make a more intelligent choice
    179         CanonicalForm BivariateU = A ( U, 2, y.level() - 1 );
    180         CFArray BivariateFactors = G;
    181         CFArray lcFactors(1,n);
    182         Univar2Bivar(BivariateU, BivariateFactors, A, bound, y);
    183         for (i = 1; i <= n; i++)
    184         {
    185             BivariateFactors[i] /= content(BivariateFactors[i]);
    186             lcFactors[i] = LC(BivariateFactors[i],Variable(1));
    187         }
    188 //      GFB = GcdFreeBasis(lcFactors); // this is not right... should probably make everything squarefree
    189 //      Hensel2(lcU, GFB, A, bound, y);
     178        y = lcU.mvar(); // should make a more intelligent choice
     179        CanonicalForm BivariateU = A ( U, 2, y.level() - 1 );
     180        CFArray BivariateFactors = G;
     181        CFArray lcFactors(1,n);
     182        Univar2Bivar(BivariateU, BivariateFactors, A, bound, y);
     183        for (i = 1; i <= n; i++)
     184        {
     185            BivariateFactors[i] /= content(BivariateFactors[i]);
     186            lcFactors[i] = LC(BivariateFactors[i],Variable(1));
     187        }
     188//        GFB = GcdFreeBasis(lcFactors); // this is not right... should probably make everything squarefree
     189//        Hensel2(lcU, GFB, A, bound, y);
    190190    }
    191191    for (i = 1; i <= n; i++)
    192         G[i] *= A(TrueLcs[i])/lc(G[i]);
     192        G[i] *= A(TrueLcs[i])/lc(G[i]);
    193193    return Hensel(U, G, TrueLcs, A, bound, x);
    194194}
  • factory/fac_multihensel.cc

    rcbe9af8 rcae0b6  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fac_multihensel.cc,v 1.7 2001-01-19 18:11:51 Singular Exp $ */
     2/* $Id: fac_multihensel.cc,v 1.8 2002-10-10 17:43:40 Singular Exp $ */
    33
    44#include <config.h>
     
    229229    DEBOUTLN( cerr, "we are now performing the liftstep to reach " << Variable(k) );
    230230    DEBOUTLN( cerr, "the factors so far are " << P );
     231    DEBOUTLN( cerr, "modulus p^k= " << b.getpk() << "=" << b.getp() <<"^"<< b.getk() );
    231232
    232233    for ( i = 1; i <= r; i++ ) {
  • factory/fac_multivar.cc

    rcbe9af8 rcae0b6  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fac_multivar.cc,v 1.8 1998-03-12 14:30:55 schmidt Exp $ */
     2/* $Id: fac_multivar.cc,v 1.9 2002-10-10 17:43:40 Singular Exp $ */
    33
    44#include <config.h>
     
    1717#include "cf_binom.h"
    1818#include "cf_iter.h"
     19#include "cf_primes.h"
    1920#include "fac_distrib.h"
    2021
     
    3334
    3435    if ( ! I.hasItem() )
    35         n = 0;
     36        n = 0;
    3637    else  if ( I.getItem().factor().inBaseDomain() ) {
    37         negate = I.getItem().factor().sign() < 0;
    38         I++;
    39         n = L.length();
     38        negate = I.getItem().factor().sign() < 0;
     39        I++;
     40        n = L.length();
    4041    }
    4142    else
    42         n = L.length() + 1;
     43        n = L.length() + 1;
    4344    CFFListIterator J = I;
    4445    while ( J.hasItem() ) {
    45         n += J.getItem().exp() - 1;
    46         J++;
     46        n += J.getItem().exp() - 1;
     47        J++;
    4748    }
    4849    CFArray result( 1, n-1 );
     
    5051    i = 1;
    5152    while ( I.hasItem() ) {
    52         k = I.getItem().exp();
    53         for ( j = 1; j <= k; j++ ) {
    54             result[i] = I.getItem().factor();
    55             i++;
    56         }
    57         I++;
     53        k = I.getItem().exp();
     54        for ( j = 1; j <= k; j++ ) {
     55            result[i] = I.getItem().factor();
     56            i++;
     57        }
     58        I++;
    5859    }
    5960    if ( negate )
    60         result[1] = -result[1];
     61        result[1] = -result[1];
    6162    return result;
    6263}
     
    6869    int M = 0, i, k = f.level();
    6970    for ( i = 1; i <= k; i++ )
    70         M += degs[i];
     71        M += degs[i];
    7172    CanonicalForm b = 2 * maxNorm( f ) * power( CanonicalForm( 3 ), M );
    7273    CanonicalForm B = p;
    7374    k = 1;
    7475    while ( B < b ) {
    75         B *= p;
    76         k++;
     76        B *= p;
     77        k++;
    7778    }
    7879    return modpk( p, k );
     
    9091//     d[0] = delta * omega;
    9192//     for ( int i = 1; i <= k; i++ ) {
    92 //      q = abs(F[i]);
    93 //      for ( int j = i-1; j >= 0; j-- ) {
    94 //          r = d[j];
    95 //          do {
    96 //              r = gcd( r, q );
    97 //              q = q / r;
    98 //          } while ( r != 1 );
    99 //          if ( q == 1 )
    100 //              return false;
    101 //      }
    102 //      d[i] = q;
     93//         q = abs(F[i]);
     94//         for ( int j = i-1; j >= 0; j-- ) {
     95//             r = d[j];
     96//             do {
     97//                 r = gcd( r, q );
     98//                 q = q / r;
     99//             } while ( r != 1 );
     100//             if ( q == 1 )
     101//                 return false;
     102//         }
     103//         d[i] = q;
    103104//     }
    104105//     return true;
     
    115116    CFArray FF = CFArray( 1, F.length() );
    116117    if ( r > 0 )
    117         A.nextpoint();
     118        A.nextpoint();
    118119    while ( ! found ) {
    119         Vn = A( V );
    120         if ( Vn != 0 ) {
    121             U0 = A( U );
    122             DEBOUTLN( cerr, "U0 = " << U0 );
    123             if ( isSqrFree( U0 ) ) {
    124                 delta = content( U0 );
    125                 DEBOUTLN( cerr, "content( U0 ) = " << delta );
    126                 for ( I = F, j = 1; I.hasItem(); I++, j++ )
    127                     FF[j] = A( I.getItem().factor() );
    128                 found = nonDivisors( omega, delta, FF, D );
    129             }
    130             else {
    131                 DEBOUTLN( cerr, "not sqrfree : " << sqrFree( U0 ) );
    132             }
    133         }
    134         if ( ! found )
    135             A.nextpoint();
     120        Vn = A( V );
     121        if ( Vn != 0 ) {
     122            U0 = A( U );
     123            DEBOUTLN( cerr, "U0 = " << U0 );
     124            if ( isSqrFree( U0 ) ) {
     125                delta = content( U0 );
     126                DEBOUTLN( cerr, "content( U0 ) = " << delta );
     127                for ( I = F, j = 1; I.hasItem(); I++, j++ )
     128                    FF[j] = A( I.getItem().factor() );
     129                found = nonDivisors( omega, delta, FF, D );
     130            }
     131            else {
     132                DEBOUTLN( cerr, "not sqrfree : " << sqrFree( U0 ) );
     133            }
     134        }
     135        if ( ! found )
     136            A.nextpoint();
    136137    }
    137138    DEBDECLEVEL( cerr, "findEvaluation" );
    138139}
     140
     141#ifdef HAVE_NTL
     142int prime_number=0;
     143void find_good_prime(const CanonicalForm &f, const CanonicalForm &r,int &start)
     144{
     145  if (! f.inBaseDomain() )
     146  {
     147    int l = f.level();
     148    for ( CFIterator i = f; i.hasTerms(); i++ )
     149    {
     150      find_good_prime(i.coeff(),r,start);
     151    }
     152  }
     153  else
     154  {
     155    if(mod(f,cf_getSmallPrime(start))==0)
     156    {
     157      start++;
     158      CanonicalForm ff=r;
     159      find_good_prime(ff,r,start);
     160    }
     161  }
     162}
     163#endif
    139164
    140165static CFArray
     
    165190    maxdeg = 0;
    166191    for ( i = 2; i <= t; i++ ) {
    167         j = U.degree( Variable( i ) );
    168         if ( j > maxdeg ) maxdeg = j;
     192        j = U.degree( Variable( i ) );
     193        if ( j > maxdeg ) maxdeg = j;
    169194    }
    170195
    171196    if ( F.getFirst().factor().inCoeffDomain() ) {
    172         omega = F.getFirst().factor();
    173         F.removeFirst();
    174         if ( omega < 0 ) {
    175             negate = true;
    176             omega = -omega;
    177             U = -U;
    178         }
     197        omega = F.getFirst().factor();
     198        F.removeFirst();
     199        if ( omega < 0 ) {
     200            negate = true;
     201            omega = -omega;
     202            U = -U;
     203        }
    179204    }
    180205    else
    181         omega = 1;
     206        omega = 1;
    182207
    183208    bool goodeval = false;
     
    185210
    186211//    for ( i = 0; i < 10*t; i++ )
    187 //      A.nextpoint();
     212//        A.nextpoint();
    188213
    189214    while ( ! goodeval ) {
    190         TIMING_START(fac_findeval);
    191         findEvaluation( U, V, omega, F, A, U0, delta, D, r );
    192         TIMING_END(fac_findeval);
    193         DEBOUTLN( cerr, "the evaluation point to reduce to an univariate problem is " << A );
    194         DEBOUTLN( cerr, "corresponding delta = " << delta );
    195         DEBOUTLN( cerr, "              omega = " << omega );
    196         DEBOUTLN( cerr, "              D     = " << D );
    197         DEBOUTLN( cerr, "now factorize the univariate polynomial " << U0 );
    198         G = conv_to_factor_array( factorize( U0, false ) );
    199         DEBOUTLN( cerr, "which factorizes into " << G );
    200         b = coeffBound( U, getZFacModulus().getp() );
    201         if ( getZFacModulus().getpk() > b.getpk() )
    202             b = getZFacModulus();
    203         DEBOUTLN( cerr, "the coefficient bound of the factors of U is " << b.getpk() );
    204 
    205         r = G.size();
    206         lcG = CFArray( 1, r );
    207         UU = U;
    208         DEBOUTLN( cerr, "now trying to distribute the leading coefficients ..." );
    209         TIMING_START(fac_distrib);
    210         goodeval = distributeLeadingCoeffs( UU, G, lcG, F, D, delta, omega, A, r );
    211         TIMING_END(fac_distrib);
     215        TIMING_START(fac_findeval);
     216        findEvaluation( U, V, omega, F, A, U0, delta, D, r );
     217        TIMING_END(fac_findeval);
     218        DEBOUTLN( cerr, "the evaluation point to reduce to an univariate problem is " << A );
     219        DEBOUTLN( cerr, "corresponding delta = " << delta );
     220        DEBOUTLN( cerr, "              omega = " << omega );
     221        DEBOUTLN( cerr, "              D     = " << D );
     222        DEBOUTLN( cerr, "now factorize the univariate polynomial " << U0 );
     223        G = conv_to_factor_array( factorize( U0, false ) );
     224        DEBOUTLN( cerr, "which factorizes into " << G );
     225        #ifdef HAVE_NTL
     226        {
     227          int i=prime_number;
     228          CanonicalForm f=arg;
     229          find_good_prime(f,arg,i);
     230          f=U0;
     231          find_good_prime(f,U0,i);
     232          f=U;
     233          find_good_prime(f,U,i);
     234          int p=cf_getSmallPrime(i);
     235          //printf("found:p=%d (%d)\n",p,i);
     236          if ((i==0)||(i!=prime_number))
     237          { 
     238            b = coeffBound( U, p );
     239            prime_number=i;
     240          } 
     241          modpk bb=coeffBound(U0,p);
     242          if (bb.getpk() > b.getpk() ) b=bb;
     243          bb=coeffBound(arg,p);
     244          if (bb.getpk() > b.getpk() ) b=bb;
     245        }
     246        #else
     247        b = coeffBound( U, getZFacModulus().getp() );
     248        if ( getZFacModulus().getpk() > b.getpk() )
     249            b = getZFacModulus();
     250        #endif
     251        DEBOUTLN( cerr, "the coefficient bound of the factors of U is " << b.getpk() );
     252
     253        r = G.size();
     254        lcG = CFArray( 1, r );
     255        UU = U;
     256        DEBOUTLN( cerr, "now trying to distribute the leading coefficients ..." );
     257        TIMING_START(fac_distrib);
     258        goodeval = distributeLeadingCoeffs( UU, G, lcG, F, D, delta, omega, A, r );
     259        TIMING_END(fac_distrib);
    212260#ifdef DEBUGOUTPUT
    213         if ( goodeval ) {
    214             DEBOUTLN( cerr, "the univariate factors after distribution are " << G );
    215             DEBOUTLN( cerr, "the distributed leading coeffs are " << lcG );
    216             DEBOUTLN( cerr, "U may have changed and is now " << UU );
    217             DEBOUTLN( cerr, "which has leading coefficient " << LC( UU, Variable(1) ) );
    218 
    219             if ( LC( UU, Variable(1) ) != prod( lcG ) || A(UU) != prod( G ) ) {
    220                 DEBOUTLN( cerr, "!!! distribution was not correct !!!" );
    221                 DEBOUTLN( cerr, "product of leading coeffs is " << prod( lcG ) );
    222                 DEBOUTLN( cerr, "product of univariate factors is " << prod( G ) );
    223                 DEBOUTLN( cerr, "the new U is evaluated as " << A(UU) );
    224             }
    225             else
    226                 DEBOUTLN( cerr, "leading coeffs correct" );
    227         }
    228         else {
    229             DEBOUTLN( cerr, "we have found a bad evaluation point" );
    230         }
     261        if ( goodeval ) {
     262            DEBOUTLN( cerr, "the univariate factors after distribution are " << G );
     263            DEBOUTLN( cerr, "the distributed leading coeffs are " << lcG );
     264            DEBOUTLN( cerr, "U may have changed and is now " << UU );
     265            DEBOUTLN( cerr, "which has leading coefficient " << LC( UU, Variable(1) ) );
     266
     267            if ( LC( UU, Variable(1) ) != prod( lcG ) || A(UU) != prod( G ) ) {
     268                DEBOUTLN( cerr, "!!! distribution was not correct !!!" );
     269                DEBOUTLN( cerr, "product of leading coeffs is " << prod( lcG ) );
     270                DEBOUTLN( cerr, "product of univariate factors is " << prod( G ) );
     271                DEBOUTLN( cerr, "the new U is evaluated as " << A(UU) );
     272            }
     273            else
     274                DEBOUTLN( cerr, "leading coeffs correct" );
     275        }
     276        else {
     277            DEBOUTLN( cerr, "we have found a bad evaluation point" );
     278        }
    231279#endif
    232         if ( goodeval ) {
    233             TIMING_START(fac_hensel);
    234             goodeval = Hensel( UU, G, lcG, A, b, Variable(1) );
    235             TIMING_END(fac_hensel);
    236         }
     280        if ( goodeval ) {
     281            TIMING_START(fac_hensel);
     282            goodeval = Hensel( UU, G, lcG, A, b, Variable(1) );
     283            TIMING_END(fac_hensel);
     284        }
    237285    }
    238286    for ( i = 1; i <= r; i++ ) {
    239         G[i] /= icontent( G[i] );
    240         G[i] = M(G[i]);
     287        G[i] /= icontent( G[i] );
     288        G[i] = M(G[i]);
    241289    }
    242290    // negate noch beachten !
    243291    if ( negate )
    244         G[1] = -G[1];
     292        G[1] = -G[1];
    245293    DEBDECLEVEL( cerr, "ZFactorMulti" );
    246294    return G;
     
    260308    v1 = Variable(1);
    261309    if ( issqrfree )
    262         F = CFFactor( f, 1 );
     310        F = CFFactor( f, 1 );
    263311    else
    264         F = sqrFree( f );
     312        F = sqrFree( f );
    265313
    266314    for ( i = F; i.hasItem(); i++ ) {
    267         if ( i.getItem().factor().inCoeffDomain() ) {
    268             if ( ! i.getItem().factor().isOne() )
    269                 R.append( CFFactor( i.getItem().factor(), i.getItem().exp() ) );
    270         }
    271         else {
    272             TIMING_START(fac_content);
    273             g = compress( i.getItem().factor(), M );
    274             // now after compress g contains Variable(1)
    275             vm = g.mvar();
    276             g = swapvar( g, v1, vm );
    277             cont = content( g );
    278             g = swapvar( g / cont, v1, vm );
    279             cont = swapvar( cont, v1, vm );
    280             n = i.getItem().exp();
    281             TIMING_END(fac_content);
    282             DEBOUTLN( cerr, "now after content ..." );
    283             if ( g.isUnivariate() ) {
    284                 G = factorize( g, true );
    285                 for ( j = G; j.hasItem(); j++ )
    286                     if ( ! j.getItem().factor().isOne() )
    287                         R.append( CFFactor( M( j.getItem().factor() ), n ) );
    288             }
    289             else {
    290                 GG = ZFactorizeMulti( g );
    291                 m = GG.max();
    292                 for ( k = GG.min(); k <= m; k++ )
    293                     if ( ! GG[k].isOne() )
    294                         R.append( CFFactor( M( GG[k] ), n ) );
    295             }
    296             G = factorize( cont, true );
    297             for ( j = G; j.hasItem(); j++ )
    298                 if ( ! j.getItem().factor().isOne() )
    299                     R.append( CFFactor( M( j.getItem().factor() ), n ) );
    300         }
     315        if ( i.getItem().factor().inCoeffDomain() ) {
     316            if ( ! i.getItem().factor().isOne() )
     317                R.append( CFFactor( i.getItem().factor(), i.getItem().exp() ) );
     318        }
     319        else {
     320            TIMING_START(fac_content);
     321            g = compress( i.getItem().factor(), M );
     322            // now after compress g contains Variable(1)
     323            vm = g.mvar();
     324            g = swapvar( g, v1, vm );
     325            cont = content( g );
     326            g = swapvar( g / cont, v1, vm );
     327            cont = swapvar( cont, v1, vm );
     328            n = i.getItem().exp();
     329            TIMING_END(fac_content);
     330            DEBOUTLN( cerr, "now after content ..." );
     331            if ( g.isUnivariate() ) {
     332                G = factorize( g, true );
     333                for ( j = G; j.hasItem(); j++ )
     334                    if ( ! j.getItem().factor().isOne() )
     335                        R.append( CFFactor( M( j.getItem().factor() ), n ) );
     336            }
     337            else {
     338                GG = ZFactorizeMulti( g );
     339                m = GG.max();
     340                for ( k = GG.min(); k <= m; k++ )
     341                    if ( ! GG[k].isOne() )
     342                        R.append( CFFactor( M( GG[k] ), n ) );
     343            }
     344            G = factorize( cont, true );
     345            for ( j = G; j.hasItem(); j++ )
     346                if ( ! j.getItem().factor().isOne() )
     347                    R.append( CFFactor( M( j.getItem().factor() ), n ) );
     348        }
    301349    }
    302350    return R;
Note: See TracChangeset for help on using the changeset viewer.