Esempio n. 1
0
                                    restriction=np.matrix(1))
                 ]),
    ps.SheafCell(dimension=1, cofaces=[], stalkDim=1)
])
sec4 = ps.Section([ps.SectionCell(0, 1)])

# Extending along a line
if sec4.extend(sh2, 1) and sec4.extend(sh2, 2) and sec4.extend(sh2, 3):
    print[s.value for s in sec4.sectionCells]
    print "Test 2 passed"
else:
    print "Test 2 failed"

# Mayer-Vietoris example from tspbook
sh3 = ps.FlowSheaf(
    ps.DirectedGraph([(None, 0), (None, 0), (0, None), (0, 1), (None, 1),
                      (1, None)]))
sec5 = ps.Section([
    ps.SectionCell(0, 3),
    ps.SectionCell(1, 2),
    ps.SectionCell(2, 1),
    ps.SectionCell(4, 3),
    ps.SectionCell(5, 8)
])
sec6 = ps.Section([
    ps.SectionCell(0, 3),
    ps.SectionCell(1, 2),
    ps.SectionCell(2, 1),
    ps.SectionCell(4, 3),
    ps.SectionCell(5, 7)
])
Esempio n. 2
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))

    fs = ps.FlowSheaf(
        ps.DirectedGraph([(None, 1), (None, 1), (1, 2), (1, None), (None, 2),
                          (2, None)]))
    print 'Flow sheaf degree 0 Sheaf Betti number ' + str(fs.cobetti(0))

    fs2 = fs.star([6])
    print 'Flow sheaf degree 0 Sheaf Betti number ' + str(fs2.cobetti(0))

    fs3 = fs.star([7])
    print 'Flow sheaf degree 0 Sheaf Betti number ' + str(fs3.cobetti(0))

    print 'Dimension of local sections over a single edge ' + str(
        fs.localSectional([0])[0].cobetti(0))
    print 'Dimension of local sections over two edges ' + str(
        fs.localSectional([0, 1])[0].cobetti(0))
    print 'Dimension of local sections over three edges ' + str(
        fs.localSectional([0, 1, 2])[0].cobetti(0))
Esempio n. 3
0
# Sample persistence sheaf calculation
#
# Copyright (c) 2013-2014, Michael Robinson
# 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)