mirror of
https://github.com/Z3Prover/z3
synced 2025-04-25 10:05:32 +00:00
Z3 sources
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
3f9edad676
commit
e9eab22e5c
1186 changed files with 381859 additions and 0 deletions
33
lib/luby.cpp
Normal file
33
lib/luby.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*++
|
||||
Copyright (c) 2006 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
luby.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
<abstract>
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo de Moura (leonardo) 2008-03-04.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#include<cmath>
|
||||
|
||||
unsigned get_luby(unsigned i) {
|
||||
if (i == 1)
|
||||
return 1;
|
||||
double k = log(static_cast<double>(i+1))/log(static_cast<double>(2));
|
||||
|
||||
if (k == floor(k + 0.5))
|
||||
return static_cast<unsigned>(pow(2,k-1));
|
||||
else {
|
||||
k = static_cast<unsigned>(floor(k));
|
||||
return get_luby(i - static_cast<unsigned>(pow(2, k)) + 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue