2

My friend A is back and she now looks like

A = np.array([
    [0,1,1,1,0,0,0,0], 
    [1,0,0,1,0,0,0,0],
    [1,0,0,1,0,0,0,0],
    [1,1,1,0,0,0,0,0],
    [0,0,0,1,0,1,0,0],
    [0,0,0,0,1,0,1,1],
    [0,0,0,0,0,1,0,1],
    [0,0,0,0,0,1,1,0],
             ])

I need to find the sub-matrix that is H = A[(1,3,7), (2,3,6)]. But thats returns

array([0, 0, 1])

I'm expecting rows 1, 3 and 7 paired with columns 2,3 and 6. I can't seem to find that syntax.

H = [[0,1,0],
     [1,0,0],
     [0,0,1]]
0

1 Answer 1

2

You can use np.ix_:

A[np.ix_((1,3,7),(2,3,6))]
#array([[0, 1, 0],
#       [1, 0, 0],
#       [0, 0, 1]])
Sign up to request clarification or add additional context in comments.

1 Comment

DOH! I forgot about that. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.