# C1_W2_Assignment Exercise 4 Help

I’ve followed the instructions, using return A_ref beneath each function to test it, commenting out the rest of the code, and going thru it one by one but I still don’t understand what I’m missing and I haven’t moved onto 5 and 6. I’m following this, or at least I think I am:
MultiplyRow(A, i, j) ----> Ai = j * Ai
AddRows(A, i, j, k) -----> Aj = k * Ai + Aj
SwapRows(A, i, j) ------> Ai = Aj, Aj = Ai

Is there anyone I can privately DM for help? This is also my output:

You have to be a bit careful how you implement that, to avoid having a dependent sequence.

If it says to swap rows 2 and 10 with the matrix A_ref for example, i wrote it presented in the order of the instruction. if i try reversing it, it doesn’t actually change anything oddly enough lol.

None of the instructions tell you to use row 10.

The easiest way to implement SwapRows() is to use vectors to provide the index values. In each vector, you reverse the order of the two rows you are swapping.

If ‘a’ and ‘b’ are the two rows you are to swap, and Q is the matrix, you can do this:
`Q[[a, b]] = Q[[b, a]]`

The SwapRows() function doesn’t use A_ref. It uses a matrix parameter M, and two row indices.

Then in augmented_to_Ref(), if you have this instruction:

``````   # swap row 1 and 3 of the new matrix A_ref
A_ref = None
``````

… you use SwapRows(…) and pass it A_ref, 1, and 3.

Sorry that’s my bad, I used an example. The actual instructions are to SwapRows 0,1 and 1,3 for another.

Where does it say to do that? Can you provide a screen capture image?

Those are two separate instructions.

#swap row 0 and row 1 of matrix A_system (remember that indexing in NumPy array starts from 0)
[my code]
#swap row 1 and 3 of the new matrix A_ref
[my code]

Correct

Could you elaborate on this, the instructions refer to “new matrix A_ref”

“new matrix A_ref” refers to the A_ref matrix that was the result of the previous line of code.

You’re just calling one of those matrix manipulation instruction in each sequence, each time you modify the A_ref matrix, one operation at a time.

That’s how I have it written. What do you mean by using vectors to provide the index values for SwapRows() per your earlier comment?

The vectors would be in your SwapRows() function.