[CppAD] constructing an AD function at runtime

Michael Tautschnig tautschn at model.in.tum.de
Wed Sep 13 03:30:00 EDT 2006


[...]
> 
> How should I do it. The infixTokens is an array of function tokens. Each 
> token is a string symbol. Notice you really don't know what the string 
> array looks like except that the tokens are in standard infix and each 
> token is exactly the same as the corrsponding c++ operator.
> 
AFAIK there is no integrated string parser in CppAD, thus you need to do it
yourself.

> As an alternative to passing string array, I can pass an array of 
> AD<double> tokens (making it easy to implement the above function).
> For example, I know how to create a number AD, which is as simple as 
> AD<double> numberToken = 2.1
> But how should I create a "+" AD? I don't think I can create it like
> AD<double> plusToken = + //compile time error
> or
> AD<double> plusToken = "+" //operator = not ready to take a string?
> 
I think you got that one wrong: All you need to do is add the AD<double> tokens
in case you encounter a "+".

Say, you've got a string "2.1 + 3", then you'd need to find some way of
obtaining the following code:

AD<double> numberToken1 = 2.1;
AD<double> numberToken2 = 2.1;

AD<double> func = numberToken1 + numberToken2;

> All the hard-coded example always construct an AD with a term like 
> AD<doulbe> plusTerm = 3 + numberToken;
> 
> Hope there is a solution constructing AD function at runtime in CppAD.
>
Well, it's all about writing an appropriate string parser. If you need further
explanations or an example, feel free to get back; I do have working code doing
something similar, however, it is embedded in a bigger framework.

Hope this helps,
Michael

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://list.coin-or.org/pipermail/cppad/attachments/20060913/e542f151/attachment.bin


More information about the CppAD mailing list