Esempio n. 1
0
                             maps=[ps.LinearMorphism(np.matrix([1, 1]))]),
        ps.SheafMorphismCell(destinations=[1],
                             maps=[ps.LinearMorphism(np.matrix(1))]),
        ps.SheafMorphismCell(destinations=[2],
                             maps=[ps.LinearMorphism(np.matrix(1))])
    ])

    print 'degree 0 induced map Collapsed->Line: ' + str(
        ps.inducedMap(ColLoopSheaf, LineSheaf, MorColLine, 0))
    print 'degree 1 induced map Collapsed->Line: ' + str(
        ps.inducedMap(ColLoopSheaf, LineSheaf, MorColLine, 1))
    print 'degree 2 induced map Collapsed->Line: ' + str(
        ps.inducedMap(ColLoopSheaf, LineSheaf, MorColLine, 2))

    PerSheaf0 = ps.PersistenceSheaf([ColLoopSheaf, LineSheaf, LoopSheaf],
                                    [(0, 1, MorColLine),
                                     (0, 2, MorColLoop)], 0)

    print '0-Persistent degree 0 Sheaf Betti number ' + str(
        PerSheaf0.cobetti(0))
    print '0-Persistent degree 1 Sheaf Betti number ' + str(
        PerSheaf0.cobetti(1))

    PerSheaf1 = ps.PersistenceSheaf([ColLoopSheaf, LineSheaf, LoopSheaf],
                                    [(0, 1, MorColLine),
                                     (0, 2, MorColLoop)], 1)

    print '1-Persistent degree 0 Sheaf Betti number ' + str(
        PerSheaf1.cobetti(0))
    print '1-Persistent degree 1 Sheaf Betti number ' + str(
        PerSheaf1.cobetti(1))
Esempio n. 2
0
# Distribution of unaltered copies permitted for noncommercial use only
# All other uses require express permission of the author
# This software comes with no warrantees express or implied 

import numpy as np
import pysheaf as ps

if __name__ == '__main__':
    targ1=ps.DirectedGraph([(None,1),(1,2),(2,None),(None,3),(3,4),(4,None)])
    fs1=ps.FlowSheaf(targ1)
    targ2=ps.DirectedGraph([(None,1),(None,1),(1,2),(2,None),(2,None)])
    targ3=ps.DirectedGraph([(None,1),(None,1),(1,2),(2,None)])
    
    map1=[(0,0),(1,2),(2,3),(3,1),(4,2),(5,4),(6,5),(7,6),(8,5),(9,6)]
    map2=[(0,0),(1,1),(2,2),(3,3),(4,3),(5,4)]
    
    print 'Ready to compute!'

    pf1,pf1m=fs1.pushForward(targ2,map1)
    print 'pushforward FS 1 induced map ' + str(ps.inducedMap(pf1,fs1,pf1m,0))
    fs2,fsm2=pf1.flowCollapse()
    print 'collapse 1 induced map ' + str(ps.inducedMap(pf1,fs2,fsm2,0))
    pf2,pf2m=fs2.pushForward(targ3,map2)
    print 'pushforward FS 2 induced map ' + str(ps.inducedMap(pf2,fs2,pf2m,0))
    fs3,fsm3=pf2.flowCollapse()
    print 'collapse 2 induced map ' + str(ps.inducedMap(pf2,fs3,fsm3,0))

    persh=ps.PersistenceSheaf([fs1,pf1,fs2,pf2,fs3],[(1,0,pf1m),(1,2,fsm2),(3,2,pf2m),(3,4,fsm3)],0)
    
    print 'Persistence Sheaf Betti 0=' + str(persh.cobetti(0))