Page 242 - ARM 64 Bit Assembly Language
P. 242
230 Chapter 7
61 // Run tests
62 total += test_negate(N, a, neg);
63 total += test_cmp(N, a, b, comp);
64 total += test(N, "Add", a, b, bigint_add, add);
65 total += test(N, "Sub", a, b, bigint_sub, sub);
66 total += test(N, "Mul", a, b, bigint_mul, mul);
67 total += test_division(N, a, b, div);
68 total += test_sqrt(N, a, sqrt);
69
70 // Total time
71 printf("Total time :\t %lf\n",(total)/(double)CLOCKS_PER_SEC);
72
73 // Free
74 for(int i = 0;i<N;i++) {
75 bigint_free(a[i]);
76 bigint_free(b[i]);
77 bigint_free(add[i]);
78 bigint_free(sub[i]);
79 bigint_free(mul[i]);
80 bigint_free(sqrt[i]);
81 bigint_free(div[i]);
82 bigint_free(neg[i]);
83 }
84
85 return 0;
86 }
87
88 void matherr(bigint in1, bigint in2, bigint exp, bigint out, char *msg) {
89 char *input1, *input2, *expected, *actual;
90 input1 = bigint_to_str(in1);
91 input2 = bigint_to_str(in2);
92 expected = bigint_to_str(exp);
93 actual = bigint_to_str(out);
94 printf("Error in %s:\ninputs:\n%s\n%s\n", msg, input1, input2);
95 printf("correct output: %s\n", expected);
96 printf("output: %s\n", actual);
97 exit(4);
98 }
99
100 void sqrterr(bigint in, bigint exp, bigint out, char *msg) {
101 char *input, *expected, *actual;
102 input = bigint_to_str(in);
103 expected = bigint_to_str(exp);
104 actual = bigint_to_str(out);
105 printf("Error in %s:\ninput: %s\n", msg, input);
106 printf("correct output: %s\n", expected);
107 printf("output: %s\n", actual);
108 exit(4);
109 }