
Boost Users : 
Subject: Re: [Boostusers] proto: analyticalonly math functions
From: Eric Niebler (eric_at_[hidden])
Date: 20090306 21:32:00
Hicham Mouline wrote:
>
> Step1 is to have a derivative metafunction which computers the nth
> derivative of a function at compile time.
>
> In order to do that, I need a mathematical language to write my
> functions.
>
> so I have constants, variables, basic_functions and userdefined
> functions that are terminals of my language
>
> f(x) = log(x);
>
> g(x) = derivative(1, f, x);
>
> g(x) will be 1/x;
>
> I should manage to run derivative purely in compile time.
You won't be able to do it this way with exactly this syntax. The object
"f" will not carry the compiletime information that derivative() would
need to do its job. You might need something like this:
BOOST_PROTO_AUTO( _f, f(x) = log(x) );
BOOST_PROTO_AUTO( _g, g(x) = derivative(1, _f, x) );
Or, you could do it all in one big expression, like:
let( f(x) = log(x) )[ g(x) = derivative(1, f, x) ];
or something. And if I'm right in assuming that the first parameter of
derivative is which derivative to take, you'll need to make that
information available at compiletime as well, so:
let( f(x) = log(x) )[ g(x) = derivative<1>(f, x) ];
> Later, I will look at stochastic and partial differential equations
> and write functions to solve them analytically whenever possible...
>
> proto will help me define terminals, the grammars for what are
> acceptable expressions.
Right.
 Eric Niebler BoostPro Computing http://www.boostpro.com
Boostusers list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net