0

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.

Cleb
  • 25,102
  • 20
  • 116
  • 151
  • Could you post an example? Then it is easier to help. And you might want to take a look at [this answer](https://stackoverflow.com/a/37977222/1534017). – Cleb Jul 18 '18 at 21:11
  • 1
    The answer you shared worked for me. Thanks! – Ritik Dutta Jul 19 '18 at 16:03

0 Answers0