How to use the model from Python

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

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

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

def u2s(v): # 9b unsigned to 9b signed
    if v & 256:
	return v - 512
    return v

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

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