I suspect that what John wants is the sum of V and W as subspaces of a common ambient space (not the direct sum embedded in the direct sum of two copies of the ambient space, as Francis suggests). This can be obtained (very quickly) by doing
sage: time V + W Vector space of degree 100 and dimension 2 over Rational Field Basis matrix: 2 x 100 dense matrix over Rational Field Time: CPU 0.02 s, Wall: 0.02 s It is *really awful* that V.sum(W) attempts to sum all the elements of W! I don't know what general design decision underlies this but I don't like it. David On 8 November 2012 10:38, P Purkayastha <ppu...@gmail.com> 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-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. > > > -- 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.