[SciPy-User] Examples how to call NumPy from C++
Alexander Kalinin
alec.kalinin at gmail.com
Thu Aug 13 04:40:38 EDT 2015
Thank you very much for answers!
I have a little bit more complicated algorithm in NumPy than simple matrix
multiplication. I have a big software in C++ and want to integrate some new
math. First idea was to prototype algorithm in NumPy and next rewrite it on
C++. But in NumPy implementation suddenly becomes very clear and it works
pretty fast! So my idea now to embed this algorithm in C++ directly.
Yes, I known Swig, Cython and other tools. But all of them mostly do the
reverse task: embed C++ into Python. I did now found any detailed examples
how to solve my task: embed Python into C++.
So I found only two candidates: Python C API and boost.python with pretty
new addon boot.numpy. But also there is a lack of examples how to pass and
return complex numpy structures to C++.
But I believe I am not a first one who what to call NumPy from C++. May be
somebody already played with such tasks.
Sincerely,
Alexander
On Thu, Aug 13, 2015 at 1:29 AM Sturla Molden <sturla.molden at gmail.com>
wrote:
> Alexander Kalinin <alec.kalinin at gmail.com> wrote:
>
> > I have some software in C++. A want to call NumPy python procedures from
> > C++, for example some matrix multiplication procedures.
>
> If you want matrix multiplication in C++ you are better off using CBLAS
> (e.g. Intel MKL, OpenBLAS, Apple Accelerate Framework), Eigen or BLISS. If
> you need more linear algebra there is LAPACKE.
>
> That said, to call NumPy from C++ you must either embed the Python
> interpreter in your C++ program or extend Python with C++. The most
> relevant options are Python C API, PyCXX, Boost.Python, SIP, Swig, or
> Cython. Personally I prefer PyCXX or Cython, but it is a matter of taste.
>
> Sturla
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20150813/483566bc/attachment.html>
More information about the SciPy-User
mailing list