appliedtopology / javaplex

Persistent Homology and Topological Data Analysis Library
BSD 3-Clause "New" or "Revised" License
193 stars 57 forks source link

Retrieving to many basis elements for homology #7

Closed PeterLeChuck closed 7 years ago

PeterLeChuck commented 9 years ago

The following program should return no 1-dim basis elements of homology. It works for cohomology.

public static void main(String[] args) {
    int prime=2;
    int d = 2;

    ExplicitSimplexStream stream = new ExplicitSimplexStream();
    stream.addVertex(0);
    stream.addVertex(1);
    stream.addVertex(2);
    int[][] edges = {{0,1},{1,2},{0,2}};
    for(int i = 0; i != edges.length; ++i){
        stream.addElement(edges[i]);
    }
    stream.addElement(new int[]{0,1,2});
    stream.finalizeStream();

    AbstractPersistenceBasisAlgorithm<Simplex, int[]> simplex_annotated_algorithm = new IntAbsoluteHomology(ModularIntField.getInstance(prime), Collections.reverseOrder(SimplexComparator.getInstance()), 0, d+1);
    AnnotatedBarcodeCollection<Double, int[]> annotated_intervals = simplex_annotated_algorithm.computeAnnotatedIntervals(stream);
    System.out.println("Homology basis for " + d + "-ball:");
    System.out.println(annotated_intervals);
}

Output: Homology basis for 2-ball: Dimension: 0 [0.0, infinity): [2] Dimension: 1 [0.0, infinity): [1,2] + [0,2] + [0,1]

michiexile commented 8 years ago

Why are you reversing the simplex comparator order? I'd expect this to compute some sort of relative homology the way it's setup. (see http://iopscience.iop.org/article/10.1088/0266-5611/27/12/124003/meta for why)

michiexile commented 7 years ago

No reaction after feedback. Closing.