You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<iostream>
#include<unordered_map>
#include<string>
#include"cppad/cppad.hpp"using CppAD::AD;
using CppAD::ADFun;
using CppAD::Independent;
using CppAD::sparse_rc;
using CppAD::sparse_rcv;
typedefCPPAD_TESTVECTOR(double) d_vector;
typedefCPPAD_TESTVECTOR(AD<double>) ad_vector;
typedefCPPAD_TESTVECTOR(size_t) s_vector;
voiddebug_mvp()
{
size_t n = 3;
size_t m = 1;
CPPAD_TESTVECTOR(AD<double>) ax(n), ay(m);
Independent(ax);
ay[0] = ax[0] / ax[1] - 1.0 / (ax[2] * ax[2]);
ADFun<double> f;
f.Dependent(ax, ay);
// n by n identity matrix sparsity
sparse_rc<s_vector> pattern_in;
pattern_in.resize(n, n, n);
for (size_t k = 0; k < n; k++)
pattern_in.set(k, k, k);
// sparsity for J(x)bool transpose = false;
bool dependency = false;
bool internal_bool = true;
sparse_rc<s_vector> pattern_jac;
f.for_jac_sparsity(pattern_in, transpose, dependency, internal_bool, pattern_jac);
ADFun<AD<double>, double> af = f.base2ad();
CPPAD_TESTVECTOR(AD<double>) axp(n);
{
Independent(axp);
for (size_t j = 0; j < n; ++j)
ax[j] = axp[j];
// compute entire forward mode Jacobian
sparse_rcv<s_vector, ad_vector> subset(pattern_jac);
CppAD::sparse_jac_work work;
std::string coloring = "cppad";
size_t n_color = af.sparse_jac_rev(ax, subset, pattern_jac, coloring, work);
ADFun<double> g;
g.Dependent(axp, subset.val());
}
}
intmain(void)
{
debug_mvp();
}
The error happens at the size_t n_color = af.sparse_jac_rev(ax, subset, pattern_jac, coloring, work); line as follows:
cppad-20240602 error from a known source:
yq = f.Forward(q, xq): a zero order Taylor coefficient is nan.
Corresponding independent variables vector was written to binary a file.
vector_size = 3
file_name = C:\Users\yangyue\AppData\Local\Temp\uv5o.0
index = 0
Error detected by false result for
if( CppAD::isnan( yq[ (q+1) * index + 0 ] )
at line 265 in the file
E:\codeworkspace\cpp_try\cppad_try\thirdparty\include\cppad/core/forward/forward.hpp
Assertion failed: false, file E:\codeworkspace\cpp_try\cppad_try\thirdparty\include\cppad/utility/error_handler.hpp, line 205
The text was updated successfully, but these errors were encountered:
During the recording of a function, the function is evaluated at the independent variable values. These values are unspecified if you do not set them before the call to Independent.
If you are satisfied with this explanation, please close this issue.
The following code errors:
The error happens at the
size_t n_color = af.sparse_jac_rev(ax, subset, pattern_jac, coloring, work);
line as follows:The text was updated successfully, but these errors were encountered: