I have two matrices (of the same dimension) and I am dividing one by the other. This gives me a matrix of the same dimension in which each element is the quotient of the division of the corresponding elements in the original matrices. However, some elements of the divisor matrix are zeros. This gives me an error. I don't want to use for loops and go through each division separately. Is there any way in which I can handle the divide by zero instances by replacing the result with zeros?
I think I can use numpy.seterr()
and numpy.seterrcall()
to solve this but I can't figure out how to replace the divide by zero instances with zeros.