Re: [Numpy-discussion] generic slicing question

2011-03-04 Thread Sturla Molden
Den 04.03.2011 15:19, skrev Neal Becker: > This will subtract col 0 from all cols of a 2-d array: > > # subtract col 0 from all cols > def ll2llr (m): > return m - m[:,0][:,np.newaxis] > > > In general, how to subtract the (n-1)d slice at index 0 from all elements of > an > n-d array? > > (I

[Numpy-discussion] generic slicing question

2011-03-04 Thread Neal Becker
This will subtract col 0 from all cols of a 2-d array: # subtract col 0 from all cols def ll2llr (m): return m - m[:,0][:,np.newaxis] In general, how to subtract the (n-1)d slice at index 0 from all elements of an n-d array? (I think a 3d version is: m - m[:,:,0][:,:,np.newaxis] ) ___