import numpy as np

power = np.power(2, 10)

def uint16_to_ufloat16(uint16:int) -> float:
        """ Implementation of bespoke float type used in .e2e files.
        Notes:
            Custom float is a floating point type with no sign, 6-bit exponent, and 10-bit mantissa.
        """
        bits = '{0:016b}'.format(uint16)[::-1]
        # get mantissa and exponent
        mantissa = bits[:10]
        exponent = bits[10:]
        exponent = exponent[::-1]

        # convert to decimal representations
        mantissa_sum = 1 + int(mantissa, 2) / power
        exponent_sum = int(exponent, 2) - 63
        decimal_value = mantissa_sum * np.float_power(2, exponent_sum)
        return decimal_value
        
def get_lut() -> np.ndarray:
    LUT = []
    for i in range(0,pow(2,16)):
        LUT.append(uint16_to_ufloat16(i))
    return np.array(LUT)
