Esempio n. 1
0
 void generate()
 {
     size_t n { 0 };
     std::generate(m_lut.begin(), m_lut.end(), [&n, this]{
         return m_generator(n++);
     });
 }
Esempio n. 2
0
int Rnd::Int(int min, int max) {

    std::random_device rd;
    std::mt19937 m_generator(rd());
    std::uniform_int_distribution<int> dis(min, max);

    return dis(m_generator);

}
Esempio n. 3
0
arma::vec
dir_generator::sample(const arma::vec &alpha)
{
    arma::vec x = arma::zeros<arma::vec>( alpha.n_elem );
    for(int i = 0; i < alpha.n_elem; i++)
    {
        double runif = m_generator( ) / ( m_generator.max( ) - m_generator.min( ) + 1.0 );
        x[ i ] = gamma_cdf_inv( runif, alpha[ i ], 1.0 );
    }

    return x / sum( x );
}
Esempio n. 4
0
 virtual void _receive_msg(std::shared_ptr<const Msg>&& m, int /* index */)
 {
     if(m->type() != MSG_ID(Packet))
         throw std::runtime_error("AppendTag: wrong message type");
     uint64_t random_garbage = m_generator();
     switch (m_tag_type)
     {
     case(in):
         m->emplace_tag<int>(m_handle,(int)random_garbage);
         break;
     case(ll):
         m->emplace_tag<double>(m_handle,(double)random_garbage);
         break;
     case(fl):
         m->emplace_tag<uint64_t>(m_handle,(uint64_t)random_garbage);
         break;
     default:
         throw std::runtime_error("wrong tag type");
     }
     send_out_through(std::move(m),m_outgate_id);
 }
Esempio n. 5
0
	/*!
	* \brief Calls the generator function
	*
	* \param group Particle group responsible of the particles
	* \param mapper Particle mapper, allowing access to the particle data
	* \param startId The first ID of the particle to update (inclusive)
	* \param endId The last ID of the particle to update (inclusive)
	*/
	void ParticleFunctionGenerator::Generate(ParticleGroup& group, ParticleMapper& mapper, unsigned int startId, unsigned int endId)
	{
		m_generator(group, mapper, startId, endId);
	}
Esempio n. 6
0
 //! Generate a number on the interval [0,N)
 std::size_t operator()( std::size_t N = (std::numeric_limits<std::size_t>::max)() ) const { return (m_generator() % N); }
Esempio n. 7
0
 //! Generate a real (double) on the interval [0.0,maxReal).
 double operator()() const { return m_generator(); }
Esempio n. 8
0
 //! Generate an integer on the interval [0,maxIndex).
 std::size_t operator()() const { return m_generator(); }