Comments (1)
Interesting! The numba code can be easily converted to pythran code, as demonstrated by the extract below.
Then compile it using pythran code.py
or through distuils (see https://pythran.readthedocs.io/en/latest/MANUAL.html#distutils-integration)
from __future__ import division
import numpy as np
from numpy import zeros, array
from math import floor
from numpy import empty, sum
Ad = array([
# t^3 t^2 t 1
[-1.0/6.0, 3.0/6.0, -3.0/6.0, 1.0/6.0],
[ 3.0/6.0, -6.0/6.0, 0.0/6.0, 4.0/6.0],
[-3.0/6.0, 3.0/6.0, 3.0/6.0, 1.0/6.0],
[ 1.0/6.0, 0.0/6.0, 0.0/6.0, 0.0/6.0]
])
def make_dAd():
dAd = empty((4,4))
for i in range(1,4):
dAd[:,i] = Ad[:,i-1]*(4-i)
return dAd
dAd = make_dAd()
def make_d2Ad():
d2Ad = empty((4,4))
for i in range(1,4):
d2Ad[:,i] = dAd[:,i-1]*(4-i)
return d2Ad
d2Ad = make_d2Ad()
#pythran export eval_cubic_spline_1(float64 [], float64[], float64[], float64[], float64[])
def eval_cubic_spline_1(a, b, orders, coefs, point):
M0 = orders[0]
start0 = a[0]
dinv0 = (orders[0]-1.0)/(b[0]-a[0])
x0 = point[0]
u0 = (x0 - start0)*dinv0
i0 = int( floor( u0 ) )
i0 = max( min(i0,M0-2), 0 )
t0 = u0-i0
tp0_0 = t0*t0*t0
tp0_1 = t0*t0
tp0_2 = t0
tp0_3 = 1.0;
Phi0 = [0] * 4
if t0 < 0:
for i in range(4):
Phi0[i] = dAd[i,3]*t0 + Ad[i,3]
elif t0 > 1:
for i in range(4):
Phi0[i] = (3*Ad[i,0] + 2*Ad[i,1] + Ad[i,2])*(t0-1) + (Ad[i,0]+Ad[0,1]+Ad[i,2]+Ad[i,3])
else:
for i in range(4):
Phi0[i] = (Ad[i,0]*tp0_0 + Ad[i,1]*tp0_1 + Ad[i,2]*tp0_2 + Ad[i,3]*tp0_3)
return sum(Phi0 *coefs[i0: i0+4])
from interpolation.py.
Related Issues (20)
- Is the dependency on tempita necessary? HOT 7
- `eval_splines` gives error `TypeError: 'module' object is not callable` HOT 2
- "interp" not working with python 3.11 HOT 2
- Errors with multidimensional outputs HOT 4
- eval_spline() doesn't recognize argument `k=` HOT 5
- literal type error when eval_spline() called without some keyword arguments HOT 4
- New version HOT 5
- Numba warnings HOT 8
- eval_cubic fails when array to interpolate on is non-writable
- After 2.2.0 eval_linear needs C-order and dtype FLOAT64 HOT 3
- guvectorized wrapping of eval_linear() appears broken HOT 2
- DOC: reorganize
- 1D interpolation with eval_linear HOT 5
- Documentation link broken HOT 1
- Import jitclass error HOT 1
- interpolating wind data on the satellilte track (in same lon lat time)
- Documentation for derivatives HOT 9
- Error when running example code in the documentation HOT 3
- `curses` requirement? HOT 6
- Python 3.10 support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interpolation.py.