Skip to main content

CellularSheaf

Struct CellularSheaf 

Source
pub struct CellularSheaf {
    pub n_nodes: usize,
    pub n_edges: usize,
    pub node_stalks: Vec<usize>,
    pub edge_stalks: Vec<usize>,
    pub edges: Vec<(usize, usize)>,
    pub restriction_maps: HashMap<(usize, usize), Vec<Vec<f64>>>,
}
Expand description

A cellular sheaf on an undirected graph.

A sheaf assigns:

  • A vector space ℝ^{d_v} to each vertex v (vertex stalk).
  • A vector space ℝ^{d_e} to each edge e (edge stalk).
  • Restriction maps F_{v ◁ e} : ℝ^{d_e} → ℝ^{d_v} for each vertex-edge incidence.

The coboundary operator δ : C^0 → C^1 and the resulting Hodge-0 sheaf Laplacian L = δ^T δ capture the sheaf’s cohomology.

Reference: Hansen & Ghrist (2019).

Fields§

§n_nodes: usize

Number of nodes

§n_edges: usize

Number of edges (oriented pairs (u,v) with u < v)

§node_stalks: Vec<usize>

Stalks at nodes: node_stalks[v] = dimension of the stalk at v

§edge_stalks: Vec<usize>

Stalks at edges: edge_stalks[e] = dimension of the stalk at edge e

§edges: Vec<(usize, usize)>

Oriented edge list: edges[e] = (tail, head) with tail < head

§restriction_maps: HashMap<(usize, usize), Vec<Vec<f64>>>

Restriction maps: maps[(v, e)] = the matrix F_{v◁e} : ℝ^{d_e} → ℝ^{d_v} stored row-major as Vec<Vec> of shape (d_v, d_e)

Implementations§

Source§

impl CellularSheaf

Source

pub fn trivial(n_nodes: usize, edges: Vec<(usize, usize)>) -> Result<Self>

Create a trivial sheaf on a graph where all stalks have dimension 1.

The restriction maps are initialised to the identity (or ±1 depending on orientation).

§Arguments
  • n_nodes – number of nodes
  • edges – oriented edge list (tail, head), both < n_nodes
Source

pub fn new( n_nodes: usize, node_dim: usize, edges: Vec<(usize, usize)>, edge_dim: usize, maps: HashMap<(usize, usize), Vec<Vec<f64>>>, ) -> Result<Self>

Create a sheaf with user-specified stalk dimensions and restriction maps.

node_dim and edge_dim give the stalk dimensions. maps is a map from (node_id, edge_id) to a matrix of shape (node_dim, edge_dim).

Source

pub fn set_restriction( &mut self, v: usize, e: usize, map: Vec<Vec<f64>>, ) -> Result<()>

Set the restriction map for vertex v and edge e.

The matrix map should have shape (stalk_dim[v], edge_stalk[e]).

Source

pub fn coboundary_operator(&self) -> Array2<f64>

Compute the coboundary matrix δ : C^0 → C^1.

The full coboundary operator has shape (sum_e d_e) × (sum_v d_v).

For a section x = (x_v)_{v}, the coboundary δ(x) at edge e = (u,v) is: δ(x)_e = F_{v◁e} x_v − F_{u◁e} x_u

Returns the matrix as Array2<f64>.

Source

pub fn hodge_laplacian_0(&self) -> Array2<f64>

Compute the Hodge-0 sheaf Laplacian L_0 = δ^T δ.

Shape: (sum_v d_v) × (sum_v d_v).

Source

pub fn cohomology_h0(&self) -> usize

Compute the dimension of the 0th sheaf cohomology H^0(G; F).

dim H^0 = dim ker(δ) = total_node_dim − rank(δ).

A dimension of 1 corresponds to a “consistent” global section (like a constant function on a constant sheaf).

Source

pub fn cohomology_h1(&self) -> usize

Compute the dimension of the 1st sheaf cohomology H^1(G; F).

dim H^1 = dim ker(δ^T) restricted to the image complement = total_edge_dim − rank(δ).

Trait Implementations§

Source§

impl Clone for CellularSheaf

Source§

fn clone(&self) -> CellularSheaf

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CellularSheaf

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V