can this be made faster?
Greg Willden
gregwillden at gmail.com
Sun Oct 8 17:20:40 CDT 2006
On 10/8/06, Daniel Mahler <dmahler at gmail.com> wrote:
>
> >>> a
> array([0, 0])
> >>> b
> array([0, 1, 0, 1, 0])
> >>> c
> array([1, 1, 1, 1, 1])
>
Well for this particular example you could do
a=array([len(b)-sum(b), sum(b)])
Since you are just counting the ones and zeros.
This next one is a little closer for the case when c is not just a bunch of
1's but you still have to know how the highest number in b.
a=array([sum(c[b==0]), sum(c[b==1]), ... sum(c[b==N]) ] )
So it sort of depends on your ultimate goal.
Greg
--
Linux. Because rebooting is for adding hardware.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20061008/4920c03a/attachment.html
-------------- next part --------------
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
-------------- next part --------------
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
More information about the Numpy-discussion
mailing list