Template Class LinearCongruentialMap

Class Documentation

template<typename T>
class LinearCongruentialMap

Computes a bijection f:[p]->[p], x -> (a*x+b) mod p where p is chosen as the smallest p >= n and p prime. a and b are drawn unif at random.

Template Parameters:

T

Public Types

using value_type = T

Public Functions

inline LinearCongruentialMap()
inline explicit LinearCongruentialMap(value_type n, unsigned seed = 0)
inline LinearCongruentialMap(value_type n, std::mt19937_64 &prng)
inline LinearCongruentialMap(value_type n, value_type a, value_type b)
LinearCongruentialMap(const LinearCongruentialMap&) = default
LinearCongruentialMap(LinearCongruentialMap&&) noexcept = default
LinearCongruentialMap &operator=(const LinearCongruentialMap&) = default
LinearCongruentialMap &operator=(LinearCongruentialMap&&) noexcept = default
inline value_type hash(value_type n) const

Hashes [n] to [p] with (a*x+b) mod p.

inline value_type operator()(value_type n) const

Alias to hash(n)

inline value_type invert(value_type y) const

invert(hash(x)) == x

inline bool isGap(value_type y) const

Is true if there exists no x in [n], s.t. h(x) == y, i.e. it can be used to determine if the map maps to y

inline void sampleParameters(std::mt19937_64 &prng)

randomly samples parameters a and b

inline void setAsIdentity()

Sets parameters a = 1 and b = 0.

inline value_type param_a() const
inline value_type param_ainv() const
inline value_type param_b() const
inline value_type param_p() const