Cody

Solution 501430

Submitted on 15 Sep 2014 by J.R.! Menzinger
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))

ans = 1 2 3 4 5 6 7 8 9

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

ans = 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1

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

ans = 3 0 2 0 1 6 0 5 0 4

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

ans = 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))

ans = 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))

ans = 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))

ans = 2 1 1 7 1 4 2 5 4 3 6 2 9 10 6 6 9 4 2 5 1 7 4 3 9

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

ans = 5 4 2 4 5 3

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

ans = [] ans = 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

Suggested Problems

More from this Author45