On Jan 19, 1:43 pm, slabbe <sla...@gmail.com> wrote:
> PROBLEM :
> In a list of vectors, I want to know if there is a pair of equal
> vectors.
>
> I have two solutions. The first to create an empty list L and append
> the vectors one per one. If a vector is already in L before adding it,
> then I found a pair of equal vectors. But looking if a vector belongs
> to a list is apparently very slow on my computer :

The problem is that you're working in the symbolic ring, which is very
slow.  Do you need to?  For instance, this particular example can be
handled much more quickly in QQbar, the field of algebraic numbers:

sage: v = vector((1, QQbar(0)))
sage: w = vector((1, QQbar(sqrt(2))))
sage: time w in [v,v,v,v]
CPU times: user 0.00 s, sys: 0.00 s, total: 0.00 s
Wall time: 0.01 s
False

Carl Witty

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to