[R-pkg-devel] How to get arbitrary precise inputs from R for an Rcpp package?
Khue Tran
tr@n3 @end|ng |rom kenyon@edu
Mon Jul 22 01:39:15 CEST 2024
Dear Leonard,
Thank you so much for the detailed response! Indeed, it would be nice to
have it included in the BH header. Thank you for sharing your codes with
me, I will definitely take a look at them to see if I can apply them to my
case. I was steering away from mpfr type for a while since they were
creating issues for linkage between C++ and R, but if I can get them to
work in R to avoid complications, I might try that!
Thank you again!
Best,
Khue Tran
On Sun, Jul 21, 2024 at 8:06 AM Leo Mada <leo.mada using syonic.eu> wrote:
> Dear Khue,
>
> As mentioned before, you can use Rmpfr to read in strings or compute
> higher precision values, like
>
> x = mpfr(1, 192) /10;
> # 0.1 with 192 bits precision
> # or x = mpfr("0.1", 192);
>
> mpfr(1, 192) /10 - mpfr("0.1", 192)
> # 1 'mpfr' number of precision 192 bits
> # [1] 0
>
> However, I do not know how easy it is to convert from the mpfr format to
> the other format. Maybe the BH-team can add an mpfr constructor to the
> library.
>
> On a somewhat related topic, I did implement a very basic solver in native
> R (and based on Rmpfr). You can have a look on GitHub; it is not a package,
> but the script should be self-contained:
>
> https://github.com/discoleo/R/blob/master/Math/Polynomials.Helper.Matrix.mpfr.R
>
> It is very basic - more like a proof of concept. It does not include any
> advanced tricks and there is quit some drop of precision in some examples,
> see:
>
> https://github.com/discoleo/R/blob/master/Math/Polynomials.Helper.mpfr.Tests.R
>
> I was primarily interested in solving systems of polynomial equations
> (including complex roots); but did not have time to finish the remaining
> work. Extending the algorithm to solve for eigenvalues may be feasible
> (although I was less interested in eigenvalues). A native implementation in
> C++ would be faster; but I try to avoid any more complicated programming if
> it is not absolutely essential!
>
> Sincerely,
>
> Leonard
>
>
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list