The Sheaf
type¶
The Sheaf
class derives from CellComplex
to describe its base space. The additional attributes and methods of Sheaf
describe the “vertical fiber” structure of the sheaf.
-
class
Sheaf
(CellComplex)¶ The base sheaf class in PySheaf consists of a list
cell
ofSheafCell
instances, describing the cells and the stalks over them. Restriction maps are built intoSheafCoface
instances that are stored with eachSheafCell
.-
coboundary
(k, compactSupport=False)¶ Compute the degree k coboundary map of the
Sheaf
, returning it as anumpy.ndarray
. If you want compactly supported cohomology (if you don’t know what that means, you don’t) then set compactSupport=True.
-
cohomology
(k, compactSupport=False)¶ Compute the degree k sheaf cohomology for the
Sheaf
. If you want compactly supported cohomology (if you don’t know what that means, you don’t) then set compactSupport=True. This returns anumpy.ndarray
whose columns are the generators for cohomology.
-
betti
(k)¶ The dimension of the degree k sheaf cohomology space.
Warning
This is not the dimension of the
CellComplex.homology()
, which is inherited intoSheaf
!
-
-
class
SheafCell
(Cell)¶ -
stalkDim
¶ The dimension of the stalk over this cell.
Warning
This has nothing to do with
SheafCell.dimension
inherited fromCell
.
-
metric
¶ The metric on the stalk, used to measure distances between values in that stalk. This must by a function object that takes two arguments, each of which is a
numpy.ndarray
and produces a numerical value. By default, it is the Euclidean distance given bynumpy.linalg.norm()
.
-
cofaces
¶ Like
Cell
, this should be a list of coface relations, but unlikeCell
, they must beSheafCoface
instances!
-
-
class
SheafCoface
(Coface)¶ A coface relation in a sheaf on a cell complex is built just like a
Coface
in aCellComplex
, but with the addition of arestriction
.-
restriction
¶ A restriction in a sheaf generally needs to be a morphism in some category. It must be an object that supports composition, namely a class that implements a multiplication operator. In most examples, this is one of
SetMorphism
(for functions between sets),LinearMorphism
(for linear maps), or aSheafMorphism
(for aSheaf
of sheaves). Note that if you construct aSheafCoface
by passing anumpy.ndarray
, PySheaf will construct aLinearMorphism
restriction automatically.
-
Morphisms: SetMorphism
, LinearMorphism
, and SheafMorphism
¶
Since cellular sheaves are special functors from the face category of a cell complex to some other data category, PySheaf supports three kinds of data categories:
- Sets,
- Finite dimensional vector spaces (via
numpy
), and - Sheaves (of some of other type).
The restrictions in a given SheafCoface
instance are therefore of a corresponding morphism class:
The simplest of these is SetMorphism
.
-
class
SetMorphism
¶ This represents a set morphism, otherwise known as a function between sets. This is implemented by a single attribute
-
fcn
¶
which is a function object taking one argument.
SetMorphism
objects support a multiplication operator, which composes their respectivefcn
attributes to form a new function object. They also support call semantics, so you can simply call aSetMorphism
object as a function to access itsfcn
attribute.-
Namely, if you say:
foo = pysheaf.SetMorphism( lambda x : x**2 )
bar = pysheaf.SetMorphism( lambda y : 3*y )
then:
foo(3)
returns 9 and:
baaz = foo * bar
baaz(1)
is also 9.
A Sheaf
with only SetMorphism
restrictions does not allow you to compute Sheaf.cohomology()
. For that, you need linearity, which is implemented by the following subclass of SetMorphism
.
-
class
LinearMorphism
(SetMorphism)¶ This implements a linear map, encoded as a
numpy.ndarray
. Since it subclassesSetMorphism
, it inherits composition (as multiplication, which is of course also matrix multiplication) and call semantics. It also stores the matrix as a new attribute-
matrix
¶
as you might expect.
-
When constructing a SheafCoface
, if you pass an numpy.ndarray
as the restriction argument, PySheaf will automatically create LinearMorphism
objects as the restriction.
The final kind of morphism that is supported is SheafMorphism
, which supports composition by implementing a multiplication operator, but not call semantics since sheaf morphisms are not functions. (It is true that they induce functions of various kinds, but PySheaf refrains from demanding that any particular kind of induced maps be computed by default.)
-
class
SheafMorphism
¶ A sheaf morphism from one sheaf to another consists of lists
destinations
andmaps
which correspond to theSheaf.cells
list in the domain sheaf.-
destinations
¶ List of indices into the codomain sheaf’s
Sheaf.cells
list for each component map of the sheaf morphism. Entries correspond to theSheaf.cells
list in the domain sheaf.
-
maps
¶ List of component maps (each of which may be any morphism class, like
SetMorphism
,LinearMorphism
, or evenSetMorphism
) corresponding to theSheaf.cells
list in the domain sheaf.
-
Constructing Sheaf
instances¶
Sheaf
objects are constructed in essentially the same way as CellComplex
objects. Determining the indices for the Sheaf.cells
list is crucial, as each SheafCoface.index
will refer into it. Changes to the base space – the inherited structure from CellComplex
– are not easy and will generally involve many updates. Additionally, each SheafCoface.restriction
ought to be known beforehand, though these can be changed at run time if needed.