I have a matrix-like
[[1, 2],
[3, 4]]
and I want to replace the 1s in another matrix:
[[1, 0],
[1, 1]]
to make this matrix:
[[1, 2, 0, 0],
[3, 4, 0, 0],
[1, 2, 1, 2],
[3, 4, 3, 4]]
The 1
s in the second matrix can be in any position, this is just an example.
How can I do this?
CodePudding user response:
In other words, with the matrix A (or numpy
array a
) we indicate if the entries of B shall be added (if 1) or not (if 0).