Learn R Programming

flint (version 0.0.3)

mag-class: Fixed Precision Magnitude (Error) Bounds

Description

Class mag extends virtual class flint. It represents vectors of fixed precision error bounds. Elements are unsigned floating-point numbers with a 30-bit significand and an arbitary precision exponent. The underlying C type can represent Inf but not NaN.

Usage

## The class generator function:
.mag(...)

## Mode 1: initialize with zeros ## .mag(length = 0L) ## ## Mode 2: initialize with vector ## .mag(length = length(x), x)

Value

The class generator function returns new("mag", ...).

Arguments

...

arguments passed to methods for initialize.

Slots

.xData, names

inherited from virtual class flint.

Methods

!

signature(x = "mag"):
equivalent to (but faster than) x == 0.

+

signature(e1 = "mag", e2 = "missing"):
returns a copy of the argument.

-

signature(e1 = "mag", e2 = "missing"):
returns a copy of the argument, to be consistent with the binary operation which returns an upper bound for the absolute value of the difference.

Complex

signature(z = "mag"):
mathematical functions of one argument; see S4groupGeneric. The return value is an upper bound for the absolute value of the exact answer.

Math

signature(x = "mag"):
mathematical functions of one argument; see S4groupGeneric. The return value is an upper bound for the absolute value of the exact answer. Notably, the (inverse) trigonometric, (inverse) hyperbolic, and gamma-related member functions are not yet implemented. Users wanting those can (for now) operate on as(x, "arb").

Math2

signature(x = "mag"):
decimal rounding according to a second argument digits; see S4groupGeneric. There are just two member functions: round, signif. The return value is an upper bound for the exact answer.

Ops

signature(e1 = "ANY", e2 = "mag"):
signature(e1 = "mag", 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. For arithmetic, the return value is a mag vector only if both operands are mag vectors. In that case, the return value is an upper bound for the absolute value of the exact answer. Users wanting “standard” floating-point arithmetic must ensure that at least one operand is not a mag vector.

Summary

signature(x = "mag"):
univariate summary statistics; see S4groupGeneric. The return value is a logical vector of length 1 (any, all) or an mag vector of length 1 or 2 (sum, prod, min, max, range). For sum and prod, the return value is an upper bound for the exact answer.

anyNA

signature(x = "mag"):
returns FALSE, as mag has no representation for NaN.

as.vector

signature(x = "mag"):
returns as.vector(y, mode), where y is a double vector containing the result of converting each element of x to the range of double, rounding in the direction of Inf, not always to nearest. Coercion to types "character", "symbol" (synonym "name"), "pairlist", "list", and "expression", which are not “number-like”, is handled specially.

coerce

signature(from = "ANY", to = "mag"):
returns .mag(x = from). An error is signaled if the class or type of from is not supported by the method for initialize.

format

signature(x = "mag"):
returns a character vector suitable for printing, using scientific format. Optional arguments control the output; see format-methods.

initialize

signature(.Object = "mag", 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. .Object is not copied, so all references are affected.

initialize

signature(.Object = "mag", length = "numeric", x = "atomic|flint"):
as above, except that the new slot value points to an array initialized with upper bounds for abs(x). An error is signaled if any x[i] is NaN.

is.finite

signature(x = "mag"):
returns a logical vector indicating which elements of x are not Inf.

is.infinite

signature(x = "mag"):
returns a logical vector indicating which elements of x are Inf.

is.na, is.nan

signature(x = "mag"):
returns a logical vector whose elements are all FALSE, as mag has no representation for NaN.

is.unsorted

signature(x = "mag"):
returns a logical indicating if x is not sorted in nondecreasing order (increasing order if optional argument strictly is set to TRUE).

log

signature(x = "mag"):
returns an upper bound for the absolute value of the logarithm of the argument. The natural logarithm is computed by default (when optional argument base is unset).

mean

signature(x = "mag"):
returns an upper bound for the arithmetic mean.

References

The FLINT documentation of the underlying C type: https://flintlib.org/doc/mag.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")

See Also

Virtual class flint.

Examples

Run this code
showClass("mag")
showMethods(classes = "mag")

Run the code above in your browser using DataLab