[SciPy-dev] problem with linalg.cholesky?

Travis Oliphant oliphant.travis at ieee.org
Fri Dec 2 16:21:03 CST 2005


Andrew Jaffe wrote:

>OK, on my machine, the astype() method only gives a non-contiguous array 
>when the old and new types are different:
>
>In [33]: a = identity(4, Float64)
>
>In [34]: print transpose(a).astype(Float64).flags
>{'WRITEABLE': True, 'UPDATEIFCOPY': False, 'NOTSWAPPED': True, 
>'CONTIGUOUS': False, 'FORTRAN': True, 'ALIGNED': True, 'OWNDATA': True}
>  
>
O.K, this gives me some place to look.  I thought this produced a copy.  
Let me check into it...

Found the problem.   I can also now reproduce it (I wasn't using a 
floating-point identity matrix before...my bad).

It does produce a copy, but it is in "Fortran order" because of an 
inadvertant change to the code. 
Obviously, the way astype is used, it should always return a 
C-contiguous result.

Unfortunately, I can't check in the change because I'm in the middle of 
major edits.  However,
the code to change is in src/arraymethods.c  in the array_cast function.

Change PyArray_NewCopy(self, -1) to PyArray_NewCopy(self, 0).

Best,

-Travis




More information about the Scipy-dev mailing list