// Discussion: // // This example calls the FreeFem++ random number generators. // // Location: // // http://people.sc.fsu.edu/~jburkardt/freefem_src/random_test/random_test.edp // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 19 June 2015 // // Author: // // John Burkardt // // Reference: // // Frederic Hecht, // Freefem++, // Third Edition, version 3.22 // cout << "\n"; cout << "random_test\n"; cout << " FreeFem++ version\n"; cout << " Demonstrate random number generators.\n"; // // Use a seed to initialize the random number generator before each call. // int seed = 123456789; // // 32 bit integers. // cout << "\n"; cout << "randint32() returns 32 bit integers.\n"; cout << "\n"; int value1; randinit ( seed ); for ( int i = 1; i <= 10; i++ ) { value1 = randint32 ( ); cout << " " << i << " " << value1 << "\n"; } // // 31 bit integers. // cout << "\n"; cout << "randint31() returns 31 bit integers.\n"; cout << "\n"; int value2; randinit ( seed ); for ( int i = 1; i <= 10; i++ ) { value2 = randint31 ( ); cout << " " << i << " " << value2 << "\n"; } // // 32 bit reals. // cout << "\n"; cout << "randreal1() returns 32 bit reals.\n"; cout << "\n"; real value3; randinit ( seed ); for ( int i = 1; i <= 10; i++ ) { value3 = randreal1 ( ); cout << " " << i << " " << value3 << "\n"; } // // 32 bit reals. // cout << "\n"; cout << "randreal2() returns 32 bit reals.\n"; cout << "\n"; real value4; randinit ( seed ); for ( int i = 1; i <= 10; i++ ) { value4 = randreal2 ( ); cout << " " << i << " " << value4 << "\n"; } // // 32 bit reals. // cout << "\n"; cout << "randreal3() returns 32 bit reals.\n"; cout << "\n"; real value5; randinit ( seed ); for ( int i = 1; i <= 10; i++ ) { value5 = randreal3 ( ); cout << " " << i << " " << value5 << "\n"; } // // 53 bit reals. // cout << "\n"; cout << "randres53() returns 53 bit reals.\n"; cout << "\n"; real value6; randinit ( seed ); for ( int i = 1; i <= 10; i++ ) { value6 = randres53 ( ); cout << " " << i << " " << value6 << "\n"; } // // Terminate. // cout << "\n"; cout << "random_test:\n"; cout << " Normal end of execution.\n"; exit ( 0 );