How to multiply diagonal elements by each other using numpy?
You could use the identity matrix given by numpy.identity(n) and then multiply it by a n dimensional vector.
For the purpose of this exercise, let's consider a matrix where the element m_{i, j} is given by the rule m_{i, j} = i*j if i == j and 0 else.
Is there an easy "numpy" way of calculating such a matrix without having to resort to if statements checking for the indices?