21 #ifndef ROCRAND_LOG_NORMAL_H_
22 #define ROCRAND_LOG_NORMAL_H_
29 #include "rocrand/rocrand_lfsr113.h"
30 #include "rocrand/rocrand_mrg31k3p.h"
31 #include "rocrand/rocrand_mrg32k3a.h"
32 #include "rocrand/rocrand_mtgp32.h"
33 #include "rocrand/rocrand_philox4x32_10.h"
34 #include "rocrand/rocrand_scrambled_sobol32.h"
35 #include "rocrand/rocrand_scrambled_sobol64.h"
36 #include "rocrand/rocrand_sobol32.h"
37 #include "rocrand/rocrand_sobol64.h"
38 #include "rocrand/rocrand_threefry2x32_20.h"
39 #include "rocrand/rocrand_threefry2x64_20.h"
40 #include "rocrand/rocrand_threefry4x32_20.h"
41 #include "rocrand/rocrand_threefry4x64_20.h"
42 #include "rocrand/rocrand_xorwow.h"
44 #include "rocrand/rocrand_normal.h"
46 #include <hip/hip_runtime.h>
65 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
66 __forceinline__ __device__ __host__
float
69 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_philox4x32_10> bm_helper;
71 if(bm_helper::has_float(state))
73 return expf(mean + (stddev * bm_helper::get_float(state)));
79 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
80 bm_helper::save_float(state, r.y);
81 return expf(mean + (stddev * r.x));
99 __forceinline__ __device__ __host__
105 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
107 expf(mean + (stddev * r.x)),
108 expf(mean + (stddev * r.y))
126 __forceinline__ __device__ __host__
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__
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__
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));
268 __forceinline__ __device__ __host__
271 auto state1 = state->next();
272 auto state2 = state->next();
275 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg31k3p>(state1, state2);
276 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
294 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
295 __forceinline__ __device__ __host__
double
298 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg31k3p> bm_helper;
300 if(bm_helper::has_double(state))
302 return exp(mean + (stddev * bm_helper::get_double(state)));
305 auto state1 = state->next();
306 auto state2 = state->next();
309 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg31k3p>(state1,
311 bm_helper::save_double(state, r.y);
312 return exp(mean + r.x * stddev);
330 __forceinline__ __device__ __host__
333 auto state1 = state->next();
334 auto state2 = state->next();
337 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg31k3p>(state1,
339 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
357 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
358 __forceinline__ __device__ __host__
float
361 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg32k3a> bm_helper;
363 if(bm_helper::has_float(state))
365 return expf(mean + (stddev * bm_helper::get_float(state)));
368 auto state1 = state->next();
369 auto state2 = state->next();
372 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg32k3a>(state1, state2);
373 bm_helper::save_float(state, r.y);
374 return expf(mean + (stddev * r.x));
392 __forceinline__ __device__ __host__
395 auto state1 = state->next();
396 auto state2 = state->next();
399 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg32k3a>(state1, state2);
401 expf(mean + (stddev * r.x)),
402 expf(mean + (stddev * r.y))
421 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
422 __forceinline__ __device__ __host__
double
425 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg32k3a> bm_helper;
427 if(bm_helper::has_double(state))
429 return exp(mean + (stddev * bm_helper::get_double(state)));
432 auto state1 = state->next();
433 auto state2 = state->next();
436 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg32k3a>(state1,
438 bm_helper::save_double(state, r.y);
439 return exp(mean + r.x * stddev);
457 __forceinline__ __device__ __host__
460 auto state1 = state->next();
461 auto state2 = state->next();
464 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg32k3a>(state1,
467 exp(mean + (stddev * r.x)),
468 exp(mean + (stddev * r.y))
487 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
488 __forceinline__ __device__ __host__
float
491 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_xorwow> bm_helper;
493 if(bm_helper::has_float(state))
495 return expf(mean + (stddev * bm_helper::get_float(state)));
501 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
502 bm_helper::save_float(state, r.y);
503 return expf(mean + (stddev * r.x));
521 __forceinline__ __device__ __host__
527 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
529 expf(mean + (stddev * r.x)),
530 expf(mean + (stddev * r.y))
549 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
550 __forceinline__ __device__ __host__
double
553 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_xorwow> bm_helper;
555 if(bm_helper::has_double(state))
557 return exp(mean + (stddev * bm_helper::get_double(state)));
565 double2 r = rocrand_device::detail::normal_distribution_double2(
566 uint4 { state1, state2, state3, state4 }
568 bm_helper::save_double(state, r.y);
569 return exp(mean + (stddev * r.x));
587 __forceinline__ __device__ __host__
595 double2 r = rocrand_device::detail::normal_distribution_double2(
596 uint4 { state1, state2, state3, state4 }
599 exp(mean + (stddev * r.x)),
600 exp(mean + (stddev * r.y))
616 __forceinline__ __device__
619 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
620 return expf(mean + (stddev * r));
637 __forceinline__ __device__
643 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
644 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
659 __forceinline__ __device__
662 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
663 return exp(mean + (stddev * r));
680 __forceinline__ __device__
688 double2 r = rocrand_device::detail::normal_distribution_double2(
689 uint4{state1, state2, state3, state4});
690 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
705 __forceinline__ __device__ __host__
708 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
709 return expf(mean + (stddev * r));
724 __forceinline__ __device__ __host__
727 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
728 return exp(mean + (stddev * r));
743 __forceinline__ __device__ __host__
746 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
747 return expf(mean + (stddev * r));
762 __forceinline__ __device__ __host__
765 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
766 return exp(mean + (stddev * r));
781 __forceinline__ __device__ __host__
784 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
785 return expf(mean + (stddev * r));
800 __forceinline__ __device__ __host__
803 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
804 return exp(mean + (stddev * r));
819 __forceinline__ __device__ __host__
822 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
823 return expf(mean + (stddev * r));
838 __forceinline__ __device__ __host__
841 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
842 return exp(mean + (stddev * r));
857 __forceinline__ __device__ __host__
860 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
861 return expf(mean + (stddev * r));
878 __forceinline__ __device__ __host__
884 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
885 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
900 __forceinline__ __device__ __host__
903 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
904 return exp(mean + (stddev * r));
921 __forceinline__ __device__ __host__
929 double2 r = rocrand_device::detail::normal_distribution_double2(
930 uint4{state1, state2, state3, state4});
931 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
946 __forceinline__ __device__ __host__
949 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
950 return expf(mean + (stddev * r));
967 __forceinline__ __device__ __host__
970 float2 r = rocrand_device::detail::normal_distribution2(rocrand2(state));
971 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
986 __forceinline__ __device__ __host__
989 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
990 return exp(mean + (stddev * r));
1007 __forceinline__ __device__ __host__
1015 double2 r = rocrand_device::detail::normal_distribution_double2(
1016 uint4{state1, state2, state3, state4});
1017 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1032 __forceinline__ __device__ __host__
1035 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
1036 return expf(mean + (stddev * r));
1053 __forceinline__ __device__ __host__
1059 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1060 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1075 __forceinline__ __device__ __host__
1078 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1079 return exp(mean + (stddev * r));
1096 __forceinline__ __device__ __host__
1099 double2 r = rocrand_device::detail::normal_distribution_double2(rocrand2(state));
1100 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1115 __forceinline__ __device__ __host__
1118 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
1119 return expf(mean + (stddev * r));
1136 __forceinline__ __device__ __host__
1142 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1143 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1158 __forceinline__ __device__ __host__
1161 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1162 return exp(mean + (stddev * r));
1179 __forceinline__ __device__ __host__
1182 double2 r = rocrand_device::detail::normal_distribution_double2(
rocrand4(state));
1183 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1198 __forceinline__ __device__ __host__
1201 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
1202 return expf(mean + (stddev * r));
1219 __forceinline__ __device__ __host__
1225 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1226 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1241 __forceinline__ __device__ __host__
1244 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1245 return exp(mean + (stddev * r));
1262 __forceinline__ __device__ __host__
1268 double2 r = rocrand_device::detail::normal_distribution_double2(ulonglong2{state1, state2});
1269 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:379
__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:127
__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:67
__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:100
__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:277