[Numpy-discussion] Matrix operation.
Fri Apr 2 10:49:37 CDT 2010
With A and X being arrays:
B[A>0] = X
Quoting gerardob <email@example.com>:
> Let A be a square matrix of 0's and 1's, and let X be a one dimesional
> The length of X is equal to the number of 1's that A has.
> I would like to produce a new matrix B by traversing the matrix A row by row
> 1- whenever i find a 0, set B in that position to zero.
> 2- whenever i find a 1, set B in that position with the ith value of X
> (where i represents the ith time i found a 1).
> B =[[2,9,0],
> Which is an efficient way to accomplish this using numpy?
> View this message in context:
> Sent from the Numpy-discussion mailing list archive at Nabble.com.
> NumPy-Discussion mailing list
More information about the NumPy-Discussion