Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin > Class Template Reference
Inheritance diagram for pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >:
Collaboration diagram for pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >:

Classes

struct  can_specify_stream_tag
struct  no_specifiable_stream_tag

Public Types

typedef xtype result_type
typedef itype state_type
Public Types inherited from pcg_detail::oneseq_stream< itype >
typedef itype state_type

Public Member Functions

result_type operator() ()
result_type operator() (result_type upper_bound)
void advance (itype delta)
void backstep (itype delta)
void discard (itype delta)
bool wrapped ()
 engine (itype state=itype(0xcafef00dd15ea5e5ULL))
template<typename sm = stream_mixin>
 engine (itype state, typename sm::stream_state stream_seed)
template<typename SeedSeq>
 engine (SeedSeq &&seedSeq, typename std::enable_if< !stream_mixin::can_specify_stream &&!std::is_convertible< SeedSeq, itype >::value &&!std::is_convertible< SeedSeq, engine >::value, no_specifiable_stream_tag >::type={})
template<typename SeedSeq>
 engine (SeedSeq &&seedSeq, typename std::enable_if< stream_mixin::can_specify_stream &&!std::is_convertible< SeedSeq, itype >::value &&!std::is_convertible< SeedSeq, engine >::value, can_specify_stream_tag >::type={})
template<typename... Args>
void seed (Args &&... args)

Static Public Member Functions

static constexpr size_t period_pow2 ()
static constexpr result_type min ()
static constexpr result_type max ()
Static Public Member Functions inherited from pcg_detail::oneseq_stream< itype >
static constexpr itype stream ()
static constexpr size_t streams_pow2 ()

Protected Member Functions

itype bump (itype state)
itype base_generate ()
itype base_generate0 ()
itype distance (itype newstate, itype mask=itype(~itype(0U))) const
Protected Member Functions inherited from pcg_detail::oneseq_stream< itype >
void set_stream (...)

Static Protected Member Functions

static itype advance (itype state, itype delta, itype cur_mult, itype cur_plus)
static itype distance (itype cur_state, itype newstate, itype cur_mult, itype cur_plus, itype mask=~itype(0U))

Protected Attributes

itype state_

Friends

template<typename xtype1, typename itype1, typename output_mixin1, bool output_previous1, typename stream_mixin_lhs, typename multiplier_mixin_lhs, typename stream_mixin_rhs, typename multiplier_mixin_rhs>
bool operator== (const engine< xtype1, itype1, output_mixin1, output_previous1, stream_mixin_lhs, multiplier_mixin_lhs > &, const engine< xtype1, itype1, output_mixin1, output_previous1, stream_mixin_rhs, multiplier_mixin_rhs > &)
template<typename xtype1, typename itype1, typename output_mixin1, bool output_previous1, typename stream_mixin_lhs, typename multiplier_mixin_lhs, typename stream_mixin_rhs, typename multiplier_mixin_rhs>
itype1 operator- (const engine< xtype1, itype1, output_mixin1, output_previous1, stream_mixin_lhs, multiplier_mixin_lhs > &, const engine< xtype1, itype1, output_mixin1, output_previous1, stream_mixin_rhs, multiplier_mixin_rhs > &)
template<typename CharT, typename Traits, typename xtype1, typename itype1, typename output_mixin1, bool output_previous1, typename stream_mixin1, typename multiplier_mixin1>
std::basic_ostream< CharT, Traits > & operator<< (std::basic_ostream< CharT, Traits > &out, const engine< xtype1, itype1, output_mixin1, output_previous1, stream_mixin1, multiplier_mixin1 > &)
template<typename CharT, typename Traits, typename xtype1, typename itype1, typename output_mixin1, bool output_previous1, typename stream_mixin1, typename multiplier_mixin1>
std::basic_istream< CharT, Traits > & operator>> (std::basic_istream< CharT, Traits > &in, engine< xtype1, itype1, output_mixin1, output_previous1, stream_mixin1, multiplier_mixin1 > &rng)

Additional Inherited Members

Static Public Attributes inherited from pcg_detail::oneseq_stream< itype >
static constexpr bool can_specify_stream = false
Static Protected Attributes inherited from pcg_detail::oneseq_stream< itype >
static constexpr bool is_mcg = false

Constructor & Destructor Documentation

◆ engine() [1/4]

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::engine ( itype state = itype(0xcafef00dd15ea5e5ULL))
inline
95878 : state_(this->is_mcg ? state|state_type(3U)
95879 : bump(state + this->increment()))
95880 {
95881 // Nothing else to do.
95882 }
Definition duckdb.cpp:95773

◆ engine() [2/4]

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
template<typename sm = stream_mixin>
pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::engine ( itype state,
typename sm::stream_state stream_seed )
inline
95890 state_(this->is_mcg ? state|state_type(3U)
95891 : bump(state + this->increment()))
95892 {
95893 // Nothing else to do.
95894 }

◆ engine() [3/4]

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
template<typename SeedSeq>
pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::engine ( SeedSeq && seedSeq,
typename std::enable_if< !stream_mixin::can_specify_stream &&!std::is_convertible< SeedSeq, itype >::value &&!std::is_convertible< SeedSeq, engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin > >::value, no_specifiable_stream_tag >::type = {} )
inline
95901 {})
95903 {
95904 // Nothing else to do.
95905 }

