-- FreeFem++ v4.14 (mer. 06 mars 2024 16:59:04 CET - git v4.14-1-g2b2052ae) file : random_test.edp Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // random_test.edp 2 : // 3 : // Discussion: 4 : // 5 : // This example calls the FreeFem++ random number generators. 6 : // 7 : // Licensing: 8 : // 9 : // This code is distributed under the MIT license. 10 : // 11 : // Modified: 12 : // 13 : // 19 June 2015 14 : // 15 : // Author: 16 : // 17 : // John Burkardt 18 : // 19 : // Reference: 20 : // 21 : // Frederic Hecht, 22 : // Freefem++, 23 : // Third Edition, version 3.22 24 : // 25 : cout << "\n"; 26 : cout << "random_test():\n"; 27 : cout << " FreeFem++ version\n"; 28 : cout << " Demonstrate random number generators.\n"; 29 : // 30 : // Use a seed to initialize the random number generator before each call. 31 : // 32 : int seed = 123456789; 33 : // 34 : // 32 bit integers. 35 : // 36 : cout << "\n"; 37 : cout << "randint32() returns 32 bit integers.\n"; 38 : cout << "\n"; 39 : int value1; 40 : randinit ( seed ); 41 : for ( int i = 1; i <= 10; i++ ) 42 : { 43 : value1 = randint32 ( ); 44 : cout << " " << i << " " << value1 << "\n"; 45 : } 46 : // 47 : // 31 bit integers. 48 : // 49 : cout << "\n"; 50 : cout << "randint31() returns 31 bit integers.\n"; 51 : cout << "\n"; 52 : int value2; 53 : randinit ( seed ); 54 : for ( int i = 1; i <= 10; i++ ) 55 : { 56 : value2 = randint31 ( ); 57 : cout << " " << i << " " << value2 << "\n"; 58 : } 59 : // 60 : // 32 bit reals. 61 : // 62 : cout << "\n"; 63 : cout << "randreal1() returns 32 bit reals.\n"; 64 : cout << "\n"; 65 : real value3; 66 : randinit ( seed ); 67 : for ( int i = 1; i <= 10; i++ ) 68 : { 69 : value3 = randreal1 ( ); 70 : cout << " " << i << " " << value3 << "\n"; 71 : } 72 : // 73 : // 32 bit reals. 74 : // 75 : cout << "\n"; 76 : cout << "randreal2() returns 32 bit reals.\n"; 77 : cout << "\n"; 78 : real value4; 79 : randinit ( seed ); 80 : for ( int i = 1; i <= 10; i++ ) 81 : { 82 : value4 = randreal2 ( ); 83 : cout << " " << i << " " << value4 << "\n"; 84 : } 85 : // 86 : // 32 bit reals. 87 : // 88 : cout << "\n"; 89 : cout << "randreal3() returns 32 bit reals.\n"; 90 : cout << "\n"; 91 : real value5; 92 : randinit ( seed ); 93 : for ( int i = 1; i <= 10; i++ ) 94 : { 95 : value5 = randreal3 ( ); 96 : cout << " " << i << " " << value5 << "\n"; 97 : } 98 : // 99 : // 53 bit reals. 100 : // 101 : cout << "\n"; 102 : cout << "randres53() returns 53 bit reals.\n"; 103 : cout << "\n"; 104 : real value6; 105 : randinit ( seed ); 106 : for ( int i = 1; i <= 10; i++ ) 107 : { 108 : value6 = randres53 ( ); 109 : cout << " " << i << " " << value6 << "\n"; 110 : } 111 : // 112 : // Terminate. 113 : // 114 : cout << "\n"; 115 : cout << "random_test():\n"; 116 : cout << " Normal end of execution.\n"; 117 : 118 : exit ( 0 ); 119 : sizestack + 1024 =1176 ( 152 ) random_test(): FreeFem++ version Demonstrate random number generators. randint32() returns 32 bit integers. 1 2288500408 2 4254805660 3 2294099250 4 56498137 5 2188513626 6 3108979485 7 3064734188 8 580305671 9 1103802106 10 3461125348 randint31() returns 31 bit integers. 1 1144250204 2 2127402830 3 1147049625 4 28249068 5 1094256813 6 1554489742 7 1532367094 8 290152835 9 551901053 10 1730562674 randreal1() returns 32 bit reals. 1 0.532833 2 0.990649 3 0.534137 4 0.0131545 5 0.509553 6 0.723866 7 0.713564 8 0.135113 9 0.256999 10 0.805856 randreal2() returns 32 bit reals. 1 0.532833 2 0.990649 3 0.534137 4 0.0131545 5 0.509553 6 0.723866 7 0.713564 8 0.135113 9 0.256999 10 0.805856 randreal3() returns 32 bit reals. 1 0.532833 2 0.990649 3 0.534137 4 0.0131545 5 0.509553 6 0.723866 7 0.713564 8 0.135113 9 0.256999 10 0.805856 randres53() returns 53 bit reals. 1 0.532833 2 0.534137 3 0.509553 4 0.713564 5 0.256999 6 0.752694 7 0.883879 8 0.154899 9 0.670546 10 0.643445 random_test(): Normal end of execution. current line = 118 exit(0) err code 0 , mpirank 0 CodeAlloc : nb ptr 4042, size :520856 mpirank: 0 Ok: Normal End