template<typename Func> void forward_jacobian(const Func& f) { typename Func::InputType x = Func::InputType::Random(f.inputs()); typename Func::ValueType y(f.values()), yref(f.values()); typename Func::JacobianType j(f.values(),f.inputs()), jref(f.values(),f.inputs()); jref.setZero(); yref.setZero(); f(x,&yref,&jref); // std::cerr << y.transpose() << "\n\n";; // std::cerr << j << "\n\n";; j.setZero(); y.setZero(); AutoDiffJacobian<Func> autoj(f); autoj(x, &y, &j); // std::cerr << y.transpose() << "\n\n";; // std::cerr << j << "\n\n";; VERIFY_IS_APPROX(y, yref); VERIFY_IS_APPROX(j, jref); }