This text collects common pitfalls and known bugs that may lead to incorrect computation of derivatives.
Inplace Numpy Array Operations
One has to be careful with the operations += , *=, ... of numpy arrays. The problem is best explained at an example:In : import numpy In : import adolc In : x = adolc.adouble(numpy.array([1,2,3],dtype=float)) In : y = numpy.array([4,5,6],dtype=float) In : x Out: array([1(a), 2(a), 3(a)], dtype=object) In : y Out: array([ 4., 5., 6.]) In : x * y Out: array([4(a), 10(a), 18(a)], dtype=object) In : y *= x In : y Out: array([ 4., 5., 6.])
That means that the inplace operation x *= y ` is *not* the same as `x = x * y.
This is not a bug of PYADOLC but a design choice in numpy's implementation of the augmented assignment statements *=, etc. for arrays of objects.
Numpy tries to cast the dtype of y to the dtype x. If x has dtype float then on each element y[i].__float__() is called.