pyodide/benchmark/benchmarks/rosen.py

12 lines
245 B
Python
Raw Normal View History

2018-10-03 18:59:01 +00:00
# setup: import numpy as np; r = np.arange(1000000, dtype=float)
# run: rosen(r)
2018-04-05 22:07:33 +00:00
import numpy as np
2018-10-03 18:59:01 +00:00
# pythran export rosen(float[])
2018-04-05 22:07:33 +00:00
2018-10-03 12:38:48 +00:00
2018-04-05 22:07:33 +00:00
def rosen(x):
t0 = 100 * (x[1:] - x[:-1] ** 2) ** 2
t1 = (1 - x[:-1]) ** 2
return np.sum(t0 + t1)