Perseus

Persistent homology over Q, together with every prime p for which coefficients in Fp give a different answer, and a proof that the list is complete. Or simply over the field of your choice, quickly. And, beyond barcodes, homology over Z.

What Perseus 6 does, and what is new in 6.1

Perseus 6 is a complete rewrite, ten years after Perseus 4. It offers:

  • Rational barcodes with a proof. One run gives you the barcode over Q and all bad primes: the primes p for which the Fp barcode is different. For each bad prime it tells you exactly which intervals change. The rational computation is exact, so the certificate is a proof, and on typical data it costs little more than computing over a single prime field.
  • General inputs. Vietoris–Rips filtrations of point clouds and distance matrices, clique filtrations of weighted graphs, cubical complexes (images and volumes, including periodic ones, straight from numpy), simplicial complexes, simplicial sets, and filtered chain complexes over Z.
  • Integral answers. Homology over Z of filtered complexes, images of H*(Ks; Z) → H*(Kt; Z), and the torsion of H*(Kt; Z) at every step of a filtration; magnitude homology of graphs; chain complexes over Z[t, t−1]; homology and cohomology rings of finite groups.
  • Speed. On 2D images it is faster than GUDHI's dedicated image algorithm; on volumes and 4D grids it is 2–3× faster than Cubical Ripser and 5–15× faster than GUDHI; for Vietoris–Rips in degree 2 and up it is usually much faster than Ripser and than edge collapse followed by Ripser; for group homology it is often hundreds of times faster than HAP. See performance, including where other tools win.
For example, take 1024 points sampled from O(3), which is two copies of SO(3) ≅ RP3. Perseus proves that 2 is the only bad prime:
  • over Q, two H1 intervals, one in each copy, die at 1.288 and 1.307;
  • over F2, those two intervals live forever, and two H2 intervals are born at exactly those times.
This is the Z/2 in H1(RP3; Z), detected and located in the filtration.

New in 6.1

  • The default certificate is always a proof. In 6.0 the default fell back to random primes when 64-bit integers overflowed; now exact big rationals take over where needed, and they are fast enough that this costs little. Random primes run only on request (--mode fast), clearly labelled as not a proof.
  • New engines for cubical complexes: a planar engine for 2D images (6.5–26× faster than 6.0 in our tests) and a discrete-gradient engine for 3D and 4D grids (2–4× faster than 6.0, with less memory).
  • New inputs and integral outputs: torsion along filtrations (--torsion), integral homology and images (--integral, --image), simplicial sets, nerves and bar constructions, magnitude homology, Laurent coefficients, and finite groups.
  • Getting-started examples for every input, as shell scripts and Python scripts with their data (below).
  • Disconnected Vietoris–Rips filtrations are split into their components, reduced in parallel, also for the certified rational barcode: 8,192 points of O(3) through H3 take 2.2 s instead of 6.4 s, in half the memory.
  • Writing output files is about 8× faster, with byte-for-byte the same files.

The full list is in the changelog. Everything 6.0 computed, 6.1 computes identically, except that --mode auto now proves its answer.

Download, install, compile

The current version is 6.1.0. Download the executable for your operating system, install the Python module, or compile from source.

