[SciPy-Dev] Multilinear interpolation
Pauli Virtanen
pav at iki.fi
Mon Feb 25 08:32:31 EST 2013
Pablo Winant <pablo.winant <at> gmail.com> writes:
[clip]
> So I made an attempt using tempita in the case of regularly spaced
> grids. For now, it is in a temporary repository in github:
>
> https://github.com/albop/python_interpolation
[clip]
Some comments:
- "#pragma omp parallel for" statement probably doesn't do
anything: Cython interprets it as a comment.
- The code assumes C-contiguous arrays, but does not check for it.
- Do you actually need code generation here? The templated loops
can be replaced by N-dim untemplated loops. The question is
probably mostly about speed.
- The inner evaluation loop should be inside `with nogil`
[clip]
> Before, I do the same for irregularly spaced grid, I have some questions:
> - I included the templates as Python strings in the .pyx.in file . Was
> there a better way ?
As the script is executable by Python, the file extension should be .py.
You can either put the template itself to a separate file (.pyx.in)
--- note that you can put Python code inside tempita templates.
Alternatively, rename the script to `generate_multilinear.py`.
Note that tempita templates can contain executable blocks, so you can
for instance put some logic there, and use the template syntax for the
loops.
> - I was not sure about how to deal with single/double precision in the
> cython code.
You can use fused types instead of templating; the end result is the same,
but Cython takes care of picking the correct routine.
--
Pauli Virtanen
More information about the SciPy-Dev
mailing list