Skip to contents

Symbolic element-wise modulo with offset function (ternary operation) for LazyTensor objects

Usage

# S3 method for LazyTensor
mod(x, a, b = 0, ...)

Arguments

x, a, b

a LazyTensor, a ComplexLazyTensor, a vector of numeric values, or a scalar value.

...

not used, only present for method compatibility with corresponding generic function.

Value

An object of class LazyTensor.

Details

If x is a LazyTensor, mod(x, a, b) returns a LazyTensor that encodes, symbolically, the element-wise modulo of x with divisor a and offset b, i.e. x - a * floor((x - b)/a). By default b = 0, mod(x, a) corresponds to the standard R function %%.

a and b may be fixed integers or floats, or other LazyTensor. Broadcasting rules apply.

Note: If a and b are not scalar values, these should have the same inner dimension as x.

Warning: Do not confuse with Mod().

Author

Chloe Serre-Combe, Amelie Vernay

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 mod function
mod_x72 <- mod(x_i, 7, 2)

# works also with LazyTensors with same inner dimension or dimension 1
mod_xyz <- mod(x_i, y_j, z_i)
}