Cody

Solution 1941276

Submitted on 18 Sep 2019 by Augusto Mazzei
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
x = spdiags([1 2 3;4 5 6;7 8 9]); assert(isequal(spdiags(inv_spdiags(x)),x))

vec = 2 3 L = 3 x = 7 4 1 8 5 2 9 6 3 x = 1 2 3 4 5 6 7 8 9

2   Pass
b = spdiags(eye(10)); assert(isequal(spdiags(inv_spdiags(b)),b))

3   Pass
x = spdiags([1 2 3;4 5 6]); assert(isequal(spdiags(inv_spdiags(x)),x))

vec = 1 L = 3 x = 1 2 3 4 5 6

4   Pass
y = spdiags(magic(9)); assert(isequal(spdiags(inv_spdiags(y)),y))

vec = 2 3 4 5 6 7 8 9 L = 9 x = 37 36 26 16 6 77 67 57 47 48 38 28 27 17 7 78 68 58 59 49 39 29 19 18 8 79 69 70 60 50 40 30 20 10 9 80 81 71 61 51 41 31 21 11 1 2 73 72 62 52 42 32 22 12 13 3 74 64 63 53 43 33 23 24 14 4 75 65 55 54 44 34 35 25 15 5 76 66 56 46 45 x = 47 58 69 80 1 12 23 34 45 57 68 79 9 11 22 33 44 46 67 78 8 10 21 32 43 54 56 77 7 18 20 31 42 53 55 66 6 17 19 30 41 52 63 65 76 16 27 29 40 51 62 64 75 5 26 28 39 50 61 72 74 4 15 36 38 49 60 71 73 3 14 25 37 48 59 70 81 2 13 24 35

5   Pass
x = spdiags(magic(5)); assert(isequal(spdiags(inv_spdiags(x)),x))

vec = 2 3 4 5 L = 5 x = 11 10 4 23 17 18 12 6 5 24 25 19 13 7 1 2 21 20 14 8 9 3 22 16 15 x = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9

6   Pass
z = spdiags(ones(10)); assert(isequal(spdiags(inv_spdiags(z)),z))

vec = 2 3 4 5 6 7 8 9 10 L = 10 x = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 x = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

7   Pass
x = spdiags(randi(10,5)); assert(isequal(spdiags(inv_spdiags(x)),x))

vec = 2 3 4 5 L = 5 x = 6 2 6 10 4 6 1 7 1 1 6 2 1 3 6 4 9 8 3 6 9 10 1 6 4 x = 4 1 6 6 4 10 1 3 3 6 6 7 1 8 1 2 1 2 9 10 6 6 6 4 9

8   Pass
x = spdiags(randi(5,[3 2])); assert(isequal(spdiags(inv_spdiags(x)),x))

vec = 2 L = 3 x = 5 1 5 1 3 4 x = 5 4 1 3 5 1

9   Pass
a = spdiags(zeros(5)); assert(isequal(spdiags(inv_spdiags(a)),a))

m = 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