/usr/include/givaro/givintprime.h is in libgivaro-dev 4.0.2-5.
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | // =================================================================== //
// Copyright(c)'1994-2009 by The Givaro group
// This file is part of Givaro.
// Givaro is governed by the CeCILL-B license under French law
// and abiding by the rules of distribution of free software.
// see the COPYRIGHT file for more details.
// Time-stamp: <03 Aug 15 11:40:49 Jean-Guillaume.Dumas@imag.fr>
// =================================================================== //
/*! @file givintprime.h
* @ingroup integers
* @brief primes
* - Prime numbers
* - Modular powering,
* - Fermat numbers,
* - Primality tests
* - Factorization : (There are parameters to fix)
* .
*/
#ifndef __GIVARO_integers_prime_H
#define __GIVARO_integers_prime_H
#include "givaro/givinteger.h"
namespace Givaro {
// =================================================================== //
//! 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
#define GIVARO_ISLT(a,b) ((a)<(b))
#define GIVARO_ISLEQ(a,b) ((a)<=(b))
#define GIVARO_ISGT(a,b) ((a)>(b))
#define GIVARO_ISGEQ(a,b) ((a)>=(b))
// =================================================================== //
//! 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));
int64_t l;
return int32_t (int32_t(GIVARO_ISLT(n,BOUNDARY_isprime) ? isprime_Tabule((int32_t)convert(l,n)):
GIVARO_ISLT(n,BOUNDARY_2_isprime) ? isprime_Tabule2((int32_t)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 MyRandIter>
unsigned int Miller(MyRandIter& g, const Rep& n=_GIVARO_ISPRIMETESTS_) const ;
template<class MyRandIter>
Rep& test_Lehmann(MyRandIter& g, Rep&, const Rep& n=_GIVARO_ISPRIMETESTS_) const ;
template<class MyRandIter>
int Lehmann(MyRandIter& 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 Protected::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
#if 0
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
#endif
};
} // Givaro
#include "givaro/givintprime.inl"
#endif // __GIVARO_integers_prime_H
/* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
|