Opened 10 years ago

Closed 10 years ago

#11625 closed enhancement (fixed)

speed up "remove_faces" for simplicial complexes

Reported by: jhpalmieri Owned by: jhpalmieri
Priority: minor Milestone: sage-5.0
Component: algebraic topology Keywords: simplicial remove_face
Cc: Merged in: sage-5.0.beta14
Authors: John Palmieri Reviewers: Mike Hansen
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

The attached patch, taken from a discussion on ask.sagemath.org, speeds up remove_face for large simplicial complexes. For smaller ones, it is comparable, perhaps a little slower, but the speed-up for large ones is significant.

Before the patch:

sage: S = range(1,8)
sage: timeit('Z = SimplicialComplex(S, [S]); Z.remove_face([1,2,3])')
625 loops, best of 3: 767 µs per loop

sage: timeit('SimplicialComplex(10,[[0,1,2,3,4,5,6],[1,2,3,4,5,6,7],[0,1,2,4,5,6,7],[0,1,2,3,5,6,7],[0,1,2,3,4,5,7]]).remove_face(Simplex([1,2,5]))')
5 loops, best of 3: 42.2 ms per loop

After the patch:

sage: S = range(1,8)
sage: timeit('Z = SimplicialComplex(S, [S]); Z.remove_face([1,2,3])')
625 loops, best of 3: 835 µs per loop

sage: timeit('SimplicialComplex(10,[[0,1,2,3,4,5,6],[1,2,3,4,5,6,7],[0,1,2,4,5,6,7],[0,1,2,3,5,6,7],[0,1,2,3,4,5,7]]).remove_face2(Simplex([1,2,5]))')
125 loops, best of 3: 1.79 ms per loop

The original idea (from ask.sagemath.org) is by "EmersonL", and John Palmieri modified it and wrote the actual patch.

Attachments (1)

trac_11625-remove-face.patch (6.2 KB) - added by jhpalmieri 10 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 10 years ago by jhpalmieri

  • Status changed from new to needs_review

Changed 10 years ago by jhpalmieri

comment:2 Changed 10 years ago by mhansen

  • Reviewers set to Mike Hansen
  • Status changed from needs_review to positive_review

Looks good to me.

comment:3 Changed 10 years ago by jdemeyer

  • Merged in set to sage-5.0.beta14
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.