<div dir="ltr"><div><div><div><div><div><div><div>Dear Experts,<br><br></div>I am trying to use python wrapper for CppAD. My function<br></div>depends on the eigenvalues of a matrix. Can anyone help<br></div>me in this regard. The code is given below.<br><br><span style="font-family:times new roman,serif">*************************************************************<br><span style="font-family:arial,helvetica,sans-serif">from pycppad import *<br>import numpy as np<br>def Pot(arg):<br>      x=independent(arg)<br>      m00=x[0]*x[0]<br>      m11=x[1]*x[1]<br>      m01=x[0]*x[1]<br>      m10=-x[0]*x[1]<br>      m=np.array([[m00,m01],[m10,m11]])<br>      return np.array([np.sum(np.linalg.eigvalsh(m))],dtype='a2float')<br>def hessian():<br>  delta = 10. * np.finfo(float).eps<br>  x     = np.array( [ 0., 0. ] )<br>  a_x   = independent(x)<br>  a_y   = Pot(a_x)<br>  f   = adfun(a_x, a_y)<br>  x   = np.array( [ 2., 3. ] )<br>  H   = f.hessian(x, [0])<br>  print H<br>  <br>hessian()</span></span><br>*************************************************************<br><br></div>I am getting following error.<br><br><b>Traceback (most recent call last):<br>  File "hessian2.py", line 37, in <module><br>    pycppad_test_hessian()<br>  File "hessian2.py", line 30, in pycppad_test_hessian<br>    a_y   = Pot(a_x)<br>  File "hessian2.py", line 24, in Pot<br>    return np.array([np.sum(np.linalg.eigvalsh(m))],dtype='a2float')<br>  File "/usr/local/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 994, in eigvalsh<br>    w = gufunc(a, signature=signature, extobj=extobj)<br>TypeError: No loop matching the specified signature and casting<br>was found for ufunc eigvalsh_lo</b><br><br></div>Regards,<br></div>Jyotiranjan Beuria<br></div>Graduate student, HRI, INDIA<br><div><div><div><br></div></div></div></div>