[Numpy-discussion] Accessing LAPACK and BLAS from the numpy C API

Jake VanderPlas jakevdp@gmail....
Mon Nov 9 13:08:52 CST 2009

>The safe way to access them, since they are not exposed, is to call the
>function at the python level in your C code, but I don't think that's
>what you want,

I want to avoid calling functions at the python level, because of the
overhead for multiple calls within nested loops.  I may have a
solution: I've managed to get access to the BLAS fortran library by
using in the setup.py file:

  from distutils.core import Extension
  from numpy.distutils import system_info

  myextension = Extension(<...>  library_dirs =
system_info.blas_opt_info().get_lib_dirs(),  <...>)

Then in my C++ code I can declare, e.g.

  extern "C" double ddot_(const int *N, const double *DX, const int
*INCX, const double *DY, const int *INCY);

...and directly call the BLAS fortran library.  This pattern works on
my system (linux, using the system BLAS/LAPACK libraries).  Is this a
form that will work across different OSs and different installs?

More information about the NumPy-Discussion mailing list