<div dir="ltr">Hello<div><br></div><div>I also got the error of inverse_tensor_eval. I executed the example in examples/additional_examples/taylor/coordinates and received the error below. I used ADOL-C 2.6.3</div><div><br></div><div><div>COORDINATES (ADOL-C Example)</div><div><br></div><div> Cartesian coordinates:</div><div> z_1: (e.g. 4) </div><div>4</div><div> z_2: (e.g. 3) </div><div>3</div><div><br></div><div> Polar coordinates:</div><div> z_3: (e.g. 5) </div><div>5</div><div> z_4: (e.g. 0.64350110879) </div><div>0.64</div><div><br></div><div> Highest derivative degree = 3</div><div>*** Error in `./coordinates': double free or corruption (out): 0x0000000000c8df90 ***</div><div>Aborted (core dumped)</div></div><div><br></div><div>Please help to take a look.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Giang</div></div></div>
<br><div class="gmail_quote">On Thu, Aug 3, 2017 at 8:32 PM, 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">I have am trying to run a simple example using inverse_tensor_eval. To be specific<br>
F(z) = sin(z)<br>
I have been unable to figure out why I am getting memory errors when I run the<br>
code included below. When I run it in valgrind, I get the following output:<br>
==============================<wbr>==============================<wbr>==============================<wbr>=======<br>
build>valgrind ./adolc<br>
==29183== Memcheck, a memory error detector<br>
==29183== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.<br>
==29183== Using Valgrind-3.12.0 and LibVEX; rerun with -h for copyright info<br>
==29183== Command: ./adolc<br>
==29183==<br>
==29183== Invalid free() / delete / delete[] / realloc()<br>
==29183== at 0x4C2ED4A: free (vg_replace_malloc.c:530)<br>
==29183== by 0x4F8B731: inverse_tensor_eval (taylor.c:741)<br>
==29183== by 0x401094: main (adolc.cpp:37)<br>
==29183== Address 0x699cf38 is 8 bytes inside a block of size 32 alloc'd<br>
==29183== at 0x4C2FA50: calloc (vg_replace_malloc.c:711)<br>
==29183== by 0x4E63FA5: myalloc2 (adalloc.c:125)<br>
==29183== by 0x4F8B1B5: inverse_tensor_eval (taylor.c:688)<br>
==29183== by 0x401094: main (adolc.cpp:37)<br>
==29183==<br>
==29183== Invalid free() / delete / delete[] / realloc()<br>
==29183== at 0x4C2ED4A: free (vg_replace_malloc.c:530)<br>
==29183== by 0x4F8B74C: inverse_tensor_eval (taylor.c:743)<br>
==29183== by 0x401094: main (adolc.cpp:37)<br>
==29183== Address 0x699cf98 is 8 bytes inside a block of size 32 alloc'd<br>
==29183== at 0x4C2FA50: calloc (vg_replace_malloc.c:711)<br>
==29183== by 0x4E63FA5: myalloc2 (adalloc.c:125)<br>
==29183== by 0x4F8B1D2: inverse_tensor_eval (taylor.c:689)<br>
==29183== by 0x401094: main (adolc.cpp:37)<br>
==29183==<br>
tensor[0][0] = <a href="tel:0.523599" value="+49523599" target="_blank">0.523599</a><br>
tensor[0][1] = 1.1547<br>
tensor[0][2] = 0.7698<br>
z = <a href="tel:0.523599" value="+49523599" target="_blank">0.523599</a><br>
zp = 1.1547<br>
zpp = 0.7698<br>
adolc: Done<br>
==29183==<br>
==29183== HEAP SUMMARY:<br>
==29183== in use at exit: 1,094 bytes in 20 blocks<br>
==29183== total heap usage: 107 allocs, 89 frees, 19,481,090 bytes allocated<br>
==29183==<br>
==29183== LEAK SUMMARY:<br>
==29183== definitely lost: 104 bytes in 6 blocks<br>
==29183== indirectly lost: 8 bytes in 1 blocks<br>
==29183== possibly lost: 0 bytes in 0 blocks<br>
==29183== still reachable: 982 bytes in 13 blocks<br>
==29183== suppressed: 0 bytes in 0 blocks<br>
==29183== Rerun with --leak-check=full to see details of leaked memory<br>
==29183==<br>
==29183== For counts of detected and suppressed errors, rerun with: -v<br>
==29183== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)<br>
build><br>
==============================<wbr>==============================<wbr>==============================<wbr>=======<br>
# include <adolc/adolc.h><br>
int main(void)<br>
{<br>
int n = 1; // number of independent and dependent variables<br>
int d = 2; // highest order derivative<br>
int p = 1; // number of directions<br>
int size = 3; // [(p + d) choose d] = (p+d-0) *...* (p+1) / (1 *...* d)<br>
//<br>
double* S[1]; // seed matrix S[n][p]<br>
S[0] = new double[p];<br>
//<br>
double* tensor[1]; // partials of z w.r.t x tensor[n][size]<br>
tensor[0] = new double[size];<br>
<br>
// Set Seed matrix to identity<br>
S[0][0] = 1.0;<br>
<br>
// independent and dependent variables<br>
adouble az[1], ay[1]; // az[n], ay[n]<br>
double z[1], y[1]; // z[n], y[n]<br>
<br>
// record operations for y = F(z) = sin(z)<br>
short int tag = 1; // tape identifier<br>
trace_on(tag); // start recording<br>
z[0] = 1.0; // value during recording<br>
az[0] <<= z[0]; // independent variable<br>
ay[0] = sin(az[0]); // function evaluation<br>
ay[0] >>= y[0]; // dependent variable<br>
trace_off(); // turn off recording<br>
<br>
// evaluate inverse of F at x0<br>
double x0 = 0.5; // argument for inverse<br>
z[0] = std::asin(x0); // F^-1 (x0) = z0<br>
inverse_tensor_eval(tag, n, d, p, z, tensor, S);<br>
<br>
// print tensor<br>
for(int j = 0; j < size; j++)<br>
{ std::cout << "tensor[0][" << j << "] = " << tensor[0][j] << "\n";<br>
}<br>
<br>
// derivative of F^-1 (x0) = 1.0 / sqrt( 1 - x0 * x0 )<br>
double zp = 1.0 / std::sqrt(1.0 - x0 * x0 );<br>
<br>
// second derivative of F^-1 (x0) = x0 / sqrt( 1 - x0 * x0 )^3<br>
double zpp = x0 * zp * zp * zp;<br>
<br>
// print derivatives for z<br>
std::cout << "z = " << z[0] << "\n";<br>
std::cout << "zp = " << zp << "\n";<br>
std::cout << "zpp = " << zpp << "\n";<br>
//<br>
delete [] S[0];<br>
delete [] tensor[0];<br>
//<br>
std::cout << "adolc: Done\n";<br>
return 0;<br>
}<br>
<br>
______________________________<wbr>_________________<br>
ADOL-C mailing list<br>
<a href="mailto:ADOL-C@list.coin-or.org" target="_blank">ADOL-C@list.coin-or.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__list.coin-2Dor.org_mailman_listinfo_adol-2Dc&d=DwICAg&c=Ngd-ta5yRYsqeUsEDgxhcqsYYY1Xs5ogLxWPA_2Wlc4&r=0eOhD1zcLnB9JhadNXrezwNw87TYLa0fyHrxCkWC5J8&m=_Ons9tqju2E2RHmPQy2M4dxzTzDANdgNNsqJlGe3_xE&s=nCnpB-VNJPhm9DrrYdYukpvGjJLoI0XJjc321inwUW0&e=" rel="noreferrer" target="_blank">https://urldefense.proofpoint.<wbr>com/v2/url?u=https-3A__list.co<wbr>in-2Dor.org_mailman_listinfo_<wbr>adol-2Dc&d=DwICAg&c=Ngd-ta5yRY<wbr>sqeUsEDgxhcqsYYY1Xs5ogLxWPA_<wbr>2Wlc4&r=0eOhD1zcLnB9JhadNXrezw<wbr>Nw87TYLa0fyHrxCkWC5J8&m=_Ons9t<wbr>qju2E2RHmPQy2M4dxzTzDANdgNNsqJ<wbr>lGe3_xE&s=nCnpB-VNJPhm9DrrYdYu<wbr>kpvGjJLoI0XJjc321inwUW0&e=</a> </blockquote></div><br></div></div>