All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Lib.Krakatau.ssa.ssa_ops.bitwise_util.py Maven / Gradle / Ivy

There is a newer version: 1.1
Show newest version
from ..constraints import IntConstraint
import itertools, operator

def split_pow2ranges(x,y):
    '''split given range into power of two ranges of form [x, x+2^k)'''
    out = []
    while x<=y:
        #The largest power of two range of the form x,k 
        #has k min of number of zeros at end of x
        #and the largest power of two that fits in y-x
        bx = bin(x)
        numzeroes = float('inf') if x==0 else (len(bx)-bx.rindex('1')-1) 
        k = min(numzeroes, (y-x+1).bit_length()-1)
        out.append((x,k))
        x += 1< k2:
            (s1,k1),(s2,k2) = (s2,k2),(s1,k1)

        mask1 = (1<




© 2015 - 2025 Weber Informatics LLC | Privacy Policy