| 311 | } |
| 312 | |
| 313 | void testHybrj() |
| 314 | { |
| 315 | const int n=9; |
| 316 | int info; |
| 317 | VectorXd x(n); |
| 318 | |
| 319 | /* the following starting values provide a rough fit. */ |
| 320 | x.setConstant(n, -1.); |
| 321 | |
| 322 | |
| 323 | // do the computation |
| 324 | hybrj_functor functor; |
| 325 | HybridNonLinearSolver<hybrj_functor> solver(functor); |
| 326 | solver.diag.setConstant(n, 1.); |
| 327 | solver.useExternalScaling = true; |
| 328 | info = solver.solve(x); |
| 329 | |
| 330 | // check return value |
| 331 | VERIFY_IS_EQUAL(info, 1); |
| 332 | VERIFY_IS_EQUAL(solver.nfev, 11); |
| 333 | VERIFY_IS_EQUAL(solver.njev, 1); |
| 334 | |
| 335 | // check norm |
| 336 | VERIFY_IS_APPROX(solver.fvec.blueNorm(), 1.192636e-08); |
| 337 | |
| 338 | |
| 339 | // check x |
| 340 | VectorXd x_ref(n); |
| 341 | x_ref << |
| 342 | -0.5706545, -0.6816283, -0.7017325, |
| 343 | -0.7042129, -0.701369, -0.6918656, |
| 344 | -0.665792, -0.5960342, -0.4164121; |
| 345 | VERIFY_IS_APPROX(x, x_ref); |
| 346 | |
| 347 | } |
| 348 | |
| 349 | struct hybrd_functor : Functor<double> |
| 350 | { |
no test coverage detected