I wish to extract rows and columns from a matrix using a single “fancy” slice, is this possible?
m = matrix([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
My target is
matrix([[1, 3],
[7, 9]])
Where I have a list of the items I want
d = [0,2]
I can achieve the functionality by
m[d][:,d]
But is there a simpler expression?
You can do this using
numpy.ix_:which will emit: