Symbolic element-wise clamp function (ternary operation) for LazyTensor
objects.
Details
clamp(x, a, b)
returns a LazyTensor
that encodes, symbolically,
the element-wise clamping of x
in (a, b)
, i.e. a
if x < a
,
x
if a <= x <= b
, and b
if b < x
.
Broadcasting rules apply.
Note: If a
and b
are not scalar values, these should have the same
inner dimension as x
.
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 clamp function
clp <- clamp(x_i, y_j, z_i)
}