Class AgentRandom

Class Documentation

class flamegpu::AgentRandom

Utility for accessing random generation within agent functions This should only be instantiated by FLAMEGPU_API Wraps curand functions to access an internal curand state *

Public Functions

__forceinline__ __device__ AgentRandom(curandState *d_rng)

Constructs an AgentRandom instance

Parameters

d_rng – ThreadSafe device curand state instance this is a unique instance for the thread among all concurrently executing kernels

template<typename T>
__forceinline__ __device__ T uniform() const

Returns a float uniformly distributed between 0.0 and 1.0.

Note

It may return from 0.0 to 1.0, where 1.0 is included and 0.0 is excluded.

Note

Available as float or double

template<typename T>
__forceinline__ __device__ T normal() const

Returns a normally distributed float with mean 0.0 and standard deviation 1.0.

Note

This result can be scaled and shifted to produce normally distributed values with any mean/stddev.

Note

Available as float or double

template<typename T>
__forceinline__ __device__ T logNormal(const T &mean, const T &stddev) const

Returns a log-normally distributed float based on a normal distribution with the given mean and standard deviation.

Note

Available as float or double

template<typename T>
__forceinline__ __device__ T uniform(const T &min, const T &max) const

Returns an integer uniformly distributed in the inclusive range [lowerBound, max]

Uniform Int

Note

Available as signed and unsigned: char, short, int, long long

template<>
__forceinline__ __device__ float uniform() const

All templates are specialised Uniform floating point

template<>
__forceinline__ __device__ float normal() const

Normal floating point

template<>
__forceinline__ __device__ float logNormal(const float &mean, const float &stddev) const

Log Normal floating point

template<>
__forceinline__ __device__ double logNormal(const double &mean, const double &stddev) const
template<>
__forceinline__ __device__ int64_t uniform(const int64_t &min, const int64_t &max) const
template<>
__forceinline__ __device__ uint64_t uniform(const uint64_t &min, const uint64_t &max) const