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

Namespaces

namespace  detail

Classes

struct  lu_symbolic_analysis
 Result of unsymmetric (column-etree) symbolic analysis. More...
struct  supernode_partition
 Partition of the columns of L into fundamental supernodes. More...

Functions

template<typename Value, typename SizeType>
std::vector< std::size_t > column_elimination_tree (const util::csc_matrix< Value, SizeType > &A)
 Column elimination tree of A: the elimination tree of A^T A, computed without forming the product (CSparse cs_etree with ata=1).
template<typename Value, typename Parameters>
std::vector< std::size_t > column_elimination_tree (const mat::compressed2D< Value, Parameters > &A)
 CSR overload: convert to CSC and compute the column elimination tree.
template<typename Value, typename SizeType>
std::vector< std::size_t > column_counts_ata (const util::csc_matrix< Value, SizeType > &A, const std::vector< std::size_t > &parent, const std::vector< std::size_t > &post)
 Column counts of the Cholesky factor of A^T A given the column elimination tree parent and its postorder post, computed without forming A^T A (CSparse cs_counts with ata=1).
void column_supernodes (const std::vector< std::size_t > &parent, const std::vector< std::size_t > &col_counts, std::size_t n, std::size_t &nsuper, std::vector< std::size_t > &super, std::vector< std::size_t > &sn_first)
 Detect column-etree supernodes: maximal runs of consecutive columns where each column is the only child of the next in the column etree and the counts nest (col_counts[j] == col_counts[j+1] + 1) – the unsymmetric analogue of the fundamental supernodes from #178.
