[Numpy-discussion] speed up np.diag
Citi, Luca
lciti@essex.ac...
Fri Jul 10 10:16:14 CDT 2009
>> if v.flags.f_contiguous:
>> v, k, s = v.T, -k, s[::-1]
>Is this correct? The .flat iterator always traverses the array in virtual
>C-order, not in the order it's laid out in memory.
The code could work (and gives the same results) even
without the two lines above which in theory do nothing:
taking the k-th diagonal of an array or the (-k)-th of
its transpose should be the same.
But in this case ndarray.flat works faster if the
array is C-contiguous.
Best,
Luca
More information about the NumPy-Discussion
mailing list