linbox
PrimeIterator< Trait > Class Template Reference

Prime Iterator. More...

#include <random-prime.h>

+ Inheritance diagram for PrimeIterator< Trait >:

Public Types

typedef integer Prime_Type
 
typedef UniqueSamplingTrait< Trait > UniqueSamplingTag
 whether a prime can be picked more than once
 
typedef Trait IteratorTag
 

Public Member Functions

 PrimeIterator (uint64_t bits=23, uint64_t seed=0)
 Constructor.
 
PrimeIterator< Trait > & operator++ ()
 operator++() (prefix ++ operator) creates a new random prime.
 
const Prime_Typeoperator* () const
 get the random prime.
 
void setBits (uint64_t bits)
 Sets the bit size.
 
uint64_t getBits () const
 

Static Public Member Functions

static void setSeed (uint64_t ul)
 Sets the seed.
 

Protected Member Functions

virtual void generatePrime ()
 
void generatePrime ()
 
void generatePrime ()
 
void generatePrime ()
 

Protected Attributes

uint64_t _bits
 common lenght of all primes
 
integer _prime
 the generated prime.
 
Givaro::IntPrimeDom _IPD
 empty struct dealing with primality.
 

Detailed Description

template<class Trait = IteratorCategories::HeuristicTag>
class LinBox::PrimeIterator< Trait >

Prime Iterator.

Generates prime of specified length using a heuristically random distribution (no guarantee whatsoever).

It is given by nextprime(2^_bits-p) where size(p) < _bits.

Examples
examples/dixonsolve.C.

Member Typedef Documentation

◆ Prime_Type

template<class Trait = IteratorCategories::HeuristicTag>
typedef integer Prime_Type

◆ UniqueSamplingTag

template<class Trait = IteratorCategories::HeuristicTag>
typedef UniqueSamplingTrait<Trait> UniqueSamplingTag

whether a prime can be picked more than once

◆ IteratorTag

template<class Trait = IteratorCategories::HeuristicTag>
typedef Trait IteratorTag

Constructor & Destructor Documentation

◆ PrimeIterator()

template<class Trait = IteratorCategories::HeuristicTag>
PrimeIterator ( uint64_t bits = 23,
uint64_t seed = 0 )
inline

Constructor.

Parameters
bitssize of primes (in bits). Default is 23 so it can fit in a Linbox::Modular<double>.
seedif 0 a seed will be generated, otherwise, the provided seed will be use.

Member Function Documentation

◆ generatePrime() [1/4]

◆ operator++()

template<class Trait = IteratorCategories::HeuristicTag>
PrimeIterator< Trait > & operator++ ( )
inline

operator++() (prefix ++ operator) creates a new random prime.

◆ operator*()

template<class Trait = IteratorCategories::HeuristicTag>
const Prime_Type & operator* ( ) const
inline

get the random prime.

returns the actual prime.

Warning
a new prime is not generated.

◆ setSeed()

template<class Trait = IteratorCategories::HeuristicTag>
static void setSeed ( uint64_t ul)
inlinestatic

Sets the seed.

Set the random seed to be ul.

Parameters
ulthe new seed.

◆ setBits()

template<class Trait = IteratorCategories::HeuristicTag>
void setBits ( uint64_t bits)
inline

Sets the bit size.

Parameters
bitsthe new bit size.

◆ getBits()

template<class Trait = IteratorCategories::HeuristicTag>
uint64_t getBits ( ) const
inline

◆ generatePrime() [2/4]

void generatePrime ( )
inlineprotected

◆ generatePrime() [3/4]

void generatePrime ( )
inlineprotected

◆ generatePrime() [4/4]

void generatePrime ( )
inlineprotected

Field Documentation

◆ _bits

template<class Trait = IteratorCategories::HeuristicTag>
uint64_t _bits
protected

common lenght of all primes

◆ _prime

template<class Trait = IteratorCategories::HeuristicTag>
integer _prime
protected

the generated prime.

◆ _IPD

template<class Trait = IteratorCategories::HeuristicTag>
Givaro::IntPrimeDom _IPD
protected

empty struct dealing with primality.


The documentation for this class was generated from the following file: