1 // ========================================================================== 2 // Copyright(c)'1994-2009 by The Givaro group 3 // This file is part of Givaro. 4 // Givaro is governed by the CeCILL-B license under French law 5 // and abiding by the rules of distribution of free software. 6 // see the COPYRIGHT file for more details. 7 // file: givadicqfq.h 8 // Time-stamp: <30 Nov 11 11:12:05 Jean-Guillaume.Dumas@imag.fr> 9 // date: 2007 10 // version: 11 // author: Jean-Guillaume.Dumas 12 13 /*! @file zpz/givtablelimits.h 14 * @ingroup zpz 15 * @brief Zech extension. 16 * Zech extension fitting a small enough memory space 17 * t-adic max sizes for BLAS based linear algebra over extension fields 18 * @bib 19 * - Dumas, Gautier, Pernet <i>Finite field linear algebra subroutines.</i> 20 * ISSAC'02: Proceedings of the 2002 International Symposium on Symbolic 21 * and Algebraic Computation, Lille, France pp 63--74. 22 */ 23 24 #ifndef __GIVARO_tablesize_MAX_H 25 #define __GIVARO_tablesize_MAX_H 26 27 28 #ifndef _GIVARO_FF_TABLE_MAX 29 // 2^23 ---> 2^23*4*3 = 100K 30 // #define FF_TABLE_MAX 8388608U 31 // 2^20 ---> 2s on 735MHz 32 //#define FF_TABLE_MAX 1048576U 33 // Now 2^21+1 seems OK 34 #define _GIVARO_FF_TABLE_MAX 2097153U 35 #endif 36 37 #ifndef _GIVARO_FF_MAXEXPONENT_ 38 #define _GIVARO_FF_MAXEXPONENT_ 21 39 #endif 40 41 42 #include <iostream> 43 #include <vector> 44 #include "givaro/givprimes16.h" 45 46 #include <cmath> 47 #include <stddef.h> 48 49 namespace Givaro { 50 51 // --------------------------------------------- class 52 class AdicSize { 53 public: 54 nmax53(const unsigned long P,const unsigned long e)55 static size_t nmax53(const unsigned long P, const unsigned long e) { 56 size_t i = 0; 57 while (Primes16::ith(i) < P) ++i; 58 return n_max_53[i][e-2]; 59 } 60 qmax53(const unsigned long P,const unsigned long e)61 static size_t qmax53(const unsigned long P, const unsigned long e) { 62 size_t i = 0; 63 while (Primes16::ith(i) < P) ++i; 64 return qadic_53[i][e-2]; 65 } 66 nmax64(const unsigned long P,const unsigned long e)67 static size_t nmax64(const unsigned long P, const unsigned long e) { 68 size_t i = 0; 69 while (Primes16::ith(i) < P) ++i; 70 return n_max_64[i][e-2]; 71 } 72 qmax64(const unsigned long P,const unsigned long e)73 size_t qmax64(const unsigned long P, const unsigned long e) { 74 size_t i = 0; 75 while (Primes16::ith(i) < P) ++i; 76 return qadic_64[i][e-2]; 77 } 78 twopmax53(const unsigned long P,const unsigned long e,const unsigned long nm)79 static size_t twopmax53(const unsigned long P, const unsigned long e, const unsigned long nm) { 80 double tmp = double(P-1); 81 tmp *= double(P-1); 82 tmp *= double(e); 83 tmp *= double(nm); 84 size_t k = (size_t)ilogb(tmp); 85 return ( (53/(2*e-1))>k ? ++k : 0); 86 } 87 twopmax53(const unsigned long P,const unsigned long e)88 static size_t twopmax53(const unsigned long P, const unsigned long e) { 89 size_t k = 53/(2*e-1); 90 return ( std::pow((double)2.0,double(k))>double(e*(P-1)*(P-1)) ? k: 0); 91 } 92 93 private: 94 static const size_t n_max_53[][_GIVARO_FF_MAXEXPONENT_]; 95 static const size_t n_max_64[][_GIVARO_FF_MAXEXPONENT_]; 96 static const size_t qadic_53[][_GIVARO_FF_MAXEXPONENT_]; 97 static const size_t qadic_64[][_GIVARO_FF_MAXEXPONENT_]; 98 }; 99 100 } // namespace Givaro 101 102 #endif // __GIVARO_tablesize_MAX_H 103 /* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 104 // vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s 105