aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/MLRsearch/WidthArithmetics.py
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2021-07-12 19:52:26 +0200
committerMaciek Konstantynowicz <mkonstan@cisco.com>2021-07-12 18:18:37 +0000
commit52f109b0e14b5f192e2b7f0573e6cebb601d0651 (patch)
tree3e2bfa0d2a8c658d88693d7620786f4305612d55 /resources/libraries/python/MLRsearch/WidthArithmetics.py
parent8f9290d1594d35eb838c0c4c9d754b80a35e4a3a (diff)
IETF: Update MLRsearch draft
Change-Id: I591b76b72868697242cfbece8f569dc82128ed85 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python/MLRsearch/WidthArithmetics.py')
-rw-r--r--resources/libraries/python/MLRsearch/WidthArithmetics.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/resources/libraries/python/MLRsearch/WidthArithmetics.py b/resources/libraries/python/MLRsearch/WidthArithmetics.py
index 81decfd12f..21316c5441 100644
--- a/resources/libraries/python/MLRsearch/WidthArithmetics.py
+++ b/resources/libraries/python/MLRsearch/WidthArithmetics.py
@@ -54,10 +54,12 @@ def halve_relative_width(relative_width, goal_width):
fallback_width = 1.0 - math.sqrt(1.0 - relative_width)
# Wig means Width In Goals.
wig = math.log(1.0 - relative_width) / math.log(1.0 - goal_width)
- cwig = math.ceil(wig)
- if wig <= 2.0 or cwig != math.ceil(wig * ROUNDING_CONSTANT):
+ cwig = 2.0 * math.ceil(wig / 2.0)
+ fwig = 2.0 * math.ceil(wig * ROUNDING_CONSTANT / 2.0)
+ if wig <= 2.0 or cwig != fwig:
+ # Avoid too uneven splits.
return fallback_width
- coefficient = cwig // 2
+ coefficient = cwig / 2
new_width = multiply_relative_width(goal_width, coefficient)
return new_width