Hi Guillem

On Wed, May 02, 2007 at 12:38:12AM +0200, Guillem Borrell i Nogueras wrote:
> I wrote the next function just to learn how ctypes work with numpy arrays.  I 
> am not trying to write yet another wrapper to lapack, it's just an 
> experiment. (you can cut and paste the code)
> 
> from ctypes import c_int
> from numpy import array,float64
> from numpy.ctypeslib import load_library,ndpointer
> 
> def dgesv(N,A,B):
> #    A=array([[1,2],[3,4]],dtype=float64,order='FORTRAN')
> #    B=array([1,2],dtype=float64,order='FORTRAN')

Here, I'd use something like

A = asfortranarray(A.astype(float64))
B = asfortranarray(B.astype(float64))

>     cN=c_int(N)
>     NRHS=c_int(1)
>     LDA=c_int(N)
>     IPIV=(c_int * N)()
>     LDB=c_int(N)
>     INFO=c_int(1)
>     
>     lapack=load_library('liblapack.so','/usr/lib/')
> 
>     lapack.argtypes=[c_int,c_int,
>                      ndpointer(dtype=float64,
>                                ndim=2,
>                                flags='FORTRAN'),
>                      c_int,c_int,
>                      ndpointer(dtype=float64,
>                                ndim=1,
>                                flags='FORTRAN'),
>                      c_int,c_int]

This should be lapack.dgesv_.argtypes.

Cheers
Stéfan
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to