[SciPy-User] missing lapack functions in scipy.linalg.flapack

Sturla Molden sturla at molden.no
Thu Jul 12 06:57:40 EDT 2012


On 08.07.2012 18:36, michf at post.tau.ac.il wrote:
> I'm trying to access a few lapack functions that don't seem to be
> available directly in scipy as far as I can tell. Specifically I need
> at the moment ?trsyl (solve triagonal sylvester equation) and the
> various subfunctions for computing eigenvectors (the whole stack used
> behind ?geev)
>
> I'm currently using the 64bit windows distribution from enthought
> (academic version).
>
> Any ideas?


The easiest way to get a LAPACK function not in SciPy is to use LAPACKE 
(the new C interface) from Cython or ctypes.

Enthought comes with Intel MKL (at least on Windows) which already has a 
LAPACKE interface:


from ctypes import CDLL, c_char, c_int
import numpy as np
from numpy.ctypeslib import ndpointer
LAPACK_ROW_MAJOR = 101
LAPACK_COL_MAJOR = 102
intel_mkl = CDLL('mk2_rt.dll')
LAPACKE_dtrsyl = intel_mkl.LAPACKE_dtrsyl
array_t = ndpointer(dtype=np.float64, ndim=2)
LAPACKE_dtrsyl.restype = c_int
LAPACKE_dtrsyl.argtypes = [c_int, c_char, c_char, c_int, c_int, c_int,
     _array_t, c_int, _array_t, c_int, _array_t, c_int, c_double]


And then you can call the function like this:

info = LAPACKE_dtrsyl(LAPACK_ROW_MAJOR, # or LAPACK_COL_MAJOR
     'N', 'N', ISGN, M, N, A, LDA, B, LDB, C, LDC, SCALE)



Sturla



More information about the SciPy-User mailing list