/usr/include/linbox/randiter/random-prime.h is in liblinbox-dev 1.1.6~rc0-4.1.
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 | /* -*- mode:C++ -*- */
/* File: primeiter.h
* Time-stamp: <12 Mar 07 18:35:26 Jean-Guillaume.Dumas@imag.fr>
*/
#ifndef __RANDOM_PRIME_ITERATOR_H__
#define __RANDOM_PRIME_ITERATOR_H__
#include <linbox/integer.h>
#include <linbox/util/timer.h>
namespace LinBox {
class RandomPrimeIterator {
public:
int _bits;
integer _shift;
integer _prime;
RandomPrimeIterator(int bits = 30, unsigned long seed = 0)
: _bits(bits)
{
_shift = integer(1)<<_bits;
if (! seed)
RandomPrimeIterator::setSeed( BaseTimer::seed() );
else
RandomPrimeIterator::setSeed( seed );
integer::random(_prime,_bits-1);
_prime = _shift - _prime;
nextprime( _prime, _prime);
}
// define the prime type
typedef integer Prime_Type;
/** @brief operator++()
* creates a new random prime
*/
inline RandomPrimeIterator &operator ++ () {
integer::random(_prime,_bits-1);
_prime = _shift - _prime;
nextprime( _prime, _prime);
return *this;
}
/** @brief operator*()
* returns the actual prime
*/
Prime_Type &operator * () {
return _prime;
}
/** @brief setSeed (unsigned long ul)
* Set the random seed to be ul.
*/
void static setSeed(unsigned long ul) {
integer::seeding(ul);
}
};
}
#endif
|