Cody

Solution 1941254

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

L = 3 m = 0 2 3 0 5 6 0 8 9 0 2 3 0 5 6 0 8 9

Assertion failed.

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

L = 1

Index in position 2 exceeds array bounds (must not exceed 1). Error in inv_spdiags (line 11) m(vec(i),1:L) = x(vec(i),i+(1:L)); Error in Test2 (line 2) assert(isequal(spdiags(inv_spdiags(b)),b))

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

Index exceeds the number of array elements (1). Error in inv_spdiags (line 8) L = length(find(x(vec(1)-(vec(2)-vec(1)),:))) Error in Test3 (line 2) assert(isequal(spdiags(inv_spdiags(x)),x))

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

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

Assertion failed.

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

L = 5 m = 0 24 1 8 15 0 5 7 14 16 0 6 13 20 22 0 12 19 21 3 0 18 25 2 9 0 24 1 8 15 0 5 7 14 16 0 6 13 20 22 0 12 19 21 3 0 18 25 2 9

Assertion failed.

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

L = 10 m = 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1

Assertion failed.

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

L = 5 m = 0 4 6 7 1 0 8 5 8 5 0 6 1 3 3 0 10 6 7 5 0 2 8 1 3 0 4 6 7 1 0 8 5 8 5 0 6 1 3 3 0 10 6 7 5 0 2 8 1 3

Assertion failed.

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

Index exceeds the number of array elements (1). Error in inv_spdiags (line 8) L = length(find(x(vec(1)-(vec(2)-vec(1)),:))) Error in Test8 (line 2) assert(isequal(spdiags(inv_spdiags(x)),x))

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

Index exceeds the number of array elements (0). Error in inv_spdiags (line 3) if x(1) Error in Test9 (line 2) assert(isequal(spdiags(inv_spdiags(a)),a))