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 <adolc/adouble.h><br>#include <boost/units/systems/si.hpp><br><br>int main(int argc, char **argv) {<br>
<br> for (int i = 0; i < 9; i++) {<br> boost::units::quantity<boost::units::si::length, adouble> a = 1 * boost::units::si::meters;<br> boost::units::quantity<boost::units::si::length, adouble> b = 2 * boost::units::si::meters;<br>
boost::units::quantity<boost::units::si::length, adouble> c = 3 * boost::units::si::meters;<br> boost::units::quantity<boost::units::si::length, adouble> d = 4 * boost::units::si::meters;<br> boost::units::quantity<boost::units::si::volume, adouble>* x = new boost::units::quantity<boost::units::si::volume, adouble>();<br>
<br> *x = a * b * (c - d);<br><br> std::cout << *x << 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>