[ADOL-C] active section declaration

Kshitij Kulshreshtha kshitij at math.upb.de
Sun Jun 27 07:13:55 EDT 2010


As on 2010-06-27 12:56, borja artamendi did write:
> Dear all,

Dear Borja,

> My question is: I have defined the active section on eval which eval
> calls to eval2. Then eval2 use class funSIN, so, do i have to define a
> new active section in class funSIN, or is not necessary cz i have
> defined in eval ?

No you don't need to define any new active section. Any set of commands,
function calls etc that are executed between a trace_on and a trace_off
are recorded on the trace.

> class funSIN: public funcion<adouble>
> {
>   string toString() const
>   { return "sin"; }
>   double eval(const vector<adouble> & args)
>   {
>     double valor, aux;
>     adouble aux2;
>    
>     if(args.size() != 1) throw runtime_error("funSIN::eval(): n args
> incorrecto")
>     {
>       adouble args[0] >>= valor;
>       aux = sin(valor);
>       aux2 <<= aux;
>       return aux2;
>     }
>   }
>   unsigned int aridad()
>   { return 1; }
> };
> 
> Well, if i want to use sin() function of mathcalls.h, I need to convert
> adouble to double (adouble args[0] >>= valor;) .

Unfortunately I must say I don't understand what this code is trying to
do. The operator <<= defines the independents of your function and the
operator >>= defines the dependents.

Especially the code:

>     {
>       adouble args[0] >>= valor;
>       aux = sin(valor);
>       aux2 <<= aux;
>       return aux2;
>     }

Makes no sense at all to me, it won't even compile I'm afraid. You've
already the function argument for funSIN::eval as 'vector<adouble> args,
then args[0] is automatically an adouble. The compiler will complain
when you try to redeclare args[0] in

>       adouble args[0] >>= valor;

also the operator will try to exract the value stored in args[0] and
copy it to valor, making args[0] a dependent variable on the trace. Then
you do

>       aux = sin(valor);

which is computed as a double and will not be recorded on the trace.
Afterwards you declare another independent on the trace with

>       aux2 <<= aux;

and return. Is this what you really want to do?
-- 
Kshitij Kulshreshtha

Institut für Mathematik,
Universität Paderborn,
Warburger Straße 100,
33098 Paderborn.

Büro: A3.319

Privatanschrift:
Arnikaweg 62
33100 Paderborn.



More information about the ADOL-C mailing list