Code Example
This is an example of adding a code example compiled with Literate.jl in the docs.
First we want to load our package with using
using CellularSheaves
using LinearAlgebra
Using the Package
Here is a simple example of creating a sheaf using the @cellular_sheaf
macro.
A = [1.0 0.0 1.0 0.0]
B = [1.0 0.0 0.0 1.0]
C = [1.0 0.0 0.0 0.0]
sheaf = @cellular_sheaf A, B, C begin
x::Stalk{4}, y::Stalk{4}, z::Stalk{4}
A(x) == B(y)
A(x) == C(z)
B(y) == C(z)
end
A network sheaf with 3 vertex stalks and 3 edge stalks.
Let's compute a global section of this sheaf. We start with a random 0-cochain:
x0 = rand(sum(vertex_stalks(sheaf)))
global_section = nearest_global_section(sheaf, x0)
3-blocked 12-element BlockVector{Float64}:
0.44580000522136615
0.4097909504750348
0.14401925806699073
0.8306461649657294
───────────────────
0.362111333313761
0.33024671280308004
0.947482906794697
0.22770792997459566
───────────────────
0.5898192632883568
0.2940774421495559
0.6314378706434358
0.2936964101982473
Now we can check that this is indeed a global section by verifying that the coboundary map applied to it is zero.
d = coboundary_map(sheaf)
norm(d * global_section)
2.7194799110210365e-16