◆ engine() [4/4]

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
template<typename SeedSeq>
pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::engine ( SeedSeq && seedSeq,
typename std::enable_if< stream_mixin::can_specify_stream &&!std::is_convertible< SeedSeq, itype >::value &&!std::is_convertible< SeedSeq, engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin > >::value, can_specify_stream_tag >::type = {} )
inline
95912 {})
95913 : engine(generate_one<itype,1,2>(seedSeq),
95915 {
95916 // Nothing else to do.
95917 }

Member Function Documentation

◆ period_pow2()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
constexpr size_t pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::period_pow2 ( )
inlinestaticconstexpr
95788 {
95789 return sizeof(state_type)*8 - 2*stream_mixin::is_mcg;
95790 }

◆ min()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
constexpr result_type pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::min ( )
inlinestaticconstexpr
95796 {
95797 return result_type(0UL);
95798 }

◆ max()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
constexpr result_type pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::max ( )
inlinestaticconstexpr
95801 {
95802 return result_type(~result_type(0UL));
95803 }

◆ bump()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
itype pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::bump ( itype state)
inlineprotected
95807 {
95808 return state * multiplier() + increment();
95809 }

◆ base_generate()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
itype pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::base_generate ( )
inlineprotected
95812 {
95813 return state_ = bump(state_);
95814 }

◆ base_generate0()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
itype pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::base_generate0 ( )
inlineprotected
95817 {
95818 itype old_state = state_;
95819 state_ = bump(state_);
95820 return old_state;
95821 }

◆ operator()() [1/2]

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
result_type pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::operator() ( )
inline
95825 {
95826 if (output_previous)
95827 return this->output(base_generate0());
95828 else
95829 return this->output(base_generate());
95830 }

◆ operator()() [2/2]

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
result_type pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::operator() ( result_type upper_bound)
inline
95833 {
95834 return bounded_rand(*this, upper_bound);
95835 }

◆ advance() [1/2]

template<typename xtype, typename itype, typename output_mixin, bool output_previous, typename stream_mixin, typename multiplier_mixin>
itype pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::advance ( itype state,
itype delta,
itype cur_mult,
itype cur_plus )
staticprotected
96039{
96040 // The method used here is based on Brown, "Random Number Generation
96041 // with Arbitrary Stride,", Transactions of the American Nuclear
96042 // Society (Nov. 1994). The algorithm is very similar to fast
96043 // exponentiation.
96044 //
96045 // Even though delta is an unsigned integer, we can pass a
96046 // signed integer to go backwards, it just goes "the long way round".
96047
96048 constexpr itype ZERO = 0u; // itype may be a non-trivial types, so
96049 constexpr itype ONE = 1u; // we define some ugly constants.
96050 itype acc_mult = 1;
96051 itype acc_plus = 0;
96052 while (delta > ZERO) {
96053 if (delta & ONE) {
96054 acc_mult *= cur_mult;
96056 }
96058 cur_mult *= cur_mult;
96059 delta >>= 1;
96060 }
96061 return acc_mult * state + acc_plus;
96062}

◆ distance() [1/2]

template<typename xtype, typename itype, typename output_mixin, bool output_previous, typename stream_mixin, typename multiplier_mixin>
itype pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::distance ( itype cur_state,
itype newstate,
itype cur_mult,
itype cur_plus,
itype mask = ~itype(0U) )
staticprotected
96070{
96071 constexpr itype ONE = 1u; // itype could be weird, so use constant
96072 bool is_mcg = cur_plus == itype(0);
96073 itype the_bit = is_mcg ? itype(4u) : itype(1u);
96074 itype distance = 0u;
96075 while ((cur_state & mask) != (newstate & mask)) {
96076 if ((cur_state & the_bit) != (newstate & the_bit)) {
96078 distance |= the_bit;
96079 }
96081 the_bit <<= 1;
96083 cur_mult *= cur_mult;
96084 }
96085 return is_mcg ? distance >> 2 : distance;
96086}
#define assert(x)
Definition duckdb.cpp:486071

◆ distance() [2/2]

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
itype pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::distance ( itype newstate,
itype mask = itype(~itype(0U)) ) const
inlineprotected
95845 {
95846 return distance(state_, newstate, multiplier(), increment(), mask);
95847 }

◆ advance() [2/2]

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
void pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::advance ( itype delta)
inline
95851 {
95852 state_ = advance(state_, delta, this->multiplier(), this->increment());
95853 }

◆ backstep()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
void pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::backstep ( itype delta)
inline
95856 {
95857 advance(-delta);
95858 }

◆ discard()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
void pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::discard ( itype delta)
inline
95861 {
95862 advance(delta);
95863 }

◆ wrapped()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
bool pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::wrapped ( )
inline
95866 {
95868 // For MCGs, the low order two bits never change. In this
95869 // implementation, we keep them fixed at 3 to make this test
95870 // easier.
95871 return state_ == 3;
95872 } else {
95873 return state_ == 0;
95874 }
95875 }

◆ seed()

template<typename xtype, typename itype, typename output_mixin, bool output_previous = true, typename stream_mixin = oneseq_stream<itype>, typename multiplier_mixin = default_multiplier<itype>>
template<typename... Args>
void pcg_detail::engine< xtype, itype, output_mixin, output_previous, stream_mixin, multiplier_mixin >::seed ( Args &&... args)
inline
95922 {
95923 new (this) engine(std::forward<Args>(args)...);
95924 }

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