Element-wise maximum of two arrays, like base::pmax().
Arguments
- lhs, rhs
(
arrayish)
Two inputs with a common data type. Can be any data type. Scalars are broadcast. An R value takes the other operand's data type when that is in its own or a higher category. Otherwise it settles on its default data type, and the operands meet at their common data type.
Value
(arrayish)
Has the inputs' broadcast shape and common data type.
See also
prim_pmax() for the underlying primitive.
Examples
x <- nv_array(c(1, 5, 3))
y <- nv_array(c(4, 2, 6))
nv_pmax(x, y)
#> AnvlArray
#> 4
#> 5
#> 6
#> [ CPUf32{3} ]
# different data types are promoted to their common one
nv_pmax(nv_scalar(1, "f32"), nv_scalar(5, "f64"))
#> AnvlArray
#> 5
#> [ CPUf64{} ]
# a scalar is broadcast and an R integer is converted to a float
nv_pmax(x, 2L)
#> AnvlArray
#> 2
#> 5
#> 3
#> [ CPUf32{3} ]