/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocrand/checkouts/docs-6.3.0/library/include/rocrand/rocrand_log_normal.h Source File

/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocrand/checkouts/docs-6.3.0/library/include/rocrand/rocrand_log_normal.h Source File#

API library: /home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-rocrand/checkouts/docs-6.3.0/library/include/rocrand/rocrand_log_normal.h Source File
rocrand_log_normal.h
1 // Copyright (c) 2017-2024 Advanced Micro Devices, Inc. All rights reserved.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef ROCRAND_LOG_NORMAL_H_
22 #define ROCRAND_LOG_NORMAL_H_
23 
29 #include <math.h>
30 
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"
45 
46 #include "rocrand/rocrand_normal.h"
47 
63 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
64 __forceinline__ __device__ __host__ float
65  rocrand_log_normal(rocrand_state_philox4x32_10* state, float mean, float stddev)
66 {
67  typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_philox4x32_10> bm_helper;
68 
69  if(bm_helper::has_float(state))
70  {
71  return expf(mean + (stddev * bm_helper::get_float(state)));
72  }
73 
74  auto state1 = rocrand(state);
75  auto state2 = rocrand(state);
76 
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));
80 }
81 #endif // ROCRAND_DETAIL_BM_NOT_IN_STATE
82 
97 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_philox4x32_10* state,
98  float mean,
99  float stddev)
100 {
101  auto state1 = rocrand(state);
102  auto state2 = rocrand(state);
103 
104  float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
105  return float2 {
106  expf(mean + (stddev * r.x)),
107  expf(mean + (stddev * r.y))
108  };
109 }
110 
125 __forceinline__ __device__ __host__ float4 rocrand_log_normal4(rocrand_state_philox4x32_10* state,
126  float mean,
127  float stddev)
128 {
129  float4 r = rocrand_device::detail::normal_distribution4(rocrand4(state));
130  return float4 {
131  expf(mean + (stddev * r.x)),
132  expf(mean + (stddev * r.y)),
133  expf(mean + (stddev * r.z)),
134  expf(mean + (stddev * r.w))
135  };
136 }
137 
153 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
154 __forceinline__ __device__ __host__ double
155  rocrand_log_normal_double(rocrand_state_philox4x32_10* state, double mean, double stddev)
156 {
157  typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_philox4x32_10> bm_helper;
158 
159  if(bm_helper::has_double(state))
160  {
161  return exp(mean + (stddev * bm_helper::get_double(state)));
162  }
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);
166 }
167 #endif // ROCRAND_DETAIL_BM_NOT_IN_STATE
168 
183 __forceinline__ __device__ __host__ double2
184  rocrand_log_normal_double2(rocrand_state_philox4x32_10* state, double mean, double stddev)
185 {
186  double2 r = rocrand_device::detail::normal_distribution_double2(rocrand4(state));
187  return double2 {
188  exp(mean + (stddev * r.x)),
189  exp(mean + (stddev * r.y))
190  };
191 }
192 
207 __forceinline__ __device__ __host__ double4
208  rocrand_log_normal_double4(rocrand_state_philox4x32_10* state, double mean, double stddev)
209 {
210  double2 r1, r2;
211  r1 = rocrand_log_normal_double2(state, mean, stddev);
212  r2 = rocrand_log_normal_double2(state, mean, stddev);
213  return double4 {
214  r1.x, r1.y, r2.x, r2.y
215  };
216 }
217 
233 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
234 __forceinline__ __device__ __host__ float
235  rocrand_log_normal(rocrand_state_mrg31k3p* state, float mean, float stddev)
236 {
237  typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg31k3p> bm_helper;
238 
239  if(bm_helper::has_float(state))
240  {
241  return expf(mean + (stddev * bm_helper::get_float(state)));
242  }
243 
244  auto state1 = state->next();
245  auto state2 = state->next();
246 
247  float2 r
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));
251 }
252 #endif // ROCRAND_DETAIL_BM_NOT_IN_STATE
253 
268 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_mrg31k3p* state,
269  float mean,
270  float stddev)
271 {
272  auto state1 = state->next();
273  auto state2 = state->next();
274 
275  float2 r
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))};
278 }
279 
295 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
296 __forceinline__ __device__ __host__ double
297  rocrand_log_normal_double(rocrand_state_mrg31k3p* state, double mean, double stddev)
298 {
299  typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg31k3p> bm_helper;
300 
301  if(bm_helper::has_double(state))
302  {
303  return exp(mean + (stddev * bm_helper::get_double(state)));
304  }
305 
306  auto state1 = state->next();
307  auto state2 = state->next();
308 
309  double2 r
310  = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg31k3p>(state1,
311  state2);
312  bm_helper::save_double(state, r.y);
313  return exp(mean + r.x * stddev);
314 }
315 #endif // ROCRAND_DETAIL_BM_NOT_IN_STATE
316 
331 __forceinline__ __device__ __host__ double2
332  rocrand_log_normal_double2(rocrand_state_mrg31k3p* state, double mean, double stddev)
333 {
334  auto state1 = state->next();
335  auto state2 = state->next();
336 
337  double2 r
338  = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg31k3p>(state1,
339  state2);
340  return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
341 }
342 
358 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
359 __forceinline__ __device__ __host__ float
360  rocrand_log_normal(rocrand_state_mrg32k3a* state, float mean, float stddev)
361 {
362  typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg32k3a> bm_helper;
363 
364  if(bm_helper::has_float(state))
365  {
366  return expf(mean + (stddev * bm_helper::get_float(state)));
367  }
368 
369  auto state1 = state->next();
370  auto state2 = state->next();
371 
372  float2 r
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));
376 }
377 #endif // ROCRAND_DETAIL_BM_NOT_IN_STATE
378 
393 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_mrg32k3a* state,
394  float mean,
395  float stddev)
396 {
397  auto state1 = state->next();
398  auto state2 = state->next();
399 
400  float2 r
401  = rocrand_device::detail::mrg_normal_distribution2<rocrand_state_mrg32k3a>(state1, state2);
402  return float2 {
403  expf(mean + (stddev * r.x)),
404  expf(mean + (stddev * r.y))
405  };
406 }
407 
423 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
424 __forceinline__ __device__ __host__ double
425  rocrand_log_normal_double(rocrand_state_mrg32k3a* state, double mean, double stddev)
426 {
427  typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_mrg32k3a> bm_helper;
428 
429  if(bm_helper::has_double(state))
430  {
431  return exp(mean + (stddev * bm_helper::get_double(state)));
432  }
433 
434  auto state1 = state->next();
435  auto state2 = state->next();
436 
437  double2 r
438  = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg32k3a>(state1,
439  state2);
440  bm_helper::save_double(state, r.y);
441  return exp(mean + r.x * stddev);
442 }
443 #endif // ROCRAND_DETAIL_BM_NOT_IN_STATE
444 
459 __forceinline__ __device__ __host__ double2
460  rocrand_log_normal_double2(rocrand_state_mrg32k3a* state, double mean, double stddev)
461 {
462  auto state1 = state->next();
463  auto state2 = state->next();
464 
465  double2 r
466  = rocrand_device::detail::mrg_normal_distribution_double2<rocrand_state_mrg32k3a>(state1,
467  state2);
468  return double2 {
469  exp(mean + (stddev * r.x)),
470  exp(mean + (stddev * r.y))
471  };
472 }
473 
489 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
490 __forceinline__ __device__ __host__ float
491  rocrand_log_normal(rocrand_state_xorwow* state, float mean, float stddev)
492 {
493  typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_xorwow> bm_helper;
494 
495  if(bm_helper::has_float(state))
496  {
497  return expf(mean + (stddev * bm_helper::get_float(state)));
498  }
499 
500  auto state1 = rocrand(state);
501  auto state2 = rocrand(state);
502 
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));
506 }
507 #endif // ROCRAND_DETAIL_BM_NOT_IN_STATE
508 
523 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_xorwow* state,
524  float mean,
525  float stddev)
526 {
527  auto state1 = rocrand(state);
528  auto state2 = rocrand(state);
529 
530  float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
531  return float2 {
532  expf(mean + (stddev * r.x)),
533  expf(mean + (stddev * r.y))
534  };
535 }
536 
552 #ifndef ROCRAND_DETAIL_BM_NOT_IN_STATE
553 __forceinline__ __device__ __host__ double
554  rocrand_log_normal_double(rocrand_state_xorwow* state, double mean, double stddev)
555 {
556  typedef rocrand_device::detail::engine_boxmuller_helper<rocrand_state_xorwow> bm_helper;
557 
558  if(bm_helper::has_double(state))
559  {
560  return exp(mean + (stddev * bm_helper::get_double(state)));
561  }
562 
563  auto state1 = rocrand(state);
564  auto state2 = rocrand(state);
565  auto state3 = rocrand(state);
566  auto state4 = rocrand(state);
567 
568  double2 r = rocrand_device::detail::normal_distribution_double2(
569  uint4 { state1, state2, state3, state4 }
570  );
571  bm_helper::save_double(state, r.y);
572  return exp(mean + (stddev * r.x));
573 }
574 #endif // ROCRAND_DETAIL_BM_NOT_IN_STATE
575 
590 __forceinline__ __device__ __host__ double2 rocrand_log_normal_double2(rocrand_state_xorwow* state,
591  double mean,
592  double stddev)
593 {
594  auto state1 = rocrand(state);
595  auto state2 = rocrand(state);
596  auto state3 = rocrand(state);
597  auto state4 = rocrand(state);
598 
599  double2 r = rocrand_device::detail::normal_distribution_double2(
600  uint4 { state1, state2, state3, state4 }
601  );
602  return double2 {
603  exp(mean + (stddev * r.x)),
604  exp(mean + (stddev * r.y))
605  };
606 }
607 
620 __forceinline__ __device__ float
621  rocrand_log_normal(rocrand_state_mtgp32* state, float mean, float stddev)
622 {
623  float r = rocrand_device::detail::normal_distribution(rocrand(state));
624  return expf(mean + (stddev * r));
625 }
626 
641 __forceinline__ __device__ float2 rocrand_log_normal2(rocrand_state_mtgp32* state,
642  float mean,
643  float stddev)
644 {
645  auto state1 = rocrand(state);
646  auto state2 = rocrand(state);
647 
648  float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
649  return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
650 }
651 
664 __forceinline__ __device__ double
665  rocrand_log_normal_double(rocrand_state_mtgp32* state, double mean, double stddev)
666 {
667  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
668  return exp(mean + (stddev * r));
669 }
670 
685 __forceinline__ __device__ double2 rocrand_log_normal_double2(rocrand_state_mtgp32* state,
686  double mean,
687  double stddev)
688 {
689  auto state1 = rocrand(state);
690  auto state2 = rocrand(state);
691  auto state3 = rocrand(state);
692  auto state4 = rocrand(state);
693 
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))};
697 }
698 
711 __forceinline__ __device__ __host__ float
712  rocrand_log_normal(rocrand_state_sobol32* state, float mean, float stddev)
713 {
714  float r = rocrand_device::detail::normal_distribution(rocrand(state));
715  return expf(mean + (stddev * r));
716 }
717 
730 __forceinline__ __device__ __host__ double
731  rocrand_log_normal_double(rocrand_state_sobol32* state, double mean, double stddev)
732 {
733  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
734  return exp(mean + (stddev * r));
735 }
736 
749 __forceinline__ __device__ __host__ float
750  rocrand_log_normal(rocrand_state_scrambled_sobol32* state, float mean, float stddev)
751 {
752  float r = rocrand_device::detail::normal_distribution(rocrand(state));
753  return expf(mean + (stddev * r));
754 }
755 
768 __forceinline__ __device__ __host__ double
769  rocrand_log_normal_double(rocrand_state_scrambled_sobol32* state, double mean, double stddev)
770 {
771  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
772  return exp(mean + (stddev * r));
773 }
774 
787 __forceinline__ __device__ __host__ float
788  rocrand_log_normal(rocrand_state_sobol64* state, float mean, float stddev)
789 {
790  float r = rocrand_device::detail::normal_distribution(rocrand(state));
791  return expf(mean + (stddev * r));
792 }
793 
806 __forceinline__ __device__ __host__ double
807  rocrand_log_normal_double(rocrand_state_sobol64* state, double mean, double stddev)
808 {
809  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
810  return exp(mean + (stddev * r));
811 }
812 
825 __forceinline__ __device__ __host__ float
826  rocrand_log_normal(rocrand_state_scrambled_sobol64* state, float mean, float stddev)
827 {
828  float r = rocrand_device::detail::normal_distribution(rocrand(state));
829  return expf(mean + (stddev * r));
830 }
831 
844 __forceinline__ __device__ __host__ double
845  rocrand_log_normal_double(rocrand_state_scrambled_sobol64* state, double mean, double stddev)
846 {
847  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
848  return exp(mean + (stddev * r));
849 }
850 
863 __forceinline__ __device__ __host__ float
864  rocrand_log_normal(rocrand_state_lfsr113* state, float mean, float stddev)
865 {
866  float r = rocrand_device::detail::normal_distribution(rocrand(state));
867  return expf(mean + (stddev * r));
868 }
869 
884 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_lfsr113* state,
885  float mean,
886  float stddev)
887 {
888  auto state1 = rocrand(state);
889  auto state2 = rocrand(state);
890 
891  float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
892  return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
893 }
894 
907 __forceinline__ __device__ __host__ double
908  rocrand_log_normal_double(rocrand_state_lfsr113* state, double mean, double stddev)
909 {
910  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
911  return exp(mean + (stddev * r));
912 }
913 
928 __forceinline__ __device__ __host__ double2 rocrand_log_normal_double2(rocrand_state_lfsr113* state,
929  double mean,
930  double stddev)
931 {
932  auto state1 = rocrand(state);
933  auto state2 = rocrand(state);
934  auto state3 = rocrand(state);
935  auto state4 = rocrand(state);
936 
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))};
940 }
941 
954 __forceinline__ __device__ __host__ float
955  rocrand_log_normal(rocrand_state_threefry2x32_20* state, double mean, double stddev)
956 {
957  float r = rocrand_device::detail::normal_distribution(rocrand(state));
958  return expf(mean + (stddev * r));
959 }
960 
975 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_threefry2x32_20* state,
976  float mean,
977  float stddev)
978 {
979  float2 r = rocrand_device::detail::normal_distribution2(rocrand2(state));
980  return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
981 }
982 
995 __forceinline__ __device__ __host__ double
996  rocrand_log_normal_double(rocrand_state_threefry2x32_20* state, double mean, double stddev)
997 {
998  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
999  return exp(mean + (stddev * r));
1000 }
1001 
1016 __forceinline__ __device__ __host__ double2
1017  rocrand_log_normal_double2(rocrand_state_threefry2x32_20* state, double mean, double stddev)
1018 {
1019  auto state1 = rocrand(state);
1020  auto state2 = rocrand(state);
1021  auto state3 = rocrand(state);
1022  auto state4 = rocrand(state);
1023 
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))};
1027 }
1028 
1041 __forceinline__ __device__ __host__ float
1042  rocrand_log_normal(rocrand_state_threefry2x64_20* state, double mean, double stddev)
1043 {
1044  float r = rocrand_device::detail::normal_distribution(rocrand(state));
1045  return expf(mean + (stddev * r));
1046 }
1047 
1062 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_threefry2x64_20* state,
1063  float mean,
1064  float stddev)
1065 {
1066  auto state1 = rocrand(state);
1067  auto state2 = rocrand(state);
1068 
1069  float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1070  return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1071 }
1072 
1085 __forceinline__ __device__ __host__ double
1086  rocrand_log_normal_double(rocrand_state_threefry2x64_20* state, double mean, double stddev)
1087 {
1088  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
1089  return exp(mean + (stddev * r));
1090 }
1091 
1106 __forceinline__ __device__ __host__ double2
1107  rocrand_log_normal_double2(rocrand_state_threefry2x64_20* state, double mean, double stddev)
1108 {
1109  double2 r = rocrand_device::detail::normal_distribution_double2(rocrand2(state));
1110  return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1111 }
1112 
1125 __forceinline__ __device__ __host__ float
1126  rocrand_log_normal(rocrand_state_threefry4x32_20* state, double mean, double stddev)
1127 {
1128  float r = rocrand_device::detail::normal_distribution(rocrand(state));
1129  return expf(mean + (stddev * r));
1130 }
1131 
1146 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_threefry4x32_20* state,
1147  float mean,
1148  float stddev)
1149 {
1150  auto state1 = rocrand(state);
1151  auto state2 = rocrand(state);
1152 
1153  float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1154  return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1155 }
1156 
1169 __forceinline__ __device__ __host__ double
1170  rocrand_log_normal_double(rocrand_state_threefry4x32_20* state, double mean, double stddev)
1171 {
1172  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
1173  return exp(mean + (stddev * r));
1174 }
1175 
1190 __forceinline__ __device__ __host__ double2
1191  rocrand_log_normal_double2(rocrand_state_threefry4x32_20* state, double mean, double stddev)
1192 {
1193  double2 r = rocrand_device::detail::normal_distribution_double2(rocrand4(state));
1194  return double2{exp(mean + (stddev * r.x)), exp(mean + (stddev * r.y))};
1195 }
1196 
1209 __forceinline__ __device__ __host__ float
1210  rocrand_log_normal(rocrand_state_threefry4x64_20* state, double mean, double stddev)
1211 {
1212  float r = rocrand_device::detail::normal_distribution(rocrand(state));
1213  return expf(mean + (stddev * r));
1214 }
1215 
1230 __forceinline__ __device__ __host__ float2 rocrand_log_normal2(rocrand_state_threefry4x64_20* state,
1231  float mean,
1232  float stddev)
1233 {
1234  auto state1 = rocrand(state);
1235  auto state2 = rocrand(state);
1236 
1237  float2 r = rocrand_device::detail::normal_distribution2(state1, state2);
1238  return float2{expf(mean + (stddev * r.x)), expf(mean + (stddev * r.y))};
1239 }
1240 
1253 __forceinline__ __device__ __host__ double
1254  rocrand_log_normal_double(rocrand_state_threefry4x64_20* state, double mean, double stddev)
1255 {
1256  double r = rocrand_device::detail::normal_distribution_double(rocrand(state));
1257  return exp(mean + (stddev * r));
1258 }
1259 
1274 __forceinline__ __device__ __host__ double2
1275  rocrand_log_normal_double2(rocrand_state_threefry4x64_20* state, double mean, double stddev)
1276 {
1277  auto state1 = rocrand(state);
1278  auto state2 = rocrand(state);
1279 
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))};
1282 }
1283  // end of group rocranddevice
1285 
1286 #endif // ROCRAND_LOG_NORMAL_H_
__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