hutilscpp (version 0.10.4)

pmaxC: Parallel maximum/minimum

Description

Faster pmax() and pmin().

Usage

pmaxC(
  x,
  a,
  in_place = FALSE,
  keep_nas = FALSE,
  dbl_ok = NA,
  nThread = getOption("hutilscpp.nThread", 1L)
)

pminC( x, a, in_place = FALSE, keep_nas = FALSE, dbl_ok = NA, nThread = getOption("hutilscpp.nThread", 1L) )

pmax0( x, in_place = FALSE, sorted = FALSE, keep_nas = FALSE, nThread = getOption("hutilscpp.nThread", 1L) )

pmin0( x, in_place = FALSE, sorted = FALSE, keep_nas = FALSE, nThread = getOption("hutilscpp.nThread", 1L) )

pmaxV( x, y, in_place = FALSE, dbl_ok = TRUE, nThread = getOption("hutilscpp.nThread", 1L) )

pminV( x, y, in_place = FALSE, dbl_ok = TRUE, nThread = getOption("hutilscpp.nThread", 1L) )

pmax3(x, y, z, in_place = FALSE)

pmin3(x, y, z, in_place = FALSE)

Value

Versions of pmax and pmin, designed for performance.

When in_place = TRUE, the values of x are modified in-place. For advanced users only.

The differences are:

pmaxC(x, a) and pminC(x, a)

Both x and a must be numeric and a must be length-one.

Arguments

x
numeric(n)

A numeric vector.

a

in_place
TRUE | FALSE, default: FALSE

Should x be modified in-place? For advanced use only.

keep_nas
TRUE | FALSE, default: FALSE

Should NAs values be preserved? By default, FALSE, so the behaviour of the function is dependent on the representation of NAs at the C++ level.

dbl_ok
logical(1), default: NA

Is it acceptable to return a non-integer vector if x is integer?

This argument will have effect a is both double and cannot be coerced to integer:

If NA, the default, a message is emitted whenever a double vector needs to be returned. If FALSE, an error is returned. If TRUE, neither an error nor a message is returned.

nThread
integer(1)

The number of threads to use. Combining nThread > 1 and in_place = TRUE is not supported.

sorted
TRUE | FALSE, default: FALSE

Is x known to be sorted? If TRUE, x is assumed to be sorted. Thus the first zero determines whether the position at which zeroes start or end.

y, z

Examples

Run this code
pmaxC(-5:5, 2)
pmaxC(1:4, 5.5)
pmaxC(1:4, 5.5, dbl_ok = TRUE)
# pmaxC(1:4, 5.5, dbl_ok = FALSE)  # error

Run the code above in your browser using DataLab