1
00:00:00,890 --> 00:00:02,870
Time to debug exercise number nine.

2
00:00:04,939 --> 00:00:11,030
So we want to produce a lower triangular matrix from this predefine to the array and now a lower triangular

3
00:00:11,030 --> 00:00:14,550
matrix is one where everything above the main diagonal is zero.

4
00:00:15,170 --> 00:00:21,350
In this case, the values that indices zero one zero two and one two should be zero.

5
00:00:23,280 --> 00:00:26,790
But if we run the current code, what are we going to get, let's see.

6
00:00:28,110 --> 00:00:29,790
OK, Lisa didn't crash.

7
00:00:30,910 --> 00:00:35,230
I'm going to have the usual breakpoint so I can at least visualize what the heck is happening here.

8
00:00:39,560 --> 00:00:40,520
Launched the debugger.

9
00:00:47,920 --> 00:00:54,430
We're at the first pass I zero is zero, nothing should happen when I injera zero, but this condition

10
00:00:54,430 --> 00:00:55,720
is going to evaluate to true.

11
00:00:56,550 --> 00:00:57,240
Sending this to.

12
00:00:59,710 --> 00:01:01,950
So we'll take off the equal sign and try again.

13
00:01:16,330 --> 00:01:19,090
OK, but now nothing happens in the first pass.

14
00:01:22,820 --> 00:01:27,500
Or the second pass, which means whoever wrote this code did not know what they were doing.

15
00:01:28,250 --> 00:01:33,590
OK, so I'm going to remove this code entirely because sometimes it's better to just start over than

16
00:01:33,590 --> 00:01:35,480
to fix something that's completely broken.

17
00:01:36,570 --> 00:01:38,280
OK, relaunched the debugger.

18
00:01:46,260 --> 00:01:51,240
Starting again, I zero G is zero here, we don't want to do anything.

19
00:01:58,410 --> 00:02:00,740
But now the inner loop suddenly breaks.

20
00:02:00,820 --> 00:02:03,000
Hmm, now I is one.

21
00:02:03,060 --> 00:02:03,900
Wait a second.

22
00:02:04,440 --> 00:02:11,190
I need to update indices 01 and 02, but the way the inner loop code was designed, it's never going

23
00:02:11,190 --> 00:02:11,940
to reach them.

24
00:02:12,240 --> 00:02:17,400
It seems like they tried to get all fancy, but in reality, we need to loop through every single element

25
00:02:17,400 --> 00:02:20,390
in each row so we can use a regular nested loop.

26
00:02:20,400 --> 00:02:21,900
I don't know what the heck they were doing.

27
00:02:31,750 --> 00:02:33,730
Relaunched the debuggers starting again.

28
00:02:42,050 --> 00:02:43,790
I zero g zero.

29
00:02:44,830 --> 00:02:49,030
Here, we don't want to do anything, but when I zero in just one.

30
00:02:51,490 --> 00:02:53,470
Now we want to set this to zero.

31
00:02:56,090 --> 00:03:02,780
OK, I think I found the pattern we should only set the element equal to zero if its index is higher

32
00:03:02,780 --> 00:03:04,130
than the row index I.

33
00:03:06,970 --> 00:03:09,100
So if Jay is higher than I.

34
00:03:12,880 --> 00:03:15,220
Then we're going to set that element equal to zero.

35
00:03:20,110 --> 00:03:21,330
OK, try it out now.

36
00:03:37,480 --> 00:03:38,920
Here, the condition is false.

37
00:03:40,740 --> 00:03:44,820
But now Jay is bigger than I said, the element equal to zero.

38
00:03:46,720 --> 00:03:47,740
Once more here.

39
00:03:51,650 --> 00:03:56,630
In the second pass, I equals one, this condition is going to be false for the first two elements in

40
00:03:56,630 --> 00:03:59,510
that row, but then it's going to be true for inducts to.

41
00:04:03,610 --> 00:04:07,270
And for the final row, the condition should be false through about.

