Cody

# Problem 1812. Tridiagonal

Solution 2044889

Submitted on 4 Dec 2019 by Asif Newaz
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
a = 1; b = 2; c = 3; n = 5; y_correct = [ 2 3 0 0 0; 1 2 3 0 0; 0 1 2 3 0; 0 0 1 2 3; 0 0 0 1 2]; assert(isequal(tridiag(a, b, c, n),y_correct))

T = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 2 2 2 2 2 c = 3 3 3 3 a = 1 1 1 1 T1 = 2 0 0 0 0 0 2 0 0 0 0 0 2 0 0 0 0 0 2 0 0 0 0 0 2 T2 = 0 3 0 0 0 0 0 3 0 0 0 0 0 3 0 0 0 0 0 3 0 0 0 0 0 T3 = 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 T = 2 3 0 0 0 1 2 3 0 0 0 1 2 3 0 0 0 1 2 3 0 0 0 1 2

2   Pass
a = 9; b = 5; c = -17; n = 3; y_correct = [ 5 -17 0 ; 9 5 -17 ; 0 9 5 ]; assert(isequal(tridiag(a, b, c, n),y_correct))

T = 0 0 0 0 0 0 0 0 0 b = 5 5 5 c = -17 -17 a = 9 9 T1 = 5 0 0 0 5 0 0 0 5 T2 = 0 -17 0 0 0 -17 0 0 0 T3 = 0 0 0 9 0 0 0 9 0 T = 5 -17 0 9 5 -17 0 9 5

3   Pass
a = 4; b = -1; c = 8; n = 4; y_correct = [-1 8 0 0; 4 -1 8 0; 0 4 -1 8; 0 0 4 -1]; assert(isequal(tridiag(a, b, c, n),y_correct))

T = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = -1 -1 -1 -1 c = 8 8 8 a = 4 4 4 T1 = -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 T2 = 0 8 0 0 0 0 8 0 0 0 0 8 0 0 0 0 T3 = 0 0 0 0 4 0 0 0 0 4 0 0 0 0 4 0 T = -1 8 0 0 4 -1 8 0 0 4 -1 8 0 0 4 -1

4   Pass
a = 11; b = 21; c = 30; n = 5; y_correct = [21 30 0 0 0; 11 21 30 0 0; 0 11 21 30 0; 0 0 11 21 30; 0 0 0 11 21]; assert(isequal(tridiag(a, b, c, n),y_correct))

T = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 b = 21 21 21 21 21 c = 30 30 30 30 a = 11 11 11 11 T1 = 21 0 0 0 0 0 21 0 0 0 0 0 21 0 0 0 0 0 21 0 0 0 0 0 21 T2 = 0 30 0 0 0 0 0 30 0 0 0 0 0 30 0 0 0 0 0 30 0 0 0 0 0 T3 = 0 0 0 0 0 11 0 0 0 0 0 11 0 0 0 0 0 11 0 0 0 0 0 11 0 T = 21 30 0 0 0 11 21 30 0 0 0 11 21 30 0 0 0 11 21 30 0 0 0 11 21