21 #ifndef ROCRAND_LOG_NORMAL_H_
22 #define ROCRAND_LOG_NORMAL_H_
25 #define FQUALIFIERS __forceinline__ __device__
35 #include "rocrand/rocrand_lfsr113.h"
36 #include "rocrand/rocrand_mrg31k3p.h"
37 #include "rocrand/rocrand_mrg32k3a.h"
38 #include "rocrand/rocrand_mtgp32.h"
39 #include "rocrand/rocrand_philox4x32_10.h"
40 #include "rocrand/rocrand_scrambled_sobol32.h"
41 #include "rocrand/rocrand_scrambled_sobol64.h"
42 #include "rocrand/rocrand_sobol32.h"
43 #include "rocrand/rocrand_sobol64.h"
44 #include "rocrand/rocrand_threefry2x32_20.h"
45 #include "rocrand/rocrand_threefry2x64_20.h"
46 #include "rocrand/rocrand_threefry4x32_20.h"
47 #include "rocrand/rocrand_threefry4x64_20.h"
48 #include "rocrand/rocrand_xorwow.h"
50 #include "rocrand/rocrand_normal.h"
67 #ifndef ROCRAND_DETAIL_PHILOX_BM_NOT_IN_STATE
71 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_philox4x32_10> bm_helper;
73 if(bm_helper::has_float(state))
75 return expf(mean + (stddev * bm_helper::get_float(state)));
81 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
82 bm_helper::save_float(state, r.y);
83 return expf(mean + (stddev * r.x));
107 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
109 expf(mean + (stddev * r.x)),
110 expf(mean + (stddev * r.y))
131 float4 r = rocrand_device::detail::normal_distribution4(
rocrand4(state));
133 expf(mean + (stddev * r.x)),
134 expf(mean + (stddev * r.y)),
135 expf(mean + (stddev * r.z)),
136 expf(mean + (stddev * r.w))
155 #ifndef ROCRAND_DETAIL_PHILOX_BM_NOT_IN_STATE
159 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_philox4x32_10> bm_helper;
161 if(bm_helper::has_double(state))
163 return exp(mean + (stddev * bm_helper::get_double(state)));
165 double2 r = rocrand_device::detail::normal_distribution_double2(
rocrand4(state));
166 bm_helper::save_double(state, r.y);
167 return exp(mean + r.x * stddev);
188 double2 r = rocrand_device::detail::normal_distribution_double2(
rocrand4(state));
190 exp(mean + (stddev * r.x)),
191 exp(mean + (stddev * r.y))
216 r1.x, r1.y, r2.x, r2.y
235 #ifndef ROCRAND_DETAIL_MRG31K3P_BM_NOT_IN_STATE
238 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg31k3p> bm_helper;
240 if(bm_helper::has_float(state))
242 return expf(mean + (stddev * bm_helper::get_float(state)));
245 auto state1 = state->next();
246 auto state2 = state->next();
249 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg31k3p>(state1, state2);
250 bm_helper::save_float(state, r.y);
251 return expf(mean + (stddev * r.x));
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_MRG31K3P_BM_NOT_IN_STATE
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);
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_MRG32K3A_BM_NOT_IN_STATE
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));
396 auto state1 = state->next();
397 auto state2 = state->next();
400 = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg32k3a>(state1, state2);
402 expf(mean + (stddev * r.x)),
403 expf(mean + (stddev * r.y))
422 #ifndef ROCRAND_DETAIL_MRG32K3A_BM_NOT_IN_STATE
426 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg32k3a> bm_helper;
428 if(bm_helper::has_double(state))
430 return exp(mean + (stddev * bm_helper::get_double(state)));
433 auto state1 = state->next();
434 auto state2 = state->next();
437 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg32k3a>(state1,
439 bm_helper::save_double(state, r.y);
440 return exp(mean + r.x * stddev);
461 auto state1 = state->next();
462 auto state2 = state->next();
465 = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg32k3a>(state1,
468 exp(mean + (stddev * r.x)),
469 exp(mean + (stddev * r.y))
488 #ifndef ROCRAND_DETAIL_XORWOW_BM_NOT_IN_STATE
492 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_xorwow> bm_helper;
494 if(bm_helper::has_float(state))
496 return expf(mean + (stddev * bm_helper::get_float(state)));
502 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
503 bm_helper::save_float(state, r.y);
504 return expf(mean + (stddev * r.x));
528 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
530 expf(mean + (stddev * r.x)),
531 expf(mean + (stddev * r.y))
550 #ifndef ROCRAND_DETAIL_XORWOW_BM_NOT_IN_STATE
554 typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_xorwow> bm_helper;
556 if(bm_helper::has_double(state))
558 return exp(mean + (stddev * bm_helper::get_double(state)));
566 double2 r = rocrand_device::detail::normal_distribution_double2(
567 uint4 { state1, state2, state3, state4 }
569 bm_helper::save_double(state, r.y);
570 return exp(mean + (stddev * r.x));
596 double2 r = rocrand_device::detail::normal_distribution_double2(
597 uint4 { state1, state2, state3, state4 }
600 exp(mean + (stddev * r.x)),
601 exp(mean + (stddev * r.y))
620 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
621 return expf(mean + (stddev * r));
639 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
640 return exp(mean + (stddev * r));
658 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
659 return expf(mean + (stddev * r));
677 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
678 return exp(mean + (stddev * r));
696 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
697 return expf(mean + (stddev * r));
715 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
716 return exp(mean + (stddev * r));
734 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
735 return expf(mean + (stddev * r));
753 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
754 return exp(mean + (stddev * r));
772 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
773 return expf(mean + (stddev * r));
791 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
792 return exp(mean + (stddev * r));
810 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
811 return expf(mean + (stddev * r));
834 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
835 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
853 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
854 return exp(mean + (stddev * r));
879 double2 r = rocrand_device::detail::normal_distribution_double2(
880 uint4{state1, state2, state3, state4});
881 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
899 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
900 return expf(mean + (stddev * r));
924 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
925 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
943 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
944 return exp(mean + (stddev * r));
970 double2 r = rocrand_device::detail::normal_distribution_double2(
971 uint4{state1, state2, state3, state4});
972 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
990 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
991 return expf(mean + (stddev * r));
1015 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1016 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1034 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1035 return exp(mean + (stddev * r));
1061 double2 r = rocrand_device::detail::normal_distribution_double2(
1062 uint4{state1, state2, state3, state4});
1063 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1081 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
1082 return expf(mean + (stddev * r));
1106 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1107 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1125 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1126 return exp(mean + (stddev * r));
1152 double2 r = rocrand_device::detail::normal_distribution_double2(
1153 uint4{state1, state2, state3, state4});
1154 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1172 float r = rocrand_device::detail::normal_distribution(
rocrand(state));
1173 return expf(mean + (stddev * r));
1197 float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1198 return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1216 double r = rocrand_device::detail::normal_distribution_double(
rocrand(state));
1217 return exp(mean + (stddev * r));
1243 double2 r = rocrand_device::detail::normal_distribution_double2(
1244 uint4{state1, state2, state3, state4});
1245 return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
FQUALIFIERS 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:186
FQUALIFIERS 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:157
FQUALIFIERS 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:129
FQUALIFIERS 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:102
FQUALIFIERS unsigned int rocrand(rocrand_state_lfsr113 *state)
Returns uniformly distributed random unsigned int value from [0; 2^32 - 1] range.
Definition: rocrand_lfsr113.h:253
FQUALIFIERS 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:210
FQUALIFIERS 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:69
FQUALIFIERS 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:410
#define FQUALIFIERS
Shorthand for commonly used function qualifiers.
Definition: rocrand_uniform.h:31