Skip to content

Class Hierarchy Plan

Mikael Vejdemo-Johansson edited this page Feb 25, 2024 · 5 revisions

Here, we will plan out the class hierarchy intended for porting JavaPlex to TDA4j.

Conventions for type parameters

We will consistently use the following choices of type parameters:

  • VertexT is the type of the vertices of a simplex. Typically Int, but does not need to be. Should be totally ordered.
  • FiltrationT is the type of the filtration value of a filtered simplex. Typically Double or Real, but does not need to be. Should be totally ordered.
  • CoefficientT is the type of the field coefficients of the chain modules. Typically some sort of finite field, or maybe Double. We may need to fiddle around with good (fast) implementations of finite field arithmetic here.

Core classes (for algebra and generation)

classDiagram


%% AbstractSimplex and Simplex implement (and type alias) a basic Simplex type
Simplex --|> AbstractSimplex~VertexT~ : VertexT=Int
AbstractSimplex~VertexT~ ..|> Cell~VertexT~
AbstractSimplex~VertexT~ ..|> SortedSet~VertexT~

Cell : +Chain~VertexT,FieldT~ boundary()

%% FilteredSimplex adds support for a filtration value and an ordering based on it
FilteredSimplex~VertexT,FiltrationT~ --|> AbstractSimplex~VertexT~
FilteredSimplex : +FiltrationT filterValue F

VietorisRips~VertexT,FiltrationT~ ..|> Stream~FilteredSimplex[VertexT,FiltrationT]~
AlphaComplex~VertexT,FiltrationT~ ..|> Stream~FilteredSimplex[VertexT,FiltrationT]~

%% Chain represents a linear combination of cells of some kind
%% QUESTION: Do we want a Cell interface that AbstractSimplex implements?
Chain~Cell[VertexT],FieldT <: Rational~ ..|> Map~Cell[VertexT],FieldT~
Chain~Cell[VertexT],FieldT <: Rational~ ..|> Integral

FieldT ..|> Rational
Loading

Some Scala-notes on the class hierarchy that are difficult to represent in the Mermaid diagram DSL:

  • VertexT : Ordering - VertexT needs to have an associated (implicit) Ordering[V].
  • FieldT <: Field - FieldT takes things that look like a field (as defined by the Field trait)
  • ExplicitStream in JavaPlex can probably be dropped, with instructions for a user to simply write their own instance of Stream[FilteredSimplex[VertexT,FiltrationT]] to take its place.

Recall that:

  • A ring is an algebraic structure that admits +, -, * (and has a 0 and a 1)
  • A field is a ring that also admits / (except for the operation x/0 which is still forbidden)
  • A module is an abelian group (ie admits + and - and has a 0) that also has a scalar multiplication wrt some specific ring.
  • A vector space is a module where the scalars form a field.

We expect our coefficients FieldT to come from a field (ring is not enough), and we will produce a module as our persistence space (strictly speaking over the polynomial ring K[t], or one of several almost equivalent formalisms in common use).

Persistence algorithm implementations

classDiagram
%% Persistence holds methods for running the computation
class Persistence~VertexT,FiltrationT,FieldT~
<<Interface>> Persistence
Persistence : +Barcode[FiltrationT] computeBarcode(Stream[FilteredSimplex[VertexT,FiltrationT]])
Persistence : +RepresentativeBarcode[VertexT,FiltrationT,FieldT] computeRepresentativeBarcode(Stream[FilteredSimplex[VertexT,FiltrationT]])

class AbsolutePersistence~VertexT,FiltrationT,FieldT~
class RelativePersistence~VertexT,FiltrationT,FieldT~

AbsolutePersistence ..|> Persistence
RelativePersistence ..|> Persistence
Loading

Matlab accessibility convenience functionality

classDiagram
class API
API : +Stream[FilteredSimplex[Int,Double]] VietorisRips(double[][] pointcloud)
API : +Stream[FilteredSimplex[Int,Double]] AlphaComplex(double[][] pointcloud)
API : +Stream[FilteredSimplex[Int,Double]] createEmptyStream()
API : +Stream[FilteredSimplex[Int,Double]] addSimplexToStream(stream, int[] vertices, double filtrationValue)
API : +AbsolutePersistence[Int,Double,Field2] AbsoluteBooleanPersistence
API : +RelativePersistence[Int,Double,Field2] RelativeBooleanPersistence
API : +AbsolutePersistence[Int,Double,Fieldp] AbsoluteModularPersistence(Int prime)
API : +RelativePersistence[Int,Double,Fieldp] RelativeModularPersistence(Int prime)
Loading