Jeff Abrahamson on 24 Dec 2005 20:23:44 -0000 |
I just wrote the following loop in python, which sums those values of the matrix W that have the property that their distinct coordinates are both in a set called H: for i in range(len(k)): for j in range(len(k)): if(i != j and i in H and j in H): w += W[i,j] I feel I ought to be able to do this with a list comprehension, but it's not clear how to get the double loop. Any thoughts? w = sum([W[i,j] for ?? ]) -- Jeff Jeff Abrahamson <http://www.purple.com/jeff/> +1 215/837-2287 GPG fingerprint: 1A1A BA95 D082 A558 A276 63C6 16BF 8C4C 0D1D AE4B Attachment:
signature.asc ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug
|
|