MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::sparse::ordering::detail Namespace Reference

Classes

struct  nd_rng
 splitmix64 (Steele, Lea & Flood 2014): fixed output for a fixed seed on every platform, unlike the std:: distributions. More...
struct  nd_graph
 A weighted undirected graph in CSR form, without self-loops; each edge is stored in both directions. More...
struct  nd_weights
 Part weights of a labelling. More...

Typedefs

using idx = std::ptrdiff_t

Functions

std::size_t tarjan_scc (const std::vector< std::vector< std::size_t > > &adj, std::vector< std::size_t > &comp)
 Iterative Tarjan SCC.
constexpr idx cs_flip (idx i)
constexpr idx cs_unflip (idx i)
idx mark_add (idx a, idx b)
idx cs_wclear (idx mark, idx lemax, std::vector< idx > &w, std::size_t n)
idx tdfs (idx j, idx k, std::vector< idx > &head, std::vector< idx > &next, std::vector< idx > &post, std::vector< idx > &stack)
std::vector< std::size_t > minimum_degree_core (std::size_t n, const std::vector< idx > &Cp_in, const std::vector< idx > &Ci_in, idx dense)
 Minimum-degree ordering on a prebuilt symmetric pattern C (no diagonal), given as integer CSC arrays: Cp_in (size n+1) and Ci_in (size Cp_in[n]).
idx dense_threshold (std::size_t n)
template<typename Value, typename Parameters>
void build_aplusat_pattern (const mat::compressed2D< Value, Parameters > &A, std::vector< idx > &Cp, std::vector< idx > &Ci)
 Build the symmetric pattern of A + A^T (no diagonal) as CSC integer arrays.
template<typename Value, typename Parameters>
void build_ata_pattern (const mat::compressed2D< Value, Parameters > &A, std::vector< idx > &Cp, std::vector< idx > &Ci)
 Build the column-intersection pattern (A^T*A, no diagonal) over the columns of A, dropping dense rows of A.
template<typename Value, typename Parameters>
std::vector< std::size_t > minimum_degree (int order, const mat::compressed2D< Value, Parameters > &A)
 order == 1 : AMD (A + A^T). order == 2 : COLAMD (A^T A, drop dense rows).
nd_graph nd_coarsen (const nd_graph &g, std::vector< idx > &cmap, nd_rng &rng, idx maxvwgt)
 One level of heavy-edge matching.
nd_weights nd_part_weights (const nd_graph &g, const std::vector< signed char > &where)
void nd_refine (const nd_graph &g, std::vector< signed char > &where, double balance, int max_passes=10)
 Vertex-separator Fiduccia-Mattheyses refinement of where, in place.
std::vector< signed char > nd_initial_separator (const nd_graph &g, double balance, nd_rng &rng, int trials=4)
 Initial separator on a (small) graph: for each of trials seeds, grow breadth-first regions of 1 - balance up to half the weight, take each region's boundary as a separator and refine it; keep the best.
void nd_thin_separator (const nd_graph &g, std::vector< signed char > &where)
 Move separator vertices that touch only one side to that side.
std::vector< signed char > multilevel_separator (const nd_graph &g, double balance, std::uint64_t seed, bool thin=true)
 Multilevel vertex separator of a connected graph.
std::vector< std::size_t > nested_dissection_core (std::size_t n, const std::vector< idx > &Cp, const std::vector< idx > &Ci, std::size_t cutoff, double balance, nd_separator method=nd_separator::level_structure)
 Nested dissection on a symmetric pattern without diagonal, given as integer CSC arrays (the A + A^T pattern build_aplusat_pattern produces).

Variables

constexpr signed char nd_part_a = 0
 Part labels.
constexpr signed char nd_part_b = 1
constexpr signed char nd_part_s = 2

Typedef Documentation

◆ idx

using mtl::sparse::ordering::detail::idx = std::ptrdiff_t

Function Documentation

◆ build_aplusat_pattern()

template<typename Value, typename Parameters>
void mtl::sparse::ordering::detail::build_aplusat_pattern ( const mat::compressed2D< Value, Parameters > & A,
std::vector< idx > & Cp,
std::vector< idx > & Ci )

Build the symmetric pattern of A + A^T (no diagonal) as CSC integer arrays.

For the symmetric case (CSR == CSC), this is the AMD input.

◆ build_ata_pattern()

template<typename Value, typename Parameters>
void mtl::sparse::ordering::detail::build_ata_pattern ( const mat::compressed2D< Value, Parameters > & A,
std::vector< idx > & Cp,
std::vector< idx > & Ci )

Build the column-intersection pattern (A^T*A, no diagonal) over the columns of A, dropping dense rows of A.

This is the COLAMD input.

◆ cs_flip()

idx mtl::sparse::ordering::detail::cs_flip ( idx i)
constexpr

