|
1 | 1 | namespace CSparse.Tests.Ordering |
2 | 2 | { |
| 3 | + using CSparse.Double; |
3 | 4 | using CSparse.Ordering; |
| 5 | + using CSparse.Storage; |
4 | 6 | using NUnit.Framework; |
5 | 7 | using System; |
6 | 8 |
|
@@ -33,5 +35,46 @@ public void TestGenerate2() |
33 | 35 |
|
34 | 36 | Assert.That(dm.StructuralRank == n, Is.True); |
35 | 37 | } |
| 38 | + |
| 39 | + [Test] |
| 40 | + public void TestGenerate3() |
| 41 | + { |
| 42 | + var A = SparseMatrix.OfRowMajor(8, 8, |
| 43 | + [ |
| 44 | + 11, 12, 0, 0, 0, 0, 0, 0, |
| 45 | + 0, 22, 23, 0, 25, 26, 0, 0, |
| 46 | + 0, 0, 33, 34, 0, 0, 37, 0, |
| 47 | + 0, 0, 43, 44, 0, 0, 0, 48, |
| 48 | + 51, 0, 0, 0, 55, 56, 0, 0, |
| 49 | + 0, 0, 0, 0, 0, 66, 67, 0, |
| 50 | + 0, 0, 0, 0, 0, 76, 77, 0, |
| 51 | + 0, 0, 0, 84, 0, 0, 87, 88 |
| 52 | + ]); |
| 53 | + |
| 54 | + var S = SymbolicColumnStorage.Create(A); |
| 55 | + |
| 56 | + var dm = DulmageMendelsohn.Generate(S, 1); |
| 57 | + |
| 58 | + Assert.That(dm.StructuralRank, Is.EqualTo(8)); |
| 59 | + Assert.That(dm.Blocks, Is.EqualTo(3)); |
| 60 | + |
| 61 | + int[] expected = [0, 1, 4, 2, 3, 7, 5, 6]; |
| 62 | + |
| 63 | + Assert.That(dm.RowPermutation, Is.EqualTo(expected).AsCollection); |
| 64 | + Assert.That(dm.ColumnPermutation, Is.EqualTo(expected).AsCollection); |
| 65 | + |
| 66 | + expected = [0, 3, 6, 8]; |
| 67 | + |
| 68 | + Assert.That(dm.BlockRowPointers, Is.EqualTo(expected).AsCollection); |
| 69 | + Assert.That(dm.BlockColumnPointers, Is.EqualTo(expected).AsCollection); |
| 70 | + |
| 71 | + expected = [0, 0, 8, 8, 8]; |
| 72 | + |
| 73 | + Assert.That(dm.CoarseRowDecomposition, Is.EqualTo(expected).AsCollection); |
| 74 | + |
| 75 | + expected = [0, 0, 0, 8, 8]; |
| 76 | + |
| 77 | + Assert.That(dm.CoarseColumnDecomposition, Is.EqualTo(expected).AsCollection); |
| 78 | + } |
36 | 79 | } |
37 | 80 | } |
0 commit comments