void primitive_root(int n, int* a) { /** * TERMINATE condition */ if (n <= 2) return; int p = find_closest_prime(n); int l = (p+1)/2; int r = (n+1)/2 - l; /** * Before shift: * |---l---| |--r--| |---l---| |--r--| * ^^^^^^^^^^^^^^^^^ * * After shift: * * |---l---| |---l---| |--r--| |--r--| * ^^^^^^^^^^^^^^^^^ */ shift_right(r+l, a+l, l); primitive_root_prime(l+l, a); primitive_root(r+r, a+l+l); }
/*---------------------------------------------------------------------*/ int hash_check_size(int size) { int ret = 0; /* TBB: for now ensure that we adjust to the */ /* same size no matter what hash function is used. */ ret = find_closest_prime(size); return ret; }