np.dot and array order
np.__version__ '1.5.1' official win32 installer (playing with ipython for once) I thought np.dot is Lapack based and favors fortran order, but if the second array is fortran ordered, then dot takes twice as long. The order of the first array seems irrelevant (or maybe just with my shapes, in case it matters: the first array is float64, the second is bool, and I'm low in left over memory) In [93]: %timeit np.dot(x.T, indi) 1 loops, best of 3: 1.33 s per loop In [94]: %timeit np.dot(xf.T, indi) 1 loops, best of 3: 1.27 s per loop In [95]: %timeit np.dot(xf.T, indif) 1 loops, best of 3: 3 s per loop In [100]: %timeit np.dot(x.T, indif) 1 loops, best of 3: 3.05 s per loop In [96]: x.flags.c_contiguous Out[96]: True In [97]: xf.flags.c_contiguous Out[97]: False In [98]: indi.flags.c_contiguous Out[98]: True In [99]: indif.flags.c_contiguous Out[99]: False In [101]: x.shape Out[101]: (200000, 20) In [102]: indi.shape Out[102]: (200000, 500) It's just the way it is, or does it depend on ....? Josef
01.12.2011 03:31, josef.pktd@gmail.com kirjoitti: [clip]
I thought np.dot is Lapack based and favors fortran order, but if the second array is fortran ordered, then dot takes twice as long.
It uses C-LAPACK, and will make copies if the arrays are not in C-order. -- Pauli Virtanen
participants (2)
-
josef.pktd@gmail.com -
Pauli Virtanen