2018-10-03 18:59:01 +00:00
|
|
|
# from: http://wiki.scipy.org/Cookbook/Theoretical_Ecology/Hastings_and_Powell
|
|
|
|
# setup: import numpy as np ; y = np.random.rand(3) ; args = np.random.rand(7)
|
|
|
|
# run: hasting(y, *args)
|
2018-04-05 22:07:33 +00:00
|
|
|
|
2018-10-03 18:59:01 +00:00
|
|
|
# pythran export hasting(float [], float, float, float, float, float,
|
|
|
|
# float, float)
|
2018-04-05 22:07:33 +00:00
|
|
|
import numpy as np
|
2018-10-03 18:59:01 +00:00
|
|
|
|
|
|
|
|
2018-04-05 22:07:33 +00:00
|
|
|
def hasting(y, t, a1, a2, b1, b2, d1, d2):
|
|
|
|
yprime = np.empty((3,))
|
2018-10-03 18:59:01 +00:00
|
|
|
yprime[0] = y[0] * (1. - y[0]) - a1 * y[0] * y[1] / (1. + b1 * y[0])
|
|
|
|
yprime[1] = a1 * y[0] * y[1] / (1. + b1 * y[0]) - \
|
|
|
|
a2 * y[1] * y[2] / (1. + b2 * y[1]) - d1 * y[1]
|
|
|
|
yprime[2] = a2 * y[1] * y[2] / (1. + b2 * y[1]) - d2 * y[2]
|
2018-04-05 22:07:33 +00:00
|
|
|
return yprime
|