Ticket #9511: givaro-3.2.13-3.7.0.diff

File givaro-3.2.13-3.7.0.diff, 31.1 KB (added by jdemeyer, 10 years ago)

Diff between the 3.2.13.p0 (#12761) and 3.7.0 givaro spkgs. For review only.

  • givaro-3.

    diff -Nru givaro-3.2.13.p0/.hgtags givaro-3.7.0/.hgtags
    old new  
    11a152977c5f16ec48ec8ed43c8218290c820d6e26 givaro-3.2.13.rc1.p3
    2292dc2a3203b83d8e2470ac8a800d204cf7135792 givaro-3.2.13.rc1.p4
    3 b78a477bcf9b2c47246dfe6afdc3974313f450ca givaro-3.2.13.p0
  • SPKG.txt

    diff -Nru givaro-3.2.13.p0/SPKG.txt givaro-3.7.0/SPKG.txt
    old new  
    1 = givaro =
     1= Givaro =
    22
    33== Description ==
    44
    5 Givaro is a C++ library for arithmetic and algebraic computations. Its main
    6 features are implementations of the basic arithmetic of many mathematical
    7 entities: Primes fields, Extensions Fields, Finite Fields, Finite Rings,
    8 Polynomials, Algebraic numbers, Arbitrary precision integers and rationals
    9 (C++ wrappers over GMP). It also provides data structures and templated
    10 classes for the manipulation of basic algebraic objects, such as vectors,
    11 matrices (dense, sparse, structured), univariate polynomials (and therefore
    12 recursive multivariate).
     5Givaro is a C++ library for arithmetic and algebraic computations. Its
     6main features are implementations of the basic arithmetic of many
     7mathematical entities: Primes fields, Extensions Fields, Finite
     8Fields, Finite Rings, Polynomials, Algebraic numbers, Arbitrary
     9precision integers and rationals (C++ wrappers over gmp) It also
     10provides data-structures and templated classes for the manipulation of
     11basic algebraic objects, such as vectors, matrices (dense, sparse,
     12structured), univariate polynomials (and therefore recursive
     13multivariate).
    1314
    1415Website: http://www-lmc.imag.fr/CASYS/LOGICIELS/givaro/
    1516
     17SPKG Repository: https://bitbucket.org/malb/givaro-spkg
     18
    1619== License ==
    1720
    1821 * GNU GPL
     
    2629 * GNU patch
    2730 * GMP/MPIR
    2831
    29 == SPKG Maintainers ==
     32== Maintainers ==
    3033
    3134  * Clement Pernet
    32   * Martin Albrecht <malb@informatik.uni-bremen.de>
    33 
    34 == Special Update/Build Instructions ==
    35 
    36  * Make sure the patches are still needed and do apply.
    37 
    38  * Make sure newer upstream sources conform to C++11, e.g. build with
    39    GCC 4.7.x, *without* `-fpermissive`.  Note that some of the Sage library's
    40    extension modules use Givaro's headers, hence also check whether `./sage -b`
    41    works after installation of a new Givaro spkg.
    42    Also test whether Givaro's test suite builds with GCC 4.7.x, since these
    43    tests use other code parts than the Sage library does (template instanti-
    44    ation!).
    45 
    46  * Doesn't seem that `make check` actually *runs* any tests, it just builds
    47    a lot.  Perhaps we'd have to extend `spkg-check` regarding that.
     35  * Martin Albrecht <martinralbrecht@googlemail.com>
    4836
    4937== Changelog ==
    5038
     39=== givaro-3.7.0 (Martin Albrecht, June 7th, 2012) ===
     40 * #9511 updated to new upstram release
     41
    5142=== givaro-3.2.13.p0 (Jeroen Demeyer, 25 May 2012) ===
    5243 * #12761: Restore upstream sources to vanilla 3.2.13 (the previous
    5344   src/ directory was some never-released CVS version between
  • patches/cplusplus_scoping.patch

    diff -Nru givaro-3.2.13.p0/patches/cplusplus_scoping.patch givaro-3.7.0/patches/cplusplus_scoping.patch
    old new  
    1 --- src/src/kernel/integer/givintnumtheo.inl    2008-07-10 19:25:29.000000000 +0200
    2 +++ patches/givintnumtheo.inl   2012-03-27 04:47:24.897732595 +0200
    3 @@ -17,8 +17,8 @@
    4  // =================================================================== //
    5  template<class RandIter>
    6  typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::phi(Rep& res, const Rep& n) const {
    7 -    if (isleq(n,1)) return res=n;
    8 -    if (isleq(n,3)) return sub(res,n,this->one);
    9 +    if (IntNumTheoDom<RandIter>::isleq(n,1)) return res=n;
    10 +    if (IntNumTheoDom<RandIter>::isleq(n,3)) return IntNumTheoDom<RandIter>::sub(res,n,this->one);
    11      std::list<Rep> Lf;
    12      Father_t::set(Lf,n);
    13      //return phi (res,Lf,n);
    14 @@ -29,11 +29,11 @@
    15  template<class RandIter>
    16  template< template<class, class> class Container, template<class> class Alloc>
    17   typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::phi(Rep& res, const Container<Rep, Alloc<Rep> >& Lf, const Rep& n) const {
    18 -    if (isleq(n,1)) return res=n;
    19 -    if (isleq(n,3)) return sub(res,n,this->one);
    20 +    if (IntNumTheoDom<RandIter>::isleq(n,1)) return res=n;
    21 +    if (IntNumTheoDom<RandIter>::isleq(n,3)) return IntNumTheoDom<RandIter>::sub(res,n,this->one);
    22      res = n; Rep t,m;
    23      for(typename Container<Rep, Alloc<Rep> >::const_iterator f=Lf.begin(); f!=Lf.end(); ++f)
    24 -        mul(res, divexact(t,res,*f), sub(m, *f, this->one));
    25 +        IntNumTheoDom<RandIter>::mul(res, IntNumTheoDom<RandIter>::divexact(t,res,*f), IntNumTheoDom<RandIter>::sub(m, *f, this->one));
    26      return res;
    27  }
    28  
    29 @@ -80,26 +80,26 @@
    30          // n must be in {2,4,p^m,2p^m} where p is an odd prime
    31          // else infinite loop
    32  
    33 -    if (isleq(n,4)) return sub(A,n,this->one);
    34 -    if (isZero(mod(A,n,4))) return A=this->zero;
    35 +    if (IntNumTheoDom<RandIter>::isleq(n,4)) return IntNumTheoDom<RandIter>::sub(A,n,this->one);
    36 +    if (isZero(IntNumTheoDom<RandIter>::mod(A,n,4))) return A=this->zero;
    37      Rep p,ismod2, q, no2, root;
    38 -    if (isZero(mod(ismod2,n,2))) divexact(no2,n,2); else no2=n;
    39 +    if (isZero(IntNumTheoDom<RandIter>::mod(ismod2,n,2))) IntNumTheoDom<RandIter>::divexact(no2,n,2); else no2=n;
    40      p=no2;
    41      int k = 1;
    42 -    while (! isprime(p) ) {
    43 +    while (! IntNumTheoDom<RandIter>::isprime(p) ) {
    44          sqrt(root, p);
    45 -        while (mul(q,root,root) == p) {
    46 +        while (IntNumTheoDom<RandIter>::mul(q,root,root) == p) {
    47              p = root;
    48              sqrt(root,p);
    49          }
    50 -        if (! isprime(p) ) {
    51 +        if (! IntNumTheoDom<RandIter>::isprime(p) ) {
    52              q=p;
    53 -            while( p == q ) factor(p, q);
    54 -            divin(q,p);
    55 +            while( p == q ) IntNumTheoDom<RandIter>::factor(p, q);
    56 +            IntNumTheoDom<RandIter>::divin(q,p);
    57              if (q < p) p = q;
    58          }
    59      }
    60 -    if (isZero(ismod2)) mul(q,p,2); else q=p;
    61 +    if (isZero(ismod2)) IntNumTheoDom<RandIter>::mul(q,p,2); else q=p;
    62      for(;q != n;++k,q*=p);
    63      Rep phin, tmp;
    64      phi(phin,p);
    65 @@ -134,21 +134,21 @@
    66      while (! found) {
    67         do {
    68              this->random(this->_g, A, p);
    69 -            addin( modin(A,sub(tmp,p,7)) , 7);
    70 +            IntNumTheoDom<RandIter>::addin( IntNumTheoDom<RandIter>::modin(A,IntNumTheoDom<RandIter>::sub(tmp,p,7)) , 7);
    71          } while ( ! isOne(gcd(tmp,A,p)) );
    72          found = ++runs;
    73          for(f=Lf.begin();(f!=Lf.end() && found);f++)
    74              found = (! isOne( this->powmod(tmp,A,*f,p)) );
    75      }
    76      if (k == 1) {
    77 -        if (isZero(ismod2) && isZero(mod(ismod2, A, 2)))
    78 +        if (isZero(ismod2) && isZero(IntNumTheoDom<RandIter>::mod(ismod2, A, 2)))
    79              return A+=p;
    80          else
    81              return A;
    82      } else {
    83          if (! is_prim_root(A,no2))
    84              A+=p;
    85 -        if (isZero(ismod2) && isZero(mod(ismod2, A, 2)))
    86 +        if (isZero(ismod2) && isZero(IntNumTheoDom<RandIter>::mod(ismod2, A, 2)))
    87              return A+=no2;
    88          else
    89              return A;
    90 @@ -204,18 +204,18 @@
    91        Lq.pop_back();
    92         this->div(Temp, pmun, Q);
    93        do {
    94 -          nonzerorandom(this->_g, alea, p);
    95 -          modin(alea, p);
    96 +          IntNumTheoDom<RandIter>::nonzerorandom(this->_g, alea, p);
    97 +          IntNumTheoDom<RandIter>::modin(alea, p);
    98            this->powmod(essai, alea, Temp, p);
    99  //std::cerr << alea << " should be of order " << Q << " mod " << p << std::endl;
    100        } while (essai == 1);
    101  // looking for alea, of order Q with high probability     
    102        
    103 -      mulin(primroot, essai);
    104 +      IntNumTheoDom<RandIter>::mulin(primroot, essai);
    105  
    106  //  1-(1+2/(p-1))*(1-1/L^2)^log_B(Q)  < 1-(1+2^(-log_2(p)))*(1-1/L^2)^log_B(Q);
    107        essai = L;
    108 -      mul(Temp, essai, L);
    109 +      IntNumTheoDom<RandIter>::mul(Temp, essai, L);
    110        error = 1-1.0/(double)Temp;
    111        error = power(error, logp(Q,Temp) );
    112        error *= (1.0+1.0/((double)Q-1.0));
    113 @@ -228,8 +228,8 @@
    114    for ( ; Lqi != Lq.end(); ++Lqi, ++ei) {
    115         this->div(Temp, pmun, *Lqi);
    116        do {
    117 -          nonzerorandom(this->_g, alea, p);
    118 -          modin(alea, p);
    119 +          IntNumTheoDom<RandIter>::nonzerorandom(this->_g, alea, p);
    120 +          IntNumTheoDom<RandIter>::modin(alea, p);
    121            this->powmod(essai, alea, Temp, p);
    122  //std::cerr << alea << " should be of order at least " << *Lqi << "^" << *ei << "==" << power(*Lqi,*ei) << " mod " << p << std::endl;
    123        } while( essai == 1 ) ;
    124 @@ -239,10 +239,10 @@
    125  //std::cerr << alea << " is of order at least " << (*Lqi) << "^" << (*ei) << "==" << power(*Lqi,*ei) << " mod " << p << std::endl;
    126            
    127        this->divin(Temp, power(*Lqi,*ei-1));
    128 -      mulin(primroot, this->powmod(essai, alea, Temp, p));   
    129 +      IntNumTheoDom<RandIter>::mulin(primroot, this->powmod(essai, alea, Temp, p));   
    130    }
    131  
    132 -  modin(primroot, p);
    133 +  IntNumTheoDom<RandIter>::modin(primroot, p);
    134    
    135    return primroot;
    136  // return primroot with high probability
    137 @@ -298,7 +298,7 @@
    138  typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::prim_root_of_prime(Rep& A, const Rep& n) const {
    139      
    140      std::vector<Rep> Lf;
    141 -    Rep phin; sub(phin,n,this->one);
    142 +    Rep phin; IntNumTheoDom<RandIter>::sub(phin,n,this->one);
    143      Father_t::set(Lf,phin);
    144      return prim_root_of_prime(A, Lf, phin, n);
    145  }
    146 @@ -330,14 +330,14 @@
    147  
    148      Rep primeorder;
    149      
    150 -    for(bool exemp = true; exemp; nextprimein(prime) ) {
    151 +    for(bool exemp = true; exemp; IntNumTheoDom<RandIter>::nextprimein(prime) ) {
    152          A = prime;
    153          primeorder = phin;
    154          for(typename Array::const_iterator f = Lf.begin(); f != Lf.end(); ++f) {
    155              this->powmod(tmp, prime, this->div(expo, primeorder, *f), n);
    156              if (isOne(tmp)) {
    157                  newLf.push_back(*f);
    158 -                while (isZero(mod(tmp,expo,*f)) && isOne( this->powmod(tmp, prime, this->div(temp, expo, *f), n) ) ) { expo = temp; }
    159 +                while (isZero(IntNumTheoDom<RandIter>::mod(tmp,expo,*f)) && isOne( this->powmod(tmp, prime, this->div(temp, expo, *f), n) ) ) { expo = temp; }
    160                  primeorder = expo;
    161  //                 std::cerr << "2 Order (Div): " << primeorder << std::endl;
    162              } else {
    163 @@ -357,7 +357,7 @@
    164  //     std::cerr << "Root : " << A << std::endl;
    165  //     std::cerr << "Order : " << Aorder << std::endl;
    166      
    167 -    for ( ; islt(Aorder,phin); nextprimein(prime) ) {
    168 +    for ( ; IntNumTheoDom<RandIter>::islt(Aorder,phin); IntNumTheoDom<RandIter>::nextprimein(prime) ) {
    169          newLf.resize(0); oldLf.resize(0);
    170  
    171          for(typename Array::const_iterator f = Lf.begin(); f != Lf.end(); ++f) {
    172 @@ -379,9 +379,9 @@
    173  
    174              this->powmod(tmp, prime, g, n);
    175  
    176 -            modin( mulin(A, tmp), n );
    177 +            IntNumTheoDom<RandIter>::modin( IntNumTheoDom<RandIter>::mulin(A, tmp), n );
    178  
    179 -            mulin(Aorder, this->div(tmp, phin, g));
    180 +            IntNumTheoDom<RandIter>::mulin(Aorder, this->div(tmp, phin, g));
    181  
    182              Lf = newLf;
    183          }
    184 @@ -402,8 +402,8 @@
    185  typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::lowest_prim_root(Rep& A, const Rep& n) const {
    186          // n must be in {2,4,p^m,2p^m} where p is an odd prime
    187          // else returns zero
    188 -    if (isleq(n,4)) return sub(A,n,this->one);
    189 -    if (isZero(mod(A,n,4))) return A=this->zero;
    190 +    if (IntNumTheoDom<RandIter>::isleq(n,4)) return IntNumTheoDom<RandIter>::sub(A,n,this->one);
    191 +    if (isZero(IntNumTheoDom<RandIter>::mod(A,n,4))) return A=this->zero;
    192      Rep phin, tmp;
    193      phi(phin,n);
    194      std::list<Rep> Lf;
    195 @@ -412,15 +412,15 @@
    196      for(f=Lf.begin();f!=Lf.end();++f)
    197              this->div(*f,phin,*f);
    198      int found=0;
    199 -    for(A = 2;(isleq(A,n) && (! found));addin(A,1)) {
    200 +    for(A = 2;(IntNumTheoDom<RandIter>::isleq(A,n) && (! found));IntNumTheoDom<RandIter>::addin(A,1)) {
    201          if (isOne(gcd(tmp,A,n))) {
    202              found = 1;
    203              for(f=Lf.begin();(f!=Lf.end() && found);f++)
    204                  found = (! isOne( this->powmod(tmp,A,*f,n)) );
    205          }
    206      }
    207 -    if (isleq(A,n))
    208 -        return subin(A,1);
    209 +    if (IntNumTheoDom<RandIter>::isleq(A,n))
    210 +        return IntNumTheoDom<RandIter>::subin(A,1);
    211      else
    212          return A=this->zero;
    213  }
    214 @@ -434,7 +434,7 @@
    215      std::list<Rep> Lf;
    216      Father_t::set(Lf,phin);
    217      typename std::list<Rep>::iterator f=Lf.begin();
    218 -    Rep A; mod(A,p,n);
    219 +    Rep A; IntNumTheoDom<RandIter>::mod(A,p,n);
    220      if (isOne(gcd(tmp,A,n))) {
    221          found = true;
    222          for(;(f!=Lf.end() && found);f++) {
    223 @@ -449,13 +449,13 @@
    224  bool IntNumTheoDom<RandIter>::isorder(const Rep& g, const Rep& p, const Rep& n) const {
    225          // returns 1 if p is of order g in Z/nZ
    226      Rep tmp;
    227 -    return (isOne( this->powmod(tmp, p, g, n) ) && areEqual( g, order(tmp,p,n) ) );
    228 +    return (isOne( this->powmod(tmp, p, g, n) ) && IntNumTheoDom<RandIter>::areEqual( g, order(tmp,p,n) ) );
    229  }
    230  
    231  template<class RandIter>
    232  typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::order(Rep& g, const Rep& p, const Rep& n) const {
    233          // returns 0 if failed
    234 -    Rep A; mod(A,p,n);
    235 +    Rep A; IntNumTheoDom<RandIter>::mod(A,p,n);
    236      if (isZero(A))
    237         return g = this->zero;
    238      if (isOne(A))
    239 @@ -474,7 +474,7 @@
    240                  break;
    241          if (noprimroot) {
    242              for(;f!=Lf.end();++f)
    243 -                while (isZero(mod(tmp,g,*f)) && isOne(  this->powmod(tmp,A,  this->div(gg,g,*f),n) ) )
    244 +                while (isZero(IntNumTheoDom<RandIter>::mod(tmp,g,*f)) && isOne(  this->powmod(tmp,A,  this->div(gg,g,*f),n) ) )
    245                      g = gg;
    246              return g;
    247          } else
    248 @@ -492,12 +492,12 @@
    249  
    250  template<class RandIter>
    251  typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::prim_elem(Rep& A, const Rep& n) const {
    252 -    if (isleq(n,4)) {
    253 +    if (IntNumTheoDom<RandIter>::isleq(n,4)) {
    254          Rep tmp;
    255          return this->sub(A,n,this->one);
    256      }
    257      
    258 -    if (areEqual(n,8)) return init(A,2);
    259 +    if (IntNumTheoDom<RandIter>::areEqual(n,8)) return IntNumTheoDom<RandIter>::init(A,2);
    260      return prim_base(A, n);
    261  }
    262  
    263 @@ -516,8 +516,8 @@
    264      typename std::vector<Rep>::iterator a = Ra.begin() ;
    265      for( ;p!=Lp.end();++p, ++e, ++pe, ++a) {
    266          dom_power( *pe, *p, *e, *this);
    267 -        if (areEqual(*p,2))
    268 -            init(*a, 3);
    269 +        if (IntNumTheoDom<RandIter>::areEqual(*p,2))
    270 +            IntNumTheoDom<RandIter>::init(*a, 3);
    271          else
    272              prim_root(*a, *pe);
    273      }
    274 @@ -544,13 +544,13 @@
    275  template<class RandIter>
    276  typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::lambda_inv_primpow(Rep & z, const Rep& p, const unsigned long e) const {
    277          // Prerequisite : p prime.
    278 -    if (areEqual(p, 2)) {
    279 -        if (e<=2) return init(z,e);
    280 -        if (e==3) return init(z,2);
    281 +    if (IntNumTheoDom<RandIter>::areEqual(p, 2)) {
    282 +        if (e<=2) return IntNumTheoDom<RandIter>::init(z,e);
    283 +        if (e==3) return IntNumTheoDom<RandIter>::init(z,2);
    284          return dom_power(z, p, e-2, *this);
    285      } else {
    286          Rep tmp;
    287 -        return mulin( dom_power(z, p, e-1, *this), sub(tmp, p, this->one) );
    288 +        return IntNumTheoDom<RandIter>::mulin( dom_power(z, p, e-1, *this), IntNumTheoDom<RandIter>::sub(tmp, p, this->one) );
    289      }
    290  }
    291  
    292 @@ -559,16 +559,16 @@
    293      
    294  template<class RandIter>
    295  typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::lambda_inv(Rep & z, const Rep& m) const {
    296 -        if (areEqual(m,2)) return init(z,1);
    297 -        if (areEqual(m,3) || areEqual(m,4) || areEqual(m,8) ) return init(z,2);
    298 +        if (IntNumTheoDom<RandIter>::areEqual(m,2)) return IntNumTheoDom<RandIter>::init(z,1);
    299 +        if (IntNumTheoDom<RandIter>::areEqual(m,3) || IntNumTheoDom<RandIter>::areEqual(m,4) || IntNumTheoDom<RandIter>::areEqual(m,8) ) return IntNumTheoDom<RandIter>::init(z,2);
    300          return lambda_base(z, m);
    301  }
    302  
    303  template<class RandIter>
    304  typename IntNumTheoDom<RandIter>::Rep& IntNumTheoDom<RandIter>::lambda(Rep & z, const Rep& m) const {
    305 -        if (areEqual(m,2)) return init(z,1);
    306 -        if (areEqual(m,3) || areEqual(m,4)) return init(z,2);
    307 -        if (areEqual(m,8) ) return init(z,3);
    308 +        if (IntNumTheoDom<RandIter>::areEqual(m,2)) return IntNumTheoDom<RandIter>::init(z,1);
    309 +        if (IntNumTheoDom<RandIter>::areEqual(m,3) || IntNumTheoDom<RandIter>::areEqual(m,4)) return IntNumTheoDom<RandIter>::init(z,2);
    310 +        if (IntNumTheoDom<RandIter>::areEqual(m,8) ) return IntNumTheoDom<RandIter>::init(z,3);
    311          return lambda_base(z, m);
    312  }
    313  
    314 @@ -592,7 +592,7 @@
    315  //            Rep g;
    316  //            gcd(g, z, tmp);
    317  //            mulin(z, this->divin(tmp, g));
    318 -           lcmin(z,tmp);
    319 +           IntNumTheoDom<RandIter>::lcmin(z,tmp);
    320          }
    321          
    322          return z;
    323 --- src/src/kernel/integer/givintrsa.inl        2008-04-21 16:01:56.000000000 +0200
    324 +++ patches/givintrsa.inl       2012-03-27 03:43:34.037731848 +0200
    325 @@ -195,14 +195,14 @@
    326          this->random(g,t,3);
    327          this->random(g,s,3);
    328      }
    329 -    nextprimein( t );
    330 -    nextprimein( s );
    331 +    IntRSADom<RandIter>::nextprimein( t );
    332 +    IntRSADom<RandIter>::nextprimein( s );
    333      
    334      
    335  
    336      r = t<<1;
    337      ++r;
    338 -    while( ! isprime(r,4) ) {
    339 +    while( ! IntRSADom<RandIter>::isprime(r,4) ) {
    340          r += t<<1;
    341      }
    342  
    343 @@ -221,7 +221,7 @@
    344      r <<= 1;
    345      
    346      p = q+r;
    347 -    while( ! isprime(p,4) ) {
    348 +    while( ! IntRSADom<RandIter>::isprime(p,4) ) {
    349          p += r;
    350      }
    351  
    352 @@ -246,21 +246,21 @@
    353      do  strong_prime(g, qsize, q); while (q == p);
    354      
    355  
    356 -    Element phim; mul(phim, sub(d,p,IntFactorDom<RandIter>::one), sub(l,q,IntFactorDom<RandIter>::one));
    357 -    mul(m, p, q);
    358 +    Element phim; IntRSADom<RandIter>::mul(phim, IntRSADom<RandIter>::sub(d,p,IntFactorDom<RandIter>::one), IntRSADom<RandIter>::sub(l,q,IntFactorDom<RandIter>::one));
    359 +    IntRSADom<RandIter>::mul(m, p, q);
    360  
    361      Element v, gd;
    362  
    363      if (_fast_impl) {
    364 -        mod(k,SIMPLE_EXPONENT, phim);
    365 +        IntRSADom<RandIter>::mod(k,SIMPLE_EXPONENT, phim);
    366          this->gcd(gd,u,v,k,phim);
    367      } else {
    368          do {
    369              this->random(g,k,phim);
    370          } while (this->gcd(gd,u,v,k,phim) != 1);
    371      }
    372 -    modin(u,phim);
    373 -    if ( islt(u,IntFactorDom<RandIter>::zero) ) addin(u,phim);
    374 +    IntRSADom<RandIter>::modin(u,phim);
    375 +    if ( IntRSADom<RandIter>::islt(u,IntFactorDom<RandIter>::zero) ) IntRSADom<RandIter>::addin(u,phim);
    376  }
    377  
    378  // =================================================================== //
    379 @@ -270,10 +270,10 @@
    380  typename IntRSADom<RandIter>::Element& IntRSADom<RandIter>::point_break(Element& u) {
    381      if ( isZero(_u) ) {
    382          Element p,v,d, pm;
    383 -        factor(p, _m);
    384 -        mul(pm, sub(v,p,IntFactorDom<RandIter>::one), subin( this->div(d,_m,p), IntFactorDom<RandIter>::one ) );
    385 +        IntRSADom<RandIter>::factor(p, _m);
    386 +        IntRSADom<RandIter>::mul(pm, IntRSADom<RandIter>::sub(v,p,IntFactorDom<RandIter>::one), IntRSADom<RandIter>::subin( this->div(d,_m,p), IntFactorDom<RandIter>::one ) );
    387          this->gcd(d,_u,v,_k,pm);
    388 -        if (islt(_u,IntFactorDom<RandIter>::zero)) addin(_u, pm);
    389 +        if (IntRSADom<RandIter>::islt(_u,IntFactorDom<RandIter>::zero)) IntRSADom<RandIter>::addin(_u, pm);
    390      }
    391      return u = _u;
    392  }
    393 --- src/src/library/poly1/givpoly1factor.inl    2008-02-26 23:11:36.000000000 +0100
    394 +++ patches/givpoly1factor.inl  2012-03-27 15:03:08.837739790 +0200
    395 @@ -24,7 +24,7 @@
    396      , Residu_t MOD) const {
    397         typename Domain::Element one;
    398         _domain.init(one, 1UL);
    399 -    Degree dG;degree(dG,G);
    400 +    Degree dG; this->degree(dG,G);
    401      if (dG == d)
    402          L.push_back(G);
    403      else {
    404 @@ -32,7 +32,7 @@
    405          while (! splitted) {
    406              Rep tmp, G1;
    407              this->gcd(G1, G, this->random(_g, tmp, dG-1));
    408 -            Degree dG1; degree(dG1,G1);
    409 +            Degree dG1; this->degree(dG1,G1);
    410  // write(std::cerr << "SF rd: ", tmp) << std::endl;
    411  // write(std::cerr << "SF G1: ", G1) << std::endl;
    412              if ( dG1 != dG) {
    413 @@ -44,8 +44,8 @@
    414                  Integer pp = (power(Integer(MOD), d.value()) - 1)/2;
    415  // std::cerr << "pp: " << pp << std::endl;
    416                  Rep tp, tp2, G2;
    417 -                this->gcd(G2,G, sub(tp2, this->powmod(tp, tmp, pp, G) , one) );
    418 -                Degree dG2; degree(dG2,G2);
    419 +                this->gcd(G2,G, this->sub(tp2, this->powmod(tp, tmp, pp, G) , one) );
    420 +                Degree dG2; this->degree(dG2,G2);
    421  // write(std::cerr << "SF t2: ", tp2) << std::endl;
    422  // write(std::cerr << "SF G2: ", G2) << std::endl;
    423                  if ( dG2 != dG) {
    424 @@ -54,8 +54,8 @@
    425                          SplitFactor ( L, G2, d, MOD) ;
    426                      }
    427  // UNNECESSARY : ANYTHING FOUND BY G3 WOULD HAVE THE COFACTOR IN G2
    428 -                     Rep G3; this->gcd(G3, G, add(tp2,tp,one) );
    429 -                     Degree dG3; degree(dG3,G3);
    430 +                     Rep G3; this->gcd(G3, G, this->add(tp2,tp,one) );
    431 +                     Degree dG3; this->degree(dG3,G3);
    432  // write(std::cerr << "SF t3: ", tp2) << std::endl;
    433  // write(std::cerr << "SF G3: ", G3) << std::endl;
    434                       if (( dG3 != dG) && (dG3 > 0 )) {
    435 @@ -133,21 +133,21 @@
    436  // write(std::cerr << "DD in: ", f) << std::endl;
    437      Rep W, D, P = f;
    438      Degree dP;
    439 -    Rep Unit, G1; init(Unit, Degree(1), one);
    440 +    Rep Unit, G1; this->init(Unit, Degree(1), one);
    441      W.copy(Unit);
    442 -    degree(dP,P); Degree dPo = (dP/2);
    443 +    this->degree(dP,P); Degree dPo = (dP/2);
    444      for(Degree dp = 1; dp <= dPo; ++dp) {
    445  // std::cerr << "DD degree: " << dp << std::endl;
    446          this->powmod(W, D.copy(W), MOD, P);
    447 -        this->gcd (G1,sub(D,W,Unit), P) ;
    448 -        Degree dG1; degree(dG1,G1);
    449 +        this->gcd (G1,this->sub(D,W,Unit), P) ;
    450 +        Degree dG1; this->degree(dG1,G1);
    451  // write(std::cerr << "DD found: ", G1) << ", of degree " << dG1 << std::endl;
    452          if ( dG1 > 0 ) {
    453              SplitFactor (L, G1, dp, MOD);
    454 -            divin(P,G1);
    455 +            this->divin(P,G1);
    456          }
    457      }
    458 -    degree(dP,P);   
    459 +    this->degree(dP,P);   
    460      if (dP > 0)
    461          L.push_back(P);
    462  // write(std::cerr << "DD: ", P) << std::endl;
    463 @@ -165,10 +165,10 @@
    464                const Rep& P,
    465                Residu_t MOD)  const {
    466  // write(std::cerr << "CZ in: ", P) << std::endl;
    467 -    Degree dp; degree(dp,P);
    468 +    Degree dp; this->degree(dp,P);
    469      size_t nb=dp.value()+1;
    470      Rep * g = new Rep[nb];
    471 -    sqrfree(nb,g,P);
    472 +    this->sqrfree(nb,g,P);
    473  // std::cerr << "CZ sqrfree: " << nb << std::endl;
    474      for(size_t i = 0; i<nb;++i) {
    475          size_t this_multiplicity = Lf.size();
    476 @@ -200,17 +200,17 @@
    477          // Square free ?
    478     typename Domain::Element _one;
    479     _domain.init(_one,1UL);
    480 -   Rep W,D; this->gcd(W,diff(D,P),P);
    481 +   Rep W,D; this->gcd(W,Poly1FactorDom<Domain,Tag, RandIter>::diff(D,P),P);
    482      Degree d, dP;
    483 -    if (degree(d,W) > 0) return 0;
    484 +    if (Poly1FactorDom<Domain,Tag, RandIter>::degree(d,W) > 0) return 0;
    485          // Distinct degree free ?
    486 -    Rep Unit, G1; init(Unit, Degree(1), _one);
    487 +    Rep Unit, G1; Poly1FactorDom<Domain,Tag, RandIter>::init(Unit, Degree(1), _one);
    488      W.copy(Unit);
    489 -    degree(dP,P); Degree dPo = (dP/2);
    490 +    Poly1FactorDom<Domain,Tag, RandIter>::degree(dP,P); Degree dPo = (dP/2);
    491      for(Degree dp = 1; dp <= dPo; ++dp) {
    492          this->powmod(W, D.copy(W), MOD, P);
    493 -        this->gcd (G1, sub(D,W,Unit), P) ;
    494 -        if ( degree(d,G1) > 0 ) return 0;
    495 +        this->gcd (G1, Poly1FactorDom<Domain,Tag, RandIter>::sub(D,W,Unit), P) ;
    496 +        if ( Poly1FactorDom<Domain,Tag, RandIter>::degree(d,G1) > 0 ) return 0;
    497      }
    498      return 1;
    499  }
    500 --- src/src/library/poly1/givpoly1padic.h       2007-11-21 11:40:39.000000000 +0100
    501 +++ patches/givpoly1padic.h     2012-03-27 05:11:31.197732877 +0200
    502 @@ -106,11 +106,11 @@
    503              IntegerDom::divmod(iq, ir, E, q);
    504              radix(Q, iq, n-t);
    505              radix(P, ir, t);
    506 -            Degree dp; degree(dp,P); ++dp;
    507 +            Degree dp; this->degree(dp,P); ++dp;
    508              for(long i=t; dp<i; --i)
    509                  P.push_back(_domain.zero);
    510          P.insert(P.end(),Q.begin(),Q.end());
    511 -        return setdegree(P);
    512 +        return this->setdegree(P);
    513      }
    514  
    515  
    516 --- src/src/library/poly1/givpoly1proot.inl     2007-10-02 16:49:45.000000000 +0200
    517 +++ patches/givpoly1proot.inl   2012-03-27 04:57:49.437732716 +0200
    518 @@ -28,7 +28,7 @@
    519  
    520  template<class Domain, class Tag, class RandIter >
    521  inline typename Poly1FactorDom<Domain,Tag, RandIter>::Element& Poly1FactorDom<Domain,Tag, RandIter>::creux_random_irreducible (Element& R, Degree n) const {
    522 -    init(R, n, _domain.one);
    523 +    Poly1FactorDom<Domain,Tag, RandIter>::init(R, n, _domain.one);
    524      Residu_t MOD = _domain.residu();
    525  
    526          // Search for an irreducible BINOMIAL : X^n + a
    527 @@ -97,9 +97,9 @@
    528  // ---------------------------------------------------------------
    529  template<class Domain, class Tag, class RandIter >
    530  inline typename Poly1FactorDom<Domain,Tag, RandIter>::Element& Poly1FactorDom<Domain,Tag, RandIter>::ixe_irreducible (Element& R, Degree n) const {
    531 -    init(R, n, _domain.one);
    532 +    Poly1FactorDom<Domain,Tag, RandIter>::init(R, n, _domain.one);
    533      Element IXE;
    534 -    init(IXE,Degree(1),_domain.one);
    535 +    Poly1FactorDom<Domain,Tag, RandIter>::init(IXE,Degree(1),_domain.one);
    536      Residu_t MOD = _domain.residu();
    537  
    538          // Search for an irreducible BINOMIAL : X^n + a
    539 @@ -229,13 +229,13 @@
    540  template<class Domain, class Tag, class RandIter>
    541  bool Poly1FactorDom<Domain,Tag, RandIter>::is_prim_root( const Rep& P, const Rep& F)  const {
    542      bool isproot = 0;
    543 -    Rep A, G; mod(A,P,F);
    544 +    Rep A, G; Poly1FactorDom<Domain,Tag, RandIter>::mod(A,P,F);
    545      Degree d;
    546 -    if ( degree(d, this->gcd(G,A,F)) == 0) {
    547 +    if ( Poly1FactorDom<Domain,Tag, RandIter>::degree(d, this->gcd(G,A,F)) == 0) {
    548          Residu_t MOD = _domain.residu();
    549          IntFactorDom<> FD;
    550          IntFactorDom<>::Element IMOD( MOD ), q, qp;
    551 -        degree(d,F);
    552 +        Poly1FactorDom<Domain,Tag, RandIter>::degree(d,F);
    553  //         FD.pow(q ,IMOD, d.value());
    554  //         FD.sub(qp, q, FD.one);
    555          FD.subin( FD.pow(qp ,IMOD, d.value()) , FD.one);
    556 @@ -286,14 +286,14 @@
    557  
    558  template<class Domain, class Tag, class RandIter >
    559  inline typename Poly1FactorDom<Domain,Tag, RandIter>::Rep& Poly1FactorDom<Domain,Tag, RandIter>::give_prim_root(Rep& R, const Rep& F)  const {
    560 -    Degree n; degree(n,F);
    561 +    Degree n; Poly1FactorDom<Domain,Tag, RandIter>::degree(n,F);
    562      Residu_t MOD = _domain.residu();
    563  //    this->write(std::cout << "Give Pr: ", F) << std::endl;
    564      
    565      
    566          // Search for a primitive BINOMIAL : X^i + a
    567      for(Degree di=1;di<n;++di) {
    568 -        init(R, di, _domain.one);
    569 +        Poly1FactorDom<Domain,Tag, RandIter>::init(R, di, _domain.one);
    570  //         for(Residu_t a=MOD; a--; ) {
    571          for(Residu_t a=0; a<MOD;++a ) {
    572              _domain.assign(R[0],a);
    573 @@ -303,7 +303,7 @@
    574      }
    575          // Search for a primitive TRINOMIAL : X^i + b*X^j + a
    576      for(Degree di=2;di<n;++di) {
    577 -        init(R, di, _domain.one);
    578 +        Poly1FactorDom<Domain,Tag, RandIter>::init(R, di, _domain.one);
    579          for(Degree dj=1;dj<di;++dj)
    580  //             for(Residu_t b=MOD; b--;) {
    581              for(Residu_t b=0; b<MOD;++b) {
  • patches/givtablelimits.h.patch

    diff -Nru givaro-3.2.13.p0/patches/givtablelimits.h.patch givaro-3.7.0/patches/givtablelimits.h.patch
    old new  
    1 diff -ru src/src/kernel/zpz/givtablelimits.h b/src/kernel/zpz/givtablelimits.h
    2 --- src/src/kernel/zpz/givtablelimits.h 2008-07-10 19:45:18.000000000 +0200
    3 +++ b/src/kernel/zpz/givtablelimits.h   2012-05-26 00:29:24.383373188 +0200
    4 @@ -36,6 +36,10 @@
    5  #include "givaro/givprimes16.h"
    6  
    7  #include <math.h>
    8 +/* SAGE: This declaration should be in <math.h>, but it is missing
    9 + * in Cygwin. */
    10 +extern double logb(double);
    11 +
    12  #include <stddef.h>
    13  
    14    // ---------------------------------------------  class
    15 @@ -71,7 +75,7 @@
    16          tmp *= double(P-1);
    17          tmp *= double(e);
    18          tmp *= double(nm);
    19 -        size_t k = ilogb(tmp);
    20 +        size_t k = size_t(logb(tmp));
    21          return ( (53/(2*e-1))>k ? ++k : 0);       
    22      }
    23          
  • patches/gmp++_int.inl.patch

    diff -Nru givaro-3.2.13.p0/patches/gmp++_int.inl.patch givaro-3.7.0/patches/gmp++_int.inl.patch
    old new  
    1 diff -ru src/src/kernel/gmp++/gmp++_int.inl b/src/kernel/gmp++/gmp++_int.inl
    2 --- src/src/kernel/gmp++/gmp++_int.inl  2007-01-11 19:42:51.000000000 +0100
    3 +++ b/src/kernel/gmp++/gmp++_int.inl    2012-05-26 00:35:46.343372071 +0200
    4 @@ -314,8 +314,8 @@
    5  
    6  #ifdef __GMP_PLUSPLUS__
    7  inline gmp_randclass& Integer::randstate(long unsigned int seed) {
    8 -       static gmp_randclass randstate(GMP_RAND_ALG_DEFAULT,seed);
    9 -       return static_cast<gmp_randclass&>(randstate);
    10 +       static gmp_randclass* randstate = new gmp_randclass(GMP_RAND_ALG_DEFAULT,seed);
    11 +       return *randstate;
    12  }
    13  
    14  inline void Integer::seeding(long unsigned int s) {
  • spkg-install

    diff -Nru givaro-3.2.13.p0/spkg-install givaro-3.7.0/spkg-install
    old new  
    11#!/usr/bin/env bash
    22
    3 if [[ -z "$SAGE_LOCAL" ]]; then
    4     echo >&2 "Error: SAGE_LOCAL undefined - exiting..."
    5     echo >&2 "Maybe run 'sage -sh'?"
    6     exit 1
     3if [ "$SAGE_LOCAL" = "" ]; then
     4   echo "SAGE_LOCAL undefined ... exiting";
     5   echo "Maybe run 'sage -sh'?"
     6   exit 1
    77fi
    88
    99#################################
     
    3232
    3333export CFLAGS CPPFLAGS CXXFLAGS LDFLAGS
    3434
    35 
    3635cd src/
    3736
    38 #################
    39 # Apply patches #
    40 #################
    41 
    42 echo "Applying patches..."
    43 for patch in ../patches/*.patch; do
    44     patch -p1 <"$patch"
    45     if [[ $? -ne 0 ]]; then
    46         echo >&2 "Error: '$patch' failed to apply."
    47         exit 1
    48     fi
    49 done
    50 
    51 ########################################
    52 # Configure, build and install Givaro: #
    53 ########################################
    54 
    55 echo "Now configuring Givaro..."
    56 ./configure --prefix="$SAGE_LOCAL" --libdir="$SAGE_LOCAL/lib" \
    57             --with-gmp="$SAGE_LOCAL" --enable-shared
    58 if [[ $? -ne 0 ]]; then
    59     echo >&2 "Error configuring Givaro."
     37./configure --prefix=$SAGE_LOCAL --libdir="$SAGE_LOCAL/lib" --with-gmp="$SAGE_LOCAL/" --enable-shared
     38
     39if [ $? -ne 0 ]; then
     40    echo "Error configuring givaro"
    6041    exit 1
    6142fi
    6243
    63 echo "Now building Givaro..."
    6444$MAKE
    65 if [[ $? -ne 0 ]]; then
    66     echo >&2 "Error building Givaro."
    67     exit 1
     45if [ $? -ne 0 ]; then
     46    echo "Error building givaro"
    6847fi
    6948
    70 echo "Now installing Givaro..."
    7149$MAKE install
    72 if [[ $? -ne 0 ]]; then
    73     echo >&2 "Error installing Givaro."
     50if [ $? -ne 0 ]; then
     51    echo "Error installing givaro"
    7452    exit 1
    7553fi
     54