Hi
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')
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]
lapack.dgesv_(cN,NRHS,A,LDA,IPIV,B,LDB,INFO)
return B
And...
In [2]: from lapackw import dgesv
In [3]: from numpy import array
In [4]: dgesv(2,array([[1,2],[3,4]]),array([1,2]))
...
ArgumentError: argument 3: exceptions.TypeError: Don't know how to convert
parameter 3
Maybe I am sooo dumb but I just don't know what I am doing wrong. numpy-1.0.1,
ctypes 1.0.1, python 2.4.3.
thanks
guillem
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion