Пример #1
0
V = numpy.random.random(orders)
C = filter_coeffs(a, b, orders, V)

X = numpy.random.random((N, d))
res = numpy.zeros(N)
res2 = res.copy()

if d == 3:
    vec_eval_cubic_spline = vec_eval_cubic_spline_3
elif d == 2:
    vec_eval_cubic_spline = vec_eval_cubic_spline_2

vec_eval_cubic_spline(a, b, orders, C, X, res)

multilinear_interpolation(a, b, orders, V, X, res)

import time

t1 = time.time()
vec_eval_cubic_spline(a, b, orders, C, X, res)
t2 = time.time()
multilinear_interpolation(a, b, orders, V, X, res2)
t3 = time.time()

print("Cubic: {}".format(t2 - t1))
print("Linear: {}".format(t3 - t2))

# assert(abs(res-res2).max()<1e-10)

# scipy
a = numpy.array([0.0,0.0,0.0])
b = numpy.array([1.0,1.0,1.0])
orders = numpy.array([K,K,K],dtype=int)

V = numpy.random.random(orders)
C = filter_coeffs(a,b,orders,V)


X = numpy.random.random((N,3))
res = numpy.zeros(N)
res2 = res.copy()

vec_eval_cubic_spline_3(a,b,orders,C,X,res)

multilinear_interpolation(a,b,orders,V,X,res)



import time

t1 = time.time()
vec_eval_cubic_spline_3(a,b,orders,C,X,res)
t2 = time.time()
multilinear_interpolation(a,b,orders,V,X,res2)
t3 = time.time()

print("Cubic: {}".format(t2-t1))
print("Linear: {}".format(t3-t2))