Hello!<br><br>Looking for some knowledge on how to combine adolc and boost::units (<a href="http://www.boost.org/doc/libs/1_47_0/doc/html/boost_units.html">http://www.boost.org/doc/libs/1_47_0/doc/html/boost_units.html</a>).<br>
Has anyone attempted this?<br><br>The following program will exemplify the problem.<br><br>##########<br>#include &lt;adolc/adouble.h&gt;<br>#include &lt;boost/units/systems/si.hpp&gt;<br><br>int main(int argc, char **argv) {<br>
<br>    for (int i = 0; i &lt; 9; i++) {<br>        boost::units::quantity&lt;boost::units::si::length, adouble&gt; a = 1 * boost::units::si::meters;<br>        boost::units::quantity&lt;boost::units::si::length, adouble&gt; b = 2 * boost::units::si::meters;<br>
        boost::units::quantity&lt;boost::units::si::length, adouble&gt; c = 3 * boost::units::si::meters;<br>        boost::units::quantity&lt;boost::units::si::length, adouble&gt; d = 4 * boost::units::si::meters;<br>        boost::units::quantity&lt;boost::units::si::volume, adouble&gt;* x = new boost::units::quantity&lt;boost::units::si::volume, adouble&gt;();<br>
<br>        *x = a * b * (c - d);<br><br>        std::cout &lt;&lt; *x &lt;&lt; endl;<br><br>        delete x;<br>    }<br><br>    return 1;<br>}<br>##########<br><br>Output with no compiler optimization on 64bit Linux (gcc 4.5.2):<br>
<br>##########<br>4(a) m^3<br>4(a) m^3<br>-2(a) m^3<br>-2(a) m^3<br>-2(a) m^3<br>-2(a) m^3<br>-2(a) m^3<br>-2(a) m^3<br>-2(a) m^3<br>##########<br><br>As can be seen by the output there is something fishy going on... the values of the 1st two lines are wrong!<br>
<br>Unfortunately valgrind does not find anything wrong.<br>I am using boost 1.42 and adolc 2.1.12.<br><br>Any help would be appreciated.<br><br><br>Best regards,<br><br>Joao Leal<br>