4 #include "base/cl_sysdep.h"
7 #include "integer/cl_I.h"
14 // Table: For each base b (2 <= b <= 36), store k and b^k where k is the largest
15 // integer such that b^k < 2^intDsize, i.e. k == floor(log(2^intDsize-1,b)).
16 struct power_table_entry {
20 extern const power_table_entry power_table [36-2+1];
22 // Table: contains for each base b (2 <= b <= 36) either NULL or an array of
23 // lazily computed b^(k*2^i) and maybe 1/b^(k*2^i).
24 //#define MUL_REPLACES_DIV
25 struct cached_power_table_entry {
26 ALLOCATE_ANYWHERE(cached_power_table_entry)
27 cl_I base_pow; // 0 or b^(k*2^i)
28 #ifdef MUL_REPLACES_DIV
29 cl_I inv_base_pow; // if base_pow: floor(2^(2*integer_length(base_pow))/base_pow)
33 struct cached_power_table {
34 cached_power_table_entry element[40];
35 // Constructor and destructor - nothing special.
36 cached_power_table () {}
37 ~cached_power_table () {}
38 // Allocation and deallocation.
39 void* operator new (size_t size) { return malloc_hook(size); }
40 void operator delete (void* ptr) { free_hook(ptr); }
43 extern cached_power_table* ctable [36-2+1];
45 const cached_power_table_entry * cached_power (uintD base, uintL i);