What people have not been saying explicitly is this:  if you ask for
the eigenvalues of an integer matrix then they will be returned as
elements of QQbar, i.e. as algebraic numbers with a specific embedding
into CC, which display looking like approximate floating points
numbers but are not.  These are then very inefficient to do a lot of
comutations with, as you discovered.  To avoid this, explicitly change
your matrix's base ring to something approximate like  RDF and then
the eigenvalue computation will be done there, with all the usual
warnings from numerical analysis about precision issues.

John

On 10 October 2014 11:48, Volker Braun <[email protected]> wrote:
> If you don't need provable correct answers then just change to RDF/CDF for
> fast computation:
>
> sage: c26 =
> Graph('YsP@H?PC?O`?@@?_?G?@??CC?G??GG?E??@_??K???W???W???H???E_')
> sage: sum(lam for lam in
> c26.adjacency_matrix().change_ring(RDF).eigenvalues() if lam > 0)
> 19.870922489880787
>
>
>
> On Friday, October 10, 2014 9:42:44 AM UTC+1, Nico Van Cleemput wrote:
>>
>> Today I came across the following problem. I start by computing the Gutman
>> energy for a graph:
>>
>> sage: c26 =
>> Graph('YsP@H?PC?O`?@@?_?G?@??CC?G??GG?E??@_??K???W???W???H???E_')
>> sage: ge = sum(lam for lam in c26.adjacency_matrix().eigenvalues() if lam
>> > 0)
>> sage: ge
>> 19.87092248988078?
>>
>> So far everything seems to be OK, but then I try
>>
>> sage: float(ge)
>>
>> Now you can wait for a very long time. (I actually didn't test to see how
>> long it would exactly take) The type of ge is
>> sage.rings.qqbar.AlgebraicNumber. Looking at the implementation of the float
>> conversion, the problem seems to come from the following:
>>
>> sage: AA(ge)
>>
>> This indeed also seems to take forever. At that point I'm lost. I don't
>> really understand much of that part of Sage, so I don't know how to look
>> further for a solution to this problem. Is there another way to get a good
>> float approximation of that value?
>>
>> Cheers
>> Nico
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to