Creating a number of FUNCTION_1P
I am trying to declare N GiNaC 1 parameter functions (DECLARE_FUNCTION_1P), each of which represents a different function of the same single parameter (in my case, this parameter represents time). My primary motivation for doing this is to be able to easily create a bunch of symbol-like objects that all depend on time so that I can trust that the chain rule will work properly when differentiating with respect to this single parameter. I think this has come up before, but I haven't seen a way to declare a vector or list of these functions without N explicit statements to DECLARE_FUNCTION_1P. Is there a simple way to do this in GiNaC? Thanks, Luke
For undefined functions a some parameter(s), if I don't declare them using DECLARE_FUNCTION_1P, I have to manually apply the chain rule: symbol x("x"), dxdt("dxdt"); ex l = 2*x + 3*x*x; ex dldt = l.diff(x)*dxdt; // manual chain rule. Obviously, the chain is nice (and achievable with DECLARE_FUNCTION_1P) because then I can do: symbol t("t"); ex dldt = l.diff(t); // automatic chain rule But it is annoying to have to declare all my undefined functions as preprocessor macros, but I don't see a way around it. Especially if I don't know how many there will be at compile time. Is there one? Luke On Sun, Jan 20, 2013 at 3:12 PM, Dale Lukas Peterson <hazelnusse@gmail.com> wrote:
I am trying to declare N GiNaC 1 parameter functions (DECLARE_FUNCTION_1P), each of which represents a different function of the same single parameter (in my case, this parameter represents time). My primary motivation for doing this is to be able to easily create a bunch of symbol-like objects that all depend on time so that I can trust that the chain rule will work properly when differentiating with respect to this single parameter.
I think this has come up before, but I haven't seen a way to declare a vector or list of these functions without N explicit statements to DECLARE_FUNCTION_1P. Is there a simple way to do this in GiNaC?
Thanks, Luke
-- “People call me a perfectionist, but I'm not. I'm a rightist. I do something until it's right, and then I move on to the next thing.” ― James Cameron
participants (1)
-
Dale Lukas Peterson