Registered Member
|
Hello,
I came across an error in the unsupported AutoDiff module while using it to compute the second derivative (the Hessian) of a function. I like to cite viewtopic.php?f=74&t=110376 where alexanderwerner and Gael gave me the hints, how to compute the second derivative. The second derivative works perfect in the case of polynomials (operators + and *), but if I use math functions like sin(), log() etc. it fails test code (with Eigen::Dynamic size, developed by alexanderwerner)
I get the following runtime error:
If I switch to the polynomial example (y = x(0)*x(0)*x(1)*x(1);) in fun_sin() everything works fine and I get the correct output of the program
So, maybe the definition of sin() and the like in AutoDiffScalar.h has to be modified ... Another observation is (which may give a hint what's going wrong): the same test code as above, but now with fixed vector size of 2
This gives no runtime error but leads to wrong results
Please observe, that in this example y.value().derivatives() and the two scalars y.derivatives()(0).value(), y.derivatives()(1).value() are already not equal. While in the polynomial case, see above, they are. The results (6.9e-310) maybe uninitialized numerical values. Thus, also the Hessian are some "random" values ... Any idea or hints? Thanks Ralf |
Registered Member
|
in AutoDiffScalar.h on line 634 replace
typedef AutoDiffScalar<DerType>& Nested; with typedef AutoDiffScalar<DerType> Nested; |
Registered Member
|
Hello psja,
that works! Thank you very much! Ralf @Gael: Shall we file a bug concerning this? Remark: Now, the small test code produces the correct output
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]