Changeset e22ea7 in git


Ignore:
Timestamp:
Jan 5, 2005, 12:27:17 PM (19 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
7dd754926fbde53f14c682a4eee9f02960f174e1
Parents:
672566a7f6af2a2349ebd32302a58c4c91a0259e
Message:
*hannes/pfister: ezgcd fixed


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

Legend:

Unmodified
Added
Removed
  • factory/cf_gcd.cc

    r672566a re22ea7  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: cf_gcd.cc,v 1.26 2004-11-25 15:43:36 Singular Exp $ */
     2/* $Id: cf_gcd.cc,v 1.27 2005-01-05 11:27:17 Singular Exp $ */
    33
    44#include <config.h>
     
    376376        CFMap M, N;
    377377        compress( f, g, M, N );
     378#if 0
    378379        CanonicalForm r=N( ezgcd( M(f), M(g) ) );
    379380        if ((f%r!=0) || (g % r !=0))
     
    383384           return gcd_poly1( f, g, modularflag);
    384385        }
    385         else return r;
     386        else
     387           return r;
     388#else
     389         return N( ezgcd( M(f), M(g) ) );
     390#endif   
    386391    }
    387392    else if ( isOn( SW_USE_SPARSEMOD )
    388393    && ! ( f.isUnivariate() && g.isUnivariate() ) )
    389394    {
     395#if 0
    390396        CanonicalForm r=sparsemod( f, g );
    391397        if ((f%r!=0) || (g % r !=0))
     
    393399           if (si_factor_reminder)
    394400           printf("sparsemod failed, trying gcd_poly1\n");
    395            return gcd_poly1( f, g, modularflag);
     401           return r;
     402           //return gcd_poly1( f, g, modularflag);
    396403        }
    397         else return r;
     404        else
     405          return r;
     406#else
     407        return sparsemod( f, g );
     408#endif
    398409    }
    399410    else
  • factory/fac_ezgcd.cc

    r672566a re22ea7  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fac_ezgcd.cc,v 1.14 2001-01-24 18:09:41 Singular Exp $ */
     2/* $Id: fac_ezgcd.cc,v 1.15 2005-01-05 11:27:17 Singular Exp $ */
    33
    44#include <config.h>
     
    4040    CanonicalForm F, G, f, g, d, Fb, Gb, Db, Fbt, Gbt, Dbt, B0, B, D0, lcF, lcG, lcD;
    4141    CFArray DD( 1, 2 ), lcDD( 1, 2 );
    42     int degF, degG, delta, deltaold, t;
     42    int degF, degG, delta, t;
    4343    REvaluation bt;
    4444    bool gcdfound = false;
     
    5454    F = FF / f; G = GG / g;
    5555    if ( F.isUnivariate() && G.isUnivariate() )
     56    {
     57        DEBDECLEVEL( cerr, "ezgcd" );
    5658        return d * gcd( F, G );
     59    }
    5760    else  if ( gcd_test_one( F, G, false ) )
     61    {
     62        DEBDECLEVEL( cerr, "ezgcd" );
    5863        return d;
     64    }
    5965    lcF = LC( F, x ); lcG = LC( G, x );
    6066    lcD = gcd( lcF, lcG );
     
    6470    bound = findBound( F, G, lcF, lcG, degF, degG );
    6571    if ( ! internal )
    66         b = REvaluation( 2, t, IntRandom( 100 ) );
     72        b = REvaluation( 2, t, IntRandom( 50 ) );
    6773    while ( ! gcdfound ) {
    6874        /// ---> A2
     
    7884        /// ---> A3
    7985        if ( delta == 0 )
    80             return d;
     86        {
     87          DEBDECLEVEL( cerr, "ezgcd" );
     88          return d;
     89        }
    8190        /// ---> A4
    82         deltaold = delta + 1;
    83         while ( deltaold != delta ) {
     91        //deltaold = delta;
     92        while ( 1 ) {
    8493            bt = b;
    8594            findeval( F, G, Fbt, Gbt, Dbt, bt, delta + 1, degF, degG );
    86             if ( degree( Dbt ) == 0 )
     95            int dd=degree( Dbt );
     96            if ( dd /*degree( Dbt )*/ == 0 )
     97            {
     98                DEBDECLEVEL( cerr, "ezgcd" );
    8799                return d;
    88             if ( degree( Dbt ) == delta )
    89                 deltaold = delta;
    90             else  if ( degree( Dbt ) < delta ) {
    91                 deltaold = delta;
    92                 delta = degree( Dbt );
     100            }
     101            if ( dd /*degree( Dbt )*/ == delta )
     102                break;
     103            else  if ( dd /*degree( Dbt )*/ < delta ) {
     104                delta = dd /*degree( Dbt )*/;
    93105                b = bt;
    94106                Db = Dbt; Fb = Fbt; Gb = Gbt;
     
    98110        /// ---> A5
    99111        if ( degF <= degG && delta == degF && divides( F, G ) )
     112        {
     113            DEBDECLEVEL( cerr, "ezgcd" );
    100114            return d*F;
     115        }
    101116        if ( degG < degF && delta == degG && divides( G, F ) )
     117        {
     118            DEBDECLEVEL( cerr, "ezgcd" );
    102119            return d*G;
     120        }
    103121        if ( delta != degF && delta != degG ) {
    104122            /// ---> A6
     
    144162            gcdfound = Hensel( B, DD, lcDD, b, bound, x );
    145163            DEBOUTLN( cerr, "(hensel finished) DD   = " << DD );
     164           
     165            if (gcdfound)
     166            {
     167              CanonicalForm cand=DD[2] / content(DD[2],Variable(1));
     168              if (B==F)
     169              {
     170                DEBOUTLN( cerr, "(test) G: "<<G<<" % gcd:"<<cand<<" -> " << G%cand );
     171                gcdfound= divides(cand,G);
     172                //gcdfound= ((G-((G/cand)*cand))==0);
     173                //gcdfound= ((G % cand)==0);
     174              }
     175              else
     176              {
     177                DEBOUTLN( cerr, "(test) F: "<<F<<" % gcd:"<<cand<<" -> " << F%cand);
     178                gcdfound= divides(cand,F);
     179                //gcdfound= ((F-((F/cand)*cand))==0);
     180                //gcdfound= ((F % cand)==0);
     181              }
     182            }
    146183            /// ---> A8 (gcdfound)
    147184        }
     
    234271findeval( const CanonicalForm & F, const CanonicalForm & G, CanonicalForm & Fb, CanonicalForm & Gb, CanonicalForm & Db, REvaluation & b, int delta, int degF, int degG )
    235272{
     273//    int t=tmax(F.level(),G.level());
     274    int i;
    236275    bool ok;
    237276    if ( delta != 0 )
    238277        b.nextpoint();
     278//    i=2;
     279//    while(i<=t)
     280//    {
     281//      if (b[i]==0) { b.nextpoint(); i=2; }
     282//      else i++;
     283//    }
     284    DEBOUTLN( cerr, "ezgcd: (findeval) F = " << F  <<", G="<< G);
     285    DEBOUTLN( cerr, "ezgcd: (findeval) degF = " << degF << ", degG="<<degG );
    239286    do {
    240287        DEBOUTLN( cerr, "ezgcd: (findeval) b = " << b );
     
    245292            ok = degree( Gb ) == degG;
    246293        }
     294       
    247295        if ( ok ) {
    248             Db = gcd( Fb, Gb );
    249             if ( delta > 0 )
     296//          if ((Fb.isZero())||(Gb.isZero()))
     297//            ok=false;
     298//          else
     299            {   
     300              Db = gcd( Fb, Gb );
     301              if ( delta > 0 )
    250302                ok = degree( Db ) < delta;
     303            }
    251304        }
    252305        if ( ! ok )
Note: See TracChangeset for help on using the changeset viewer.