/usr/include/givaro/givintprime.h is in libgivaro-dev 3.2.13-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | // =================================================================== //
// Givaro : Prime numbers
// Modular powering,
// Fermat numbers,
// Primality tests, Factorization :
// (There are parameters to fix)
// Time-stamp: <06 Jun 06 14:48:16 Jean-Guillaume.Dumas@imag.fr>
// =================================================================== //
#ifndef _GIVARO_INTEGERS_PRIME_H_
#define _GIVARO_INTEGERS_PRIME_H_
#ifndef _GIVARO_ISPRIMETESTS_
#define _GIVARO_ISPRIMETESTS_ 5
#endif
#include "givaro/givinteger.h"
// =================================================================== //
// Fermat numbers
// =================================================================== //
class FermatDom : public IntegerDom {
public:
FermatDom() : IntegerDom() {}
Rep& fermat (Rep&, const long) const ;
int pepin (const long) const ;
};
// =================================================================== //
// Primality tests and factorization algorithms
// =================================================================== //
// Those macros are parameters to fix
// primes known
// first array
#define LOGMAX 3512
#define TABMAX 32768
// second array
#define LOGMAX2 3031
#define TABMAX2 65536
// Bounds between big and small
#define BOUNDARY_isprime TABMAX
#define BOUNDARY_2_isprime TABMAX2
// =================================================================== //
// Primality tests
// =================================================================== //
class IntPrimeDom : public IntegerDom {
public:
IntPrimeDom() : IntegerDom() {}
int isprime(const Rep& n, int r=_GIVARO_ISPRIMETESTS_) const
{
/*
return probab_prime(n);
*/
// return ((n)<BOUNDARY_isprime ? isprime_Tabule(n) :
// (n)<BOUNDARY_2_isprime ? isprime_Tabule2(n) :
// probab_prime(n));
long l;
return (islt(n,BOUNDARY_isprime) ? isprime_Tabule(convert(l,n)):
islt(n,BOUNDARY_2_isprime) ? isprime_Tabule2(convert(l,n)):
local_prime(n,r));
}
// if p is a prime power, p = r^return
// else return is 0 and r is undefined
unsigned int isprimepower(Rep&, const Rep&) const ;
template<class RandIter>
unsigned int Miller(RandIter& g, const Rep& n=_GIVARO_ISPRIMETESTS_) const ;
template<class RandIter>
Rep& test_Lehmann(RandIter& g, Rep&, const Rep& n=_GIVARO_ISPRIMETESTS_) const ;
template<class RandIter>
int Lehmann(RandIter& g, const Rep& n=_GIVARO_ISPRIMETESTS_) const ;
int isprime_Tabule(const int n) const ;
int isprime_Tabule2(const int n) const ;
Rep& nextprime(Rep&, const Rep&, int r=_GIVARO_ISPRIMETESTS_) const ;
Rep& prevprime(Rep&, const Rep&, int r=_GIVARO_ISPRIMETESTS_) const ;
Rep& nextprimein(Rep&, int r=_GIVARO_ISPRIMETESTS_) const ;
Rep& prevprimein(Rep&, int r=_GIVARO_ISPRIMETESTS_) const ;
// Using Integer
int local_prime(const Rep& n, int r=_GIVARO_ISPRIMETESTS_) const { return probab_prime(n,r); }
private:
static int IP[LOGMAX+5]; // -- table for Tabule
static const int * TP; // -- shifted table
static int IP2[LOGMAX2+5]; // -- table for Tabule2
static const int * TP2; // -- shifted table
/*
static int Tabule2(const Integer& p) ;
static int Tabule(const Integer& p) ;
static int _memTab2[LOGMAX2+5]; // -- table for Tabule2
static const int* _Tab2; // -- shifted _memTabule2
static int _memTab[]; // -- table for Tabule
static const int* _Tab; // -- shifted _memTabule
*/
};
#include "givaro/givintprime.inl"
#endif
|