How do I create an identity matrix with numpy? Is there a simpler syntax than
numpy.matrix(numpy.identity(n))
I don't think there is a simpler solution. You can do it slightly more efficiently, though:
numpy.matrix(numpy.identity(n), copy=False)
This avoids unnecessarily copying the data.