mpfr.utils {Rmpfr} | R Documentation |
MPFR Number Utilities
Description
mpfrVersion()
returns the version of the MPFR library which
Rmpfr is currently linked to.
c(x,y,...)
can be used to combine MPFR numbers in the
same way as regular numbers IFF the first argument x
is
of class mpfr
.
mpfrIs0(.)
uses the MPFR library in the documented way to
check if (a vector of) MPFR numbers are zero. It was called
mpfr.is.0
which is strongly deprecated now.
.mpfr.is.whole(x)
uses the MPFR library in the documented way to
check if (a vector of) MPFR numbers is integer valued. This is
equivalent to x == round(x)
, but not at all to
is.integer(as(x, "numeric"))
.
You should typically rather use (the "mpfr"
method of the
generic function) is.whole(x)
instead.
The former name mpfr.is.integer
is deprecated now.
Usage
mpfrVersion()
mpfrIs0(x)
## S3 method for class 'mpfr'
c(...)
## S3 method for class 'mpfr'
diff(x, lag = 1L, differences = 1L, ...)
Arguments
x |
an object of class |
... |
for |
lag , differences |
for |
Value
mpfrIs0
returns a logical vector of length length(x)
with values TRUE
iff the corresponding x[i]
is an MPFR
representation of zero (0
).
Similarly, .mpfr.is.whole
and is.whole
return a
logical vector of length length(x)
.
mpfrVersion
returns an object of S3 class
"numeric_version"
, so it can be used in comparisons.
The other functions return MPFR number (vectors), i.e., extending
class mpfr
.
See Also
str.mpfr
for the str
method.
erf
for special mathematical functions on MPFR.
The class description mpfr
page mentions many
generic arithmetic and mathematical functions for which "mpfr"
methods are available.
Examples
mpfrVersion()
(x <- c(Const("pi", 64), mpfr(-2:2, 64)))
mpfrIs0(x) # one of them is
x[mpfrIs0(x)] # but it may not have been obvious..
str(x)
x <- rep(-2:2, 5)
stopifnot(is.whole(mpfr(2, 500) ^ (1:200)),
all.equal(diff(x), diff(as.numeric(x))))