How to use the model from Python

#Make sure that cython extension is installed
#> pip install --user cython

# The source code of the mul16s_HF7 extension needs to be downloaded first
> curl -s "https://ehw.fit.vutbr.cz/evoapproxlib/v1.2022?folder=multiplers/16x16_signed/pareto_pwr_mae&file=mul16s_HF7.c&pyx=bash" | bash

#Finally, the extension can be used in a Python script as follows
> python
import pyximport; pyximport.install()
import mul16s_HF7

def u2s(v): # 32b unsigned to 32b signed
    if v & 2147483648:
	return v - 4294967296
    return v

wce = e = 0
for i in range(-2**15,2**15):
    for j in range(-2**15,2**15):
        diff = abs(u2s(mul16s_HF7.mul(i,j)) - (i*j))
        if diff > wce: wce = diff
        e += diff

print('average error magnitude (mae)',e/(2.0**(32)))
print('worst-case error magnitude (wce)',wce)