fun8_2_randn.cpp 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. //
  2. // File: randn_8_2.cpp
  3. //
  4. // MATLAB Coder version : 5.2
  5. // C/C++ source code generated on : 10-Mar-2023 11:08:29
  6. //
  7. // Include Files
  8. #include "fun8_2_randn.h"
  9. #include "fun8_2_FMjamming_H_data.h"
  10. #include "eml_rand_mt19937ar.h"
  11. #include "rt_nonfinite.h"
  12. #include "coder_array.h"
  13. #include <cmath>
  14. // Function Definitions
  15. //
  16. // Arguments : const double varargin_1[2]
  17. // ::coder::array<double, 2U> &r
  18. // Return Type : void
  19. //
  20. namespace coder {
  21. void randn_8_2(const double *varargin_1, ::coder::array<double, 2U> &r)
  22. {
  23. static const double dv[257]{0.0,
  24. 0.215241895984875,
  25. 0.286174591792068,
  26. 0.335737519214422,
  27. 0.375121332878378,
  28. 0.408389134611989,
  29. 0.43751840220787,
  30. 0.46363433679088,
  31. 0.487443966139235,
  32. 0.50942332960209,
  33. 0.529909720661557,
  34. 0.549151702327164,
  35. 0.567338257053817,
  36. 0.584616766106378,
  37. 0.601104617755991,
  38. 0.61689699000775,
  39. 0.63207223638606,
  40. 0.646695714894993,
  41. 0.660822574244419,
  42. 0.674499822837293,
  43. 0.687767892795788,
  44. 0.700661841106814,
  45. 0.713212285190975,
  46. 0.725446140909999,
  47. 0.737387211434295,
  48. 0.749056662017815,
  49. 0.760473406430107,
  50. 0.771654424224568,
  51. 0.782615023307232,
  52. 0.793369058840623,
  53. 0.80392911698997,
  54. 0.814306670135215,
  55. 0.824512208752291,
  56. 0.834555354086381,
  57. 0.844444954909153,
  58. 0.854189171008163,
  59. 0.863795545553308,
  60. 0.87327106808886,
  61. 0.882622229585165,
  62. 0.891855070732941,
  63. 0.900975224461221,
  64. 0.909987953496718,
  65. 0.91889818364959,
  66. 0.927710533401999,
  67. 0.936429340286575,
  68. 0.945058684468165,
  69. 0.953602409881086,
  70. 0.96206414322304,
  71. 0.970447311064224,
  72. 0.978755155294224,
  73. 0.986990747099062,
  74. 0.99515699963509,
  75. 1.00325667954467,
  76. 1.01129241744,
  77. 1.01926671746548,
  78. 1.02718196603564,
  79. 1.03504043983344,
  80. 1.04284431314415,
  81. 1.05059566459093,
  82. 1.05829648333067,
  83. 1.06594867476212,
  84. 1.07355406579244,
  85. 1.0811144097034,
  86. 1.08863139065398,
  87. 1.09610662785202,
  88. 1.10354167942464,
  89. 1.11093804601357,
  90. 1.11829717411934,
  91. 1.12562045921553,
  92. 1.13290924865253,
  93. 1.14016484436815,
  94. 1.14738850542085,
  95. 1.15458145035993,
  96. 1.16174485944561,
  97. 1.16887987673083,
  98. 1.17598761201545,
  99. 1.18306914268269,
  100. 1.19012551542669,
  101. 1.19715774787944,
  102. 1.20416683014438,
  103. 1.2111537262437,
  104. 1.21811937548548,
  105. 1.22506469375653,
  106. 1.23199057474614,
  107. 1.23889789110569,
  108. 1.24578749554863,
  109. 1.2526602218949,
  110. 1.25951688606371,
  111. 1.26635828701823,
  112. 1.27318520766536,
  113. 1.27999841571382,
  114. 1.28679866449324,
  115. 1.29358669373695,
  116. 1.30036323033084,
  117. 1.30712898903073,
  118. 1.31388467315022,
  119. 1.32063097522106,
  120. 1.32736857762793,
  121. 1.33409815321936,
  122. 1.3408203658964,
  123. 1.34753587118059,
  124. 1.35424531676263,
  125. 1.36094934303328,
  126. 1.36764858359748,
  127. 1.37434366577317,
  128. 1.38103521107586,
  129. 1.38772383568998,
  130. 1.39441015092814,
  131. 1.40109476367925,
  132. 1.4077782768464,
  133. 1.41446128977547,
  134. 1.42114439867531,
  135. 1.42782819703026,
  136. 1.43451327600589,
  137. 1.44120022484872,
  138. 1.44788963128058,
  139. 1.45458208188841,
  140. 1.46127816251028,
  141. 1.46797845861808,
  142. 1.47468355569786,
  143. 1.48139403962819,
  144. 1.48811049705745,
  145. 1.49483351578049,
  146. 1.50156368511546,
  147. 1.50830159628131,
  148. 1.51504784277671,
  149. 1.521803020761,
  150. 1.52856772943771,
  151. 1.53534257144151,
  152. 1.542128153229,
  153. 1.54892508547417,
  154. 1.55573398346918,
  155. 1.56255546753104,
  156. 1.56939016341512,
  157. 1.57623870273591,
  158. 1.58310172339603,
  159. 1.58997987002419,
  160. 1.59687379442279,
  161. 1.60378415602609,
  162. 1.61071162236983,
  163. 1.61765686957301,
  164. 1.62462058283303,
  165. 1.63160345693487,
  166. 1.63860619677555,
  167. 1.64562951790478,
  168. 1.65267414708306,
  169. 1.65974082285818,
  170. 1.66683029616166,
  171. 1.67394333092612,
  172. 1.68108070472517,
  173. 1.68824320943719,
  174. 1.69543165193456,
  175. 1.70264685479992,
  176. 1.7098896570713,
  177. 1.71716091501782,
  178. 1.72446150294804,
  179. 1.73179231405296,
  180. 1.73915426128591,
  181. 1.74654827828172,
  182. 1.75397532031767,
  183. 1.76143636531891,
  184. 1.76893241491127,
  185. 1.77646449552452,
  186. 1.78403365954944,
  187. 1.79164098655216,
  188. 1.79928758454972,
  189. 1.80697459135082,
  190. 1.81470317596628,
  191. 1.82247454009388,
  192. 1.83028991968276,
  193. 1.83815058658281,
  194. 1.84605785028518,
  195. 1.8540130597602,
  196. 1.86201760539967,
  197. 1.87007292107127,
  198. 1.878180486293,
  199. 1.88634182853678,
  200. 1.8945585256707,
  201. 1.90283220855043,
  202. 1.91116456377125,
  203. 1.91955733659319,
  204. 1.92801233405266,
  205. 1.93653142827569,
  206. 1.94511656000868,
  207. 1.95376974238465,
  208. 1.96249306494436,
  209. 1.97128869793366,
  210. 1.98015889690048,
  211. 1.98910600761744,
  212. 1.99813247135842,
  213. 2.00724083056053,
  214. 2.0164337349062,
  215. 2.02571394786385,
  216. 2.03508435372962,
  217. 2.04454796521753,
  218. 2.05410793165065,
  219. 2.06376754781173,
  220. 2.07353026351874,
  221. 2.0833996939983,
  222. 2.09337963113879,
  223. 2.10347405571488,
  224. 2.11368715068665,
  225. 2.12402331568952,
  226. 2.13448718284602,
  227. 2.14508363404789,
  228. 2.15581781987674,
  229. 2.16669518035431,
  230. 2.17772146774029,
  231. 2.18890277162636,
  232. 2.20024554661128,
  233. 2.21175664288416,
  234. 2.22344334009251,
  235. 2.23531338492992,
  236. 2.24737503294739,
  237. 2.25963709517379,
  238. 2.27210899022838,
  239. 2.28480080272449,
  240. 2.29772334890286,
  241. 2.31088825060137,
  242. 2.32430801887113,
  243. 2.33799614879653,
  244. 2.35196722737914,
  245. 2.36623705671729,
  246. 2.38082279517208,
  247. 2.39574311978193,
  248. 2.41101841390112,
  249. 2.42667098493715,
  250. 2.44272531820036,
  251. 2.4592083743347,
  252. 2.47614993967052,
  253. 2.49358304127105,
  254. 2.51154444162669,
  255. 2.53007523215985,
  256. 2.54922155032478,
  257. 2.56903545268184,
  258. 2.58957598670829,
  259. 2.61091051848882,
  260. 2.63311639363158,
  261. 2.65628303757674,
  262. 2.68051464328574,
  263. 2.70593365612306,
  264. 2.73268535904401,
  265. 2.76094400527999,
  266. 2.79092117400193,
  267. 2.82287739682644,
  268. 2.85713873087322,
  269. 2.89412105361341,
  270. 2.93436686720889,
  271. 2.97860327988184,
  272. 3.02783779176959,
  273. 3.08352613200214,
  274. 3.147889289518,
  275. 3.2245750520478,
  276. 3.32024473383983,
  277. 3.44927829856143,
  278. 3.65415288536101,
  279. 3.91075795952492};
  280. static const double dv1[257]{1.0,
  281. 0.977101701267673,
  282. 0.959879091800108,
  283. 0.9451989534423,
  284. 0.932060075959231,
  285. 0.919991505039348,
  286. 0.908726440052131,
  287. 0.898095921898344,
  288. 0.887984660755834,
  289. 0.878309655808918,
  290. 0.869008688036857,
  291. 0.860033621196332,
  292. 0.851346258458678,
  293. 0.842915653112205,
  294. 0.834716292986884,
  295. 0.826726833946222,
  296. 0.818929191603703,
  297. 0.811307874312656,
  298. 0.803849483170964,
  299. 0.796542330422959,
  300. 0.789376143566025,
  301. 0.782341832654803,
  302. 0.775431304981187,
  303. 0.768637315798486,
  304. 0.761953346836795,
  305. 0.755373506507096,
  306. 0.748892447219157,
  307. 0.742505296340151,
  308. 0.736207598126863,
  309. 0.729995264561476,
  310. 0.72386453346863,
  311. 0.717811932630722,
  312. 0.711834248878248,
  313. 0.705928501332754,
  314. 0.700091918136512,
  315. 0.694321916126117,
  316. 0.688616083004672,
  317. 0.682972161644995,
  318. 0.677388036218774,
  319. 0.671861719897082,
  320. 0.66639134390875,
  321. 0.660975147776663,
  322. 0.655611470579697,
  323. 0.650298743110817,
  324. 0.645035480820822,
  325. 0.639820277453057,
  326. 0.634651799287624,
  327. 0.629528779924837,
  328. 0.624450015547027,
  329. 0.619414360605834,
  330. 0.614420723888914,
  331. 0.609468064925773,
  332. 0.604555390697468,
  333. 0.599681752619125,
  334. 0.594846243767987,
  335. 0.590047996332826,
  336. 0.585286179263371,
  337. 0.580559996100791,
  338. 0.575868682972354,
  339. 0.571211506735253,
  340. 0.566587763256165,
  341. 0.561996775814525,
  342. 0.557437893618766,
  343. 0.552910490425833,
  344. 0.548413963255266,
  345. 0.543947731190026,
  346. 0.539511234256952,
  347. 0.535103932380458,
  348. 0.530725304403662,
  349. 0.526374847171684,
  350. 0.522052074672322,
  351. 0.517756517229756,
  352. 0.513487720747327,
  353. 0.509245245995748,
  354. 0.505028667943468,
  355. 0.500837575126149,
  356. 0.49667156905249,
  357. 0.492530263643869,
  358. 0.488413284705458,
  359. 0.484320269426683,
  360. 0.480250865909047,
  361. 0.476204732719506,
  362. 0.47218153846773,
  363. 0.468180961405694,
  364. 0.464202689048174,
  365. 0.460246417812843,
  366. 0.456311852678716,
  367. 0.452398706861849,
  368. 0.448506701507203,
  369. 0.444635565395739,
  370. 0.440785034665804,
  371. 0.436954852547985,
  372. 0.433144769112652,
  373. 0.429354541029442,
  374. 0.425583931338022,
  375. 0.421832709229496,
  376. 0.418100649837848,
  377. 0.414387534040891,
  378. 0.410693148270188,
  379. 0.407017284329473,
  380. 0.403359739221114,
  381. 0.399720314980197,
  382. 0.396098818515832,
  383. 0.392495061459315,
  384. 0.388908860018789,
  385. 0.385340034840077,
  386. 0.381788410873393,
  387. 0.378253817245619,
  388. 0.374736087137891,
  389. 0.371235057668239,
  390. 0.367750569779032,
  391. 0.364282468129004,
  392. 0.360830600989648,
  393. 0.357394820145781,
  394. 0.353974980800077,
  395. 0.350570941481406,
  396. 0.347182563956794,
  397. 0.343809713146851,
  398. 0.340452257044522,
  399. 0.337110066637006,
  400. 0.333783015830718,
  401. 0.330470981379163,
  402. 0.327173842813601,
  403. 0.323891482376391,
  404. 0.320623784956905,
  405. 0.317370638029914,
  406. 0.314131931596337,
  407. 0.310907558126286,
  408. 0.307697412504292,
  409. 0.30450139197665,
  410. 0.301319396100803,
  411. 0.298151326696685,
  412. 0.294997087799962,
  413. 0.291856585617095,
  414. 0.288729728482183,
  415. 0.285616426815502,
  416. 0.282516593083708,
  417. 0.279430141761638,
  418. 0.276356989295668,
  419. 0.273297054068577,
  420. 0.270250256365875,
  421. 0.267216518343561,
  422. 0.264195763997261,
  423. 0.261187919132721,
  424. 0.258192911337619,
  425. 0.255210669954662,
  426. 0.252241126055942,
  427. 0.249284212418529,
  428. 0.246339863501264,
  429. 0.24340801542275,
  430. 0.240488605940501,
  431. 0.237581574431238,
  432. 0.23468686187233,
  433. 0.231804410824339,
  434. 0.228934165414681,
  435. 0.226076071322381,
  436. 0.223230075763918,
  437. 0.220396127480152,
  438. 0.217574176724331,
  439. 0.214764175251174,
  440. 0.211966076307031,
  441. 0.209179834621125,
  442. 0.206405406397881,
  443. 0.203642749310335,
  444. 0.200891822494657,
  445. 0.198152586545776,
  446. 0.195425003514135,
  447. 0.192709036903589,
  448. 0.190004651670465,
  449. 0.187311814223801,
  450. 0.1846304924268,
  451. 0.181960655599523,
  452. 0.179302274522848,
  453. 0.176655321443735,
  454. 0.174019770081839,
  455. 0.171395595637506,
  456. 0.168782774801212,
  457. 0.166181285764482,
  458. 0.163591108232366,
  459. 0.161012223437511,
  460. 0.158444614155925,
  461. 0.15588826472448,
  462. 0.153343161060263,
  463. 0.150809290681846,
  464. 0.148286642732575,
  465. 0.145775208005994,
  466. 0.143274978973514,
  467. 0.140785949814445,
  468. 0.138308116448551,
  469. 0.135841476571254,
  470. 0.133386029691669,
  471. 0.130941777173644,
  472. 0.12850872228,
  473. 0.126086870220186,
  474. 0.123676228201597,
  475. 0.12127680548479,
  476. 0.11888861344291,
  477. 0.116511665625611,
  478. 0.114145977827839,
  479. 0.111791568163838,
  480. 0.109448457146812,
  481. 0.107116667774684,
  482. 0.104796225622487,
  483. 0.102487158941935,
  484. 0.10018949876881,
  485. 0.0979032790388625,
  486. 0.095628536713009,
  487. 0.093365311912691,
  488. 0.0911136480663738,
  489. 0.0888735920682759,
  490. 0.0866451944505581,
  491. 0.0844285095703535,
  492. 0.082223595813203,
  493. 0.0800305158146631,
  494. 0.0778493367020961,
  495. 0.0756801303589272,
  496. 0.0735229737139814,
  497. 0.0713779490588905,
  498. 0.0692451443970068,
  499. 0.0671246538277886,
  500. 0.065016577971243,
  501. 0.0629210244377582,
  502. 0.06083810834954,
  503. 0.0587679529209339,
  504. 0.0567106901062031,
  505. 0.0546664613248891,
  506. 0.0526354182767924,
  507. 0.0506177238609479,
  508. 0.0486135532158687,
  509. 0.0466230949019305,
  510. 0.0446465522512946,
  511. 0.0426841449164746,
  512. 0.0407361106559411,
  513. 0.0388027074045262,
  514. 0.0368842156885674,
  515. 0.0349809414617162,
  516. 0.0330932194585786,
  517. 0.0312214171919203,
  518. 0.0293659397581334,
  519. 0.0275272356696031,
  520. 0.0257058040085489,
  521. 0.0239022033057959,
  522. 0.0221170627073089,
  523. 0.0203510962300445,
  524. 0.0186051212757247,
  525. 0.0168800831525432,
  526. 0.0151770883079353,
  527. 0.0134974506017399,
  528. 0.0118427578579079,
  529. 0.0102149714397015,
  530. 0.00861658276939875,
  531. 0.00705087547137324,
  532. 0.00552240329925101,
  533. 0.00403797259336304,
  534. 0.00260907274610216,
  535. 0.0012602859304986,
  536. 0.000477467764609386};
  537. unsigned int u[2];
  538. int i;
  539. i = static_cast<int>(varargin_1[1]);
  540. r.set_size(1, i);
  541. for (int k{0}; k < i; k++) {
  542. double b_r;
  543. int b_i;
  544. int exitg1;
  545. do {
  546. exitg1 = 0;
  547. genrand_uint32_vector(state_8_2, u);
  548. b_i = static_cast<int>((u[1] >> 24U) + 1U);
  549. b_r = ((static_cast<double>(u[0] >> 3U) * 1.6777216E+7 +
  550. static_cast<double>(static_cast<int>(u[1]) & 16777215)) *
  551. 2.2204460492503131E-16 -
  552. 1.0) *
  553. dv[b_i];
  554. if (std::abs(b_r) <= dv[b_i - 1]) {
  555. exitg1 = 1;
  556. } else if (b_i < 256) {
  557. double b_u;
  558. // ========================= COPYRIGHT NOTICE
  559. // ============================
  560. // This is a uniform (0,1) pseudorandom number generator based on:
  561. //
  562. // A C-program for MT19937, with initialization improved 2002/1/26.
  563. // Coded by Takuji Nishimura and Makoto Matsumoto.
  564. //
  565. // Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
  566. // All rights reserved.
  567. //
  568. // Redistribution and use in source and binary forms, with or without
  569. // modification, are permitted provided that the following conditions
  570. // are met:
  571. //
  572. // 1. Redistributions of source code must retain the above copyright
  573. // notice, this list of conditions and the following disclaimer.
  574. //
  575. // 2. Redistributions in binary form must reproduce the above
  576. // copyright
  577. // notice, this list of conditions and the following disclaimer
  578. // in the documentation and/or other materials provided with the
  579. // distribution.
  580. //
  581. // 3. The names of its contributors may not be used to endorse or
  582. // promote products derived from this software without specific
  583. // prior written permission.
  584. //
  585. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  586. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  587. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  588. // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  589. // COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  590. // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  591. // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  592. // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  593. // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  594. // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  595. // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  596. // POSSIBILITY OF SUCH DAMAGE.
  597. //
  598. // ============================= END =================================
  599. do {
  600. genrand_uint32_vector(state_8_2, u);
  601. u[0] >>= 5U;
  602. u[1] >>= 6U;
  603. b_u = 1.1102230246251565E-16 *
  604. (static_cast<double>(u[0]) * 6.7108864E+7 +
  605. static_cast<double>(u[1]));
  606. } while (b_u == 0.0);
  607. if (dv1[b_i] + b_u * (dv1[b_i - 1] - dv1[b_i]) <
  608. std::exp(-0.5 * b_r * b_r)) {
  609. exitg1 = 1;
  610. }
  611. } else {
  612. double b_u;
  613. double x;
  614. do {
  615. // ========================= COPYRIGHT NOTICE
  616. // ============================
  617. // This is a uniform (0,1) pseudorandom number generator based on:
  618. //
  619. // A C-program for MT19937, with initialization improved 2002/1/26.
  620. // Coded by Takuji Nishimura and Makoto Matsumoto.
  621. //
  622. // Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
  623. // All rights reserved.
  624. //
  625. // Redistribution and use in source and binary forms, with or without
  626. // modification, are permitted provided that the following conditions
  627. // are met:
  628. //
  629. // 1. Redistributions of source code must retain the above
  630. // copyright
  631. // notice, this list of conditions and the following disclaimer.
  632. //
  633. // 2. Redistributions in binary form must reproduce the above
  634. // copyright
  635. // notice, this list of conditions and the following disclaimer
  636. // in the documentation and/or other materials provided with the
  637. // distribution.
  638. //
  639. // 3. The names of its contributors may not be used to endorse or
  640. // promote products derived from this software without specific
  641. // prior written permission.
  642. //
  643. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  644. // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  645. // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  646. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  647. // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  648. // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  649. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  650. // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  651. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  652. // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  653. // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  654. // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  655. // OF SUCH DAMAGE.
  656. //
  657. // ============================= END
  658. // =================================
  659. do {
  660. genrand_uint32_vector(state_8_2, u);
  661. u[0] >>= 5U;
  662. u[1] >>= 6U;
  663. b_u = 1.1102230246251565E-16 *
  664. (static_cast<double>(u[0]) * 6.7108864E+7 +
  665. static_cast<double>(u[1]));
  666. } while (b_u == 0.0);
  667. x = std::log(b_u) * 0.273661237329758;
  668. // ========================= COPYRIGHT NOTICE
  669. // ============================
  670. // This is a uniform (0,1) pseudorandom number generator based on:
  671. //
  672. // A C-program for MT19937, with initialization improved 2002/1/26.
  673. // Coded by Takuji Nishimura and Makoto Matsumoto.
  674. //
  675. // Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
  676. // All rights reserved.
  677. //
  678. // Redistribution and use in source and binary forms, with or without
  679. // modification, are permitted provided that the following conditions
  680. // are met:
  681. //
  682. // 1. Redistributions of source code must retain the above
  683. // copyright
  684. // notice, this list of conditions and the following disclaimer.
  685. //
  686. // 2. Redistributions in binary form must reproduce the above
  687. // copyright
  688. // notice, this list of conditions and the following disclaimer
  689. // in the documentation and/or other materials provided with the
  690. // distribution.
  691. //
  692. // 3. The names of its contributors may not be used to endorse or
  693. // promote products derived from this software without specific
  694. // prior written permission.
  695. //
  696. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  697. // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  698. // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  699. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  700. // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  701. // BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  702. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  703. // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  704. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  705. // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  706. // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  707. // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  708. // OF SUCH DAMAGE.
  709. //
  710. // ============================= END
  711. // =================================
  712. do {
  713. genrand_uint32_vector(state_8_2, u);
  714. u[0] >>= 5U;
  715. u[1] >>= 6U;
  716. b_u = 1.1102230246251565E-16 *
  717. (static_cast<double>(u[0]) * 6.7108864E+7 +
  718. static_cast<double>(u[1]));
  719. } while (b_u == 0.0);
  720. } while (!(-2.0 * std::log(b_u) > x * x));
  721. if (b_r < 0.0) {
  722. b_r = x - 3.65415288536101;
  723. } else {
  724. b_r = 3.65415288536101 - x;
  725. }
  726. exitg1 = 1;
  727. }
  728. } while (exitg1 == 0);
  729. r[k] = b_r;
  730. }
  731. }
  732. } // namespace coder
  733. //
  734. // File trailer for randn_8_2.cpp
  735. //
  736. // [EOF]
  737. //