[ADOL-C] result seems to differ for double and adouble

Nozomu Tomita layers.of.unitcells at gmail.com
Sun Aug 11 03:55:02 EDT 2013


Dear all,

I'm writing 3-dimensional geometrical calculation, such as how long a line penetrates a box,
with templated class.

The problem is that my templated function returns different results for double and adouble,
and "const adouble" quantities seem to change in the middle of calculation.

I'm sorry for the mess of source code, but I couldn't pick out the exact place that harms...

My code http://pastebin.ca/2430586 is meant to do an identical calculation for both double and adouble,
checking whether a line that is parallel to z-axis and on (1/2, 1/2, 0), penetrates
a square (0,0,0)-(1,0,0)-(1,1,0)-(0,1,0).

That returns correctly true for double, but false for adouble.
Compiling this with -DDEBUG produces this output: http://pastebin.ca/2430588

Line 55 - 67 of this output correspond to line 173 - 216 of source with template argument Real==adouble.
The Odd thing is that although X and u (and its members) are declared as const,
they change during calculation, from line 57 (u == vector3(0(a), 0(a), 1(a)))
and line 59 (u == vector3(0(a), 0(a), 0(a))).


I tested this result for ADOL-C 2.4.1 in two environments:
* Debian 6.0.1,
 with g++ (Debian 4.4.5-8) 4.4.5
* MacOS X 10.8.4,
 with g++ i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)


Thank you!

Tomita


More information about the ADOL-C mailing list