Applies a reduction to a LazyTensor.
Arguments
- x
a
LazyTensoror aComplexLazyTensor.- opstr
a
stringformula (like "Sum" or "Max").- index
a
charactercorresponding to the wanted reduction dimension, either"i"or"j", to specify whether if the reduction is done along the indexiorj.- opt_arg
an optional argument: an
integer(e.g. forKminreduction), acharacter, aLazyTensoror aComplexLazyTensor.NULLif not used (default).
Details
reduction.LazyTensor(x, opstr, index) will :
if
index = "i", return theopstrreduction ofxover the "i" indexes;if
index = "j", return theopstrreduction ofxover the "j" indexes.
Examples
if (FALSE) {
x <- matrix(runif(150 * 3), 150, 3) # arbitrary R matrix, 150 rows, 3 columns
x_i <- LazyTensor(x, index = 'i') # creating LazyTensor from matrix x,
# indexed by 'i'
red_x <- reduction.LazyTensor(x_i, "Sum", "i")
}