Iterators for various structures

7 views
Skip to first unread message

Johan Nielsen

unread,
Aug 2, 2010, 5:53:24 AM8/2/10
to sage-...@googlegroups.com
Trac ticket 8361 (http://trac.sagemath.org/sage_trac/ticket/8361) implements an iterator for vectors over integers. I dislike this extension for several reasons:

Johan S. R. Nielsen

unread,
Aug 2, 2010, 6:09:32 AM8/2/10
to sage-devel
Argh, my mail client just tricked me. Anyway:

The main reason is that I see no mathematical obvious way of iterating
through all vectors of the integers. The (arbitrarily) decided way in
the patch seems usable in only very few cases (and it does not even
contain vectors with any negative elements). If one would ever want to
have such an iterator, it seems to me that it would almost always be
vectors of some length that was the purpose.

A secondary reason is generality: If it is decided to keep this
iterator, I think a similar iterator should be implemented for all
finite or countably infinite vector spaces (even modules). In the case
of finite rings as basis, it might actually make good sense;
especially, if one specifies the length of the vector in the iterator.

Thirdly, with an iterator, the IntegerVectors supports the syntax
{{{
v = IntegerVectors()[25]
}}}
The implementation suggested in the patch would give calls like this
something like quadratic running time. I think that the syntax should
then explicitly be banned (by implementing a faulting __getitem__
function?) or implemented as calculating the vector directly in some
way. The last suggestion again seems to be hard with the current
implementation.

I have updated the trac to "needs work" and referred to this
discussion.

Cheers,
Johan

David Joyner

unread,
Aug 2, 2010, 6:15:23 AM8/2/10
to sage-...@googlegroups.com
Hi Johan:

Maybe your email got cut off somehow?

I'm not sure what you were going to say, but sometimes you can
also make comments on the ticket itself. If you don't have a trac
account, please see http://trac.sagemath.org/sage_trac/prefs/account
A guide to the trac system is here:
http://www.sagemath.org/doc/developer/trac.html

> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to
> sage-devel+...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>

Johan S. R. Nielsen

unread,
Aug 2, 2010, 6:16:38 AM8/2/10
to sage-devel
Now my compilation of the patched Sage finished, and it seems that the
patch doesn't even work anymore. SearchTree doesn't have a
breadth_first_search_iterator; maybe that class has changed while the
patch has been waiting for review?

On Aug 2, 12:09 pm, "Johan S. R. Nielsen" <santaph...@gmail.com>
wrote:

Johan S. R. Nielsen

unread,
Aug 2, 2010, 6:18:23 AM8/2/10
to sage-devel
Hi David
Thanks. I thought I would start a discussion here, though, because it
seems like a general issue whether or not to add iterators on such
structures.

Cheers,
Johan

On Aug 2, 12:15 pm, David Joyner <wdjoy...@gmail.com> wrote:
> Hi Johan:
>
> Maybe your email got cut off somehow?
>
> I'm not sure what you were going to say, but sometimes you can
> also make comments on the ticket itself. If you don't have a trac
> account, please seehttp://trac.sagemath.org/sage_trac/prefs/account
> A guide to the trac system is here:http://www.sagemath.org/doc/developer/trac.html
>

David Joyner

unread,
Aug 2, 2010, 6:27:38 AM8/2/10
to sage-...@googlegroups.com
Good. Looks like you are on trac after all. Can you please add your
initials and real name to
the list at the bottom of the main trac page http://trac.sagemath.org/sage_trac?

The ticket is by nborie (= Nicolas Borie, Université Paris Sud XI,
Orsay) who I think works
with N Thiery in the combinatorics section. So maybe it is needed for
some combinatorics
machinery they are developing. In any case, possibly the email should
be cross-posted to
sage-combinat-devel http://groups.google.com/group/sage-combinat-devel?pli=1 ?

Nicolas Borie

unread,
Aug 2, 2010, 8:26:24 AM8/2/10
to sage-devel
Hello,

I put a message on the trac 8361...

I still work on the SearchForest feature (and rebase it because it no
longer worked with 4.5.2). But it is definitely right that an iterator
of IntergerVectors doesn't deserve to use the SearchForest engine
(SearchForest is only adapted for poor tree-like structure,
IntegerVectors are a too much rich structure and need a proper
code...). This ticket sleep a very long time due to my fault and in
spite of I opened it, I have no really good mathematical argument or
idea to produced a good method. Fell free to give any proposition and
assign to anyone the ticket.

For information, I don't think the combinat community use this code
(It'a has been broken the whole last month on the combinat
repository...) as no one already asked me to clean it.

Sorry for my English and many thanks for your comments and the time
took to deal with this ticket.
Reply all
Reply to author
Forward
0 new messages