#19078: Finite posets: Faster is_antichain_of_poset()
-------------------------------------+-------------------------------------
       Reporter:  jmantysalo         |        Owner:
           Type:  defect             |       Status:  new
       Priority:  minor              |    Milestone:  sage-6.9
      Component:  combinatorics      |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Jori Mäntysalo     |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/jmantysalo/finite_posets__faster_is_antichain_of_poset__|  
38400a3da6f9d4885f0b36cd2169cc5c14b0142c
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------
Changes (by jmantysalo):

 * commit:   => 38400a3da6f9d4885f0b36cd2169cc5c14b0142c


Comment:

 After `P = Posets.BooleanLattice(10); l = P.level_sets()[5]` this patch
 reduced time for `P.is_antichain_of_poset(l)` from 642 ms to 558 ms. That
 is 13% faster.

 At the same time the index in `posets.py` can be slightly better, as now
 both `is_chain_of_poset()` and `is_antichain_of_poset()` are defined in
 the same file. Also the user will get error message always, if there is an
 element of `elms` not in the poset.

 The code may seem slightly odd, but AFAIK there is no built-in way in
 Python to get pairs `(a,b)` from list `L` such that `L.index(a) <
 L.index(b)`. This implementation was fastest I found.

 However, I am waiting for #18941 to get accepted (or rejected). Then I'll
 add this to index of functions. (Assuming that #19061 isn't done yet.)
 ----
 New commits:
 
||[http://git.sagemath.org/sage.git/commit/?id=6bd3062abf58e9bb1db4cb5d4aced453c72edf5e
 6bd3062]||{{{Added a function is_antichain_of_poset to posets.py.}}}||
 
||[http://git.sagemath.org/sage.git/commit/?id=38400a3da6f9d4885f0b36cd2169cc5c14b0142c
 38400a3]||{{{Removed spaces from empty line.}}}||

--
Ticket URL: <http://trac.sagemath.org/ticket/19078#comment:3>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to