Learn R Programming

rkeops (version 1.4.2.2)

format_var_aliases: Format formula argument list in triplet (type, dimension, position)

Description

The function format_var_aliases formats KeOps formula arguments to be understood by the C++ code.

Usage

format_var_aliases(args)

Value

a list with different information about formula input arguments:

args

vector of text string, input parameter args

var_name

vector of text string, corresponding name of formula arguments

var_type

vector of text string, corresponding type of formula arguments (among Vi, Vj, Pm).

var_pos

vector of integer, corresponding arguments positions.

var_aliases

text string, declaration of formula input arguments for the C++ KeOps API.

Arguments

args

vector of text string, formula input arguments (see Details).

Author

Ghislain Durif

Details

Mathematical formula: sum_i e^(lambda*||x_i - y_j||^2) where x_i, y_j are 3d vectors, and lambda is a scaler parameter.

Corresponding KeOps formula and input parameters:

formula = "Sum_Reduction(Exp(lambda * SqNorm2(x-y)), 0)"
args = c("x=Vi(3)", "y=Vj(3)", "lambda=Pm(1)")

Input arguments can be of different types:

|---------|-------------------------|-----------| | keyword | meaning | type | |---------|-------------------------|-----------| | Vi | variable indexed by i | 0 | | Vj | variable indexed by j | 1 | | Pm | parameter | 2 | |---------|-------------------------|-----------|

An input parameters should be defined as follows "x=YY(dim)" or "x=YY(pos, dim)" where YY can be Vi, Vj or Pm:

  • dim is the dimension of the variable or parameter. For Vi and Vj, the range of i or j is not known at compile time, only at runtime.

  • pos is the position of the variable as it will be supplied to the operator, starting from 0. This position should be specify for all variable or none, if not specify the natural order in the vector args is used.

For the formula "Sum_Reduction(Exp(lambda * SqNorm2(x-y)), 0)", both args = c("x=Vi(3)", "y=Vj(3)", "lambda=Pm(1)") and args <- c("x=Vi(0,3)", "y=Vj(1,3)", "beta=Vj(2,3)", "lambda=Pm(3,1)") are equivalent. When specifying the pos parameter, the natural order in the vector args may not correspond to the order of the formula input arguments.

Note: we recommand to use the Vi(dim) notation and let the position be determined by the argument order.