29 Jul
2003
29 Jul
'03
8:58 p.m.
"Perry" == Perry Greenfield
writes:
Perry> [Note that I reordered the index arrays to match b; I Perry> wasn't sure what was intended] Yep, I think that was a blooper on my part; to be precise, here is the matlab code a = zeros( 8,8 ); b = ones( 3,4 ); rind = [2,4,6]; cind = [1,4,5,6]; a(rind, cind) = b; and the equivalent python from Numeric import * a = zeros( (8,8) ) b = ones( (3,4) ) rind = [1,3,5] cind = [0,3,4,5] for ia, ib in zip(rind, range(len(rind))): for ja, jb in zip(cind, range(len(cind))): a[ia,ja] = b[ib,jb] print a And the question is: is there a good way to avoid the double loop using Numeric? Thanks, John