Cody

Problem 2585. How to reverse spdiags ?

Solution 2711913

Submitted on 19 Jul 2020 by Ramesh Kumar V
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))

m1 = 3 n1 = 5 m = 3 n = 3

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

m1 = 10 n1 = 1 p = 1 y = 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))

m1 = 2 n1 = 4 m = 2 n = 5

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

m1 = 9 n1 = 17 m = 9 n = 9

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

m1 = 5 n1 = 9 m = 5 n = 5

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

m1 = 10 n1 = 19 m = 10 n = 10 y = 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))

m1 = 5 n1 = 9 m = 5 n = 5

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

m1 = 2 n1 = 4 m = 2 n = 3

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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!