| 395 | } |
| 396 | |
| 397 | void testHybrd() |
| 398 | { |
| 399 | const int n=9; |
| 400 | int info; |
| 401 | VectorXd x; |
| 402 | |
| 403 | /* the following starting values provide a rough fit. */ |
| 404 | x.setConstant(n, -1.); |
| 405 | |
| 406 | // do the computation |
| 407 | hybrd_functor functor; |
| 408 | HybridNonLinearSolver<hybrd_functor> solver(functor); |
| 409 | solver.parameters.nb_of_subdiagonals = 1; |
| 410 | solver.parameters.nb_of_superdiagonals = 1; |
| 411 | solver.diag.setConstant(n, 1.); |
| 412 | solver.useExternalScaling = true; |
| 413 | info = solver.solveNumericalDiff(x); |
| 414 | |
| 415 | // check return value |
| 416 | VERIFY_IS_EQUAL(info, 1); |
| 417 | VERIFY_IS_EQUAL(solver.nfev, 14); |
| 418 | |
| 419 | // check norm |
| 420 | VERIFY_IS_APPROX(solver.fvec.blueNorm(), 1.192636e-08); |
| 421 | |
| 422 | // check x |
| 423 | VectorXd x_ref(n); |
| 424 | x_ref << |
| 425 | -0.5706545, -0.6816283, -0.7017325, |
| 426 | -0.7042129, -0.701369, -0.6918656, |
| 427 | -0.665792, -0.5960342, -0.4164121; |
| 428 | VERIFY_IS_APPROX(x, x_ref); |
| 429 | } |
| 430 | |
| 431 | struct lmstr_functor : Functor<double> |
| 432 | { |
no test coverage detected