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))
y =
1 2 3
4 5 6
7 8 9
tst =
1 2 3
4 5 6
7 8 9
|
2 | Pass |
b = spdiags(eye(10));
assert(isequal(spdiags(inv_spdiags(b)),b))
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
tst =
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))
y =
3 0
2 0
1 6
0 5
0 4
tst =
3 0
2 0
1 6
0 5
0 4
|
4 | Pass |
y = spdiags(magic(9));
assert(isequal(spdiags(inv_spdiags(y)),y))
y =
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
tst =
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))
y =
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
tst =
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))
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
tst =
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 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))
y =
1 3 6 2 9
9 9 5 2 1
3 10 9 1 10
2 8 6 8 5
5 2 7 1 10
tst =
1 3 6 2 9
9 9 5 2 1
3 10 9 1 10
2 8 6 8 5
5 2 7 1 10
|
8 | Pass |
x = spdiags(randi(5,[3 2]));
assert(isequal(spdiags(inv_spdiags(x)),x))
y =
3 4
1 5
1 1
tst =
3 4
1 5
1 1
|
9 | Pass |
a = spdiags(zeros(5));
assert(isequal(spdiags(inv_spdiags(a)),a))
|
Determine if a Given Number is a Triangle Number
322 Solvers
Project Euler: Problem 2, Sum of even Fibonacci
835 Solvers
Back to basics 11 - Max Integer
678 Solvers
Check if number exists in vector
4465 Solvers
Calculate the Number of Sign Changes in a Row Vector (No Element Is Zero)
225 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!