Learn R Programming

Rmpfr (version 0.4-8)

gmp-conversions: Conversion Utilities gmp <-> Rmpfr

Description

Coerce from and to big integers (bigz) and mpfr numbers.

Further, coerce from big rationals (bigq) to mpfr numbers.

Usage

.bigz2mpfr(x)
.mpfr2bigz(x, mod = NA)
.bigq2mpfr(from)

Arguments

x
an Robject of class bigz or mpfr respectively.
from
an Robject of class bigq.
mod
a possible modulus, see as.bigz in package gmp.

Value

  • a numeric vector of the same length as x, of the desired class.

Details

Note that we also provide the natural (S4) coercions, as(x, "mpfr") for x inheriting from class "bigz" or "bigq".

See Also

mpfr(), as.bigz and as.bigq in package gmp.

Examples

Run this code
S <- gmp::Stirling2(50,10)
 show(S)
 SS <- S * as.bigz(1:3)^128
 stopifnot(all.equal(log2(SS[2]) - log2(S), 128, tol=1e-15),
           identical(SS, .mpfr2bigz(.bigz2mpfr(SS))))

 ## rational --> mpfr:
 sq <- SS / as.bigz(2)^100
 MP <- as(sq, "mpfr")
 stopifnot(identical(MP, .bigq2mpfr(sq)),
           SS == MP * as(2, "mpfr")^100)

Run the code above in your browser using DataLab