Changeset 22ab34 in git


Ignore:
Timestamp:
Aug 19, 2005, 12:59:19 PM (19 years ago)
Author:
Wilfred Pohl <pohl@…>
Branches:
(u'spielwiese', '4a9821a93ffdc22a6696668bd4f6b8c9de3e6c5f')
Children:
d116ec8d2a0671141e480634f435e120ecfdb2c9
Parents:
a73dde79cb0d6ba682d8ae94d597e8079aaf0e69
Message:
optimal variable for ezgcd


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

Legend:

Unmodified
Added
Removed
  • factory/fac_ezgcd.cc

    ra73dde7 r22ab34  
    11/* emacs edit mode for this file is -*- C++ -*- */
    2 /* $Id: fac_ezgcd.cc,v 1.19 2005-05-03 09:35:34 Singular Exp $ */
     2/* $Id: fac_ezgcd.cc,v 1.20 2005-08-19 10:59:19 pohl Exp $ */
    33
    44#include <config.h>
     
    1717#include "ftmpl_functions.h"
    1818
     19#define OPTIMALVAR 1
     20
     21#ifdef OPTIMALVAR
     22static Variable getOptimalVar( const CanonicalForm & FF, const CanonicalForm & GG );
     23#endif
    1924
    2025static void findeval( const CanonicalForm & F, const CanonicalForm & G, CanonicalForm & Fb, CanonicalForm & Gb, CanonicalForm & Db, REvaluation & b, int delta, int degF, int degG );
     
    2833static modpk enlargeBound ( const CanonicalForm & F, const CanonicalForm & Lb, const CanonicalForm & Db, const modpk & pk );
    2934
     35#ifdef OPTIMALVAR
     36CanonicalForm ezgcd( const CanonicalForm & FF, const CanonicalForm & GG )
     37{
     38  CanonicalForm F,G;
     39  REvaluation b;
     40  Variable Z=getOptimalVar(FF,GG);
     41//Test:  return Z;
     42  if(Z==Variable(1)){return ezgcd( FF, GG, b, false );}
     43  F=swapvar(FF,Z,Variable(1));
     44  G=swapvar(GG,Z,Variable(1));
     45  return swapvar(ezgcd( F, G, b, false ),Z,Variable(1));
     46}
     47#else
    3048CanonicalForm
    3149ezgcd ( const CanonicalForm & FF, const CanonicalForm & GG )
     
    3452    return ezgcd( FF, GG, b, false );
    3553}
     54#endif
    3655
    3756static CanonicalForm
     
    359378    return modpk( p, i );
    360379}
     380
     381#ifdef OPTIMALVAR
     382static Variable getOptimalVar( const CanonicalForm & FF, const CanonicalForm & GG )
     383{
     384  int ii,tt,d,dd,s,so;
     385  CanonicalForm F,G,Fbz,Gbz,Dbz;
     386  Variable opt=Variable(1);
     387  if((FF.level()<3)||(GG.level()<3)){return opt;}
     388  REvaluation bz=REvaluation(2,tmax(FF.level(),GG.level()),IntRandom(50));
     389  Fbz=bz(FF);
     390  Gbz=bz(GG);
     391  Dbz=gcd(Fbz,Gbz);
     392  dd=degree(Dbz);
     393  so=size(Dbz);
     394  tt=FF.level();
     395  if(GG.level()<tt){tt=GG.level();}
     396  for(ii=2;ii<=tt;ii++)
     397  {
     398    F=swapvar(FF,Variable(ii),Variable(1));
     399    G=swapvar(GG,Variable(ii),Variable(1));
     400    Fbz=bz(F);
     401    Gbz=bz(G);
     402    Dbz=gcd(Fbz,Gbz);
     403    d=degree(Dbz);
     404    if(d==dd)
     405    {
     406      s=size(Dbz);
     407      if(s>so){so=s;opt=Variable(ii);}
     408    }
     409    if(d>dd){dd=d;so=size(Dbz);opt=Variable(ii);}
     410  }
     411  return opt;
     412}
     413#endif
Note: See TracChangeset for help on using the changeset viewer.