Class arb
extends virtual class flint
. It represents
vectors of arbitrary precision floating-point real numbers with error
bounds. Elements are specified by a pair of mixed format
floating-point numbers: an arf
midpoint and a
mag
radius.
Arithmetic on arb
vectors is midpoint-radius interval
arithmetic, also known as ball arithmetic, enabling computation with
rigorous propagation of errors. Logic and comparison involving
arb
vectors are defined as follows: unary op(x)
is true
if and only if op
is true for all elements of the interval
x
, and binary op(x, y)
is true if and only if op
is true for all elements of the Cartesian product of the intervals
x
and y
. A corollary is that the operator <=
does not define a total order on the range of arb
(that
is, the set of intervals \([m-r,m+r]\)), and a consequence is that
methods for generic functions that necessitate a total order tend to
signal an error.
## The class generator function:
.arb(...)## Mode 1: initialize with zeros
## .arb(length = 0L)
##
## Mode 2: initialize with vector
## .arb(length = length(x), x)
##
## Mode 3: initialize by parts
## .arb(length = max0(length(mid), length(rad)), mid, rad)
##
## where max0 <- function(m, n) if (min(m, n)) max(m, n) else 0L
The class generator function returns new("arb", ...)
.
arguments passed to methods for initialize
.
.xData
, names
inherited from virtual class flint
.
Due to constraints imposed by generic functions, methods typically do
not provide a formal argument prec
allowing for a
precision to be indicated in the function call. Such methods use the
current default precision set by flintPrec
.
!
signature(x = "arb")
:
equivalent to (but faster than) x == 0
.
+
signature(e1 = "arb", e2 = "missing")
:
returns a copy of the argument.
-
signature(e1 = "arb", e2 = "missing")
:
returns the negation of the argument.
Complex
signature(z = "arb")
:
mathematical functions of one argument; see
S4groupGeneric
.
Math
signature(x = "arb")
:
mathematical functions of one argument; see
S4groupGeneric
.
Math2
signature(x = "arb")
:
decimal rounding according to a second argument digits
; see
S4groupGeneric
. There are just two member
member functions: round
, signif
.
Ops
signature(e1 = "ANY", e2 = "arb")
:
signature(e1 = "arb", e2 = "ANY")
:
binary arithmetic, comparison, and logical operators; see
S4groupGeneric
. The “other” operand
must be atomic or inherit from virtual class
flint
. The operands are recycled and
promoted as necessary.
Summary
signature(x = "arb")
:
univariate summary statistics; see
S4groupGeneric
. The return value is a
logical vector of length 1 (any
, all
) or an
arb
vector of length 1 or 2 (sum
, prod
,
min
, max
, range
).
anyNA
signature(x = "arb")
:
returns TRUE
if any element of x
has midpoint
NaN
, FALSE
otherwise.
as.vector
signature(x = "arb")
:
returns as.vector(y, mode)
, where y
is a double
vector containing the result of converting the midpoints of
x
to the range of double, rounding if the value is not
exactly representable in double precision. The rounding mode is
to the nearest representable number (with precedence to even
significands in case of ties), unless a midpoint exceeds
.Machine[["double.xmax"]]
in absolute value, in which case
-Inf
or Inf
is introduced with a warning. Coercion
to types "character"
, "symbol"
(synonym
"name"
), "pairlist"
, "list"
, and
"expression"
, which are not “number-like”, is
handled specially.
coerce
signature(from = "ANY", to = "arb")
:
returns .arb(x = from)
. An error is signaled if the class
or type of from
is not supported by the method for
initialize
.
format
signature(x = "arb")
:
returns a character vector suitable for printing, using string
format "(m +/- r)"
and scientific format for m
and
r
. Optional arguments control the output; see
format-methods
.
initialize
signature(.Object = "arb", length = "numeric")
:
returns .Object
after setting its .xData
slot. The
new slot value is an external pointer to an array of the
corresponding C type, which is newly allocated and
initialized entirely with zeros (zero midpoint, zero radius).
.Object
is not copied, so all references are affected.
initialize
signature(.Object = "arb", length = "numeric", x = "atomic|flint")
:
as above, except that the new slot value points to an array
initialized by the elements of x
.
initialize
signature(.Object = "arb", length = "numeric", mid = "atomic|flint", rad = "atomic|flint")
:
as above, except that the new slot value points to an array whose
midpoints and radii are initialized separately with values from
mid
and rad
, which are coerced to classes
arf
and mag
and recycled
as necessary.
is.finite
signature(x = "arb")
:
returns a logical vector indicating which elements of x
do not have midpoint NaN
, -Inf
, or Inf
or
radius Inf
.
is.infinite
signature(x = "arb")
:
returns a logical vector indicating which elements of x
have midpoint -Inf
or Inf
or radius Inf
.
is.na
, is.nan
signature(x = "arb")
:
returns a logical vector indicating which elements of x
have midpoint NaN
.
is.unsorted
signature(x = "arb")
:
signals an error indicating that <=
is not a total order
on the range of arb
; see xtfrm
below.
log
signature(x = "arb")
:
returns the logarithm of the argument. The natural logarithm is
computed by default (when optional argument base
is
unset).
mean
signature(x = "arb")
:
returns the arithmetic mean.
xtfrm
signature(x = "arb")
:
signals an error indicating that <=
is not a total order
on the range of arb
: a <= b || b <= a
is is not
TRUE
for all finite a
and b
of class
arb
. Thus, direct sorting of arb
is not supported.
Users wanting to order the midpoints should operate on
Mid(x)
.
The FLINT documentation of the underlying C type: https://flintlib.org/doc/arb.html
Johansson, F. (2017). Arb: efficient arbitrary-precision midpoint-radius interval arithmetic. IEEE Transactions on Computers, 66(8), 1281-1292. tools:::Rd_expr_doi("10.1109/TC.2017.2690633")
Virtual class flint
. Generic functions
Mid
and Rad
and their replacement forms
for getting and setting midpoints and radii.
showClass("arb")
showMethods(classes = "arb")
Run the code above in your browser using DataLab