Thanks! will try that and see how the performance varies depending on the size of my arrays.
thanks again! Eric > Constructing big intermediate arrays, might not improve performance > compared to a loop > >>>> >>> np.arange(30).reshape(6,5) > array([[ 0, 1, 2, 3, 4], > [ 5, 6, 7, 8, 9], > [10, 11, 12, 13, 14], > [15, 16, 17, 18, 19], > [20, 21, 22, 23, 24], > [25, 26, 27, 28, 29]]) > >>>> >>> np.arange(30).reshape(6,5)[np.array([[1,2,2,1]]).T,np.arange(0,3)+np.array([[0,1,2,1]]).T] > array([[ 5, 6, 7], > [11, 12, 13], > [12, 13, 14], > [ 6, 7, 8]]) > >>>> >>> np.arange(30).reshape(6,5)[np.array([[1,2,2,1]]).T,np.arange(0,3)+np.array([[0,1,2,1]]).T].sum(0) > array([34, 38, 42]) > > Josef _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