◆ cs_unflip()

idx mtl::sparse::ordering::detail::cs_unflip ( idx i)
constexpr

◆ cs_wclear()

idx mtl::sparse::ordering::detail::cs_wclear ( idx mark,
idx lemax,
std::vector< idx > & w,
std::size_t n )
inline

◆ dense_threshold()

idx mtl::sparse::ordering::detail::dense_threshold ( std::size_t n)
inline

◆ mark_add()

idx mtl::sparse::ordering::detail::mark_add ( idx a,
idx b )
inline

◆ minimum_degree()

template<typename Value, typename Parameters>
std::vector< std::size_t > mtl::sparse::ordering::detail::minimum_degree ( int order,
const mat::compressed2D< Value, Parameters > & A )

order == 1 : AMD (A + A^T). order == 2 : COLAMD (A^T A, drop dense rows).

◆ minimum_degree_core()

std::vector< std::size_t > mtl::sparse::ordering::detail::minimum_degree_core ( std::size_t n,
const std::vector< idx > & Cp_in,
const std::vector< idx > & Ci_in,
idx dense )
inline

Minimum-degree ordering on a prebuilt symmetric pattern C (no diagonal), given as integer CSC arrays: Cp_in (size n+1) and Ci_in (size Cp_in[n]).

dense is the dense-node threshold. Returns permutation p with p[new]=old.

◆ multilevel_separator()

std::vector< signed char > mtl::sparse::ordering::detail::multilevel_separator ( const nd_graph & g,
double balance,
std::uint64_t seed,
bool thin = true )
inline

Multilevel vertex separator of a connected graph.

Returns where[v] in {nd_part_a, nd_part_b, nd_part_s}, with no edge between A and B. With thin false the final thinning is skipped, which leaves the refined separator, the one the balance bound applies to.

◆ nd_coarsen()

nd_graph mtl::sparse::ordering::detail::nd_coarsen ( const nd_graph & g,
std::vector< idx > & cmap,
nd_rng & rng,
idx maxvwgt )
inline

One level of heavy-edge matching.

Returns the coarse graph and fills cmap (fine vertex -> coarse vertex).

◆ nd_initial_separator()

std::vector< signed char > mtl::sparse::ordering::detail::nd_initial_separator ( const nd_graph & g,
double balance,
nd_rng & rng,
int trials = 4 )
inline

Initial separator on a (small) graph: for each of trials seeds, grow breadth-first regions of 1 - balance up to half the weight, take each region's boundary as a separator and refine it; keep the best.

◆ nd_part_weights()

nd_weights mtl::sparse::ordering::detail::nd_part_weights ( const nd_graph & g,
const std::vector< signed char > & where )
inline

◆ nd_refine()

void mtl::sparse::ordering::detail::nd_refine ( const nd_graph & g,
std::vector< signed char > & where,
double balance,
int max_passes = 10 )
inline

Vertex-separator Fiduccia-Mattheyses refinement of where, in place.

◆ nd_thin_separator()

void mtl::sparse::ordering::detail::nd_thin_separator ( const nd_graph & g,
std::vector< signed char > & where )
inline

Move separator vertices that touch only one side to that side.

Afterwards every separator vertex has a neighbour in A and a neighbour in B.

◆ nested_dissection_core()

std::vector< std::size_t > mtl::sparse::ordering::detail::nested_dissection_core ( std::size_t n,
const std::vector< idx > & Cp,
const std::vector< idx > & Ci,
std::size_t cutoff,
double balance,
nd_separator method = nd_separator::level_structure )
inline

Nested dissection on a symmetric pattern without diagonal, given as integer CSC arrays (the A + A^T pattern build_aplusat_pattern produces).

Returns perm with perm[new] = old.

◆ tarjan_scc()

std::size_t mtl::sparse::ordering::detail::tarjan_scc ( const std::vector< std::vector< std::size_t > > & adj,
std::vector< std::size_t > & comp )
inline

Iterative Tarjan SCC.

adj is the adjacency list of an n-node digraph. Fills comp[v] with the component id of v and returns the number of components. Component ids are assigned in reverse topological order: if there is an edge u -> v then comp[v] <= comp[u].

◆ tdfs()

idx mtl::sparse::ordering::detail::tdfs ( idx j,
idx k,
std::vector< idx > & head,
std::vector< idx > & next,
std::vector< idx > & post,
std::vector< idx > & stack )
inline

Variable Documentation

◆ nd_part_a

signed char mtl::sparse::ordering::detail::nd_part_a = 0
inlineconstexpr

Part labels.

◆ nd_part_b

signed char mtl::sparse::ordering::detail::nd_part_b = 1
inlineconstexpr

◆ nd_part_s

signed char mtl::sparse::ordering::detail::nd_part_s = 2
inlineconstexpr