Converting arb_t to a double

41 views
Skip to first unread message

Valentina Sarti

unread,
Mar 22, 2024, 5:36:17 AMMar 22
to flint-devel
Dear All,

I am newbie to Flint, and I am currently using it since I need to use in my calculation a confluent hypergeometric function with complex arguments (acb_hypgeom_1f1).

I am currently at this stage of my dedicated function:

    acb_t result_acb;
    acb_init(result_acb);
    int regularized = 0;
    acb_hypgeom_1f1(result_acb, eta_acb, 0, zeta_acb, regularized, 64);

and now I would need simply to store the real and imaginary part of the result_acb into a std::complex<double> result (acb_realref(result_acb), acb_imagref(result_acb));

So I am facing the issue to convert the output of acb_realref to a double.
I need this since in my code then I use other libraries (gsl,etc...) and all the remaining calculations use double objects.

Can you provide me some suggestions in how to do this?

Thanks in advance!!

Valentina

Fredrik Johansson

unread,
Mar 22, 2024, 5:43:39 AMMar 22
to flint...@googlegroups.com
Hello Valentina,

The easiest way to accomplish this is to use the ready-made wrapper in arb_fpwrap.h. See the example code here: https://github.com/flintlib/flint/blob/main/examples/fpwrap.c. In your case you would call arb_fpwrap_cdouble_hypgeom_1f1.

If you want to wrap the acb function yourself, the way to convert back to doubles is

double real = arf_get_d(arb_midref(acb_realref(z)), ARF_RND_NEAR);
double imag = arf_get_d(arb_midref(acb_imagref(z)), ARF_RND_NEAR);

Best,
Fredrik


--

---
You received this message because you are subscribed to the Google Groups "flint-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flint-devel...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/flint-devel/904409b2-e2ec-4895-a231-9aa5a5b1fbb4n%40googlegroups.com.

Valentina Sarti

unread,
Mar 26, 2024, 4:38:11 AMMar 26
to flint-devel
Dear Fredrik,

thanks so much for the help!! 
Everything now runs, hopefully also the numbers will make sense :)!

Thanks again!!!

Best,

Valentina
Reply all
Reply to author
Forward
0 new messages