Changeset f63dbca in git


Ignore:
Timestamp:
Jul 8, 1996, 10:21:10 AM (28 years ago)
Author:
Rüdiger Stobbe <stobbe@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
7b4bfe63f5e8232ccce6c9f00ab9238ceabc1041
Parents:
d675c7716d78a6d5c5238c8820480fc2f09a860e
Message:
"gcd_poly: now uses ezgcd if the switch SW_USE_EZGCD is on.
"


git-svn-id: file:///usr/local/Singular/svn/trunk@39 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_gcd.cc

    rd675c7 rf63dbca  
    11// emacs edit mode for this file is -*- C++ -*-
    2 // $Id: cf_gcd.cc,v 1.3 1996-06-18 12:22:54 stobbe Exp $
     2// $Id: cf_gcd.cc,v 1.4 1996-07-08 08:21:10 stobbe Exp $
    33
    44/*
    55$Log: not supported by cvs2svn $
     6Revision 1.3  1996/06/18 12:22:54  stobbe
     7"gcd_poly_univar0: now uses getSmallPrimes (due to changes in the handling
     8                  of prime numbers in cf_primes.
     9"
     10
    611Revision 1.2  1996/06/13 08:18:34  stobbe
    712"balance: Now balaces polynomials even if the coefficient sizes are higher
     
    3136#include "cf_primes.h"
    3237#include "cf_chinese.h"
     38#include "cf_map.h"
     39#include "fac_util.h"
    3340#include "templates/functions.h"
    3441
     
    5158}
    5259
    53 static bool
    54 gcd_test_one ( const CanonicalForm & f, const CanonicalForm & g )
     60bool
     61gcd_test_one ( const CanonicalForm & f, const CanonicalForm & g, bool swap )
    5562{
    5663    int count = 0;
    5764    // assume polys have same level;
    5865    CFRandom * sample = CFRandomFactory::generate();
    59     REvaluation e( 2, f.level(), *sample );
     66    REvaluation e( 2, tmax( f.level(), g.level() ), *sample );
    6067    delete sample;
    61     CanonicalForm lcf = swapvar( LC( f ), Variable(1), f.mvar() );
    62     CanonicalForm lcg = swapvar( LC( g ), Variable(1), f.mvar() );
     68    CanonicalForm lcf, lcg;
     69    if ( swap ) {
     70        lcf = swapvar( LC( f ), Variable(1), f.mvar() );
     71        lcg = swapvar( LC( g ), Variable(1), f.mvar() );
     72    }
     73    else {
     74        lcf = LC( f, Variable(1) );
     75        lcg = LC( g, Variable(1) );
     76    }
    6377    while ( ( e( lcf ).isZero() || e( lcg ).isZero() ) && count < 100 ) {
    6478        e.nextpoint();
     
    6781    if ( count == 100 )
    6882        return false;
    69     CanonicalForm F=swapvar( f, Variable(1), f.mvar() );
    70     CanonicalForm G=swapvar( g, Variable(1), g.mvar() );
     83    CanonicalForm F, G;
     84    if ( swap ) {
     85        F=swapvar( f, Variable(1), f.mvar() );
     86        G=swapvar( g, Variable(1), g.mvar() );
     87    }
     88    else {
     89        F = f;
     90        G = g;
     91    }
    7192    if ( e(F).taildegree() > 0 && e(G).taildegree() > 0 )
    7293        return false;
     
    291312        if ( i >= 0 ) {
    292313            // now balance D mod q
    293             D = pp( balance( cg * D, q ) );
     314            D = pp( balance( D, q ) );
    294315            if ( divides( D, f ) && divides( D, g ) )
    295316                return D * c;
     
    300321            return gcd_poly( F, G, false );
    301322        }
    302     }
    303 }
    304 
    305 
    306 static CanonicalForm
    307 gcd_poly( const CanonicalForm & f, const CanonicalForm& g, bool modularflag )
     323        cerr << "another try ..." << endl;
     324    }
     325}
     326
     327
     328static CanonicalForm
     329gcd_poly1( const CanonicalForm & f, const CanonicalForm & g, bool modularflag )
    308330{
    309331    CanonicalForm C, Ci, Ci1, Hi, bi, pi, pi1, pi2;
     
    325347    }
    326348    else
    327         if ( gcd_test_one( pi1, pi ) )
     349        if ( gcd_test_one( pi1, pi, true ) )
    328350            return C;
    329351    delta = degree( pi, v ) - degree( pi1, v );
     
    353375}
    354376
     377
     378static CanonicalForm
     379gcd_poly( const CanonicalForm & f, const CanonicalForm & g, bool modularflag )
     380{
     381    if ( isOn( SW_USE_EZGCD ) && ! ( f.isUnivariate() && g.isUnivariate() ) ) {
     382        CFMap M, N;
     383        compress( f, g, M, N );
     384        return N( ezgcd( M(f), M(g) ) );
     385    }
     386    else {
     387        return gcd_poly1( f, g, modularflag );
     388    }
     389}
     390   
    355391
    356392static CanonicalForm
Note: See TracChangeset for help on using the changeset viewer.