pyodide/benchmark/benchmarks/rosen.py

12 lines
242 B
Python
Raw Normal View History

2018-04-05 22:07:33 +00:00
#setup: import numpy as np; r = np.arange(1000000, dtype=float)
#run: rosen(r)
import numpy as np
#pythran export rosen(float[])
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)