| 155 | }; |
| 156 | |
| 157 | template<typename Func> void forward_jacobian_cpp11(const Func& f) |
| 158 | { |
| 159 | typedef typename Func::ValueType::Scalar Scalar; |
| 160 | typedef typename Func::ValueType ValueType; |
| 161 | typedef typename Func::InputType InputType; |
| 162 | typedef typename AutoDiffJacobian<Func>::JacobianType JacobianType; |
| 163 | |
| 164 | InputType x = InputType::Random(InputType::RowsAtCompileTime); |
| 165 | ValueType y, yref; |
| 166 | JacobianType j, jref; |
| 167 | |
| 168 | const Scalar dt = internal::random<double>(); |
| 169 | |
| 170 | jref.setZero(); |
| 171 | yref.setZero(); |
| 172 | f(x, &yref, &jref, dt); |
| 173 | |
| 174 | //std::cerr << "y, yref, jref: " << "\n"; |
| 175 | //std::cerr << y.transpose() << "\n\n"; |
| 176 | //std::cerr << yref << "\n\n"; |
| 177 | //std::cerr << jref << "\n\n"; |
| 178 | |
| 179 | AutoDiffJacobian<Func> autoj(f); |
| 180 | autoj(x, &y, &j, dt); |
| 181 | |
| 182 | //std::cerr << "y j (via autodiff): " << "\n"; |
| 183 | //std::cerr << y.transpose() << "\n\n"; |
| 184 | //std::cerr << j << "\n\n"; |
| 185 | |
| 186 | VERIFY_IS_APPROX(y, yref); |
| 187 | VERIFY_IS_APPROX(j, jref); |
| 188 | } |
| 189 | #endif |
| 190 | |
| 191 | template<typename Func> void forward_jacobian(const Func& f) |
no test coverage detected