The function parse_args formats KeOps formula arguments to be
understood by the C++ code.
parse_args(formula, args)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.
text string, an operator formula (see Details).
vector of text string, formula input arguments (see Details).
Ghislain Durif
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 recommend to use the Vi(dim) notation and let the position be
determined by the argument order.