flint-class function

Class of FLINT-Type Vectors

Class of FLINT-Type Vectors

Class flint is a virtual class representing vectors of any FLINT type. The type is determined by the class attribute and interfaced exactly using 's external pointer type. class

Slots

  • .xData: an external pointer. The protected field is an integer vector of length 1 or 2 storing the object length whose size is 32 or 64 bits depending on the ABI; see flintABI. The pointer field contains the address of a block of allocated memory of size greater than or equal to the object length times the size of the FLINT type. It is a null pointer if and only if the object length is zero.

     Methods for `initialize` set a finalizer on `.xData` (see `reg.finalizer`) to ensure that allocated memory is freed before `.xData` is itself freed by the garbage collector.
    
  • names: a character vector of length 0, indicating that the object is unnamed, or of length equal to the object length. A corollary is that objects whose length exceeds the maximum length of a character vector cannot have names.

Methods

  • [: signature(x = "ANY", i = "flint", j = "missing", drop = "missing"):

      `signature(x = "flint", i = "ANY", j = "missing", drop = "missing")`:
     
      `signature(x = "flint", i = "flint", j = "missing", drop = "missing")`:
     
     return a traditional vector or a `flint` vector containing the elements of `x` indexed by `i` (the subscript ). The subscript can be missing, `NULL`, logical, integer, double, character, `ulong`, `slong`, `fmpz`, or `fmpq`. Methods for signatures with `x = "flint"` signal an error for `NA` and out of bounds subscripts, as the types interfaced by `flint`
     
     vectors have no representation for missing values. Note that `[` does not perform S4 dispatch if its first positional argument is not an S4 object. If it is known that `i` is a `flint` vector and not known whether `x`
     
     is a `flint` vector, then consider programming defensively by calling `[` as ```[`(i = i, x = x)`` rather than as `x[i]`.
    
  • [<-: signature(x = "ANY", i = "ANY", j = "missing", value = "flint"):

      `signature(x = "ANY", i = "flint", j = "missing", value = "ANY")`:
     
      `signature(x = "ANY", i = "flint", j = "missing", value = "flint")`:
     
      `signature(x = "flint", i = "ANY", j = "missing", value = "ANY")`:
     
      `signature(x = "flint", i = "ANY", j = "missing", value = "flint")`:
     
      `signature(x = "flint", i = "flint", j = "missing", value = "ANY")`:
     
      `signature(x = "flint", i = "flint", j = "missing", value = "flint")`:
     
     return the traditional vector or `flint` vector obtained by replacing the elements of `x` indexed by `i` (the subscript ) with elements of `value`, which are recycled as necessary. The subscript can be missing, `NULL`, logical, integer, double, character, `ulong`, `slong`, `fmpz`, or `fmpq`. The class of the return value is determined following strict rules from the classes of `x` and `value`, which are promoted to the value class as necessary. If the value class is a subclass of `flint`, then an error is signaled for `NA` and out of bounds subscripts, as the types interfaced by `flint` vectors have no representation for missing values. Note that `[<-`
     
     does not perform S4 dispatch if its first positional argument is not an S4 object. If it is known that `i` is a `flint`
     
     vector and not known whether `x` is a `flint` vector, then consider calling `[<-` as ```[`(i = i, x = x) <- value`` rather than as `x[i] <- value`. If it known that `value` is a `flint` vector and not known whether `x` or `i` is a `flint` vector, then consider doing something like ``x <- `[<-`(value = value, x = x, i = i)``.
    
  • [[: signature(x = "ANY", i = "flint", j = "missing"):

      `signature(x = "flint", i = "ANY", j = "missing")`:
     
      `signature(x = "flint", i = "flint", j = "missing")`:
     
     similar to `[`, with differences as documented in `Extract`.
    
  • [[<-: signature(x = "ANY", i = "ANY", j = "missing", value = "flint"):

      `signature(x = "ANY", i = "flint", j = "missing", value = "ANY")`:
     
      `signature(x = "ANY", i = "flint", j = "missing", value = "flint")`:
     
      `signature(x = "flint", i = "ANY", j = "missing", value = "ANY")`:
     
      `signature(x = "flint", i = "ANY", j = "missing", value = "flint")`:
     
      `signature(x = "flint", i = "flint", j = "missing", value = "ANY")`:
     
      `signature(x = "flint", i = "flint", j = "missing", value = "flint")`:
     
     similar to `[<-`, with differences as documented in `Extract`.
    
  • all.equal: signature(x = "ANY", y = "flint"):

      `signature(x = "flint", y = "ANY")`:
     
      `signature(x = "flint", y = "flint")`:
     
     returns either `TRUE`, indicating that there is no meaningful difference between `x` and `y`, or a character vector describing differences. The implementation (including optional arguments) is adapted from `all.equal.numeric`, hence see **its** documentation. Notably, comparison of objects inheriting from different subclasses of virtual class `flint`
     
     and comparison with objects (typically atomic vectors) coercible to virtual class `flint` are supported with `check.class = FALSE`. See `flintIdentical` for much more strict comparison objects inheriting from `flint`.
    
  • anyDuplicated: signature(x = "flint"):

     returns `anyDuplicated(mtfrm(x), ...)`.
    
  • as.raw, as.logical, as.integer, as.numeric, as.complex: signature(x = "flint"):

     returns the value of `as.vector(x, mode = *)`. Methods for `as.vector` must be defined for subclasses of `flint`. Note that `as.double` dispatches internally the method for `as.numeric`, so there is no method for `as.double`; see also `as.numeric`, section S4 Methods .
    
  • as.matrix, as.array, as.Date, as.POSIXct, as.POSIXlt: signature(x = "flint"):

     coerces the argument with `as.vector` and dispatches.
    
  • as.data.frame: signature(x = "flint"):

     this method is a copy of `as.data.frame.vector`. It enables the construction of data frames containing `flint`
     
     vectors using `as.data.frame` and functions that call it such as `data.frame` and `cbind.data.frame`.
    
  • c: signature(x = "flint"):

     returns `c.flint(x, ...)`, the concatenation of the arguments. Function `c.flint` is exported to work around the fact that `c(x, ...)` dispatches only on `x`.
    
  • coerce: signature(from = "ANY", to = "flint"):

     coerces atomic (except character) vectors `from` to the most specific subclass of `flint` whose range contains the range of `typeof(from)`.
    
  • cut: signature(x = "flint"):

     returns `findInterval(x=x, vec=breaks, left.open=right,rightmost.closed=include.lowest)`, hence see below. The behaviour is consistent with the default method for `cut` with argument `labels` set to `FALSE`, provided that `breaks` is sorted and no element of `x` is out of bounds.
    
  • duplicated: signature(x = "flint"):

     returns `duplicated(mtfrm(x), ...)`.
    
  • findInterval: returns a ulong vector of length equal to the length of x, following the documented behaviour of the base function, hence see findInterval. A caveat is that an error is signaled if x contains NaN, because ulong has no representation for 's missing value NA_integer_.

  • is.na<-: signature(x = "flint"):

     returns the value of `x` after `x[value] <- na`, where `na` is an `NA` of integer, double, or complex type, depending on the class of `x`.
    
  • length: signature(x = "flint"):

     returns `flintLength(x, exact = FALSE)`.
    
  • length<-: signature(x = "flint"):

     returns a `flint` vector of length given by the second argument `value`. The first `min(length(x), value)`
     
     elements are copied from `x` and the remaining elements are initialized to zero.
    
  • match: signature(x = "ANY", table = "flint"):

      `signature(x = "flint", table = "ANY")`:
     
      `signature(x = "flint", table = "flint")`:
     
     returns an integer vector matching `x` to `table` after coercing to a common class then match transforming with `mtfrm`. The behaviour is parallel to that of the default method, hence see `match`.
    
  • mtfrm: signature(x = "flint"):

     returns `format(x, base = 62L, digits = 0L)`, a character vector representing the elements of `x` exactly in base 62 (chosen over smaller bases to reduce the number of characters in the output); see also `format-methods`.
    
  • names: signature(x = "flint"):

     returns the value of the `names` slot or `NULL`, `NULL` if the `names` slot has zero length.
    
  • names<-: signature(x = "flint", value = "NULL"):

     returns `x` with `names` slot set to a character vector of length zero.
    
  • names<-: signature(x = "flint", value = "character"):

     returns `x` with `names` slot set to `value`. Attributes of `value` are stripped. `NA_character_` are appended to `value` if its length is less than the length of `x`. An error is signaled if its length is greater.
    
  • print: signature(x = "flint"):

     prints `format(x)` without quotes and returns `x`
     
     invisibly. The output has a header listing the class and length of `x` and the address stored by its `.xData` slot. If the output might be differenced by `Rdiff`, then one can set optional argument `Rdiff` to `TRUE` to indicate that the address should be formatted as `<pointer: 0x...>` rather than as `0x...`, as the longer format is recognized and ignored by `Rdiff`. The default value `NULL` is equivalent to `getOption("flint.Rdiff", FALSE)`. For greater control over output, consider doing `print(format(x, ...), ...)`
     
     instead of `print(x, ...)`.
    
  • quantile: signature(x = "flint"):

     returns a `flint` vector containing sample quantiles computed according to additional arguments `probs` and `type`; see `quantile`. Currently, an error is is signaled for `x` of length zero and `x` containing `NaN`.
    
  • rep: signature(x = "flint"):

     repeats `x` (or elements of `x`) according to optional arguments `times`, `length.out`, and `each`. The behaviour is parallel to that of the internal default method, hence see `rep`. One difference is that `rep(0-length, length.out=nonzero)` signals an error, because the underlying types have no representation for missing values.
    
  • rep.int, rep_len: signature(x = "flint"):

     analogues of `rep(x, times=)` and `rep(x, length.out=)` not preserving names, faster than `rep` when `x` has names.
    
  • seq: signature(... = "flint"):

     generates `flint` vectors whose elements are equally spaced. This method is dispatched by calls to `seq` or `seq.int`
     
     in which the first positional argument is a `flint` vector. Accepted usage is any of
     
     ```
     seq(length.out=)
     seq(length.out=, by=)
     seq(from=, to=)
     seq(from=, to=, by=)
     seq(from=, to=, length.out=)
     seq(from=, by=, length.out=)
     seq(to=, by=, length.out=)
     ```
     
     where `length.out=n` and `along.with=x` are equivalent for `x` of length `n`. Good users name all arguments.
    
  • sequence: signature(nvec = "flint"):

     returns the concatenation of `seq(from = from[i], by = by[i], length.out = nvec[i])`
     
     after recycling arguments `nvec`, `from`, and `by`
     
     to a common length.
    
  • show: signature(object = "flint"):

     prints `format(object)` and returns `NULL`
     
     invisibly.
    
  • summary: signature(object = "flint"):

     returns a `flint` vector containing the minimum, first quartile, median, mean, third quartile, maximum, and (if nonzero) the number of `NaN`, unless `object` is complex (inherits from `acf` or `acb`) or `x` has error bounds (inherits from `arb` or `acb`) or optional argument `triple` is `TRUE`, in which case the value is just `flintTriple()` with names.
    
  • unique: signature(x = "flint"):

     returns `x[!duplicated(x, ...)]`.
    

Methods are on purpose not defined for generic functions whose default methods correctly handle objects inheriting from virtual class flint, typically by calling other generic functions for which methods are defined. Examples are as.character, as.list, diff, rev, seq.int, sort, and split.

See Also

The nonvirtual subclasses: ulong, slong, fmpz, fmpq, mag, arf, acf, arb, and acb.

Examples

showClass("flint") showMethods(classes = "flint")
  • Maintainer: Mikael Jagan
  • License: GPL (>= 2)
  • Last published: 2025-03-24