Skip to contents

Symbolically applies opstr operation to x and y.

Usage

binaryop.LazyTensor(
  x,
  y,
  opstr,
  is_operator = FALSE,
  dim_check_type = "sameor1",
  res_type = NA,
  dim_res = NA,
  opt_arg = NA
)

Arguments

x

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

y

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

opstr

A text string corresponding to an operation.

is_operator

A boolean used to specify if opstr is an operator like +, - or a "genuine" function.

dim_check_type

A string to specify if, and how, we should check input dimensions. Supported values are:

  • "same": x and y should have the same inner dimension;

  • "sameor1" (default): x and y should have the same inner dimension or at least one of them should be of dimension 1;

  • NA: no dimension restriction.

res_type

NA (default) or a character string among "LazyTensor" and "ComplexLazyTensor", to specify if a change of class is required for the result. (Useful especially when dealing with complex-to-real or real-to-complex functions).

dim_res

NA (default) or an integer corresponding to the inner dimension of the output LazyTensor. If NA, dim_res is set to the maximum between the inner dimensions of the two input LazyTensors.

opt_arg

NA (default) or list of optional arguments for the formula encoding the binary operation on input LazyTensors.

Value

An object of class "LazyTensor".

Author

Chloe Serre-Combe, Amelie Vernay

Examples

if (FALSE) {
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
y <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i')   # LazyTensor from matrix x, indexed by 'i'
y_j <- LazyTensor(y, index = 'j')   # LazyTensor from matrix y, indexed by 'j'
# symbolic matrix:
bin_xy <- binaryop.LazyTensor(x_i, y_j, "+", is_operator = TRUE)
}