-- FreeFem++ v4.6 (Thu Apr 2 15:47:38 CEST 2020 - git v4.6) Load: lg_fem lg_mesh lg_mesh3 eigenvalue 1 : // Discussion: 2 : // 3 : // This example calls the FreeFem++ random number generators. 4 : // 5 : // Location: 6 : // 7 : // http://people.sc.fsu.edu/~jburkardt/freefem_src/random_test/random_test.edp 8 : // 9 : // Licensing: 10 : // 11 : // This code is distributed under the GNU LGPL license. 12 : // 13 : // Modified: 14 : // 15 : // 19 June 2015 16 : // 17 : // Author: 18 : // 19 : // John Burkardt 20 : // 21 : // Reference: 22 : // 23 : // Frederic Hecht, 24 : // Freefem++, 25 : // Third Edition, version 3.22 26 : // 27 : cout << "\n"; 28 : cout << "random_test\n"; 29 : cout << " FreeFem++ version\n"; 30 : cout << " Demonstrate random number generators.\n"; 31 : // 32 : // Use a seed to initialize the random number generator before each call. 33 : // 34 : int seed = 123456789; 35 : // 36 : // 32 bit integers. 37 : // 38 : cout << "\n"; 39 : cout << "randint32() returns 32 bit integers.\n"; 40 : cout << "\n"; 41 : int value1; 42 : randinit ( seed ); 43 : for ( int i = 1; i <= 10; i++ ) 44 : { 45 : value1 = randint32 ( ); 46 : cout << " " << i << " " << value1 << "\n"; 47 : } 48 : // 49 : // 31 bit integers. 50 : // 51 : cout << "\n"; 52 : cout << "randint31() returns 31 bit integers.\n"; 53 : cout << "\n"; 54 : int value2; 55 : randinit ( seed ); 56 : for ( int i = 1; i <= 10; i++ ) 57 : { 58 : value2 = randint31 ( ); 59 : cout << " " << i << " " << value2 << "\n"; 60 : } 61 : // 62 : // 32 bit reals. 63 : // 64 : cout << "\n"; 65 : cout << "randreal1() returns 32 bit reals.\n"; 66 : cout << "\n"; 67 : real value3; 68 : randinit ( seed ); 69 : for ( int i = 1; i <= 10; i++ ) 70 : { 71 : value3 = randreal1 ( ); 72 : cout << " " << i << " " << value3 << "\n"; 73 : } 74 : // 75 : // 32 bit reals. 76 : // 77 : cout << "\n"; 78 : cout << "randreal2() returns 32 bit reals.\n"; 79 : cout << "\n"; 80 : real value4; 81 : randinit ( seed ); 82 : for ( int i = 1; i <= 10; i++ ) 83 : { 84 : value4 = randreal2 ( ); 85 : cout << " " << i << " " << value4 << "\n"; 86 : } 87 : // 88 : // 32 bit reals. 89 : // 90 : cout << "\n"; 91 : cout << "randreal3() returns 32 bit reals.\n"; 92 : cout << "\n"; 93 : real value5; 94 : randinit ( seed ); 95 : for ( int i = 1; i <= 10; i++ ) 96 : { 97 : value5 = randreal3 ( ); 98 : cout << " " << i << " " << value5 << "\n"; 99 : } 100 : // 101 : // 53 bit reals. 102 : // 103 : cout << "\n"; 104 : cout << "randres53() returns 53 bit reals.\n"; 105 : cout << "\n"; 106 : real value6; 107 : randinit ( seed ); 108 : for ( int i = 1; i <= 10; i++ ) 109 : { 110 : value6 = randres53 ( ); 111 : cout << " " << i << " " << value6 << "\n"; 112 : } 113 : // 114 : // Terminate. 115 : // 116 : cout << "\n"; 117 : cout << "random_test:\n"; 118 : cout << " Normal end of execution.\n"; 119 : 120 : 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. times: compile 0.004801s, execution 0.000371s, mpirank:0 CodeAlloc : nb ptr 3670, size :472936 mpirank: 0 Ok: Normal End