]> www.ginac.de Git - cln.git/blob - tests/timerecip2adic-compare.cc
* */*: Removed problematic stdin, stdout and stderr definitions.
[cln.git] / tests / timerecip2adic-compare.cc
1 #include <cln/number.h>
2 #include <cln/io.h>
3 #include <cln/integer.h>
4 #include "cl_DS.h"
5 #include "cl_2DS.h"
6 #include <cln/random.h>
7 #include "cl_random_impl.h"
8 #include <cln/abort.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <cln/timing.h>
12
13 int main (int argc, char * argv[])
14 {
15         int repetitions = 1;
16         if ((argc >= 3) && !strcmp(argv[1],"-r")) {
17                 repetitions = atoi(argv[2]);
18                 argc -= 2; argv += 2;
19         }
20         if (argc < 3)
21                 exit(1);
22         uintL len = atoi(argv[1]);
23         int threshold = atoi(argv[2]);
24         SAVE_NUM_STACK;
25         uintD* a_MSDptr;
26         uintD* a_LSDptr;
27         uintD* b_MSDptr;
28         uintD* b_LSDptr;
29         uintD* bn_MSDptr;
30         uintD* bn_LSDptr;
31         num_stack_alloc(len,a_MSDptr=,a_LSDptr=);
32         num_stack_alloc(len,b_MSDptr=,b_LSDptr=);
33         num_stack_alloc(len,bn_MSDptr=,bn_LSDptr=);
34         random_UDS(default_random_state,a_MSDptr,len);
35         lspref(a_LSDptr,0) |= 1; // force a to be odd
36         extern int recip2adic_threshold;
37         // Check.
38         recip2adic_threshold = 1000000;
39         recip2adic(len,a_LSDptr,b_LSDptr);
40         recip2adic_threshold = threshold;
41         recip2adic(len,a_LSDptr,bn_LSDptr);
42         if (compare_loop_msp(b_MSDptr,bn_MSDptr,len)) cl_abort();
43         // Time.
44         recip2adic_threshold = 1000000;
45         { CL_TIMING;
46           for (int rep = repetitions; rep > 0; rep--)
47             { recip2adic(len,a_LSDptr,b_LSDptr); }
48         }
49         recip2adic_threshold = threshold;
50         { CL_TIMING;
51           for (int rep = repetitions; rep > 0; rep--)
52             { recip2adic(len,a_LSDptr,b_LSDptr); }
53         }
54 }