
Hi Hicham, Hicham Mouline wrote:
Hello,
There are a few posts these days about generic libraries for math derivation of math functions, analytically or numerically.
<snip>
template
struct function_tag {};
Use MPL Integral Constants here instead:
template
I want to have 0 variables (nothing) for the 0-dim function in the proto::function case, and I want to have exactly dim variables in the dim>0 proto::function case.
Is it possible to “math-define” the function at the same time of the function<> object definition (in c++ terms) and have the dimension deducted, like:
function f(x,y,z) = x+y+z ;
Yes. Your LHS grammar should look something like this (untested):
struct lhs_grammar
: proto::or_<
// lone functions are ok
proto::terminal< function_tag< mpl::size_t<0> > >
, proto::and_<
// f(x,y,z,...) is ok ...
proto::function<
proto::terminal< function_tag< proto::_ > >
, proto::vararg< proto::terminal< variable_tag > >
>
// ... as long as the dimension of the function
// matches the number of arguments.
, proto::if_<
mpl::equal_to<
dimension_of< proto::_value(proto::_child0) >
, mpl::prior