Learn R Programming

flint (version 0.1.0)

Part: Get or Set One Part of a Vector

Description

The subclasses of virtual class flint are interfaces to C types in the FLINT C library. For types implemented recursively as C structs, it is often very natural to get and set the struct members. The functions documented here provide support for this common operation; they are all S4 generic.

Usage

Num(q)
Num(q) <- value
Den(q)
Den(q) <- value

Mid(x) Mid(x) <- value Rad(x) Rad(x) <- value

Real(z) Real(z) <- value Imag(z) Imag(z) <- value

Value

Num, Den, Mid, Rad, Real, and

Imag and their replacement forms return a vector-like R

object preserving the length, dimensions, dimension names, and names of the argument. See ‘Details’ for behaviour specific to methods in package flint.

Arguments

q

a vector-like R object with elements representing quotients of numbers. Package flint provides methods for class fmpq.

x

a vector-like R object with elements representing balls in a metric space. Package flint provides methods for class arb.

z

a vector-like R object with elements representing complex numbers. Package flint provides methods for classes acf and acb.

value

a vector-like R object; the replacement value. Methods in package flint support atomic vectors and vectors inheriting from virtual class flint, of length equal to 1 or the length of the argument.

Details

Num and Den extract fmpz numerators and denominators from fmpq q. The replacement form of Num constructs a new fmpq vector from value (coerced to fmpz) and Den(q). The replacement form of Den constructs a new fmpq vector from Num(q) and value (coerced to fmpz).

Mid and Rad extract arf midpoints and mag radii from arb x. The replacement form of Mid constructs a new arb vector from value (coerced to arf) and Rad(x). The replacement form of Rad constructs a new arb vector from Mid(x) and value (coerced to mag).

Real and Imag extract arf real and imaginary parts from acf z and arb real and imaginary parts from acb z. The replacement form of Real constructs a new acf or acb vector from value (coerced to arf or arb) and Imag(z). The replacement form of Imag constructs a new acf or acb vector from Real(z) and value (coerced to arf or arb).

For convenience, Mid and its replacement form also work for acb x, getting and setting the complex midpoint defined by the midpoints of the real and imaginary parts of x.

See Also

Virtual class flint.

Examples

Run this code
(q <- q. <- fmpq(num = 1:10, den = 2L))
Num(q)
Den(q)
Num(q) <- Den(q)
q
(m <- Num(q))
(n <- Den(q))
stopifnot(m == 1L, n == 1L, q == 1L)

Run the code above in your browser using DataLab