void speed() { xsadd_t xsa; xsadd_init(&xsa, 1234); clock_t start = clock(); uint32_t sum = 0; for (int i = 0; i < 100000000; i++) { sum ^= xsadd_uint32(&xsa); } double ell = clock() - start; printf("consumed time for generating 10^8 numbers = %.2fms\n", (ell / CLOCKS_PER_SEC) * 1000); }
int main(int argc, char * argv[]) { uint32_t seed = (uint32_t)clock(); xsadd_init(&xsadd, seed); // これを忘れてはならない numpl_array array; int r = 0; #if defined(DEBUG) printf("start digging_hole\n"); #endif do { r = prepare_array(&array); } while (r != 1); #if defined(DEBUG) printf("after prepare_array r = %d\n", r); output_detail(&array); #endif numpl_array save = array; do { array = save; r = digging_hole(&array, 1); } while (r != 1); #if defined(DEBUG) printf("after digging_hole r = %d\n", r); output_detail(&array); #endif fixed_only(&array, FULL_SYMBOL); save = array; solve_info info; r = digging_hole_recursion(&array, 0, &info, 1); if (r <= 0) { array = save; } #if defined(DEBUG) printf("after digging_hole_recursion r = %d\n", r); output_detail(&array); #endif r = solve(&array, &info); print_solve_info(&info, 1); if (r == 1) { fixed_only(&array, 0); output_detail(&array); } else { printf("failure\n"); output_detail(&array); return -1; } return 0; }
void print_output() { xsadd_t xsa; xsadd_init(&xsa, 1234); printf("xsadd_init(&xsa, 1234);\n"); printf("xsadd_uint32\n"); for (int i = 0; i < 10; i++) { for (int j = 0; j < 4; j++) { printf("%10u ", xsadd_uint32(&xsa)); } printf ("\n"); } printf("xsadd_float\n"); for (int i = 0; i < 10; i++) { for (int j = 0; j < 4; j++) { printf("%.8f ", xsadd_float(&xsa)); } printf ("\n"); } printf("xsadd_floatOC\n"); for (int i = 0; i < 10; i++) { for (int j = 0; j < 4; j++) { printf("%.8f ", xsadd_floatOC(&xsa)); } printf ("\n"); } uint32_t seed[4] = {0x0a, 0x0b, 0x0c, 0x0d}; xsadd_init_by_array(&xsa, seed, 4); printf("\nuint32_t seed[4] = {0x0a, 0x0b, 0x0c, 0x0d};\n"); printf("xsadd_init_by_array(&xsa, seed, 4);\n"); printf("xsadd_uint32\n"); for (int i = 0; i < 10; i++) { for (int j = 0; j < 4; j++) { printf("%08" PRIx32 " ", xsadd_uint32(&xsa)); } printf ("\n"); } printf("xsadd_double\n"); for (int i = 0; i < 10; i++) { for (int j = 0; j < 4; j++) { printf("%.15f ", xsadd_double(&xsa)); } printf ("\n"); } }