]> www.ginac.de Git - ginac.git/blob - check/randomize_serials.cpp
Bug fix related to the usage of int instead of cl_I.
[ginac.git] / check / randomize_serials.cpp
1 #include <cstdlib>
2 #include <ctime>
3 #include "ginac.h"
4 using namespace std;
5 using namespace GiNaC;
6
7 /** Generate a random amount of symbols and destroy them again immediatly.
8  *  This operation effectively makes the serial numbers of all subsequent
9  *  symbols unpredictable.  If the serials are unpredictable, then so are
10  *  their hash values.  If the hash values are unpredictable, then so are
11  *  the canonical orderings.  If the canonical orderings are unpredictable,
12  *  all subsequent times are subject to some variation.  This variation,
13  *  however is natural and desireable for two reasons: First, we cannot know
14  *  how many symbols have been generated before in real world computations.
15  *  Second, the following timings are subject to some semi-random variation
16  *  anyways because short timings need to be repeated until enough time has
17  *  gone by for the measurement to be reliable.  During this process the serial
18  *  numbers will be shifted anyways in a semi-random way.  It is better not
19  *  to lull the user in a false sense of reproducibility and instead confront
20  *  her with the normal variation to be expected.
21  */
22 void randomify_symbol_serials()
23 {
24         srand(time(NULL));
25         const int m = rand() % 666;
26         for (int s=0; s<m; ++s ) {
27                 symbol("dummy");
28         }
29 }
30
31