permaviss.persistence_algebra.PH_classic

PH_classic.py

This module implements a function which computes bases for the image and kernel of morphisms between persistence modules.

Functions

persistent_homology(D, R, max_rad, p) Given the differentials of a filtered simplicial complex X, we compute its homology.
permaviss.persistence_algebra.PH_classic._pivot(l)[source]

Compute pivot of a list of integers.

Parameters:l (list(int)) –
Returns:index – Index of last nonzero entry. Returns -1 if the list is zero.
Return type:int
permaviss.persistence_algebra.PH_classic.persistent_homology(D, R, max_rad, p)[source]

Given the differentials of a filtered simplicial complex X, we compute its homology.

In this function, the domain is on the columns and the range on the rows. Coordinates are stored as columns in an array. Barcode ranges are stored as pairs in an array of two columns.

Parameters:
  • D (list(Numpy Array)) – The ith entry stores the ith differential of the simplicial complex.
  • R (list(int)) – The ith entry contains the radii of filtration for the ith skeleton of X. For example, the 1st entry contains, in order, the radii of each edge in X. In dimension 0 we have an empty list.
  • p (int(prime)) – Chosen prime to perform arithmetic mod p.
Returns:

  • Hom (list(barcode_bases)) – The i entry contains the i Persistent Homology classes for X. These are stored as barcode_bases. If a cycle does not die we put max_rad as death radius. Additionally, each entry is ordered according to the standard barcode order.
  • Im (list(barcode_bases)) – The i entry contains the image of the i+1 differential as barcode_bases.
  • PreIm (list(Numpy Array (len(R[*]), Im[*].dim)) – Preimage matrices, ‘how to go back from boundaries’

Example

>>> from permaviss.sample_point_clouds.examples import circle
>>> from permaviss.simplicial_complexes.differentials import
... complex_differentials
>>> from permaviss.simplicial_complexes.vietoris_rips import
... vietoris_rips
>>> import scipy.spatial.distance as dist
>>> point_cloud = circle(10, 1)
>>> max_rad = 1
>>> p = 5
>>> max_dim = 3
>>> Dist = dist.squareform(dist.pdist(point_cloud))
>>> compx, R = vietoris_rips(Dist, max_rad, max_dim)
>>> differentials = complex_differentials(compx, p)
>>> Hom, Im, PreIm = persistent_homology(differentials, R, max_rad, p)
>>> print(Hom[0])
Barcode basis
[[ 0.          1.        ]
 [ 0.          0.61803399]
 [ 0.          0.61803399]
 [ 0.          0.61803399]
 [ 0.          0.61803399]
 [ 0.          0.61803399]
 [ 0.          0.61803399]
 [ 0.          0.61803399]
 [ 0.          0.61803399]
 [ 0.          0.61803399]]
[[ 1.  1.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  4.  1.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  4.  1.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  4.  1.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  4.  0.  0.  1.  0.  0.]
 [ 0.  0.  0.  0.  0.  1.  0.  4.  0.  0.]
 [ 0.  0.  0.  0.  0.  4.  0.  0.  1.  0.]
 [ 0.  0.  0.  0.  0.  0.  1.  0.  4.  0.]
 [ 0.  0.  0.  0.  0.  0.  4.  0.  0.  1.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.  4.]]
>>> print(Hom[1])
Barcode basis
[[ 0.61803399  1.        ]]
[[ 4.]
 [ 4.]
 [ 4.]
 [ 4.]
 [ 4.]
 [ 4.]
 [ 4.]
 [ 4.]
 [ 4.]
 [ 1.]]
>>> print(Im[0])
Barcode basis
[[ 0.61803399  1.        ]
 [ 0.61803399  1.        ]
 [ 0.61803399  1.        ]
 [ 0.61803399  1.        ]
 [ 0.61803399  1.        ]
 [ 0.61803399  1.        ]
 [ 0.61803399  1.        ]
 [ 0.61803399  1.        ]
 [ 0.61803399  1.        ]]
[[ 1.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 4.  1.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  4.  1.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  4.  1.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  4.  0.  0.  1.  0.  0.]
 [ 0.  0.  0.  0.  1.  0.  4.  0.  0.]
 [ 0.  0.  0.  0.  4.  0.  0.  1.  0.]
 [ 0.  0.  0.  0.  0.  1.  0.  4.  0.]
 [ 0.  0.  0.  0.  0.  4.  0.  0.  1.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  4.]]
>>> print(Im[1])
Barcode basis
[]
>>> print(PreIm[0])
[]
>>> print(PreIm[1])
[[ 1.  0.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  1.  0.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  1.  0.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  1.  0.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  1.  0.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  1.  0.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  1.  0.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  1.  0.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  1.]
 [ 0.  0.  0.  0.  0.  0.  0.  0.  0.]]