MyraMath
rcm


Source: tests/multifrontal/symbolic/rcm.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // Containers.
16 
17 // Algorithms.
21 
22 // Reporting.
23 #include <tests/myratest.h>
24 
25 // For std::max.
26 #include <algorithm>
27 
28 using namespace myra;
29 
30 namespace {
31 
32 // Helper function to compute the bandwidth of a Pattern.
33 int bandwidth(const Pattern& A)
34  {
35  int bw = 0;
36  for (auto aij = A.begin(); aij != A.end(); ++aij)
37  bw = std::max(bw, std::abs(aij.i()-aij.j()) );
38  return bw;
39  }
40 
41 }
42 
43 ADD_TEST("rcm","[symbolic]")
44  {
45  Pattern A = stencil2(100,10);
46  Permutation P = rcm(A);
47  Pattern B = permute(P,A);
48  int bandwidth_A = bandwidth(A);
49  int bandwidth_B = bandwidth(B);
50  myra::out() << "bandwidth(A) = " << bandwidth_A << std::endl;
51  myra::out() << "bandwidth(B) = " << bandwidth_B << std::endl;
52  REQUIRE(bandwidth_B < bandwidth_A);
53  }
Represents a Permutation matrix, used to reorder rows/columns/etc of various numeric containers...
Definition: Permutation.h:34
Definition: syntax.dox:1
Range/Iterator types associated with Pattern.
Given a SparseMatrix A and permutations P and Q, returns P&#39;*A*Q.
PatternIterator begin() const
Returns iterators over all of A(:,:)
Definition: Pattern.cpp:163
Holds the nonzero pattern of a sparse matrix.
Definition: Pattern.h:55
Container class for a sparse nonzero pattern, used in reordering/symbolic analysis.
Aggregates a (perm, iperm, swaps) triple into a vocabulary type.
Reverse Cuthill-Mckee ordering, tries to minimize bandwidth.
Helper routines for reordering/filling 2D structured grids. Used by many unit tests.
Interface class for representing subranges of contiguous int&#39;s.


Results: [PASS]

bandwidth(A) = 100
bandwidth(B) = 11


Go back to Summary of /test programs.