8#ifndef _AUROSTD_XRANDOM_CPP_
9#define _AUROSTD_XRANDOM_CPP_
36 (*_idum) = -std::labs(_num) - 1969;
46 gettimeofday(&tim,
nullptr);
50 const int PID = getpid();
52 const long int seed = tim.tv_usec + tim.tv_sec + PID + TID;
63#define _AUROSTD_XRANDOM_RAN0_IA 16807
64#define _AUROSTD_XRANDOM_RAN0_IM 2147483647
65#define _AUROSTD_XRANDOM_RAN0_AM (1.0 / _AUROSTD_XRANDOM_RAN0_IM)
66#define _AUROSTD_XRANDOM_RAN0_IQ 127773
67#define _AUROSTD_XRANDOM_RAN0_IR 2836
68#define _AUROSTD_XRANDOM_RAN0_MASK 123459876
85#undef _AUROSTD_XRANDOM_RAN0_IA
86#undef _AUROSTD_XRANDOM_RAN0_IM
87#undef _AUROSTD_XRANDOM_RAN0_AM
88#undef _AUROSTD_XRANDOM_RAN0_IQ
89#undef _AUROSTD_XRANDOM_RAN0_IR
90#undef _AUROSTD_XRANDOM_RAN0_MASK
93#define _AUROSTD_XRANDOM_RAN1_IA 16807
94#define _AUROSTD_XRANDOM_RAN1_IM 2147483647
95#define _AUROSTD_XRANDOM_RAN1_AM (1.0 / _AUROSTD_XRANDOM_RAN1_IM)
96#define _AUROSTD_XRANDOM_RAN1_IQ 127773
97#define _AUROSTD_XRANDOM_RAN1_IR 2836
98#define _AUROSTD_XRANDOM_RAN1_NTAB 32
99#define _AUROSTD_XRANDOM_RAN1_EPS 1.2e-7
100#define _AUROSTD_XRANDOM_RAN1_RNMX (1.0 - _AUROSTD_XRANDOM_RAN1_EPS)
110 static long int iy = 0;
113 if (*
_idum <= 0 || !iy) {
146#undef _AUROSTD_XRANDOM_RAN1_IA
147#undef _AUROSTD_XRANDOM_RAN1_IM
148#undef _AUROSTD_XRANDOM_RAN1_AM
149#undef _AUROSTD_XRANDOM_RAN1_IQ
150#undef _AUROSTD_XRANDOM_RAN1_IR
151#undef _AUROSTD_XRANDOM_RAN1_NTAB
152#undef _AUROSTD_XRANDOM_RAN1_EPS
153#undef _AUROSTD_XRANDOM_RAN1_RNMX
157#define _AUROSTD_XRANDOM_RAN2_IM1 2147483563
158#define _AUROSTD_XRANDOM_RAN2_IM2 2147483399
159#define _AUROSTD_XRANDOM_RAN2_AM (1.0 / _AUROSTD_XRANDOM_RAN2_IM1)
160#define _AUROSTD_XRANDOM_RAN2_IMM1 (_AUROSTD_XRANDOM_RAN2_IM1 - 1)
161#define _AUROSTD_XRANDOM_RAN2_IA1 40014
162#define _AUROSTD_XRANDOM_RAN2_IA2 40692
163#define _AUROSTD_XRANDOM_RAN2_IQ1 53668
164#define _AUROSTD_XRANDOM_RAN2_IQ2 52774
165#define _AUROSTD_XRANDOM_RAN2_IR1 12211
166#define _AUROSTD_XRANDOM_RAN2_IR2 3791
167#define _AUROSTD_XRANDOM_RAN2_NTAB 32
168#define _AUROSTD_XRANDOM_RAN2_NDIV (1 + _AUROSTD_XRANDOM_RAN2_IMM1 / _AUROSTD_XRANDOM_RAN2_NTAB)
169#define _AUROSTD_XRANDOM_RAN2_EPS 1.2e-7
170#define _AUROSTD_XRANDOM_RAN2_RNMX (1.0 - _AUROSTD_XRANDOM_RAN2_EPS)
175 static long int _idum2 = 123456789;
176 static long int iy = 0;
222#undef _AUROSTD_XRANDOM_RAN2_IM1
223#undef _AUROSTD_XRANDOM_RAN2_IM2
224#undef _AUROSTD_XRANDOM_RAN2_AM
225#undef _AUROSTD_XRANDOM_RAN2_IMM1
226#undef _AUROSTD_XRANDOM_RAN2_IA1
227#undef _AUROSTD_XRANDOM_RAN2_IA2
228#undef _AUROSTD_XRANDOM_RAN2_IQ1
229#undef _AUROSTD_XRANDOM_RAN2_IQ2
230#undef _AUROSTD_XRANDOM_RAN2_IR1
231#undef _AUROSTD_XRANDOM_RAN2_IR2
232#undef _AUROSTD_XRANDOM_RAN2_NTAB
233#undef _AUROSTD_XRANDOM_RAN2_NDIV
234#undef _AUROSTD_XRANDOM_RAN2_EPS
235#undef _AUROSTD_XRANDOM_RAN2_RNMX
239#define _AUROSTD_XRANDOM_RAN3_MBIG 1000000000
240#define _AUROSTD_XRANDOM_RAN3_MSEED 161803398
241#define _AUROSTD_XRANDOM_RAN3_MZ 0
242#define _AUROSTD_XRANDOM_RAN3_FAC (1.0 / _AUROSTD_XRANDOM_RAN3_MBIG)
247 static long int ma[56];
255 if (*
_idum < 0 || iff == 0) {
261 for (i = 1; i <= 54; i++) {
270 for (k = 1; k <= 4; k++) {
271 for (i = 1; i <= 55; i++) {
272 ma[i] -= ma[1 + (i + 30) % 55];
285 if (++inextp == 56) {
288 mj = ma[inext] - ma[inextp];
295#undef _AUROSTD_XRANDOM_RAN3_MBIG
296#undef _AUROSTD_XRANDOM_RAN3_MSEED
297#undef _AUROSTD_XRANDOM_RAN3_MZ
298#undef _AUROSTD_XRANDOM_RAN3_FAC
303 inline double ran(
void) {
308 inline double ran(
void) {
313 inline double ran(
void) {
322 inline double ran(
void) {
330 template <
class utype>
inline utype
uniform(
const utype& x) {
332 return (utype) x * ((utype)
ran());
335 template <
class utype>
inline utype
uniform(
const utype& x,
const utype& y) {
337 return (utype) x + (y - x) * ((utype)
ran());
340#define AST_TEMPLATE(utype) template utype uniform(const utype&);
343#define AST_TEMPLATE(utype) template utype uniform(const utype&, const utype&);
361 v1 = 2.0 *
ran() - 1.0;
362 v2 = 2.0 *
ran() - 1.0;
363 rsq = v1 * v1 + v2 * v2;
364 }
while (rsq >= 1.0 || rsq == 0.0);
365 fac = std::sqrt(-2.0 *
log(rsq) / rsq);
375 template <
class utype>
380 return (utype) sigma * ((utype)
gaussian());
383 template <
class utype>
402 template <
class utype>
410 return (utype) -lambda * ((utype)
log(u));
422 return u < 0.5 ?
log(2.0 * u) : -
log(2.0 * (1.0 - u));
425 template <
class utype>
434 return u < 0.5 ? a * ((utype)
log(2.0 * u)) : -a * ((utype)
log(2.0 * (1.0 - u)));
437 template <
class utype>
446 return u < 0.5 ? a * ((utype)
log(2.0 * u)) + lambda : -a * ((utype)
log(2.0 * (1.0 - u))) + lambda;
455#ifdef _AUROSTD_XVECTOR_CPP_
459 template <
class utype>
462 for (
int i = a.
lrows; i <= a.
urows; i++) a[i] = (utype) x + (y - x) *
uniform(utype(1.0));
467 template <
class utype>
470 return uniform(a, utype(0.0), utype(y));
473 template <
class utype>
476 return uniform(a, utype(0.0), utype(1.0));
479 template <
class utype>
490 template <
class utype>
495 return uniform(a, utype(0.0), x, utype(0.0), y);
498 template <
class utype>
502 return uniform(a, utype(0.0), y, utype(0.0), y);
505 template <
class utype>
508 return uniform(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
516 template <
class utype>
521 a[i] = (utype) m + sigma *
gaussian();
525 template <
class utype>
530 a[i] = (utype) m[i] + sigma[i] *
gaussian();
534 template <
class utype>
537 return gaussian(a, utype(0.0), utype(sigma));
540 template <
class utype>
543 return gaussian(a, utype(0.0), utype(1.0));
546 template <
class utype>
552 const utype& sigma2) {
560 template <
class utype>
564 const utype& sigma) {
565 return gaussian(a, utype(0.0), m, utype(0.0), sigma);
568 template <
class utype>
571 const utype& sigma) {
572 return gaussian(a, utype(0.0), sigma, utype(0.0), sigma);
575 template <
class utype>
578 return gaussian(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
586#ifdef _AUROSTD_XMATRIX_CPP_
590 template <
class utype>
594 for (
int j = a.
lcols; j <= a.
ucols; j++) a[i][j] = (utype) x + (y - x) *
uniform(utype(1.0));
598 template <
class utype>
601 return uniform(a, utype(0.0), utype(y));
604 template <
class utype>
607 return uniform(a, utype(0.0), utype(1.0));
610 template <
class utype>
622 template <
class utype>
627 return uniform(a, utype(0.0), x, utype(0.0), y);
630 template <
class utype>
634 return uniform(a, utype(0.0), y, utype(0.0), y);
637 template <
class utype>
640 return uniform(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
648 template <
class utype>
654 a[i][j] = (utype) (utype) m + sigma *
gaussian();
658 template <
class utype>
661 return gaussian(a, utype(0.0), utype(sigma));
664 template <
class utype>
667 return gaussian(a, utype(0.0), utype(1.0));
670 template <
class utype>
676 const utype& sigma2) {
685 template <
class utype>
689 const utype& sigma2) {
690 return gaussian(a, utype(0.0), sigma1, utype(0.0), sigma2);
693 template <
class utype>
696 const utype& sigma) {
697 return gaussian(a, utype(0.0), sigma, utype(0.0), sigma);
700 template <
class utype>
703 return gaussian(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
715 template <
class utype>
717 uniform(
const xtensor3<utype>& a,
const utype& x,
const utype& y) {
718 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
719 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
720 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++) a[i][j][k] = (utype) x + (y - x) *
uniform(utype(1.0));
724 template <
class utype>
726 uniform(
const xtensor3<utype>& a,
const utype& y) {
727 return uniform(a, utype(0.0), utype(y));
730 template <
class utype>
732 uniform(
const xtensor3<utype>& a) {
733 return uniform(a, utype(0.0), utype(1.0));
736 template <
class utype>
737 xtensor3<xcomplex<utype>>
743 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
744 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
745 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++) a[i][j][k] =
xcomplex<utype>(x1 + (y1 - x1) *
uniform(utype(1.0)), x2 + (y2 - x2) *
uniform(utype(1.0)));
749 template <
class utype>
750 xtensor3<xcomplex<utype>>
754 return uniform(a, utype(0.0), x, utype(0.0), y);
757 template <
class utype>
758 xtensor3<xcomplex<utype>>
761 return uniform(a, utype(0.0), y, utype(0.0), y);
764 template <
class utype>
765 xtensor3<xcomplex<utype>>
767 return uniform(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
775 template <
class utype>
777 gaussian(
const xtensor3<utype>& a,
const utype& m,
const utype& sigma) {
778 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
779 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
780 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
782 a[i][j][k] = (utype) (utype) m + sigma *
gaussian();
786 template <
class utype>
788 gaussian(
const xtensor3<utype>& a,
const utype& sigma) {
789 return gaussian(a, utype(0.0), utype(sigma));
792 template <
class utype>
794 gaussian(
const xtensor3<utype>& a) {
795 return gaussian(a, utype(0.0), utype(1.0));
798 template <
class utype>
799 xtensor3<xcomplex<utype>>
804 const utype& sigma2) {
805 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
806 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
807 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
814 template <
class utype>
815 xtensor3<xcomplex<utype>>
818 const utype& sigma2) {
819 return gaussian(a, utype(0.0), sigma1, utype(0.0), sigma2);
822 template <
class utype>
823 xtensor3<xcomplex<utype>>
825 const utype& sigma) {
826 return gaussian(a, utype(0.0), sigma, utype(0.0), sigma);
829 template <
class utype>
830 xtensor3<xcomplex<utype>>
832 return gaussian(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
845 template <
class utype>
847 uniform(
const xtensor4<utype>& a,
const utype& x,
const utype& y) {
848 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
849 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
850 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
851 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++) a[i][j][k][l] = (utype) x + (y - x) *
uniform(utype(1.0));
855 template <
class utype>
857 uniform(
const xtensor4<utype>& a,
const utype& y) {
858 return uniform(a, utype(0.0), utype(y));
861 template <
class utype>
863 uniform(
const xtensor4<utype>& a) {
864 return uniform(a, utype(0.0), utype(1.0));
867 template <
class utype>
868 xtensor4<xcomplex<utype>>
874 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
875 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
876 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
877 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++) a[i][j][k][l] =
xcomplex<utype>(x1 + (y1 - x1) *
uniform(utype(1.0)), x2 + (y2 - x2) *
uniform(utype(1.0)));
881 template <
class utype>
882 xtensor4<xcomplex<utype>>
886 return uniform(a, utype(0.0), x, utype(0.0), y);
889 template <
class utype>
890 xtensor4<xcomplex<utype>>
893 return uniform(a, utype(0.0), y, utype(0.0), y);
896 template <
class utype>
897 xtensor4<xcomplex<utype>>
899 return uniform(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
907 template <
class utype>
909 gaussian(
const xtensor4<utype>& a,
const utype& m,
const utype& sigma) {
910 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
911 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
912 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
913 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
915 a[i][j][k][l] = (utype) (utype) m + sigma *
gaussian();
919 template <
class utype>
921 gaussian(
const xtensor4<utype>& a,
const utype& sigma) {
922 return gaussian(a, utype(0.0), utype(sigma));
925 template <
class utype>
927 gaussian(
const xtensor4<utype>& a) {
928 return gaussian(a, utype(0.0), utype(1.0));
931 template <
class utype>
932 xtensor4<xcomplex<utype>>
937 const utype& sigma2) {
938 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
939 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
940 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
941 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
948 template <
class utype>
949 xtensor4<xcomplex<utype>>
952 const utype& sigma2) {
953 return gaussian(a, utype(0.0), sigma1, utype(0.0), sigma2);
956 template <
class utype>
957 xtensor4<xcomplex<utype>>
959 const utype& sigma) {
960 return gaussian(a, utype(0.0), sigma, utype(0.0), sigma);
963 template <
class utype>
964 xtensor4<xcomplex<utype>>
966 return gaussian(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
979 template <
class utype>
981 uniform(
const xtensor5<utype>& a,
const utype& x,
const utype& y) {
982 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
983 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
984 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
985 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
986 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++) a[i][j][k][l][m] = (utype) x + (y - x) *
uniform(utype(1.0));
990 template <
class utype>
992 uniform(
const xtensor5<utype>& a,
const utype& y) {
993 return uniform(a, utype(0.0), utype(y));
996 template <
class utype>
998 uniform(
const xtensor5<utype>& a) {
999 return uniform(a, utype(0.0), utype(1.0));
1002 template <
class utype>
1003 xtensor5<xcomplex<utype>>
1009 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1010 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1011 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1012 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1013 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++) a[i][j][k][l][m] =
xcomplex<utype>(x1 + (y1 - x1) *
uniform(utype(1.0)), x2 + (y2 - x2) *
uniform(utype(1.0)));
1017 template <
class utype>
1018 xtensor5<xcomplex<utype>>
1022 return uniform(a, utype(0.0), x, utype(0.0), y);
1025 template <
class utype>
1026 xtensor5<xcomplex<utype>>
1029 return uniform(a, utype(0.0), y, utype(0.0), y);
1032 template <
class utype>
1033 xtensor5<xcomplex<utype>>
1035 return uniform(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
1043 template <
class utype>
1045 gaussian(
const xtensor5<utype>& a,
const utype& m,
const utype& sigma) {
1046 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1047 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1048 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1049 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1050 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1052 a[i][j][k][l][m] = (utype) (utype) m + sigma *
gaussian();
1056 template <
class utype>
1058 gaussian(
const xtensor5<utype>& a,
const utype& sigma) {
1059 return gaussian(a, utype(0.0), utype(sigma));
1062 template <
class utype>
1064 gaussian(
const xtensor5<utype>& a) {
1065 return gaussian(a, utype(0.0), utype(1.0));
1068 template <
class utype>
1069 xtensor5<xcomplex<utype>>
1072 const utype& sigma1,
1074 const utype& sigma2) {
1075 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1076 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1077 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1078 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1079 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1086 template <
class utype>
1087 xtensor5<xcomplex<utype>>
1089 const utype& sigma1,
1090 const utype& sigma2) {
1091 return gaussian(a, utype(0.0), sigma1, utype(0.0), sigma2);
1094 template <
class utype>
1095 xtensor5<xcomplex<utype>>
1097 const utype& sigma) {
1098 return gaussian(a, utype(0.0), sigma, utype(0.0), sigma);
1101 template <
class utype>
1102 xtensor5<xcomplex<utype>>
1104 return gaussian(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
1113#ifdef __XTENSOR6_CPP
1117 template <
class utype>
1119 uniform(
const xtensor6<utype>& a,
const utype& x,
const utype& y) {
1120 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1121 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1122 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1123 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1124 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1125 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++) a[i][j][k][l][m][n] = (utype) x + (y - x) *
uniform(utype(1.0));
1129 template <
class utype>
1131 uniform(
const xtensor6<utype>& a,
const utype& y) {
1132 return uniform(a, utype(0.0), utype(y));
1135 template <
class utype>
1137 uniform(
const xtensor6<utype>& a) {
1138 return uniform(a, utype(0.0), utype(1.0));
1141 template <
class utype>
1142 xtensor6<xcomplex<utype>>
1148 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1149 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1150 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1151 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1152 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1153 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++) a[i][j][k][l][m][n] =
xcomplex<utype>(x1 + (y1 - x1) *
uniform(utype(1.0)), x2 + (y2 - x2) *
uniform(utype(1.0)));
1157 template <
class utype>
1158 xtensor6<xcomplex<utype>>
1162 return uniform(a, utype(0.0), x, utype(0.0), y);
1165 template <
class utype>
1166 xtensor6<xcomplex<utype>>
1169 return uniform(a, utype(0.0), y, utype(0.0), y);
1172 template <
class utype>
1173 xtensor6<xcomplex<utype>>
1175 return uniform(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
1183 template <
class utype>
1185 gaussian(
const xtensor6<utype>& a,
const utype& m,
const utype& sigma) {
1186 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1187 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1188 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1189 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1190 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1191 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1193 a[i][j][k][l][m][n] = (utype) (utype) m + sigma *
gaussian();
1197 template <
class utype>
1199 gaussian(
const xtensor6<utype>& a,
const utype& sigma) {
1200 return gaussian(a, utype(0.0), utype(sigma));
1203 template <
class utype>
1205 gaussian(
const xtensor6<utype>& a) {
1206 return gaussian(a, utype(0.0), utype(1.0));
1209 template <
class utype>
1210 xtensor6<xcomplex<utype>>
1213 const utype& sigma1,
1215 const utype& sigma2) {
1216 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1217 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1218 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1219 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1220 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1221 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1228 template <
class utype>
1229 xtensor6<xcomplex<utype>>
1231 const utype& sigma1,
1232 const utype& sigma2) {
1233 return gaussian(a, utype(0.0), sigma1, utype(0.0), sigma2);
1236 template <
class utype>
1237 xtensor6<xcomplex<utype>>
1239 const utype& sigma) {
1240 return gaussian(a, utype(0.0), sigma, utype(0.0), sigma);
1243 template <
class utype>
1244 xtensor6<xcomplex<utype>>
1246 return gaussian(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
1255#ifdef __XTENSOR7_CPP
1259 template <
class utype>
1261 uniform(
const xtensor7<utype>& a,
const utype& x,
const utype& y) {
1262 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1263 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1264 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1265 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1266 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1267 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1268 for (
int o = a.lindex[7]; o <= a.uindex[7]; o++) a[i][j][k][l][m][n][o] = (utype) x + (y - x) *
uniform(utype(1.0));
1272 template <
class utype>
1274 uniform(
const xtensor7<utype>& a,
const utype& y) {
1275 return uniform(a, utype(0.0), utype(y));
1278 template <
class utype>
1280 uniform(
const xtensor7<utype>& a) {
1281 return uniform(a, utype(0.0), utype(1.0));
1284 template <
class utype>
1285 xtensor7<xcomplex<utype>>
1291 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1292 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1293 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1294 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1295 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1296 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1297 for (
int o = a.lindex[7]; o <= a.uindex[7]; o++) a[i][j][k][l][m][n][o] =
xcomplex<utype>(x1 + (y1 - x1) *
uniform(utype(1.0)), x2 + (y2 - x2) *
uniform(utype(1.0)));
1301 template <
class utype>
1302 xtensor7<xcomplex<utype>>
1306 return uniform(a, utype(0.0), x, utype(0.0), y);
1309 template <
class utype>
1310 xtensor7<xcomplex<utype>>
1313 return uniform(a, utype(0.0), y, utype(0.0), y);
1316 template <
class utype>
1317 xtensor7<xcomplex<utype>>
1319 return uniform(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
1327 template <
class utype>
1329 gaussian(
const xtensor7<utype>& a,
const utype& m,
const utype& sigma) {
1330 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1331 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1332 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1333 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1334 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1335 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1336 for (
int o = a.lindex[7]; o <= a.uindex[7]; o++)
1338 a[i][j][k][l][m][n][o] = (utype) (utype) m + sigma *
gaussian();
1342 template <
class utype>
1344 gaussian(
const xtensor7<utype>& a,
const utype& sigma) {
1345 return gaussian(a, utype(0.0), utype(sigma));
1348 template <
class utype>
1350 gaussian(
const xtensor7<utype>& a) {
1351 return gaussian(a, utype(0.0), utype(1.0));
1354 template <
class utype>
1355 xtensor7<xcomplex<utype>>
1358 const utype& sigma1,
1360 const utype& sigma2) {
1361 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1362 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1363 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1364 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1365 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1366 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1367 for (
int o = a.lindex[7]; o <= a.uindex[7]; o++)
1374 template <
class utype>
1375 xtensor7<xcomplex<utype>>
1377 const utype& sigma1,
1378 const utype& sigma2) {
1379 return gaussian(a, utype(0.0), sigma1, utype(0.0), sigma2);
1382 template <
class utype>
1383 xtensor7<xcomplex<utype>>
1385 const utype& sigma) {
1386 return gaussian(a, utype(0.0), sigma, utype(0.0), sigma);
1389 template <
class utype>
1390 xtensor7<xcomplex<utype>>
1392 return gaussian(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
1401#ifdef __XTENSOR8_CPP
1405 template <
class utype>
1407 uniform(
const xtensor8<utype>& a,
const utype& x,
const utype& y) {
1408 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1409 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1410 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1411 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1412 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1413 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1414 for (
int o = a.lindex[7]; o <= a.uindex[7]; o++)
1415 for (
int p = a.lindex[8]; p <= a.uindex[8]; p++) a[i][j][k][l][m][n][o][p] = (utype) x + (y - x) *
uniform(utype(1.0));
1419 template <
class utype>
1421 uniform(
const xtensor8<utype>& a,
const utype& y) {
1422 return uniform(a, utype(0.0), utype(y));
1425 template <
class utype>
1427 uniform(
const xtensor8<utype>& a) {
1428 return uniform(a, utype(0.0), utype(1.0));
1431 template <
class utype>
1432 xtensor8<xcomplex<utype>>
1438 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1439 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1440 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1441 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1442 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1443 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1444 for (
int o = a.lindex[7]; o <= a.uindex[7]; o++)
1445 for (
int p = a.lindex[8]; p <= a.uindex[8]; p++) a[i][j][k][l][m][n][o][p] =
xcomplex<utype>(x1 + (y1 - x1) *
uniform(utype(1.0)), x2 + (y2 - x2) *
uniform(utype(1.0)));
1449 template <
class utype>
1450 xtensor8<xcomplex<utype>>
1454 return uniform(a, utype(0.0), x, utype(0.0), y);
1457 template <
class utype>
1458 xtensor8<xcomplex<utype>>
1461 return uniform(a, utype(0.0), y, utype(0.0), y);
1464 template <
class utype>
1465 xtensor8<xcomplex<utype>>
1467 return uniform(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
1475 template <
class utype>
1477 gaussian(
const xtensor8<utype>& a,
const utype& m,
const utype& sigma) {
1478 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1479 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1480 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1481 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1482 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1483 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1484 for (
int o = a.lindex[7]; o <= a.uindex[7]; o++)
1485 for (
int p = a.lindex[8]; p <= a.uindex[8]; p++)
1487 a[i][j][k][l][m][n][o][p] = (utype) (utype) m + sigma *
gaussian();
1491 template <
class utype>
1493 gaussian(
const xtensor8<utype>& a,
const utype& sigma) {
1494 return gaussian(a, utype(0.0), utype(sigma));
1497 template <
class utype>
1499 gaussian(
const xtensor8<utype>& a) {
1500 return gaussian(a, utype(0.0), utype(1.0));
1503 template <
class utype>
1504 xtensor8<xcomplex<utype>>
1507 const utype& sigma1,
1509 const utype& sigma2) {
1510 for (
int i = a.lindex[1]; i <= a.uindex[1]; i++)
1511 for (
int j = a.lindex[2]; j <= a.uindex[2]; j++)
1512 for (
int k = a.lindex[3]; k <= a.uindex[3]; k++)
1513 for (
int l = a.lindex[4]; l <= a.uindex[4]; l++)
1514 for (
int m = a.lindex[5]; m <= a.uindex[5]; m++)
1515 for (
int n = a.lindex[6]; n <= a.uindex[6]; n++)
1516 for (
int o = a.lindex[7]; o <= a.uindex[7]; o++)
1517 for (
int p = a.lindex[8]; p <= a.uindex[8]; p++)
1524 template <
class utype>
1525 xtensor8<xcomplex<utype>>
1527 const utype& sigma1,
1528 const utype& sigma2) {
1529 return gaussian(a, utype(0.0), sigma1, utype(0.0), sigma2);
1532 template <
class utype>
1533 xtensor8<xcomplex<utype>>
1535 const utype& sigma) {
1536 return gaussian(a, utype(0.0), sigma, utype(0.0), sigma);
1539 template <
class utype>
1540 xtensor8<xcomplex<utype>>
1542 return gaussian(a, utype(0.0), utype(1.0), utype(0.0), utype(1.0));
This file contains the preprocessor macros to ensure a proper instantiation of all aurostd functions.
#define AST_GEN_1(type_selection)
autogenerate 1D code based on AST_TEMPLATE
#define _AUROSTD_XRANDOM_RAN1_IA
#define _AUROSTD_XRANDOM_RAN2_IA1
#define _AUROSTD_XRANDOM_RAN1_RNMX
#define _AUROSTD_XRANDOM_RAN3_MBIG
#define _AUROSTD_XRANDOM_RAN2_IA2
#define _AUROSTD_XRANDOM_RAN2_IMM1
#define _AUROSTD_XRANDOM_RAN0_IQ
#define _AUROSTD_XRANDOM_RAN0_IR
#define _AUROSTD_XRANDOM_RAN2_IQ1
#define _AUROSTD_XRANDOM_RAN2_NTAB
#define _AUROSTD_XRANDOM_RAN2_AM
#define _AUROSTD_XRANDOM_RAN0_AM
#define _AUROSTD_XRANDOM_RAN0_MASK
#define _AUROSTD_XRANDOM_RAN1_IM
#define _AUROSTD_XRANDOM_RAN1_AM
#define _AUROSTD_XRANDOM_RAN2_IR1
#define _AUROSTD_XRANDOM_RAN0_IA
#define _AUROSTD_XRANDOM_RAN2_IM1
#define _AUROSTD_XRANDOM_RAN2_IR2
#define _AUROSTD_XRANDOM_RAN1_IQ
#define _AUROSTD_XRANDOM_RAN2_RNMX
#define _AUROSTD_XRANDOM_RAN1_NTAB
#define _AUROSTD_XRANDOM_RAN3_MZ
#define _AUROSTD_XRANDOM_RAN3_MSEED
#define _AUROSTD_XRANDOM_RAN0_IM
#define _AUROSTD_XRANDOM_RAN1_IR
#define _AUROSTD_XRANDOM_RAN2_NDIV
#define _AUROSTD_XRANDOM_RAN2_IQ2
#define _AUROSTD_XRANDOM_RAN2_IM2
#define _AUROSTD_XRANDOM_RAN3_FAC
utype uniform(const utype &x)
utype mean(const vector< utype > vec)
unsigned long long int getTID()
xcomplex< utype > log(const xcomplex< utype > &x)
long int _random_initialize()