Learn R Programming

flint (version 0.1.0)

flint-package: R Package flint

Description

An R interface to FLINT, a C library for number theory.

Usage

flintABI()
flintClass(object)
flintLength(object, exact = TRUE)
flintPrec(prec = NULL)
flintRnd(rnd = NULL)
flintSize(object)
flintTriple(object)
flintVersion()

Value

flintABI returns the size in bits of C type

long int, either 32 or 64. The value is determined when package flint is configured. It is checked at configure time and at load time that linked C libraries were configured for the same ABI.

flintClass returns a character string naming the direct nonvirtual subclass of virtual class flint from which

object inherits. (Hence a possible value is "ulong"

but not the name of any subclass of ulong.) If object does not inherit from virtual class flint, then the return value is NA_character_.

flintLength returns a representation of the length of

object. If exact = TRUE, then the return value is an object of class ulong representing the length exactly. Otherwise, if the length is less than or equal to

.Machine[["integer.max"]], then the return value is a traditional integer vector representing the length exactly. Otherwise, the return value is a traditional double vector representing the length exactly if and only if

\(n \le 2^d-1\) or

\(2^{d+p} \le n < 2^{d+p+1}\) and \(n\)

is divisible by \(2^{p+1}\), where \(n\) is the length,

\(d\) is .Machine[["double.digits"]], and

\(p = 0,1,\ldots\). Lengths not exactly representable in double precision are rounded to the next representable number in the direction of zero. Return values not representing the length exactly have an attribute off preserving the rounding error (an integer in \(1,\ldots,2^p\)). If object does not inherit from virtual class flint, then the return value is

NA_integer_.

flintPrec returns the previous default precision.

flintRnd returns the previous default rounding mode.

flintSize returns an upper bound for the number of bytes used by object, as an object of class object_size (following function object.size in package utils). If no members of the recursive structure share memory, then the upper bound is exact. Recursion starts at the address stored by the R object, not at the address of the object itself. A corollary is that

flintSize(object) is zero for object of length zero. Another corollary is that the bytes counted by flintSize and the bytes counted by object.size are disjoint. If

object does not inherit from virtual class flint, then the return value is NA_real_ (beneath the class).

flintTriple returns a character vector of length 3 containing the class of object, the length of object, and the address stored by object. If object does not inherit from virtual class flint, then all of the elements are

NA.

flintVersion returns a named list of numeric versions with elements:

package

the R package version.

flint.h

the FLINT header version.

libflint

the FLINT library version.

mpfr.h

the GNU MPFR header version.

libmpfr

the GNU MPFR library version.

gmp.h

the GNU MP header version.

libgmp

the GNU MP library version.

Header versions are determined at compile time. Library versions are determined at compile time (static linking) or at load time (dynamic linking).

Arguments

object

an R object, typically inheriting from virtual class flint.

exact

a logical indicating if the length should be represented exactly as an object of class ulong.

prec

a new default value for the precision of inexact floating-point operations, if non-NULL. The value should be a positive integer indicating a number of bits.

rnd

a new default value for the rounding mode of inexact floating-point operations, if non-NULL. The value should be a character string indicating a rounding mode for signed floating-point types. Valid characters are [Uu] (towards positive infinity), [Dd] (towards negative infinity), [Zz] (towards zero), [Aa] (away from zero), and [Nn] (to nearest, with precedence to even significands).

Author

Mikael Jagan jaganmn@mcmaster.ca

Details

To report a bug or request a feature, use bug.report(package = "flint").

To render the change log, use news(package = "flint").

To render the index, use help(package = "flint")

To render a list of help topics for S4 classes, use help.search(package = "flint", keyword = "classes")

To render a list of help topics for special mathematical functions, use help.search(package = "flint", keyword = "math")

References

FLINT Team (2025). FLINT: Fast Library for Number Theory. https://flintlib.org/

Examples

Run this code
flintABI()

oprec <- flintPrec()
nprec <- 100L
stopifnot(identical(flintPrec(nprec), oprec),
          identical(flintPrec(), nprec),
          identical(flintPrec(oprec), nprec),
          identical(flintPrec(), oprec))

ornd <- flintRnd()
nrnd <- "Z"
stopifnot(identical(flintRnd(nrnd), ornd),
          identical(flintRnd(), nrnd),
          identical(flintRnd(ornd), nrnd),
          identical(flintRnd(), ornd))

flintVersion()

Run the code above in your browser using DataLab