a = np.arange(10)<div>b = (a[::2]).sum()<br><br></div><div><br></div><div>Patrick</div><div><br></div><div><br></div><div><br></div><div><br><div class="gmail_quote">On Mon, Apr 12, 2010 at 9:21 AM, Nicola Creati <span dir="ltr"><<a href="mailto:ncreati@inogs.it">ncreati@inogs.it</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello,<br>
I want to calculate, given a one dimension array, the sum over every two<br>
elements of the array.<br>
I found this working solution:<br>
<br>
a = N.arange(10)<br>
b = a.reshape(a, (5, 2))<br>
c = b.sum(axis=1)<br>
<br>
Is there any better solution?<br>
<br>
Thanks,<br>
<br>
Nicola Creati<br>
<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Patrick Marsh<br>Ph.D. Student / NSSL Liaison to the HWT<br>School of Meteorology / University of Oklahoma<br>Cooperative Institute for Mesoscale Meteorological Studies<br>

National Severe Storms Laboratory<br><a href="http://www.patricktmarsh.com">http://www.patricktmarsh.com</a><br><br>
</div>