z3-z3-4.13.0.src.util.luby.cpp Maven / Gradle / Ivy
The newest version!
/*++
Copyright (c) 2006 Microsoft Corporation
Module Name:
luby.cpp
Abstract:
Author:
Leonardo de Moura (leonardo) 2008-03-04.
Revision History:
--*/
#include
unsigned get_luby(unsigned i) {
if (i == 1)
return 1;
double k = log(static_cast(i+1))/log(static_cast(2));
if (k == floor(k + 0.5))
return static_cast(pow(2,k-1));
else {
k = static_cast(floor(k));
return get_luby(i - static_cast(pow(2, k)) + 1);
}
}