Learn R Programming

rkeops (version 2.2.2)

parse_args: Parse formula argument list in triplet (type, dimension, position)

Description

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

Usage

parse_args(formula, 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_dim: vector of integer, corresponding arguments inner dimensions.

  • decl: character string, either "dim" if Vi|Vj|Pm(<dim>) argument declaration convention is used, or "pos_dim" if Vi|Vj|Pm(<pos>,<dim>) argument declaration convention is used.

Arguments

formula

text string, an operator formula (see Details).

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:

|---------|-------------------------|-----------|

keywordmeaningtype
Vivariable indexed by i0
Vjvariable indexed by j1
Pmparameter2
---------------------------------------------

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 recommend to use the Vi(dim) notation and let the position be determined by the argument order.