Open sbos opened 8 years ago
That's because of how prod
is implemented (and this is a lazy implementation, which should be fixed)
def prod(x, axis=None, keepdims=False):
"""
Like numpy.prod
"""
return cgt.exp(cgt.sum(cgt.log(x), axis=axis, keepdims=keepdims))
I'm trying to implement the product of matrix diagonal elements. For some reason, my code return
nan
when at least one of the elements is negative. I'm using the latest master.Here is my code:
The last output is always
nan
as one of diagonal elements is negative, the first one is always a number since all the numbers are non-negative. Is this a bug or I'm doing something wrong?At the same time, if I pass the vector of diagonal elements to the
cgt.prod
it works well:So there might be something wrong with indexing.