This occurred to me before, its nice to have iterators/generators but there 
should be a mechanism to say that the iterator is over a finite or infinite 
set. Just to avoid doing exhaustive searches over infinite sets. Similar to 
C++ iterator traits, I guess. Of course if you were to manually implement a 
generator as a Python class (implementing __next__) you could attach other 
methods like is_finite(). But then you'd always have to write a lot of 
boilerplate to return an iterator. Its much easier to use yield, but then 
you can't return any additional information about finiteness. 

The alternative is to assume that the user knows what he is doing when he 
passes an iterator / generator object. V.sum(W) can and should still check 
that W is finite before starting to iterate over W.





On Thursday, November 8, 2012 6:32:02 AM UTC-5, John Cremona wrote:
>
> Thanks to all.  The machine is still up, as I was able to stop the 
> computation with Crtl-C. 
>
> Now I see it, of course that's what V.sum(W) says that it does, except 
> that it in fact makes no sense, since adding up the (infinitely many) 
> elements of W has nothing to do with V. 
>
> I don't quite know how I missed V+W -- thanks, David! 
>
> John 
>
> On 8 November 2012 10:38, P Purkayastha <ppu...@gmail.com <javascript:>> 
> wrote: 
> > On 11/08/2012 05:36 PM, John Cremona wrote: 
> >> 
> >> Either I am doing something wrong or a simple operation which should 
> >> be fast is in fact very slow, but I do not know why. 
> >> 
> >> If V,W are vector spaces over QQ, subspaces of  the same ambient 
> >> space, then V.sum(W) should return their sum, with an echelon basis 
> >> obtained from the bases of V and W.  But this takes a stupidly long 
> >> time.  For example: 
> >> 
> >> sage: Q100=QQ^100 
> >> sage: V=Q100.subspace([Q100.random_element()]) 
> >> sage: W=Q100.subspace([Q100.random_element()]) 
> >> 
> >> # so V,W are both 1-dimensional 
> >> 
> >> sage: V.sum(W) 
> >> sage: time V.sum(W) 
> >> 
> >> # takes forever (on 5.3) -- why? 
> >> 
> >> John 
> >> 
> > 
> > What Francis said is correct. V.sum(W) sums the elements in W. Over QQ, 
> the 
> > number of elements is not finite. I am surprised if your machine is 
> still 
> > up, because it should have just exhausted all memory! :) 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "sage-devel" group. 
> > To post to this group, send email to 
> > sage-...@googlegroups.com<javascript:>. 
>
> > To unsubscribe from this group, send email to 
> > sage-devel+...@googlegroups.com <javascript:>. 
> > Visit this group at http://groups.google.com/group/sage-devel?hl=en. 
> > 
> > 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To post to this group, send email to sage-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-devel+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.


Reply via email to