My use case is that I have one billion of number field elements that
I want to plot. That goes through __float__ that calls
numerical_approx that goes through conversion to MPFR real field.

Considering my use case, I know how to make it faster (implement
__float__ on nf elements). Though I thought I would also make the
general real floating point conversion faster and I failed.

Note that it works perfectly well with RIF, CIF, RBF and CBF via
respectively the methods _real_mpfi_, _complex_mpfi_, _arb_ and
_acb_. You can see

sage: cm = get_coercion_model()
sage: K.<a> = NumberField(x^2 - x - 1, embedding=(1+AA(5).sqrt())/2)
sage: cm.explain(K, RIF)

And compare the timings with RR conversion!! (> factor x100)

Vincent

Le 20/12/2018 à 17:33, John Cremona a écrit :
You should say that this coercion is only being proposed when nf is a *real
quadratic field*!  For a general number field F one can get
F.embeddings(RR) (or variants with RR replaced by a RealField of any
precision, for example, or CC, or...).  Why can that not be used for this
coercion?

Personally I would never want this anyway since I would always want to
specify exactly which real embedding I wanted.  What sort of use case do
you have in mind?

John

On Thu, 20 Dec 2018 at 16:15, Vincent Delecroix <20100.delecr...@gmail.com>
wrote:

Dear all,

At #26925 I failed to make a more direct coercion nf -> RR. What
we have now go through nf -> AA -> RLF -> RR and is dramatically slow.
The coercion path can be analyzed via

sage: K.<a> = NumberField(x^2 - x - 1, embedding=(1+AA(5).sqrt())/2)
sage: cm = get_coercion_model()
sage: cm.explain(K, RR)

The real field RR declares "_mpfr_" as being a conversion method
in its constructor. However, the coercion model does prefer a
composite map with 2 intermediates rather than this direct
conversion method...

1) Would it be desirable that a direct named conversion such as _mpfr_
would be preferred than a coercion through intermediate?

2) Is there a way to tell Sage that I want this specific coercion to
go through the _mpfr_ method?

Any input appreciated.

Vincent

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



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

Reply via email to