Learn R Programming

rkeops (version 2.2.2)

fix_variables: Fix variables.

Description

Assigns final labels to each variable for the KeOps routine.

Usage

fix_variables(x, is_opt = FALSE)

Value

A LazyTensor or a ComplexLazyTensor.

Arguments

x

A LazyTensor or a ComplexLazyTensor.

Author

Chloe Serre-Combe, Amelie Vernay

Details

fix_variables(x) will change the identifiers of x variables in x$args and x$formula into simpler ordered labels of the form V<n> where n is the apparition order of the variable in the formula.

Examples

Run this code
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')   # creating LazyTensor from matrix x, 
                                    # indexed by 'i'
y_j <- LazyTensor(y, index = 'j')   # creating LazyTensor from matrix y, 
                                    # indexed by 'j'

a <- x_i + y_j       # combination of LazyTensors with variable labels 
                     # of the form "A0x.*"

b <- fix_variables(a) # combination of LazyTensors with variable labels 
                     # of the form "V0" and "V1"
b$formula            # returns "V0+V1"
b$args               # returns a vector containing "V0=Vi(3)" and "V1=Vj(3)"
}

Run the code above in your browser using DataLab