Time to debug exercise number nine.
So we want to produce a lower triangular matrix from this predefine to the array and now a lower triangular
matrix is one where everything above the main diagonal is zero.
In this case, the values that indices zero one zero two and one two should be zero.
But if we run the current code, what are we going to get, let's see.
OK, Lisa didn't crash.
I'm going to have the usual breakpoint so I can at least visualize what the heck is happening here.
Launched the debugger.
We're at the first pass I zero is zero, nothing should happen when I injera zero, but this condition
is going to evaluate to true.
Sending this to.
So we'll take off the equal sign and try again.
OK, but now nothing happens in the first pass.
Or the second pass, which means whoever wrote this code did not know what they were doing.
OK, so I'm going to remove this code entirely because sometimes it's better to just start over than
to fix something that's completely broken.
OK, relaunched the debugger.
Starting again, I zero G is zero here, we don't want to do anything.
But now the inner loop suddenly breaks.
Hmm, now I is one.
Wait a second.
I need to update indices 01 and 02, but the way the inner loop code was designed, it's never going
to reach them.
It seems like they tried to get all fancy, but in reality, we need to loop through every single element
in each row so we can use a regular nested loop.
I don't know what the heck they were doing.
Relaunched the debuggers starting again.
I zero g zero.
Here, we don't want to do anything, but when I zero in just one.
Now we want to set this to zero.
OK, I think I found the pattern we should only set the element equal to zero if its index is higher
than the row index I.
So if Jay is higher than I.
Then we're going to set that element equal to zero.
OK, try it out now.
Here, the condition is false.
But now Jay is bigger than I said, the element equal to zero.
Once more here.
In the second pass, I equals one, this condition is going to be false for the first two elements in
that row, but then it's going to be true for inducts to.
And for the final row, the condition should be false through about.