|
Boost Users : |
Subject: Re: [Boost-users] proto: analytical-only math functions
From: Hicham Mouline (hicham_at_[hidden])
Date: 2009-03-14 08:55:36
-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Eric Niebler
Sent: 07 March 2009 02:32
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] proto: analytical-only math functions
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 user-defined
> 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 compile-time 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 compile-time as well, so:
> let( f(x) = log(x) )[ g(x) = derivative<1>(f, x) ];
I am thinking about user friendliness.
I think I will have the user define this:
typedef proto::terminal< function_tag< mpl::size_t<3> > >::type
function3;
function3 f( x1, x2, x3, x1+ x2+ x3+ c6 ); // after all, store the
expression tree at runtime
1. Can I define a constructor for the terminal like this?
2. Can I store the expression tree somewhere? Inside the function_tag
template?
Regards,
Boost-users 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