<div dir="ltr">Even after removing "<span style="font-size:12.800000190734863px">x=independent(arg)" in the function definition</span><div><span style="font-size:12.800000190734863px">also does not solve the problem. It seems that </span>np.linalg.eigvalsh()</div><div>is not accepting a_float types. At this point I have a naive question,</div><div>are all linear algebra modules offered by numpy compatible with</div><div>CppAD?</div><div><br></div>I still get following error:<div><br> File "/usr/local/lib/python2.7/dist-packages/numpy/linalg/linalg.py", line 994, in eigvalsh<br><br> w = gufunc(a, signature=signature, extobj=extobj)<br><br>TypeError: No loop matching the specified signature and casting<br><br>was found for ufunc eigvalsh_lo<div> </div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 4, 2017 at 4:02 AM, Brad Bell <span dir="ltr"><<a href="mailto:bradbell@seanet.com" target="_blank">bradbell@seanet.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It seems from the statement<br>
a_y = Pot(a_x)<br>
that the return value from Pot should be an a_float.<br>
<br>
Looking at the code for Pot(arg), it is not clear what the call to independent is doing,<br>
nor how two levels are AD are used here.<br>
<br>
This makes me think that<br>
def Pot(arg) :<br>
x=independent(arg)<br>
should be replaced by<br>
def Pot(x) :<br>
and<br>
dtype='a2float'<br>
should be replaced by<br>
dtype='a_float'<div><div class="h5"><br>
<br>
<br>
<br>
On 08/03/2017 05:07 AM, Jyotiranjan Beuria wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Dear Experts,<br>
<br>
I am trying to use python wrapper for CppAD. My function<br>
depends on the eigenvalues of a matrix. Can anyone help<br>
me in this regard. The code is given below.<br>
<br>
******************************<wbr>******************************<wbr>*<br>
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<wbr>]])<br>
return np.array([np.sum(np.linalg.eig<wbr>valsh(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()<br>
******************************<wbr>******************************<wbr>*<br>
<br>
I am getting following error.<br>
<br></div></div>
*Traceback (most recent call last):<span class=""><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.eig<wbr>valsh(m))],dtype='a2float')<br>
File "/usr/local/lib/python2.7/dist<wbr>-packages/numpy/linalg/linalg.<wbr>py",<br>
line 994, in eigvalsh<br>
w = gufunc(a, signature=signature, extobj=extobj)<br>
TypeError: No loop matching the specified signature and casting<br></span>
was found for ufunc eigvalsh_lo*<span class=""><br>
<br>
Regards,<br>
Jyotiranjan Beuria<br>
Graduate student, HRI, INDIA<br>
<br>
<br>
<br></span>
______________________________<wbr>_________________<br>
CppAD mailing list<br>
<a href="mailto:CppAD@list.coin-or.org" target="_blank">CppAD@list.coin-or.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cppad&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=UxLhbaqYMJLc2OFXF6T8asQht7vpwIClD1FdrFb8omo&m=rPTSQO84d-cZe99G2qE3-3_iukhRo0yydos83tDxCYY&s=r9S0qITbXtLfkk3Dqx1Hb9vdoXe5h3QmEjLvr_on3-c&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=https-3A__list.co<wbr>in-2Dor.org_mailman_listinfo_<wbr>cppad&d=DwICAg&c=Ngd-ta5yRYsqe<wbr>UsEDgxhcqsYYY1Xs5ogLxWPA_<wbr>2Wlc4&r=UxLhbaqYMJLc2OFXF6T8as<wbr>Qht7vpwIClD1FdrFb8omo&m=<wbr>rPTSQO84d-cZe99G2qE3-3_iukhRo0<wbr>yydos83tDxCYY&s=r9S0qITbXtLfkk<wbr>3Dqx1Hb9vdoXe5h3QmEjLvr_on3-c&<wbr>e=</a><br>
<br>
</blockquote>
______________________________<wbr>_________________<br>
CppAD mailing list<br>
<a href="mailto:CppAD@list.coin-or.org" target="_blank">CppAD@list.coin-or.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_cppad&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=Q-ytHio7AaRRiIuJRtbXN8AT1n8UpuHlx7zvJ-OkcrY&m=a1LG50d2vI9UL7Ttk1Y1nZpCgW-ApCfzJSZOMe2Vsr4&s=OY_pnnHykR6L0RkY2b-r897K_2vIklZz85RoBJMwd6E&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=https-3A__list.co<wbr>in-2Dor.org_mailman_listinfo_<wbr>cppad&d=DwICAg&c=Ngd-ta5yRYsqe<wbr>UsEDgxhcqsYYY1Xs5ogLxWPA_<wbr>2Wlc4&r=Q-ytHio7AaRRiIuJRtbXN8<wbr>AT1n8UpuHlx7zvJ-OkcrY&m=a1LG50<wbr>d2vI9UL7Ttk1Y1nZpCgW-ApCfzJSZO<wbr>Me2Vsr4&s=OY_pnnHykR6L0RkY2b-<wbr>r897K_2vIklZz85RoBJMwd6E&e=</a> </blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Jyotiranjan Beuria<br>Ph.D Student, HRI Allahabad<br></div>
</div>