template<typename Value, typename Parameters>
lu_symbolic_analysis analyze_unsymmetric (const mat::compressed2D< Value, Parameters > &A)
 Full unsymmetric symbolic analysis on a square matrix already in the desired column order (apply a fill-reducing column ordering, e.g.
template<typename Value, typename SizeType>
std::vector< std::size_t > elimination_tree (const util::csc_matrix< Value, SizeType > &A)
 Compute the elimination tree of a symmetric matrix given in CSC format.
template<typename Value, typename Parameters>
std::vector< std::size_t > elimination_tree (const mat::compressed2D< Value, Parameters > &A)
 Overload: compute elimination tree from a CSR compressed2D matrix.
template<typename Value, typename SizeType>
std::vector< std::size_t > column_counts (const util::csc_matrix< Value, SizeType > &A, const std::vector< std::size_t > &parent)
 Compute the column counts of the Cholesky factor L using the elimination tree.
std::size_t total_nnz (const std::vector< std::size_t > &col_counts)
 Count the total predicted nonzeros in L given column counts.
std::vector< std::size_t > tree_postorder (const std::vector< std::size_t > &parent)
 Compute a depth-first postorder of the elimination tree.
std::vector< std::size_t > inverse_postorder (const std::vector< std::size_t > &post)
 Given a postorder, return the inverse postorder mapping: inv_post[node] = position of node in the postorder.
template<typename Value, typename SizeType>
void symbolic_cholesky_pattern (const util::csc_matrix< Value, SizeType > &C, const std::vector< std::size_t > &parent, std::vector< std::size_t > &col_ptr, std::vector< std::size_t > &row_ind)
 Compute the column-wise nonzero pattern of the Cholesky factor L.
template<typename Value, typename SizeType>
supernode_partition find_supernodes (const util::csc_matrix< Value, SizeType > &C, const std::vector< std::size_t > &parent, std::size_t relax=0)
 Detect fundamental supernodes of a symmetric matrix C (CSC, both triangles) with elimination tree parent, both in postordered space.

Variables

constexpr std::size_t no_parent = std::numeric_limits<std::size_t>::max()
 Sentinel value indicating no parent (root of the elimination tree).

Function Documentation

◆ analyze_unsymmetric()

template<typename Value, typename Parameters>
lu_symbolic_analysis mtl::sparse::analysis::analyze_unsymmetric ( const mat::compressed2D< Value, Parameters > & A)
inline

Full unsymmetric symbolic analysis on a square matrix already in the desired column order (apply a fill-reducing column ordering, e.g.

COLAMD, beforehand and pass the permuted matrix). Computes the column elimination tree, its postorder, the chol(A^T A) column counts, the supernode partition, and the static L/U fill upper bound.

◆ column_counts()

template<typename Value, typename SizeType>
std::vector< std::size_t > mtl::sparse::analysis::column_counts ( const util::csc_matrix< Value, SizeType > & A,
const std::vector< std::size_t > & parent )

Compute the column counts of the Cholesky factor L using the elimination tree.

col_counts[j] = number of nonzeros in column j of L (including the diagonal). Uses the "skeleton matrix" approach with the etree.

Reference: Gilbert, Ng, Peyton, "An efficient algorithm to compute row and column counts for sparse Cholesky factorization".

◆ column_counts_ata()

template<typename Value, typename SizeType>
std::vector< std::size_t > mtl::sparse::analysis::column_counts_ata ( const util::csc_matrix< Value, SizeType > & A,
const std::vector< std::size_t > & parent,
const std::vector< std::size_t > & post )
inline

Column counts of the Cholesky factor of A^T A given the column elimination tree parent and its postorder post, computed without forming A^T A (CSparse cs_counts with ata=1).

counts[j] = nnz in column j of chol(A^T A) including the diagonal – the static upper bound on column j of L (and of U^T) for PA = LU under any partial-pivoting permutation P.

◆ column_elimination_tree() [1/2]

template<typename Value, typename Parameters>
std::vector< std::size_t > mtl::sparse::analysis::column_elimination_tree ( const mat::compressed2D< Value, Parameters > & A)
inline

CSR overload: convert to CSC and compute the column elimination tree.

◆ column_elimination_tree() [2/2]

template<typename Value, typename SizeType>
std::vector< std::size_t > mtl::sparse::analysis::column_elimination_tree ( const util::csc_matrix< Value, SizeType > & A)
inline

Column elimination tree of A: the elimination tree of A^T A, computed without forming the product (CSparse cs_etree with ata=1).

parent[j] is the parent of column j in that tree, or no_parent if j is a root.

◆ column_supernodes()

void mtl::sparse::analysis::column_supernodes ( const std::vector< std::size_t > & parent,
const std::vector< std::size_t > & col_counts,
std::size_t n,
std::size_t & nsuper,
std::vector< std::size_t > & super,
std::vector< std::size_t > & sn_first )
inline

Detect column-etree supernodes: maximal runs of consecutive columns where each column is the only child of the next in the column etree and the counts nest (col_counts[j] == col_counts[j+1] + 1) – the unsymmetric analogue of the fundamental supernodes from #178.

Requires the columns to be in a postorder of the column etree so a supernode's columns are contiguous.

◆ elimination_tree() [1/2]

template<typename Value, typename Parameters>
std::vector< std::size_t > mtl::sparse::analysis::elimination_tree ( const mat::compressed2D< Value, Parameters > & A)

Overload: compute elimination tree from a CSR compressed2D matrix.

Converts to CSC internally (symmetric matrices are their own transpose).

◆ elimination_tree() [2/2]

template<typename Value, typename SizeType>
std::vector< std::size_t > mtl::sparse::analysis::elimination_tree ( const util::csc_matrix< Value, SizeType > & A)

Compute the elimination tree of a symmetric matrix given in CSC format.

Only the upper triangular part is accessed. Returns parent vector where parent[j] = first subdiagonal nonzero row in column j of L, or no_parent if j is a root.

Algorithm: Liu's O(nnz) algorithm using path compression (union-find). Reference: CSparse cs_etree.

◆ find_supernodes()

template<typename Value, typename SizeType>
supernode_partition mtl::sparse::analysis::find_supernodes ( const util::csc_matrix< Value, SizeType > & C,
const std::vector< std::size_t > & parent,
std::size_t relax = 0 )
inline

Detect fundamental supernodes of a symmetric matrix C (CSC, both triangles) with elimination tree parent, both in postordered space.

Columns j and j+1 join the same supernode iff j is the only child of j+1 in the elimination tree and the column counts satisfy col_counts[j] == col_counts[j+1] + 1 (i.e. identical off-diagonal structure). This yields fundamental supernodes; the relax parameter (relaxed amalgamation) is reserved for a later milestone and currently only relax == 0 is honored.

◆ inverse_postorder()

std::vector< std::size_t > mtl::sparse::analysis::inverse_postorder ( const std::vector< std::size_t > & post)
inline

Given a postorder, return the inverse postorder mapping: inv_post[node] = position of node in the postorder.

◆ symbolic_cholesky_pattern()

template<typename Value, typename SizeType>
void mtl::sparse::analysis::symbolic_cholesky_pattern ( const util::csc_matrix< Value, SizeType > & C,
const std::vector< std::size_t > & parent,
std::vector< std::size_t > & col_ptr,
std::vector< std::size_t > & row_ind )
inline

Compute the column-wise nonzero pattern of the Cholesky factor L.

C is a symmetric matrix in CSC format (both triangles present) and parent is its elimination tree. Returns the pattern as (col_ptr, row_ind): for each column j, the sorted row indices i >= j with L(i,j) != 0 (diagonal included).

Standard symbolic Cholesky: the nonzero columns of row k of L are the etree paths from each i <= k with C(i,k) != 0, up to k (CSparse cs_ereach). We walk those paths and append row k to each visited column's list; processing rows in increasing k keeps every column list sorted ascending with the diagonal first.

◆ total_nnz()

std::size_t mtl::sparse::analysis::total_nnz ( const std::vector< std::size_t > & col_counts)
inline

Count the total predicted nonzeros in L given column counts.

◆ tree_postorder()

std::vector< std::size_t > mtl::sparse::analysis::tree_postorder ( const std::vector< std::size_t > & parent)
inline

Compute a depth-first postorder of the elimination tree.

Returns a permutation vector post where post[k] = node visited at step k. The postorder ensures that for every node j, all descendants of j appear before j in the ordering.

Variable Documentation

◆ no_parent

std::size_t mtl::sparse::analysis::no_parent = std::numeric_limits<std::size_t>::max()
inlineconstexpr

Sentinel value indicating no parent (root of the elimination tree).