[ADOL-C] support for operator overloading for pdouble

hg hgbk2008 at gmail.com
Wed Feb 28 08:29:20 EST 2018


Thank you for your quick reply. I'm OK with the first construct.

Best regards
Giang

On Wed, Feb 28, 2018 at 11:27 AM, Kshitij Kulshreshtha <
kshitij at math.uni-paderborn.de> wrote:

> Hello,
>
> pdouble types are not meant to be added or multiplied together. One
> pdouble represents one actual parameter. If you combine parameters
> together, then you should either do that before converting them to
> pdoubles as simple doubles, and that combined value will then always be
> used, or the other possibility is to store the result of such a
> combination in a variable of type adouble, which you will use in the
> rest as any other adouble. The reason pdoubles cannot have overloaded
> operators is that we do not trace any operations on constants in order
> to keep the trace small, so these operations cannot be conducted when
> computing derivatives with such a trace.
>
> Your example should can either look like this:
>
> const pdouble& __o_11_n = mkparam(input.o_11_n());
> const pdouble& __o_22_n = mkparam(input.o_22_n());
> const pdouble& __o_33_n = mkparam(input.o_33_n());
>
> adouble __p_n = (adouble(__o_11_n) + __o_22_n + __o_33_n)/3;
>
> Then you can use __p_n wherever you need.
>
> Or it can look like this:
>
> const pdouble& __p_n =
>    mkparam( (input.o_11_n() + input.o_22_n() + input.o_33_n())/3);
>
> in case you only need __p_n in the rest of the code.
>
> Best wishes
> Kshitij Kulshreshtha.
>
> On 02/28/18 10:56, hg wrote:
> > Dear Adol-C developers
> >
> > I would like to report that the example taylor/inversexam.cpp failed
> > with ADOL-C release v2.6.3, but it worked with the developer version.
> > Hope the new stable release will be released soon.
> >
> > Additionally I would like to request to add the operator overloading for
> > pdouble type. Because some material constants are formed from others and
> > it would lead to a neatly code if an immediate variable of type pdouble
> > is created. Right now I have to copy a lengthy expression to a lengthy
> > one, leading to quite a complicated expression, which is then hard to
> > debug if something happen later on.
> >
> > Right now if I added the pdouble, the compilation error appears:
> >
> > const pdouble& __o_11_n = mkparam(input.o_11_n());
> > const pdouble& __o_22_n = mkparam(input.o_22_n());
> > const pdouble& __o_33_n = mkparam(input.o_33_n());
> >
> > pdouble __p_n = (__o_11_n + __o_22_n + __o_33_n)/3;
> >
> >
> > error: ambiguous overload for ‘operator+’ (operand types are ‘const
> > pdouble’ and ‘const pdouble’)
> >          pdouble __p_n = (__o_11_n + __o_22_n + __o_33_n)/3;
> >                                    ^
> > In file included from /home/hbui/opt/adol-c/include/
> adolc/adouble.h:329:0,
> >                  from /home/hbui/opt/adol-c/include/adolc/adolc.h:28,
> >                  from
> > /home/hbui/kratos_bcn2/applications/soil_mechanics_
> application/constitutive_laws/smoothed_mohr_coulomb_ad_
> explicit_lode_angle.cpp:18:
> > /home/hbui/opt/adol-c/include/adolc/param.h:105:13: note: candidate:
> > adub operator+(const pdouble&, const badouble&)
> >  inline adub operator + ( const pdouble& a, const badouble& b)
> >              ^
> > In file included from /home/hbui/opt/adol-c/include/adolc/param.h:58:0,
> >                  from /home/hbui/opt/adol-c/include/adolc/adouble.h:329,
> >                  from /home/hbui/opt/adol-c/include/adolc/adolc.h:28,
> >                  from
> > /home/hbui/kratos_bcn2/applications/soil_mechanics_
> application/constitutive_laws/smoothed_mohr_coulomb_ad_
> explicit_lode_angle.cpp:18:
> > /home/hbui/opt/adol-c/include/adolc/internal/paramfunc.h:50:34: note:
> > candidate: adub operator+(const badouble&, const pdouble&)
> >      friend ADOLC_DLL_EXPORT adub operator + ( const badouble&, const
> > pdouble&);
> >
> >
> > Best regards
> > Giang Bui
> >
> >
> >
> > _______________________________________________
> > ADOL-C mailing list
> > ADOL-C at list.coin-or.org
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__list.
> coin-2Dor.org_mailman_listinfo_adol-2Dc&d=DwIGaQ&c=Ngd-
> ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=0eOhD1zcLnB9JhadNXrezwNw87TYLa
> 0fyHrxCkWC5J8&m=YyhagFQmRBCP43JeHmTh1n3Xj3m8_3g63LF77CNcbkI&s=
> JnAlKZwjU7oHFylIbpcS7ANqQMH2bY3gCPzDo2ANArs&e=
> >
>
> --
> PD. Dr. Kshitij Kulshreshtha
>
> Institut für Mathematik,
> Universität Paderborn,
> Warburger Straße 100,
> 33098 Paderborn.
>
> Büro: TP21.1.21
> Besucheradresse:
> Technologiepark 21
> 33098 Paderborn.
>
> Privatanschrift:
> Arnikaweg 62
> 33100 Paderborn.
> _______________________________________________
> ADOL-C mailing list
> ADOL-C at list.coin-or.org
> https://urldefense.proofpoint.com/v2/url?u=https-3A__list.
> coin-2Dor.org_mailman_listinfo_adol-2Dc&d=DwIGaQ&c=Ngd-
> ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=0eOhD1zcLnB9JhadNXrezwNw87TYLa
> 0fyHrxCkWC5J8&m=YyhagFQmRBCP43JeHmTh1n3Xj3m8_3g63LF77CNcbkI&s=
> JnAlKZwjU7oHFylIbpcS7ANqQMH2bY3gCPzDo2ANArs&e=
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/adol-c/attachments/20180228/b8d4bff5/attachment.html>


More information about the ADOL-C mailing list