Symbolic element-wise if-else function (ternary operation) for
LazyTensor
objects.
Usage
# S3 method for LazyTensor
ifelse(test, yes, no)
Details
If test
is a LazyTensor
, ifelse(test, yes, no)
returns a
LazyTensor
that encodes, symbolically, yes
if test >= 0
and
no
if test < 0
.
Broadcasting rules apply.
yes
and no
may be fixed integers or floats, or other LazyTensor
.
Note: If yes
and no
are not scalar values, these should have the same
inner dimension as test
.
Examples
if (FALSE) {
# basic example
D <- 3
M <- 100
N <- 150
P <- 200
x <- matrix(runif(M * D), M, D)
y <- matrix(runif(N * D), N, D)
z <- matrix(runif(P * D), P, D)
x_i <- LazyTensor(x, index = 'i')
y_j <- LazyTensor(y, index = 'j')
z_i <- LazyTensor(z, index = 'i')
# call ifelse function
if_else_xyz <- ifelse(x_i, y_j, z_i)
}