Hi, with a multidimensional array (say, 4-dimensional), I often want to project this onto one single dimension, i.e.. let "dat" be a 4D array, I am interested in
dat.sum(0).sum(0).sum(0) # equals dat.sum(2).sum(1).sum(0) However, creating intermediate results looks more expensive than necessary; I would actually like to say dat.sum((0,1,2)) One way to achieve this is partial flattening, which I did like this: dat.reshape((numpy.prod(dat.shape[:3]), dat.shape[3])).sum(0) Is there a more elegant way to do this? Ciao, / / .o. /--/ ..o / / ANS ooo
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion