Element-wise remainder. This
differs from base R's %%, use nv_mod()/%% instead.
Arguments
- lhs, rhs
(
arrayish)
Two inputs with a common data type. Can be any numeric data type. Scalars are broadcast, and R values assume the other operand's data type within their data type category, otherwise falling back to their default data type and being converted to the common data type.
Value
(arrayish)
Has the inputs' broadcast shape and common data type.
See also
nv_mod() for the flooring remainder, prim_remainder() for the
underlying primitive.
Examples
x <- nv_array(c(7, 8, 9))
y <- nv_array(c(3, 3, 4))
nv_remainder(x, y)
#> AnvlArray
#> 1
#> 2
#> 1
#> [ CPUf32{3} ]
# different data types are promoted to their common one
nv_remainder(nv_scalar(7, "f32"), nv_scalar(3, "f64"))
#> AnvlArray
#> 1
#> [ CPUf64{} ]
# a scalar is broadcast and an R integer is converted to a float
nv_remainder(x, 3L)
#> AnvlArray
#> 1
#> 2
#> 0
#> [ CPUf32{3} ]