How to use the model from Python

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

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

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

def u2s(v): # 17b unsigned to 17b signed
    if v & 65536:
	return v - 131072
    return v

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

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