# Reference

## Simplicial Complexes

### Construction

`Hodge.SimplicialComplex`

— Type`SimplicialComplex`

Represent an abstract simplicial complex where all vertices are labeled by integers.

Internally, use the `SimplexTrees.SimplexTree`

data structure.

`Base.insert!`

— Method`insert!(sc::SimplicialComplex, σ)`

Insert the simplex `σ`

and all its faces on the `SimplicialComplex`

`sc`

.

The simplex does not need to be ordered.

`Hodge.skeleton`

— Function`skeleton(sc, k)`

Return the k-skeleton of a `SimplicialComplex`

. That is, a SimplicialComplex with the same simplices as `sc`

up to dimension `k`

.

### Accessing

`Hodge.dimension`

— Function`dimension(sc)`

Return the dimension of the largest simplex on a `SimplicialComplex`

.

`Hodge.hassimplex`

— Function`hassimplex(sc, σ)`

Test whether the `SimplicialComplex`

`sc`

contains the simplex `σ`

.

`Hodge.vertices`

— Function`vertices(sc)`

Return an array containg the vertices of the `SimplicialComplex`

`sc`

.

See also `simplices`

. Notice that this function returns an array of integers while `simplices(sc, 0)`

returns an array of singleton arrays containing the vertices.

`Hodge.numvertices`

— Function`numvertices(sc)`

Return how many vertices (1-simplices) the `SimplicialComplex`

`sc`

has.

`Hodge.simplices`

— Function`simplices(sc[, k])`

Return all simplices of the `SimplicialComplex`

`sc`

whose dimension equals `k`

.

If the parameter `k`

is not given, return **all** simplices of `sc`

including the empty face.

`Hodge.numsimplices`

— Function`numsimplices(sc[, k])`

Return the number of k-dimensional simplices of `sc`

.

If the parameter `k`

is not given, return the total number of simplices including the empty face.

This function is a more efficient implementation of `length ∘ simplices`

.

### Topological Operators

`Hodge.euler_characteristic`

— Function`euler_characteristic(K)`

Return the Euler characteristic of a `SimplicialComplex`

.

`Hodge.betti`

— Function`betti(K)`

Return the Betti numbers of a `SimplicialComplex`

.

## Cochains

### Construction

`Hodge.Cochain`

— Type`Cochain{R, n}`

Represent the `n`

-th group $C^n(K; R)$ of cochains over the ring `R`

whose basespace is the simplicial complex $K$.

For constructing Cochains, see also the methods `zero_cochain`

and `indicator_cochain`

.

The elements of this type may be seem as functions from the n-simplices of `K`

to `R`

or as skew-symmetric n-tensors over the vertices of `K`

. This second perspective follows the ideas from the paper:

- Jiang, X., Lim, L., Yao, Y. et al. Statistical ranking and combinatorial Hodge theory. Math. Program. 127, 203–244 (2011). https://doi.org/10.1007/s10107-010-0419-x

`Hodge.zero_cochain`

— Function`zero_cochain(R, K, n)`

Construct an identically zero `n`

-cochain over `R`

and whose base space is `K`

.

`Hodge.indicator_cochain`

— Function`indicator_cochain(R, K, σ)`

Return the indicator function `f`

of the n-simplex `σ`

as a `Cochain`

. That is, a cochain such that `f(σ) = 1`

and `f(τ) = 0`

for all other n-simplices of `K`

.

Notice that, nevertheless, `f`

is still skew-symmetric over permutations of `σ`

s indices.

If `Κ`

does not contain `σ`

, the returned cochain is identically zero.

### Operators

`Hodge.basespace`

— Function`basespace(ω::Cochain)`

Return the simplicial complex that `ω`

is associated with.

`Hodge.basering`

— Function`basering(ω::Cochain)`

Return the Ring that `ω`

is defined over.

`Hodge.degree`

— Function`degree(ω::Cochain)`

Return the degree of a `Cochain`

.

`Hodge.norm`

— Function`norm(ω[, p])`

Calculate the p-norm of the `Cochain`

`ω`

.

By default, `p=2`

.

Return a floating point, no matter the base ring of `ω`

.

`Hodge.norm2`

— Function`norm2(ω)`

Calculate the square of the usual inner product norm of a `Cochain`

`ω`

.

`Hodge.inner`

— Function`inner(ω, ξ)`

Usual inner product between `Cochain`

s.

For complex Cochains, the conjugation is taken on the **first** entry.

This inner product sees a n-cochain as a free vector space over the (non-oriented) n-simplices of their base space. Formally,

\[\sum_{\sigma \in \mathrm{simplices}(K,n)} \overline{f(σ)} g(σ).\]

`Hodge.cup`

— Function`cup(ω, ξ)`

The cup product $\omega \smile \xi$ of two `Cochain`

s.

`Hodge.coboundary`

— Function`coboundary(ω)`

The coboundary or **discrete exterior derivative** of a `Cochain`

.

The coboundary of $ω$ applied to a simplex $σ$ equals the alternating sum of $ω$ applied to the faces of $σ$.

`Hodge.coboundary_adj`

— Function`coboundary_adj(ω)`

The adjoint of the `coboundary`

with respect to usual inner product.

`Hodge.laplacian`

— Function`laplacian(ω)`

The (higher-order) laplacian of `ω`

, defined as

\[ \delta = d d^* + d^* d\]

where $d$ and $d^*$ are, respectively, the `coboundary`

and `coboundary_adj`

operators.

`Hodge.hodge`

— Function`hodge(ω)`

Hodge decomposition of a `Cochain`

using `inner`

as the inner product.

Return a tuple `(α,β,γ)`

such that

```
ω == coboundary(α) + coboundary_adj(β) + γ
laplacian(γ) == 0
```