All right, now we're going to debug the final exercise we need to take the transpose of a tutera.
The transpose reverses the columns, and so as a result, we should see each row converted into a column.
But if we run the code.
It seems like it worked for the most part, but something is wrong and we're going to figure it out.
So, as always, I want to add some breakpoints.
And I'm going to place the output that we want to achieve on the top rates and let's figure out what's
wrong.
OK, so inside the first pass, we're setting the element at zero zero equal to the element at zero
zero.
So nothing should change.
In the second run, we're setting the element at zero one equal to the element of one zero.
OK.
Wow, so far it's actually working.
But wait, now the two is gone forever.
That's not good.
Eventually, we need to move the two from inducts zero one to one zero.
It seems like whoever did this, their logic is correct, but instead of updating the original array,
they should create a new era so that we always have a reference to values from the original one.
OK, so what I'll do is I'll create a new era and transpose matrix.
Is equal to a new integer, to the array with the same number of rows and the same number of elements.
And now, instead of updating the original matrix with transposed values, we're going to update the
transpose matrix.
OK, relaunched the debugger.
Inside the first past, the element at zero zero equals the element zero zero good.
In the second run, the element at zero one equals the element at one zero.
And it looks like everything is going to work.
Zero two equals the element two zero.
Seems like everything is going to work out.
Every row from the original matrix is going to become a column in the transpose matrix.