Error in meta.hpp
template<typename Fun, typename... Args> using ReturnType = std::invoke_result_t<Fun, Args...>;
**Severity Code Description Project File Line Suppression State Details Error C2039 'invoke_result_t': is not a member of 'std' jacobian_autodiff_test Line 65 **
I am not sure what the error is due to. But I didn't use the path for Eigen3, I used eigen headers from the root directory of the source code available in the eigen website.
Hi, thanks for reporting this issue. Please provide more details - I cannot reproduce this issue here. Are you using the cmake build system of autodiff? Are you using c++-17 or higher?
Yes. That was the issue. The C++ standard in my VS was set to C++ 14. I changed it to the latest and that worked. What about the time complexity of the Jacobian computation that I am trying? For m functions and n variables, it is O(m*n)?
For the order discussion, see here https://github.com/autodiff/autodiff/discussions/341#discussioncomment-9726508
Can you please have a look at the code below? I have implemented Jacobian (same as one of the examples) inside a class member function and it seems to throw errors. Severity Code Description Project File Line Suppression State Details Error C3867 'myClass::f': non-standard syntax; use '&' to create a pointer to member jacobian_autodiff_test Severity Code Description Project File Line Suppression State Details Error C2672 'jacobian': no matching overloaded function found jacobian_autodiff_test
// C++ includes
#include
VectorXreal x(5); // the input vector x with 5 variables
x << 1, 2, 3, 4, 5; // x = [1, 2, 3, 4, 5]
VectorXreal p(3); // the input parameter vector p with 3 variables
p << 1, 2, 3; // p = [1, 2, 3]
real q = -2; // the input parameter q as a single variable
VectorXreal F; // the output vector F = f(x, p, q) evaluated together with Jacobian below
MatrixXd Jx = jacobian(f, wrt(x), at(x, p, q), F); // evaluate the function and the Jacobian matrix Jx = dF/dx
MatrixXd Jp = jacobian(f, wrt(p), at(x, p, q), F); // evaluate the function and the Jacobian matrix Jp = dF/dp
MatrixXd Jq = jacobian(f, wrt(q), at(x, p, q), F); // evaluate the function and the Jacobian matrix Jq = dF/dq
MatrixXd Jqpx = jacobian(f, wrt(q, p, x), at(x, p, q), F); // evaluate the function and the Jacobian matrix Jqpx = [dF/dq, dF/dp, dF/dx]
std::cout << "F = \n"
<< F << std::endl; // print the evaluated output vector F
std::cout << "Jx = \n"
<< Jx(0) << std::endl; // print the evaluated Jacobian matrix dF/dx
std::cout << "Jp = \n"
<< Jp << std::endl; // print the evaluated Jacobian matrix dF/dp
std::cout << "Jq = \n"
<< Jq << std::endl; // print the evaluated Jacobian matrix dF/dq
std::cout << "Jqpx = \n"
<< Jqpx << std::endl; // print the evaluated Jacobian matrix [dF/dq, dF/dp, dF/dx]
} }; int main() { myClass mC; mC.calcJac(); return 0; }
I think you need to make myClass::f() static, so it doesn't expect this as the first argument, and pass it to jacobian as &myClass::f.
Also see https://github.com/autodiff/autodiff/discussions/261#discussioncomment-3989220
Yes. That was the issue. The C++ standard in my VS was set to C++ 14. I changed it to the latest and that worked. What about the time complexity of the Jacobian computation that I am trying? For m functions and n variables, it is O(m*n)?
I also have this error. And i am sure i have set c++17 +. But it has error ,too. Tht error is :namespace "std" has no member "invoke_result_t"