Re: [sage-combinat-devel] Re: De Bruijn Sequences
On Tue, Dec 28, 2010 at 12:06:52PM -0800, Eviatar wrote: > What is "an_element" supposed to do, exactly? Should it return the > first item in a list, a random one, etc? Does this help? sage: C = Sets().parent_class sage: C.an_element? ... Docstring: Returns a (preferably typical) element of this parent. This is used both for illustration and testing purposes. If the set ``self`` is empty, ``an_element()`` should raise the exception ``EmptySetError``. This default implementation calls ``_an_element_()`` and cache the result. Any parent should implement either ``an_element()`` or ``_an_element_()``. sage: C = EnumeratedSets().parent_class sage: C._an_element_? Type: CachedMethodCaller Base Class: String Form:Cached version of Namespace: Interactive File: /opt/sage/local/lib/python2.6/site-packages/sage/misc/cachefunc.py Definition: C._an_element_(self, *args, **kwds) Docstring: An element in ``self``. ``self.an_element()`` returns a particular element of the set ``self``. This is a generic implementation from the category ``EnumeratedSets()`` which can be used when the method ``__iter__`` is provided. Cheers, Nicolas -- Nicolas M. Thiéry "Isil" http://Nicolas.Thiery.name/ -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-de...@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.
[sage-combinat-devel] Re: De Bruijn Sequences
What is "an_element" supposed to do, exactly? Should it return the first item in a list, a random one, etc? Thank you. -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-de...@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.
Re: [sage-combinat-devel] fast generation of combinatorial structures
Hi Vincent! On Mon, Dec 27, 2010 at 08:34:39PM +0100, Vincent Delecroix wrote: > I need for the purpose of my research fast iterator through > set-partitions of a set, let say > sage: SetPartitions(18,[3,3,3,3,3,3]).cardinality() > 190590400 > The actual version is not convincing in terms of speed, so I started > to rewrote a bunch of combinatorial generation using very basic cython > objects (look at the file fast_generation.pyx in sage/combinat/). Some > of the new iterator are called from combinatorial object and I get > better performances. I'm very careful with testing but it can happen > that some new code break. > > old timing: > sage: timeit('list(Subwords(range(10),3))') > 625 loops, best of 3: 903 µs per loop > > new timing: > sage: timeit('list(Subwords(range(10),3))') > 625 loops, best of 3: 86.5 µs per loop Yipee! It's great that someone is taking up this task which has been on the TODO list for a while. Please create a ticket, and mention it on: http://trac.sagemath.org/sage_trac/wiki/SageCombinatRoadMap A couple suggestions: - If practical, put the cython code in specific files. Say in subword_cython.pyx for the subword iterator - You probably want to use Florent's work around clones: #8702 - You probably mean "enumerated sets" instead of "combinatorial object" Keep it up! Cheers, Nicolas -- Nicolas M. Thiéry "Isil" http://Nicolas.Thiery.name/ -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-de...@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.
Re: [sage-combinat-devel] Re: De Bruijn Sequences
On Mon, Dec 27, 2010 at 02:27:14PM -0800, Eviatar wrote: > Now that I think of it cardinality would be easy to implement; there > is a formula for it. Would it be fine to have a cardinality method but > only return one sequence? Sure! And eventually someone might want to add further random/iter methods to your cardinality and an_element methods. Cheers, Nicolas -- Nicolas M. Thiéry "Isil" http://Nicolas.Thiery.name/ -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To post to this group, send email to sage-combinat-de...@googlegroups.com. To unsubscribe from this group, send email to sage-combinat-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.