21 #ifndef ROCRAND_LOG_NORMAL_H_
22 #define ROCRAND_LOG_NORMAL_H_
31 #include "rocrand/rocrand_lfsr113.h"
32 #include "rocrand/rocrand_mrg31k3p.h"
33 #include "rocrand/rocrand_mrg32k3a.h"
34 #include "rocrand/rocrand_mtgp32.h"
35 #include "rocrand/rocrand_philox4x32_10.h"
36 #include "rocrand/rocrand_scrambled_sobol32.h"
37 #include "rocrand/rocrand_scrambled_sobol64.h"
38 #include "rocrand/rocrand_sobol32.h"
39 #include "rocrand/rocrand_sobol64.h"
40 #include "rocrand/rocrand_threefry2x32_20.h"
41 #include "rocrand/rocrand_threefry2x64_20.h"
42 #include "rocrand/rocrand_threefry4x32_20.h"
43 #include "rocrand/rocrand_threefry4x64_20.h"
44 #include "rocrand/rocrand_xorwow.h"
46 #include "rocrand/rocrand_normal.h"
63 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
64 __forceinline__ __device__ __host__
float
67 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_philox4x32_10> bm_helper;
69 if(bm_helper::has_float(state))
71 return expf(mean + (stddev * bm_helper::get_float(state)));
77 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
78 bm_helper::save_float(state, r.y);
79 return expf(mean + (stddev * r.x));
104 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
106 expf(mean + (stddev * r.x)),
107 expf(mean + (stddev * r.y))
129 float4 r = rocrand_device::detail::normal_distribution4(
rocrand4(state));
131 expf(mean + (stddev * r.x)),
132 expf(mean + (stddev * r.y)),
133 expf(mean + (stddev * r.z)),
134 expf(mean + (stddev * r.w))
153 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
154 __forceinline__ __device__ __host__
double
157 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_philox4x32_10> bm_helper;
159 if(bm_helper::has_double(state))
161 return exp(mean + (stddev * bm_helper::get_double(state)));
163 double2 r = rocrand_device::detail::normal_distribution_double2(
rocrand4(state));
164 bm_helper::save_double(state, r.y);
165 return exp(mean + r.x * stddev);
183 __forceinline__ __device__ __host__ double2
186 double2 r = rocrand_device::detail::normal_distribution_double2(
rocrand4(state));
188 exp(mean + (stddev * r.x)),
189 exp(mean + (stddev * r.y))
207 __forceinline__ __device__ __host__ double4
214 r1.x, r1.y, r2.x, r2.y
233 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
234 __forceinline__ __device__ __host__
float
237 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg31k3p> bm_helper;
239 if(bm_helper::has_float(state))
241 return expf(mean + (stddev * bm_helper::get_float(state)));
244 auto state1 = state->next();
245 auto state2 = state->next();
248 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg31k3p>(state1, state2);
249 bm_helper::save_float(state, r.y);
250 return expf(mean + (stddev * r.x));
272 auto state1 = state->next();
273 auto state2 = state->next();
276 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg31k3p>(state1, state2);
277 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
295 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
296 __forceinline__ __device__ __host__
double
299 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg31k3p> bm_helper;
301 if(bm_helper::has_double(state))
303 return exp(mean + (stddev * bm_helper::get_double(state)));
306 auto state1 = state->next();
307 auto state2 = state->next();
310 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg31k3p>(state1,
312 bm_helper::save_double(state, r.y);
313 return exp(mean + r.x * stddev);
331 __forceinline__ __device__ __host__ double2
334 auto state1 = state->next();
335 auto state2 = state->next();
338 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg31k3p>(state1,
340 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
358 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
359 __forceinline__ __device__ __host__
float
362 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg32k3a> bm_helper;
364 if(bm_helper::has_float(state))
366 return expf(mean + (stddev * bm_helper::get_float(state)));
369 auto state1 = state->next();
370 auto state2 = state->next();
373 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg32k3a>(state1, state2);
374 bm_helper::save_float(state, r.y);
375 return expf(mean + (stddev * r.x));
397 auto state1 = state->next();
398 auto state2 = state->next();
401 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg32k3a>(state1, state2);
403 expf(mean + (stddev * r.x)),
404 expf(mean + (stddev * r.y))
423 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
424 __forceinline__ __device__ __host__
double
427 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg32k3a> bm_helper;
429 if(bm_helper::has_double(state))
431 return exp(mean + (stddev * bm_helper::get_double(state)));
434 auto state1 = state->next();
435 auto state2 = state->next();
438 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg32k3a>(state1,
440 bm_helper::save_double(state, r.y);
441 return exp(mean + r.x * stddev);
459 __forceinline__ __device__ __host__ double2
462 auto state1 = state->next();
463 auto state2 = state->next();
466 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg32k3a>(state1,
469 exp(mean + (stddev * r.x)),
470 exp(mean + (stddev * r.y))
489 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
490 __forceinline__ __device__ __host__
float
493 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_xorwow> bm_helper;
495 if(bm_helper::has_float(state))
497 return expf(mean + (stddev * bm_helper::get_float(state)));
503 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
504 bm_helper::save_float(state, r.y);
505 return expf(mean + (stddev * r.x));
530 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
532 expf(mean + (stddev * r.x)),
533 expf(mean + (stddev * r.y))
552 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
553 __forceinline__ __device__ __host__
double
556 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_xorwow> bm_helper;
558 if(bm_helper::has_double(state))
560 return exp(mean + (stddev * bm_helper::get_double(state)));
568 double2 r = rocrand_device::detail::normal_distribution_double2(
569 uint4 { state1, state2, state3, state4 }
571 bm_helper::save_double(state, r.y);
572 return exp(mean + (stddev * r.x));
599 double2 r = rocrand_device::detail::normal_distribution_double2(
600 uint4 { state1, state2, state3, state4 }
603 exp(mean + (stddev * r.x)),
604 exp(mean + (stddev * r.y))
620 __forceinline__ __device__
float
623 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
624 return expf(mean + (stddev * r));
648 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
649 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
664 __forceinline__ __device__
double
667 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
668 return exp(mean + (stddev * r));
694 double2 r = rocrand_device::detail::normal_distribution_double2(
695 uint4{state1, state2, state3, state4});
696 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
711 __forceinline__ __device__ __host__
float
714 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
715 return expf(mean + (stddev * r));
730 __forceinline__ __device__ __host__
double
733 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
734 return exp(mean + (stddev * r));
749 __forceinline__ __device__ __host__
float
752 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
753 return expf(mean + (stddev * r));
768 __forceinline__ __device__ __host__
double
771 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
772 return exp(mean + (stddev * r));
787 __forceinline__ __device__ __host__
float
790 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
791 return expf(mean + (stddev * r));
806 __forceinline__ __device__ __host__
double
809 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
810 return exp(mean + (stddev * r));
825 __forceinline__ __device__ __host__
float
828 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
829 return expf(mean + (stddev * r));
844 __forceinline__ __device__ __host__
double
847 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
848 return exp(mean + (stddev * r));
863 __forceinline__ __device__ __host__
float
866 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
867 return expf(mean + (stddev * r));
891 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
892 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
907 __forceinline__ __device__ __host__
double
910 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
911 return exp(mean + (stddev * r));
937 double2 r = rocrand_device::detail::normal_distribution_double2(
938 uint4{state1, state2, state3, state4});
939 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
954 __forceinline__ __device__ __host__
float
957 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
958 return expf(mean + (stddev * r));
979 float2 r = rocrand_device::detail::normal_distribution2(rocrand2(state));
980 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
995 __forceinline__ __device__ __host__
double
998 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
999 return exp(mean + (stddev * r));
1016 __forceinline__ __device__ __host__ double2
1024 double2 r = rocrand_device::detail::normal_distribution_double2(
1025 uint4{state1, state2, state3, state4});
1026 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1041 __forceinline__ __device__ __host__
float
1044 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
1045 return expf(mean + (stddev * r));
1069 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1070 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1085 __forceinline__ __device__ __host__
double
1088 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1089 return exp(mean + (stddev * r));
1106 __forceinline__ __device__ __host__ double2
1109 double2 r = rocrand_device::detail::normal_distribution_double2(rocrand2(state));
1110 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1125 __forceinline__ __device__ __host__
float
1128 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
1129 return expf(mean + (stddev * r));
1153 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1154 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1169 __forceinline__ __device__ __host__
double
1172 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1173 return exp(mean + (stddev * r));
1190 __forceinline__ __device__ __host__ double2
1193 double2 r = rocrand_device::detail::normal_distribution_double2(
rocrand4(state));
1194 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1209 __forceinline__ __device__ __host__
float
1212 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
1213 return expf(mean + (stddev * r));
1237 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1238 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1253 __forceinline__ __device__ __host__
double
1256 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1257 return exp(mean + (stddev * r));
1274 __forceinline__ __device__ __host__ double2
1280 double2 r = rocrand_device::detail::normal_distribution_double2(ulonglong2{state1, state2});
1281 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
__forceinline__ __device__ __host__ double rocrand_log_normal_double(rocrand_state_philox4x32_10 *state, double mean, double stddev)
Returns a log-normally distributed double values.
Definition: rocrand_log_normal.h:155
__forceinline__ __device__ __host__ uint4 rocrand4(rocrand_state_philox4x32_10 *state)
Returns four uniformly distributed random unsigned int values from [0; 2^32 - 1] range.
Definition: rocrand_philox4x32_10.h:386
__forceinline__ __device__ __host__ float4 rocrand_log_normal4(rocrand_state_philox4x32_10 *state, float mean, float stddev)
Returns four log-normally distributed float values.
Definition: rocrand_log_normal.h:125
__forceinline__ __device__ __host__ float rocrand_log_normal(rocrand_state_philox4x32_10 *state, float mean, float stddev)
Returns a log-normally distributed float value.
Definition: rocrand_log_normal.h:65
__forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_philox4x32_10 *state, float mean, float stddev)
Returns two log-normally distributed float values.
Definition: rocrand_log_normal.h:97
__forceinline__ __device__ __host__ double4 rocrand_log_normal_double4(rocrand_state_philox4x32_10 *state, double mean, double stddev)
Returns four log-normally distributed double values.
Definition: rocrand_log_normal.h:208
__forceinline__ __device__ __host__ double2 rocrand_log_normal_double2(rocrand_state_philox4x32_10 *state, double mean, double stddev)
Returns two log-normally distributed double values.
Definition: rocrand_log_normal.h:184
__forceinline__ __device__ __host__ unsigned int rocrand(rocrand_state_lfsr113 *state)
Returns uniformly distributed random unsigned int value from [0; 2^32 - 1] range.
Definition: rocrand_lfsr113.h:274