| 498 | } |
| 499 | |
| 500 | void testLmstr() |
| 501 | { |
| 502 | const int n=3; |
| 503 | int info; |
| 504 | double fnorm; |
| 505 | VectorXd x(n); |
| 506 | |
| 507 | /* the following starting values provide a rough fit. */ |
| 508 | x.setConstant(n, 1.); |
| 509 | |
| 510 | // do the computation |
| 511 | lmstr_functor functor; |
| 512 | LevenbergMarquardt<lmstr_functor> lm(functor); |
| 513 | info = lm.minimizeOptimumStorage(x); |
| 514 | |
| 515 | // check return values |
| 516 | VERIFY_IS_EQUAL(info, 1); |
| 517 | VERIFY_IS_EQUAL(lm.nfev, 6); |
| 518 | VERIFY_IS_EQUAL(lm.njev, 5); |
| 519 | |
| 520 | // check norm |
| 521 | fnorm = lm.fvec.blueNorm(); |
| 522 | VERIFY_IS_APPROX(fnorm, 0.09063596); |
| 523 | |
| 524 | // check x |
| 525 | VectorXd x_ref(n); |
| 526 | x_ref << 0.08241058, 1.133037, 2.343695; |
| 527 | VERIFY_IS_APPROX(x, x_ref); |
| 528 | |
| 529 | } |
| 530 | |
| 531 | struct lmdif_functor : Functor<double> |
| 532 | { |
no test coverage detected