Cody

# Problem 2585. How to reverse spdiags ?

Solution 1941266

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

Unrecognized function or variable 'ruoto'. Error in inv_spdiags (line 11) if ruoto Error in Test1 (line 2) assert(isequal(spdiags(inv_spdiags(x)),x))

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

Unrecognized function or variable 'ruoto'. Error in inv_spdiags (line 11) if ruoto 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))

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

Assertion failed.

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

Unrecognized function or variable 'ruoto'. Error in inv_spdiags (line 11) if ruoto Error in Test4 (line 2) assert(isequal(spdiags(inv_spdiags(y)),y))

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

Unrecognized function or variable 'ruoto'. Error in inv_spdiags (line 11) if ruoto Error in Test5 (line 2) assert(isequal(spdiags(inv_spdiags(x)),x))

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

Unrecognized function or variable 'ruoto'. Error in inv_spdiags (line 11) if ruoto Error in Test6 (line 2) assert(isequal(spdiags(inv_spdiags(z)),z))

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

Unrecognized function or variable 'ruoto'. Error in inv_spdiags (line 11) if ruoto Error in Test7 (line 2) assert(isequal(spdiags(inv_spdiags(x)),x))

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

Unrecognized function or variable 'ruoto'. Error in inv_spdiags (line 11) if ruoto 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))

Array indices must be positive integers or logical values. Error in inv_spdiags (line 3) if x(end)==0 Error in Test9 (line 2) assert(isequal(spdiags(inv_spdiags(a)),a))