Element-wise bitwise OR – a logical OR on a boolean input, and a
bit-by-bit one on an integer. You can also use the | operator,
which expects bool inputs, however.
Arguments
- lhs, rhs
(
arrayish)
Two inputs with a common data type. Can be any integerish 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.- e1, e2
(
arrayish)
The operands of the operator, which it passes on aslhsandrhs.
Value
(arrayish)
Has the inputs' broadcast shape and common data type.
The | operator
| is logical, like in base R.
Unlike base R it only accepts booleans and does not auto-convert non-booleans by comparing them with 0.
See also
prim_or() for the underlying primitive.
Examples
x <- nv_array(c(TRUE, FALSE, TRUE))
y <- nv_array(c(TRUE, TRUE, FALSE))
x | y
#> AnvlArray
#> 1
#> 1
#> 1
#> [ CPUbool{3} ]
# different data types are promoted to their common one
nv_or(nv_scalar(12L, "i32"), nv_scalar(10L, "i64"))
#> AnvlArray
#> 14
#> [ CPUi64{} ]
# a scalar is broadcast
x | TRUE
#> AnvlArray
#> 1
#> 1
#> 1
#> [ CPUbool{3} ]