Hello, I am trying to use the lapack_lite dgesv routine. The following sample code : from numpy import * [....] a=zeros((nbrows,nbcols),float,order='C') [....] ipiv=zeros((DIM),int,order='C') [....] linalg.lapack_lite.dgesv(DIM,1,a,DIM,asarray(ipiv),b,DIM,info) leads do the followin error message : lapack_lite.LapackError: Parameter ipiv is not of type PyArray_INT in lapack_lite.dgesv I don't understand the type problem for ipiv ! Indeed, the type of 'a' is OK, ipiv is created the same way than a, but something goes wrong. Do you have a clue for this ? Regards, Romaric -- -------------------------------------- R. David - david@icps.u-strasbg.fr Tel. : 03 90 24 45 48 (Fax 45 47) --------------------------------------
R. David wrote:
Hello,
I am trying to use the lapack_lite dgesv routine.
The following sample code :
from numpy import * [....] a=zeros((nbrows,nbcols),float,order='C') [....] ipiv=zeros((DIM),int,order='C') [....] linalg.lapack_lite.dgesv(DIM,1,a,DIM,asarray(ipiv),b,DIM,info)
leads do the followin error message : lapack_lite.LapackError: Parameter ipiv is not of type PyArray_INT in lapack_lite.dgesv
I don't understand the type problem for ipiv ! Indeed, the type of 'a' is OK, ipiv is created the same way than a, but something goes wrong. Do you have a clue for this ?
The problem is probably your definition of ipiv. "(DIM)" is just a parenthesized scalar, what you probably want is "(DIM,)", which is a one-tuple. Personally, I'd recommend using list notation ("[nbrows, nbcols]", "[DIM]") rather than tuple notation since it's both easier to read and and avoids this type of mistake. Regards, -tim
Hello Tim,
The problem is probably your definition of ipiv. "(DIM)" is just a parenthesized scalar, what you probably want is "(DIM,)", which is a one-tuple. Personally, I'd recommend using list notation ("[nbrows, nbcols]", "[DIM]") rather than tuple notation since it's both easier to read and and avoids this type of mistake.
I tried both notations and none work. In the meantime, I tried extending the ipiv arrays to a 2 dimensionnal ones (if I had more than on right member for instante), but I still get the error message. Romaric
R. David wrote:
Hello Tim,
The problem is probably your definition of ipiv. "(DIM)" is just a parenthesized scalar, what you probably want is "(DIM,)", which is a one-tuple. Personally, I'd recommend using list notation ("[nbrows, nbcols]", "[DIM]") rather than tuple notation since it's both easier to read and and avoids this type of mistake.
I tried both notations and none work.
In the meantime, I tried extending the ipiv arrays to a 2 dimensionnal ones (if I had more than on right member for instante), but I still get the error message.
Romaric, Try replacing 'int' with intc (or numpy.intc if you are not using 'import *'). The following 'works' for me in the sense that it doesn't throw any errors (although I imagine the results are nonsense): from numpy import * nbrows, nbcols = 10, 10 a=zeros([nbrows,nbcols],float,order='C') b = zeros([nbcols], float, order='C') DIM = nbrows info = 0 ipiv=zeros([DIM],intc,order='C') linalg.lapack_lite.dgesv(DIM,1,a,DIM,ipiv,b,DIM,info) [In the future, could you could you try including self contained examples, so others don't have to go back and figure out sensible values for DIMS and info and whatnot? Ideally we'd just be able to throw them into a file and run them and get the same error that you are getting] Hope that solves it. -tim
Hello,
Try replacing 'int' with intc (or numpy.intc if you are not using 'import *'). The following 'works' for me in the sense that it doesn't throw any errors (although I imagine the results are nonsense): Thanks, it works now !!
Sorry for non including the whole code, I just not wanted to annoy the whole list with bunchs of code :-) Regards, Romaric
R. David wrote:
Hello,
Try replacing 'int' with intc (or numpy.intc if you are not using 'import *'). The following 'works' for me in the sense that it doesn't throw any errors (although I imagine the results are nonsense):
Thanks, it works now !!
Great. Glad that helped.
Sorry for non including the whole code, I just not wanted to annoy the whole list with bunchs of code :-)
Don't include the whole code -- that would probably annoy somebody. What you included was almost right, except that it should run on it's own. So nbrows, nbcols, DIMS and info all needed to be defined. That's all. -tim
participants (2)
-
R. David -
Tim Hochberg