¡@

Home 

python Programming Glossary: np.einsum

more efficient way to calculate distance in numpy?

http://stackoverflow.com/questions/17527340/more-efficient-way-to-calculate-distance-in-numpy

and sums try to use one of the dot product functions or np.einsum . Since you are preallocating your arrays rather than having.. measured_flat None From here the simplest would be dist np.einsum 'ijk ijk ij' deltas deltas You could also try something like.. of 3 124 ms per loop In 16 timeit deltas a None b ... None np.einsum 'ijk ijk jk' deltas deltas 10 loops best of 3 163 ms per loop..

Why is numpy's einsum faster than numpy's built in functions?

http://stackoverflow.com/questions/18365073/why-is-numpys-einsum-faster-than-numpys-built-in-functions

lets look at the np.sum function np.all np.sum arr_3D np.einsum 'ijk ' arr_3D True timeit np.sum arr_3D 10 loops best of 3 142.. np.sum arr_3D 10 loops best of 3 142 ms per loop timeit np.einsum 'ijk ' arr_3D 10 loops best of 3 70.2 ms per loop Powers np.allclose.. 3 70.2 ms per loop Powers np.allclose arr_3D arr_3D arr_3D np.einsum 'ijk ijk ijk ijk' arr_3D arr_3D arr_3D True timeit arr_3D arr_3D..