Skip to main content

holos_tda/relative_interface/
model.rs

1use crate::Diagram;
2use crate::certificate::ChangeColumn;
3
4/// One nonzero term in a filtered cellular boundary.
5#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
6pub struct InterfaceChainTerm {
7    /// Labeled vertices of the boundary cell.
8    pub cell: Vec<usize>,
9    /// Coefficient in `1..modulus`.
10    pub coefficient: u32,
11}
12
13/// One labeled cell in a filtered relative interface.
14#[derive(Debug, Clone, PartialEq)]
15pub struct InterfaceCell {
16    /// Labeled vertices in ascending order.
17    pub vertices: Vec<usize>,
18    /// Filtration value of this cell.
19    pub value: f64,
20    /// Sparse cellular boundary in ascending cell order.
21    pub boundary: Vec<InterfaceChainTerm>,
22}
23
24impl InterfaceCell {
25    /// Dimension of this cell.
26    pub fn dimension(&self) -> usize {
27        self.vertices.len() - 1
28    }
29}
30
31/// One checked equal-filtration unit cancellation.
32#[derive(Debug, Clone, PartialEq, Eq)]
33pub struct InterfaceCancellation {
34    /// Higher-dimensional cell removed by this step.
35    pub upper: Vec<usize>,
36    /// Codimension-one cell removed by this step.
37    pub lower: Vec<usize>,
38    /// Incidence coefficient before the cancellation.
39    pub coefficient: u32,
40}
41
42/// Exact size and work of one relative interface certificate.
43#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
44pub struct RelativeInterfaceWork {
45    /// Cells before relative cancellation.
46    pub input_cells: usize,
47    /// Equal-filtration unit pairs removed.
48    pub cancellations: usize,
49    /// Cells in the retained core.
50    pub core_cells: usize,
51    /// Sparse additions used to reduce the retained core.
52    pub reduction_additions: usize,
53}
54
55/// A filtered chain core relative to protected vertices.
56///
57/// The record includes its input chain complex, cancellation trace, retained
58/// core, and one `D V = R` reduction per boundary dimension.
59#[derive(Debug, Clone)]
60pub struct RelativeInterfaceCertificate {
61    pub(super) max_dim: usize,
62    pub(super) modulus: u32,
63    pub(super) protected_vertices: Vec<usize>,
64    pub(super) input_cells: Vec<Vec<InterfaceCell>>,
65    pub(super) cancellations: Vec<InterfaceCancellation>,
66    pub(super) core_cells: Vec<Vec<InterfaceCell>>,
67    pub(super) columns: Vec<Vec<ChangeColumn>>,
68    pub(super) diagram: Diagram,
69    pub(super) digest: [u8; 32],
70    pub(super) work: RelativeInterfaceWork,
71}