Learn R Programming

flint (version 0.1.0)

acb-class: Arbitrary Precision Floating-Point Complex Numbers with Error Bounds

Description

Class acb extends virtual class flint. It represents vectors of complex numbers with error bounds on the real and imaginary parts. Elements are specified by two pairs of mixed format floating-point numbers: an arb real part and an arb imaginary part, each specified by an arf midpoint and a mag radius.

Usage

## Class generator functions

acb(x = 0i, length = 0L, names = NULL, real = 0, imag = 0)

acb.array(x = 0i, dim = length(x), dimnames = NULL, real = 0, imag = 0)

Value

An acb vector, possibly an array; see ‘Details’.

Arguments

x

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

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.

real, imag

atomic or flint vectors containing data for conversion to arb. Use these for initialization “by parts” (real and imaginary).

Conversion

Real numbers and real and imaginary parts of complex numbers are rounded according to the default precision and rounding mode set by flintPrec and flintRnd. Ball midpoints are the numbers obtained by rounding. Ball radii are upper bounds on the absolute errors incurred by rounding.

Character strings are scanned first for a real part then for an imaginary part. They can use any of three formats: "sa", "tbi", and "satbi", where, recursively, each of a and b have the format "(km+/-r)", defining a ball for each of the real and imaginary parts. k and m define the sign and absolute value of the signed ball midpoints, and r defines the unsigned ball radii. k can be empty if the ball midpoint is NaN or non-negative. s and t are unary or binary plus or minus to be reconciled with k; they are optional except in the third format where t is mandatory.

The sequences km and r 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 (for the midpoint, whereas the radius is always rounded towards Inf); 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 = "acb"):
equivalent to (but faster than) x == 0.

%*%, crossprod, tcrossprod

signature(x = "acb", y = "acb"):
signature(x = "acb", y = "ANY"):
signature(x = "ANY", y = "acb"):
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.

+

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

-

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

Complex

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

Math

signature(x = "acb"):
mathematical functions of one argument; see S4groupGeneric. Member functions floor, ceiling, trunc, cummin, cummax are not implemented.

Math2

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

Ops

signature(e1 = "acb", e2 = "acb"):
signature(e1 = "acb", e2 = "ANY"):
signature(e1 = "ANY", e2 = "acb"):
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 = "acb"):
univariate summary statistics; see S4groupGeneric. The return value is a logical vector of length 1 (any, all) or an acb vector of length 1 or 2 (sum, prod). Member functions min, max, range are not implemented.

anyNA

signature(x = "acb"):
returns TRUE if any element of x has real or imaginary part with midpoint NaN, FALSE otherwise.

as.vector

signature(x = "acb"):
returns as.vector(y, mode), where y is a complex vector containing the result of converting the midpoints of the real and imaginary parts 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. See also asVector.

backsolve

signature(r = "acb", x = "acb"):
signature(r = "acb", x = "ANY"):
signature(r = "ANY", x = "acb"):
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 = "acb"):
returns the upper triangular Cholesky factor of the positive definite matrix whose upper triangular part is the upper triangular part of x (discarding imaginary parts of diagonal entries).

chol2inv

signature(x = "acb"):
returns the inverse of the positive definite matrix whose upper triangular Cholesky factor is the upper triangular part of x (discarding imaginary parts of diagonal entries).

coerce

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

colSums, colMeans

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

det

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

determinant

signature(x = "acf"):
returns a list with components modulus and argument specifying the determinant of x, following the base function (except for the use of argument instead of sign), hence determinant.

format

signature(x = "acb"):
returns a character vector suitable for printing, using string format "(m +/- r)+(m +/- r)i" and scientific format for each m and r. Optional arguments control the output; see format-methods.

is.finite

signature(x = "acb"):
returns a logical vector indicating which elements of x do not have real or imaginary part with midpoint NaN, -Inf, or Inf or radius Inf.

is.infinite

signature(x = "acb"):
returns a logical vector indicating which elements of x have real or imaginary part with midpoint -Inf or Inf or radius Inf.

is.na, is.nan

signature(x = "acb"):
returns a logical vector indicating which elements of x have real or imaginary part with midpoint NaN.

is.unsorted

signature(x = "acb"):
signals an error indicating that <= is not a total order on the range of arb; see xtfrm below.

log

signature(x = "acb"):
returns the logarithm of the argument. The natural logarithm is computed by default (when optional argument base is unset).

mean

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

rowSums, rowMeans

signature(x = "acb"):
returns an acb 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 = "acb", b = "acb"):
signature(a = "acb", b = "ANY"):
signature(a = "ANY", b = "acb"):
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.

xtfrm

signature(x = "acb"):
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 acb, which is based on arb, is not supported. Users wanting to order the midpoints of the real and imaginary parts should operate on Mid(Real(x)) and Mid(Imag(x)).

Details

The class generator function has six distinct usages:

acb()
acb(length=)
acb(x)
acb(x, length=)
acb(real=, imag=)
acb(real=, imag=, 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. The fifth and sixth usages, in which either of real and imag can be missing, use arb(real) and arb(imag) to separately initialize the real and imaginary parts of the acb return value.

Attempts to recycle real, imag, or x of length zero to nonzero length are an error.

Usage of acb.array is modelled after array.

References

The FLINT documentation of the underlying C type: https://flintlib.org/doc/acb.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. Generic functions Real and Imag and their replacement forms for getting and setting real and imaginary parts.

Examples

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

Run the code above in your browser using DataLab