n0 = 5 # number of rows
B = np.ones((n0,3))*np.arange(3)
A = np.random.randint(3,size=(n0,3))
C = B[np.arange(n0)[:,None],A]
assert (A == C).all()
A
> array([[2, 0, 1],
>[2, 0, 1],
>[2, 1, 2],
>[0, 0, 2],
>[2, 0, 0]])
C
> array([[
josef.p...@gmail.com wrote:
> On Wed, Mar 17, 2010 at 7:12 AM, Miroslav Sedivy wrote:
>> There are two 2D arrays with dimensions: A[1,1000] and B[1,100].
>> The first dimension of both arrays corresponds to a list of 1 objects.
>>
>> The array A contains for
probably 1000 times more time to calculate... Impossible with such large
arrays... :-(
Could anyone help me, please?
Regards,
Miroslav Sedivy
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion