Skip to content

Commit d174b9a

Browse files
committed
polish the FixedPrimeIterator
1 parent 29fee65 commit d174b9a

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

examples/dixonsolve.C

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ int test(_Matrix A, std::string vector_file, bool inv, bool pp, bool sparse_elim
128128
const size_t bitsize((size_t) FieldTraits<Field>::bestBitSize(A.rowdim()));
129129
Givaro::Integer randomPrime( *(PrimeIterator<>(bitsize)) );
130130

131-
FixPrime fixedprime( randomPrime );
132-
DixonSolver<Ints, Field, FixPrime, _EliminationMethod> rsolve(A.field(), fixedprime);
131+
FixedPrimeIterator fixedprime( randomPrime );
132+
DixonSolver<Ints, Field, FixedPrimeIterator, _EliminationMethod> rsolve(A.field(), fixedprime);
133133
std::cout << "Using: " << *fixedprime << " as the fixed p-adic." << std::endl;
134134

135135
chrono.start();

linbox/randiter/random-prime.h

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,15 +317,27 @@ namespace LinBox
317317
} while(!_IPD.isprime(_prime));
318318
}
319319

320-
struct FixPrime {
321-
typedef Givaro::Integer Prime_Type;
322-
const Prime_Type _myprime;
323-
FixPrime(const Givaro::Integer& i) : _myprime(i) {}
324-
inline FixPrime &operator ++ () { return *this; }
325-
const Prime_Type &operator * () const { return randomPrime(); }
320+
/*! @brief Adaptor class to make a single prime number behave like a PrimeIterator.
321+
*/
322+
class FixedPrimeIterator {
323+
public:
324+
using Prime_Type = Givaro::Integer;
325+
using UniqueSamplingTag = std::false_type;
326+
using IteratorTag = IteratorCategories::DeterministicTag;
327+
328+
FixedPrimeIterator (const Givaro::Integer& i) : _myprime(i) {}
329+
330+
inline FixedPrimeIterator &operator ++ () { return *this; }
331+
332+
const Prime_Type & operator * () const { return randomPrime(); }
326333
const Prime_Type & randomPrime() const { return _myprime; }
334+
327335
void setBits(uint64_t bits) {}
328-
template<class _ModField> void setBitsField() { }
336+
337+
template<class _ModField> void setBitsField() {}
338+
339+
private:
340+
const Prime_Type _myprime;
329341
};
330342

331343
}

0 commit comments

Comments
 (0)