
March 19, 2001
9:40 p.m.
On Mon, 19 Mar 2001, Aureli Soria Frisch wrote:
Hello!
I have a N-dimensional array A and I want to operate in one of the axis (k) with a 1 dimensional array (for instance, subtracting an array B of length k). I have looked for some solutions in the manual and did not found any.
So after testing a lot I found following solution:
A=Numeric.array(a)
A.shape=(a1,a2,...,ak,...,aN) #where N is any int value
B=Numeric.array(b) B.shape=(ak,)
newshape = [1] * len(A.shape) newshape[k] = A.shape[k] B.shape = newshape result = A - B wbf