The executables are command-line programs: run them from a terminal. On macOS you may need to allow the downloaded file under System Settings → Privacy & Security, and make it executable with chmod +x. perseus --version prints the version. To compile from source, you need a C++17 compiler with 128-bit integers: g++ 9+ or clang 10+ (on Windows, MinGW-w64; Microsoft's compiler lacks 128-bit integers).

make                                              # builds ./perseus
make test                                         # optional: differential tests
make examples                                     # optional: runs every example
cd python && pip install --no-build-isolation .   # optional: Python module

The Python module needs pybind11 and numpy; the tests use Ripser as an oracle if it is installed.

Bug reports and feature requests are welcome on the issue tracker, or by email with “Perseus” in the subject line.

Getting started: examples

The examples/ directory of the source has nine short examples, each as a shell script for the command line and as a Python script, with their input files. Each runs in a second or two and explains what it prints.

topicshows
01point cloudsVietoris–Rips of points or distances; long and short intervals; output files
02bad primesthe barcode over Q, every bad prime, and which intervals change: a Moore space, RP2, a point cloud on RP2
03images and volumesnumpy arrays and text grids; sub- and superlevel sets; periodic axes; absent pixels
04your own filtrationa lower-star filtration on a triangulated torus; clique filtrations of weighted graphs
05integral homologyH*(K; Z), images of maps, the torsion along a random 2-complex
06simplicial setsRP2 with three simplices; nerves of categories; classifying spaces
07magnitude homologygraphs, with torsion
08Laurent coefficientsthe trefoil's Alexander polynomial
09finite groupsgroup homology, cohomology rings, persistence along a series of groups
sh examples/cli/01_point_cloud.sh                 # with perseus on your PATH (or PERSEUS=./perseus sh ...)
python3 examples/python/01_point_cloud.py         # with the Python module installed

Basic usage

perseus <format> <input file> [<output prefix>] [options]

Some examples:

perseus points cloud.txt --maxdim 2             # Rips over Q, with the bad primes
perseus points cloud.txt --maxdim 2 --coeff 3   # only the barcode over F_3
perseus distance dist.csv --maxdim 1 --fp 2,3   # over Q, plus F_2 and F_3
perseus npy image.npy --periodic 0              # an image, periodic in axis 0
perseus simplices complex.txt out               # writes out_k.txt, out_betti.txt, out_cert.json
perseus simplices complex.txt --torsion         # and the torsion of H_q(K_t; Z) at every t
perseus cells complex.txt --integral --image 0,1   # H_*(K; Z) and the image of H_*(K_0; Z) -> H_*(K_1; Z)

A summary of the certificate is printed to stderr, for example:

Q barcode: proved (exact arithmetic: int64)
bad primes: 2  (2 non-unit pivots)
optionmeaning
--coeff Q|pcoefficients: Q (default) or a prime p
--fp p,q,…also compute the barcodes over these prime fields
--maxdim dhighest homological degree (default 1 for Rips and flag, the top dimension otherwise)
--threshold rRips: ignore edges longer than r (default: the enclosing radius)
--periodic 0,2cubical: make these axes periodic
--mode proved|fasthow the rational barcode is certified: exact arithmetic, a proof (default; auto is the same), or random primes with a bounded probability of error, not a proof; see below
--target t, --seed sfast mode: aim for an error probability below 2−t (default 64); reproduce a run from its reported seed (a reproduced run is not certified)
--no-classifylist the candidate primes without settling them
--classify-by auto|sweep|rerunexplicit complexes: settle small candidate primes by batched sweeps or by one rerun each (default: whichever a timed sample predicts is cheaper)
--integral, --image s,t, --torsionexplicit complexes: integral homology, images of maps, torsion along the filtration (below)
--engine eRips/flag: auto, implicit or sparse; cubical: auto, planar, morse, classic or explicit
--collapse auto|on|full|offRips: iterated edge collapse before the reduction
--threads nthreads for settling candidate primes and independent components (default: all cores)
--print ripser|perseus|json|nonewhat to print on the screen
--statstimings and engine statistics

perseus --help lists every option, including those of the magnitude, Laurent and finite-group inputs.

Coefficients, bad primes and certificates

Over Z, persistence modules do not decompose into intervals, so there is no integral barcode. Perseus reports the next best thing:

  • the barcode over Q, and
  • the set of bad primes: those p for which the barcode over Fp (same filtration, degrees 0 to maxdim) differs from the one over Q. For each bad prime you get the intervals that appear only over Fp and those that appear only over Q.

Precisely, p is bad in degree q exactly when some relative homology group Hq(Kj, Ki; Z) or Hq−1(Ki; Z) of the filtration has p-torsion (a refinement of a theorem of Obayashi and Yoshiwaki, proved in docs/CERTIFICATE.md). So the bad primes record where the filtration carries integral torsion, and every other prime gives the rational answer. For filtrations of planar complexes, such as 2D images without periodic axes, there is never any torsion, so there are no bad primes; Perseus proves this without arithmetic, since the boundary matrices involved are totally unimodular.

How the certificate works

  1. The rational reduction. A prime that divides no pivot value of the reduction over Q cannot change the barcode. These pivot values are invariants of the filtered complex: ratios of minors of the boundary matrix.
  2. Exact arithmetic. By default the reduction over Q is exact: 64-bit numerators and denominators with every operation checked for overflow, and big rationals in a degree where they overflow, as happens with heavy torsion. The barcode and the pivot values are exact, so the certificate is a proof. With --mode fast, Perseus reduces modulo a few primes drawn at random from [261, 262) instead, and reports a bound on the probability of error that holds for every input (below 2−64 by default); that is not a proof, and every output says so.
  3. Candidates. The prime factors of the pivot values are the candidates. Each is settled by a run modulo that prime, in parallel; on explicit complexes, many small candidates can be settled at once by one sweep modulo their product.
  4. Numbers too hard to factor. A pivot value that resists factoring does not leave a gap. One run modulo the number N itself either splits N, or proves that all prime factors of N behave identically. The certificate then states the answer for all of them at once, for example "every prime factor of N is bad".

The output says what is guaranteed, and whether the description of the bad primes is complete. The mathematics, with proofs, is in docs/CERTIFICATE.md.

Input formats

formatcontents
pointsone point per line, coordinates separated by spaces or commas (Euclidean Vietoris–Rips)
distancea full symmetric distance matrix
lower-distancethe strictly lower triangle of a distance matrix, row by row (as in Ripser); inf means no edge
bin32, bin64the lower triangle in binary, float32 or float64 (Ripser's binary format)
flagthe clique filtration of a weighted graph. Lines u v birth are edges and lines v birth give vertices their births (default 0). Labels can be any words. An edge may not be born before its endpoints.
cubicala cubical grid of top-cell values: a line with the sizes, then the values in numpy's (C) order; nan marks an absent cell
npya numpy array file of top-cell values (any real or integer type, C or Fortran order), for images and volumes
cubesa sparse cubical complex: one top cube per line, its integer corner coordinates, then its birth
simplicesone simplex per line: vertex labels, then its birth (any real number). Faces that are not listed are added, born with their earliest coface.
cellsa filtered chain complex over Z: one cell per line, dim birth face coeff face coeff …, where faces are the (0-based) line numbers of earlier cells and coefficients are integers. For example, the Moore space M(Z/12, 1):
0 0
1 1
2 2 1 12
sseta finite filtered simplicial set: one nondegenerate simplex per line, dim birth d_0 … d_dim; a face is an earlier line y, or y@k1.k2… for the degenerate simplex sk1sk2… y
laurenta filtered chain complex over Z[t, t−1]: one cell per line, dim birth face:polynomial …, e.g. 2 0 1:t^2-t+1 2:-1+t^-1
magnitudea graph, one edge u v per line (vertices 0, 1, …), for magnitude homology
pcgroup, sylow, pcseriesfinite groups, written from GAP by the exporters in tools/: a solvable group with a polycyclic generating sequence; any finite group through its Sylow subgroups; a chain of homomorphisms

Lines starting with # are comments. There is an example of every format in examples/data/.

Understanding the output

  • prefix_k.txt holds the intervals in degree k, one per line as birth death. A death of −1 means the class never dies. This is the same format as Perseus 4, so persdia.m still plots it.
  • prefix_betti.txt holds the Betti numbers at every filtration value where they change.
  • prefix_cert.json (over Q) contains:
    • the barcode, the certificate mode and "proof" (true when everything is proved);
    • the bad primes with their differing intervals, and whether that list is complete;
    • the exact values of all non-unit pivots;
    • with --integral, --image or --torsion, the integral results (their text forms go to stderr).
    An entry marked every_prime_factor_of applies to every prime factor of the number given.
  • Without a prefix, intervals are printed to the screen in Ripser's style. Values are printed exactly: the shortest decimal that reads back as the same number.
  • Intervals of length zero are not reported (--zero-length keeps them for explicit complexes).

Beyond barcodes

Integral homology, images and torsion

For explicit complexes (simplices, cells, sset) Perseus computes exactly, over Z: the homology of the whole complex with its torsion (--integral); the image of H*(Ks; Z) → H*(Kt; Z) (--image s,t); and the torsion subgroup of Hq(Kt; Z) at every value t where it changes, with its invariant factors (--torsion). Nothing is sampled. On a random 2-complex on 40 vertices (examples/data/lm40.txt):

$ perseus simplices lm40.txt --torsion --print none
bad primes: 3 5 13  (36 non-unit pivots)
torsion of H_1(K_t; Z), where it changes:
  t = 661: Z/5
  t = 666: Z/975
  t = 667: Z/5
  t = 671: 0

Simplicial sets, nerves and classifying spaces

Finite filtered simplicial sets (normalised chains), with faces that may be degenerate: RP2 needs one simplex in each dimension. In Python, also nerves of finite categories, weighted so that they are filtered, and bar constructions BM of finite monoids and groups.

Magnitude homology

MHk,l(G; Z) of a graph, directed or not, with its torsion, for lengths up to --lmax; --pairs restricts to chosen endpoints. On the graphs where both finish, it agrees with gramag (which computes ranks over F2) and is 7–9× faster on inputs with more than 100,000 generators.

Laurent coefficients

Chain complexes over Z[t, t−1]: infinite cyclic covers, Alexander modules, Novikov homology. Perseus gives the barcode over Q(t) (which counts Novikov Betti numbers), the irreducible polynomials and the primes for which the residue fields give a different barcode, and the homology over Q[t, t−1] and over Fp[t, t−1] where it differs from the rational answer.

Finite groups

For a finite solvable group given by a polycyclic presentation (pcgroup), Hn(G; Z) exactly and the mod-p cohomology ring (dimensions, minimal generators, cup products), through Anick's resolution rather than the bar construction. Any finite group goes through its Sylow subgroups (sylow), and a chain of homomorphisms gives the induced maps on mod-p homology and their persistence (pcseries; for normal series these are Ellis and King's persistence matrices). The GAP exporters in tools/ write the inputs:

gap> Read("tools/export_sylow.g"); WritePerseusSylow(MathieuGroup(11), "m11.txt");
$ perseus sylow m11.txt --maxdim 8 --ring 2

Python

import numpy as np, perseus
r = perseus.rips(points=X, maxdim=2)               # or distances=D
r["barcode"][1]                                    # H1 as an (m, 2) array
r["certificate"]["proof"]                          # True: proved
perseus.bad_primes(r)                              # e.g. [2]
r["certificate"]["bad_primes"][2]["only_over_Fp"]  # what changes over F_2
perseus.cubical(image, periodic=[True, False])     # NaN = absent cell
perseus.flag([(0, 1, 0.5), (1, 2, 0.7)], vertex_births=[0, 0, 0.2])
perseus.simplices([((0, 1, 2), 1.0), ((1, 2, 3), 2.5)], torsion=True)
perseus.cells([(0, 0.0, []), (1, 1.0, []), (2, 2.0, [(1, 12)])], integral=True)
perseus.simplicial_set([(0, 0, []), (1, 0, [0, 0]), (2, 1, [1, (0, [0]), 1])], integral=True)   # RP^2
perseus.magnitude(edges, lmax=6)
perseus.laurent([(0, 0, []), (1, 0, [(0, "t - 1")])])
perseus.pc_group(**perseus.read_pcgroup("g.txt"), maxdim=8, ring=2)
perseus.rips(points=X, maxdim=2, coeff=2)          # just F_2

Intervals come as numpy arrays, with death inf for classes that never die. Every function takes the options of the command line (coeff, mode, fp, threads, …). The examples cover every function.

Performance

All timings are wall clock on a 2-core 2.1 GHz Xeon. Every answer in the comparisons below agrees exactly with the other tool's. The scripts that produce them are in bench/ in the source, and the README has the complete tables.

Images (F2)

imagePerseus 6.1GUDHI 3.13Cubical Ripser
photograph, 512²9.8 ms / 40 MB13.1 ms / 147 MB64.1 ms / 101 MB
smoothed noise, 4096²0.23 s / 253 MB0.55 s / 499 MB8.54 s / 3.0 GB
white noise, 4096²1.60 s / 451 MB1.88 s / 682 MB10.1 s / 3.0 GB
white noise, 8192²7.51 s / 1.6 GB9.85 s / 2.3 GBout of memory

The planar engine is 1.2–2.4× faster than GUDHI's image algorithm, with 27–73% less memory. Over Q it costs nothing extra.

Volumes and 4D grids (F2)

casePerseus 6.1Cubical RipserGUDHI 3.13
smoothed noise, 192³3.41 s / 764 MB10.7 s / 800 MB52.8 s / 2.7 GB
white noise, 192³11.1 s / 1.0 GB26.4 s / 1.7 GB98.4 s / 3.4 GB
smoothed noise, 48⁴7.35 s / 923 MB18.8 s / 1.2 GB88.0 s / 4.0 GB
white noise, 48⁴37.5 s / 1.6 GBout of memory above 6 GB436 s / 5.2 GB

Vietoris–Rips (F2)

casePerseus 6.1edge collapse + RipserRipserRedZeD
4096 points on O(3), H≤30.32 s1.48 s51.2 s31.4 s
1024 points on O(3), H≤30.06 s0.22 s2.66 s0.96 s
50 random points in R16, H≤7< 0.01 s0.03 s8.10 s6.19 s
fractal (512 points), H≤20.03 s0.63 s7.78 s1.82 s
sphere (192 points), H≤20.47 s1.66 s0.96 s0.24 s
dragon (2000 points), H≤10.60 s23.0 s1.93 s0.18 s

Measured 25 Nov 2026; every barcode agrees. Perseus and Ripser are timed on the command line, including start-up and reading the file; RedZeD, which is a Python package, is timed in-process with the distances already in memory. RedZeD is faster through H1 and on the small sphere. From degree 2 up on the larger inputs Perseus is 12–100× faster than RedZeD and 44–260× faster than Ripser. O(3) is two components at these thresholds, which Perseus reduces in parallel. For sparse point clouds Perseus builds the radius graph directly: 8,000 points in the unit cube at r = 0.047 take a few hundredths of a second through H2, on a par with GUDHI.

What the certificate costs

caseF2 onlyQ, all bad primes, provedbad primes
1024 points on O(3), H≤30.06 s0.08 s2
4096 points on O(3), H≤30.32 s0.38 s2
RP2 (600 points), H≤211.5 s19.2 s2
Linial–Meshulam complex, 70 vertices0.07 s4.3 s7 primes
Linial–Meshulam complex, 90 vertices0.15 s94 s6 primes, one of 117 bits

On geometric data a proof costs little beyond F2. Random 2-complexes near the threshold where their homology vanishes carry enormous torsion, and settling the hundreds of candidate primes their pivots produce takes most of the time; the default exact run never falls back to random primes.

Finite groups, against HAP

grouptaskPerseus (with GAP export)HAP 1.62
SmallGroup(64, 138)Hn(G; Z), n ≤ 80.23 s101 s
SmallGroup(128, 2000)Hn(G; Z), n ≤ 60.47 s32.3 s
M12mod-2 cohomology ring, degrees ≤ 60.80 s162 s
PSL(3, 4)Hn(G; Z), n ≤ 60.53 s81.6 s
SmallGroup(128, 1000)mod-2 cohomology ring, degrees ≤ 80.19 sover 300 s

Perseus's times include writing the input from GAP. For small groups that export is most of the time, and HAP is about as fast.

Old Perseus files

Perseus 6 does not read the Perseus 4/5 input formats (cubtop, scubtop, simtop, nmfsimtop, cellcomp, distmat, corrmat, rips, brips) directly. Instead, convert them:

python3 tools/convert_legacy.py cubtop old.txt new.txt
# prints the matching command, e.g.:  perseus cubical new.txt --coeff 2 --periodic 1

The converter reproduces the old semantics exactly, and the test suite checks converted files against the Perseus 5 executable. The printed command uses --coeff 2, because Perseus 4 and 5 computed over F2; drop it to get the rational barcode and its bad primes. Other changes from the old programs:

  • Birth times can be any real numbers; the old restriction to positive integers is gone.
  • output_betti.txt lists Betti numbers at every value where they change.
  • For Rips-type files, the old programs reported spurious infinite intervals in their top degree. The converter caps --maxdim just below it.
  • The compiler problems with Clang and recent gcc are gone.

Older versions remain available: Linux, macOS, Windows, source (Perseus 4 beta). The old example files are still here: cubgrid.txt, scubtop.txt, simtop.txt, nmfst.txt, brips.txt, rips.txt, distmat.txt.

How it works, and credits

Perseus combines many published ideas with some of its own:

  • persistent cohomology with clearing (de Silva–Morozov–Vejdemo-Johansson; Chen–Kerber);
  • Ripser's implicit coboundaries and apparent pairs (Bauer);
  • edge collapse (Boissonnat–Pritam; Glisse–Pritam) and active enumeration for H1 (Kapulkin–Kershaw's RedZeD);
  • filtered discrete Morse theory (Mischaikow–Nanda, the engine of Perseus 4 and 5, back in the cubical gradient engine), with the discrete gradients of grey-scale images (Robins–Wood–Sheppard) and union-find on critical cells (Guillou–Vidal–Tierny);
  • the dual-then-primal union-finds of GUDHI's image algorithm (Glisse), for the planar engine, and implicit cubical persistence (Kaji–Sudo–Ahara's Cubical Ripser);
  • bit-tree working columns (PHAT);
  • multi-field persistence (Boissonnat–Maria), the torsion characterisation of field dependence (Obayashi–Yoshiwaki), and interval decompositions over a PID (Luo–Henselman-Petrusek);
  • multi-modular computer algebra (rational reconstruction after Wang), integer factoring (Pollard–Brent) and Howell forms;
  • Anick resolutions as Morse complexes of rewriting systems (Anick; Brown; Sköldberg; Jöllenbeck–Welker), with G. Ellis's HAP and the Green–King database of cohomology rings as ground truth.

What is new is, above all, the certificate: an exact rational reduction and the classification of every candidate prime, including those that cannot be factored, with a theorem identifying the bad primes with the torsion of relative homology. A full catalogue, saying what is new and what is not, is in docs/TECHNIQUES.md, and the proofs behind the certificate are in docs/CERTIFICATE.md.

Licence and citing

Perseus 6 is released under the MIT licence. The software comes with no warranty.

If Perseus helps your research, please cite the software with the version you used. Every release has its own DOI on Zenodo, linked from its release page; for version 6.0.0:

Vidit Nanda. Perseus, the Persistent Homology Software, version 6.0.0. doi:10.5281/zenodo.24305983.

For results obtained with Perseus 4 or 5, whose engine is discrete Morse theory, please also cite this paper:

Konstantin Mischaikow and Vidit Nanda. Morse Theory for Filtrations and Efficient Computation of Persistent Homology. Discrete & Computational Geometry, 50(2): 330–353, September 2013.

And finally, the parts of the world where Perseus 4 was downloaded:

World map highlighting places where Perseus has been downloaded