How to use the model from Python

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

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

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

def u2s(v): # 13b unsigned to 13b signed
    if v & 4096:
	return v - 8192
    return v

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

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