Changeset 04dd0c in git


Ignore:
Timestamp:
Jun 17, 2010, 2:49:49 PM (13 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
Children:
fecc08cb1fbac7aebf01c221287ec9360849a8b4
Parents:
547f6439fcbe82be0ab53e3707bf2e0d4fbc7872
Message:
minor changes


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

Legend:

Unmodified
Added
Removed
  • factory/cf_gcd_smallp.cc

    r547f64 r04dd0c  
    3131#include "cf_random.h"
    3232
    33 // inline helper functions:
     33// iinline helper functions:
    3434#include "cf_map_ext.h"
    3535
    3636#ifdef HAVE_NTL
    3737#include <NTL/ZZ_pEX.h>
     38#include <NTLconvert.h>
    3839#endif
    3940
     
    4546/// compressing two polynomials F and G, M is used for compressing,
    4647/// N to reverse the compression
     48static inline
    4749int myCompress (const CanonicalForm& F, const CanonicalForm& G, CFMap & M,
    4850                CFMap & N, bool& top_level)
     
    335337/// based on Alg. 7.2. as described in "Algorithms for
    336338/// Computer Algebra" by Geddes, Czapor, Labahn
    337 CanonicalForm
     339static inline CanonicalForm
    338340GCD_Fp_extension (const CanonicalForm& F, const CanonicalForm& G,
    339341                  Variable & alpha, CFList& l, bool& top_level)
     
    436438
    437439      DEBOUTLN (cerr, "getMipo (alpha)= " << getMipo (alpha));
    438       DEBOUTLN (cerr, "getMipo (alpha)= " << getMipo (V_buf2));
     440      DEBOUTLN (cerr, "getMipo (V_buf2)= " << getMipo (V_buf2));
    439441      inextension= true;
    440442      for (CFListIterator i= l; i.hasItem(); i++)
     
    535537/// univariate polynomial, returns fail if there are no field elements left
    536538/// which have not been used before
     539static inline
    537540CanonicalForm
    538541GFRandomElement (const CanonicalForm& F, CFList& list, bool& fail)
     
    574577/// faster field arithmetics, however it might fail if the input is large since
    575578/// the size of the base field is bounded by 2^16, output is monic
     579inline
    576580CanonicalForm
    577581GCD_GF (const CanonicalForm& F, const CanonicalForm& G, CFList& l,
     
    663667      num_vars--;
    664668      p= getCharacteristic();
    665       expon= floor ((log ((double) ipower (d + 1, num_vars))/log ((double) p)));
     669      expon= (int) floor ((log ((double) ipower (d + 1, num_vars))/log ((double) p)));
    666670      if (expon < 2)
    667671        expon= 2;
     
    671675      else
    672676      {
    673         expon= floor((log ((double)((1<<16) - 1)))/(log((double)p)*kk));
     677        expon= (int) floor((log ((double)((1<<16) - 1)))/(log((double)p)*kk));
    674678        ASSERT (expon >= 2, "not enough points in GCD_GF");
    675679        setCharacteristic (p, (int)(kk*expon), 'b');
     
    777781/// computes a random monic irreducible univariate polynomial of random
    778782/// degree < i in x which does not divide F
     783static inline
    779784CanonicalForm
    780 randomIrredpoly (int i, const Variable & x,
    781                  CFList & list)
     785randomIrredpoly (int i, const Variable & x)
    782786{
    783   int random;
    784787  int p= getCharacteristic();
    785788  ZZ NTLp= to_ZZ (p);
     
    787790  ZZ_pX NTLirredpoly;
    788791  CanonicalForm CFirredpoly;
    789   int buf= ceil((log((double) i) / log((double) p)));
    790   buf= buf + 1;
    791   int bound= 0;
    792   //lower bound on the number of monic irreducibles of degree less than buf
    793   for (int j= 2; j < buf; j++)
    794     bound += ((ipower (p, j) - 2*ipower(p, j/2)) / j);
    795   if (list.length() > bound)
    796   {
    797     if (buf > 1)
    798       buf--;
    799     buf *= 2;
    800     buf++;
    801   }
    802   for (int j=  ((buf - 1)/2) + 1; j < buf; j++)
    803     bound += ((ipower (p, j) - 2*ipower(p, j/2)) / j);
    804   do
    805   {
    806     if (list.length() <= bound)
    807     {
    808       random= factoryrandom ((int) buf); 
    809       if (random <= 1)
    810         random= 2;
    811     }
    812     else
    813     {
    814       if (buf > 1)
    815         buf--;
    816       buf *= 2;
    817       buf++;
    818       for (int j= ((int) (buf - 1)/2) + 1; j < buf; j++)
    819         bound += ((ipower (p, j) - 2*ipower(p, j/2)) / j);
    820       random= factoryrandom ((int) buf);
    821       if (random <= 1)
    822         random= 2;
    823     }
    824     BuildIrred (NTLirredpoly, random);
    825     CFirredpoly= convertNTLZZpX2CF (NTLirredpoly, x);
    826   } while (find (list, CFirredpoly));
     792  BuildIrred (NTLirredpoly, i + 1);
     793  CFirredpoly= convertNTLZZpX2CF (NTLirredpoly, x);
    827794  return CFirredpoly;
    828795}
    829796
     797static inline
    830798CanonicalForm
    831799FpRandomElement (const CanonicalForm& F, CFList& list, bool& fail)
     
    861829}
    862830
     831static inline
    863832CanonicalForm GCD_small_p (const CanonicalForm& F, const CanonicalForm&  G,
    864833                           bool& top_level, CFList& l)
     
    977946      int deg= 3;
    978947      do {
    979         mipo= randomIrredpoly (deg, x, list);
     948        mipo= randomIrredpoly (deg, x);
    980949        alpha= rootOf (mipo);
    981950        inextension= true;
     
    10691038      d= d0;
    10701039    }
    1071    
     1040    
    10721041    TIMING_START (newton_interpolation);
    10731042    H= newtonInterp (random_element, G_random_element, newtonPoly, G_m, x);
Note: See TracChangeset for help on using the changeset viewer.