Learn R Programming

flint (version 0.1.0)

arf-class: Arbitrary Precision Floating-Point Real Numbers

Description

Class arf extends virtual class flint. It represents vectors of arbitrary precision floating-point real numbers. Elements have arbitrary precision significand and exponent. The underlying C type can represent NaN, -Inf, and Inf.

Usage

## Class generator functions

arf(x = 0, length = 0L, names = NULL)

arf.array(x = 0, dim = length(x), dimnames = NULL)

Value

A arf vector, possibly an array; see ‘Details’.

Arguments

x

an atomic or flint vector containing data for conversion to arf.

length

a numeric vector of length one giving the length of the return value. If that exceeds the length of x, then x is recycled. Non-integer values are rounded in the direction of zero.

names

the names slot of the return value, either NULL or a character vector of equal length. Non-character names are coerced to character.

dim

the dim slot of the return value, an integer vector of nonzero length. If the product exceeds the length of x, then x is recycled. Non-integer numeric dim are coerced to integer.

dimnames

the dimnames slot of the return value, either NULL or a list of length equal to the length of dim. The components are either NULL or character vectors of length given by dim. Non-character vector components of dimnames are coerced to character.

Conversion

Real numbers and real parts of complex numbers are rounded according to the default precision and rounding mode set by flintPrec and flintRnd. Imaginary parts of complex numbers are discarded.

Character strings are converted using function mpfr_strtofr from the GNU MPFR library with argument base set to 0 and argument rnd set according to the default rounding mode; see https://www.mpfr.org/mpfr-current/mpfr.html#Assignment-Functions.

Slots

.xData, dim, dimnames, names

inherited from virtual class flint.

Methods

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 = "arf"):
equivalent to (but faster than) x == 0.

%*%, crossprod, tcrossprod

signature(x = "arf", y = "arf"):
signature(x = "arf", y = "ANY"):
signature(x = "ANY", y = "arf"):
matrix products. The “other” operand must be atomic or inherit from virtual class flint. crossprod and tcrossprod behave as if y = x when y is missing or NULL. Operands are promoted as necessary and must be conformable (have compatible dimensions). Non-array operands of length k are handled as 1-by-k or k-by-1 matrices depending on the call. The return value is approximate insofar that it may not be correctly rounded.

+

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

-

signature(e1 = "arf", e2 = "missing"):
returns the negation of the argument.

Complex

signature(z = "arf"):
mathematical functions of one argument; see S4groupGeneric.

Math

signature(x = "arf"):
mathematical functions of one argument; see S4groupGeneric. Notably, the logarithmic, exponential, (inverse) trigonometric, (inverse) hyperbolic, and gamma-related member functions are not yet implemented. Users wanting those can (for now) operate on arb(x).

Math2

signature(x = "arf"):
decimal rounding according to a second argument digits; see S4groupGeneric. There are just two member member functions: round, signif.

Ops

signature(e1 = "arf", e2 = "arf"):
signature(e1 = "arf", e2 = "ANY"):
signature(e1 = "ANY", e2 = "arf"):
binary arithmetic, comparison, and logical operators; see S4groupGeneric. The “other” operand must be atomic or inherit from virtual class flint. Operands are promoted as necessary. Array operands must be conformable (have identical dimensions). Non-array operands are recycled.

Summary

signature(x = "arf"):
univariate summary statistics; see S4groupGeneric. The return value is a logical vector of length 1 (any, all) or an arf vector of length 1 or 2 (sum, prod, min, max, range).

anyNA

signature(x = "arf"):
returns TRUE if any element of x is NaN, FALSE otherwise.

as.vector

signature(x = "arf"):
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 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 the element 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. See also asVector.

backsolve

signature(r = "arf", x = "arf"):
signature(r = "arf", x = "ANY"):
signature(r = "ANY", x = "arf"):
solution of the triangular system op2(op1(r)) %*% y = x, where op1=ifelse(upper.tri, triu, tril) and op2=ifelse(transpose, t, identity) and upper.tri and transpose are optional logical arguments with default values TRUE and FALSE, respectively. The “other” operand must be atomic or inherit from virtual class flint. If x is missing, then the return value is the inverse of op2(op1(r)), as if x were the identity matrix. Operands are promoted as necessary and must be conformable (have compatible dimensions). Non-array x are handled as length(x)-by-1 matrices.

chol

signature(x = "arf"):
returns the upper triangular Cholesky factor of the positive definite matrix whose upper triangular part is the upper triangular part of x.

chol2inv

signature(x = "arf"):
returns the inverse of the positive definite matrix whose upper triangular Cholesky factor is the upper triangular part of x.

coerce

signature(from = "ANY", to = "arf"):
returns the value of arf(from).

colSums, colMeans

signature(x = "arf"):
returns an arf vector or array containing the column sums or means of x, defined as sums or means over dimensions 1:dims.

det

signature(x = "arf"):
returns the determinant of x as an arf vector of length 1.

determinant

signature(x = "arf"):
returns a list with components modulus and sign specifying the determinant of x, following the base function, hence see determinant.

format

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

is.finite

signature(x = "arf"):
returns a logical vector indicating which elements of x are not NaN, -Inf, or Inf.

is.infinite

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

is.na, is.nan

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

is.unsorted

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

mean

signature(x = "arf"):
returns the arithmetic mean.

rowSums, rowMeans

signature(x = "arf"):
returns an arf vector or array containing the row sums or means of x, defined as sums or means over dimensions (dims+1):length(dim(x)).

solve

signature(a = "arf", b = "arf"):
signature(a = "arf", b = "ANY"):
signature(a = "ANY", b = "arf"):
solution of the general system a %*% x = b. The “other” operand must be atomic or inherit from virtual class flint. If b is missing, then the return value is the inverse of a, as if b were the identity matrix. Operands are promoted as necessary and must be conformable (have compatible dimensions). Non-array b are handled as length(b)-by-1 matrices.

Details

The class generator function has four distinct usages:

arf()
arf(length=)
arf(x)
arf(x, length=)

The first usage generates an empty vector. The second usage generates a zero vector of the indicated length. The third usage converts x, preserving dimensions, dimension names, and names. The fourth usage converts x, recycling its elements to the indicated length and discarding its dimensions, dimension names, and names. Attempts to recycle x of length zero to nonzero length are an error.

Usage of arf.array is modelled after array.

References

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

Run the code above in your browser using DataLab