MCPcopy Create free account
hub / github.com/abess-team/abess / forward_jacobian_cpp11

Function forward_jacobian_cpp11

python/include/unsupported/test/autodiff.cpp:157–188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155};
156
157template<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
191template<typename Func> void forward_jacobian(const Func& f)

Callers 1

test_autodiff_jacobianFunction · 0.85

Calls 2

fFunction · 0.85
setZeroMethod · 0.45

Tested by

no test coverage detected