Skip to content
Browse files

LevenbergMarquardt: If solve_symmetric failes, fallback to general so…

…lver
  • Loading branch information...
1 parent 32a0cc1 commit 8c8a3e7dd10e170467cceb5ec9a337fa5feacea9 @oleg-alexandrov oleg-alexandrov committed
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/vw/Math/LevenbergMarquardt.h
View
15 src/vw/Math/LevenbergMarquardt.h
@@ -251,9 +251,18 @@ namespace math {
// in this situation in a multi-threaded environment.
delta_x = inverse(hessian_lm)*del_J;
}else{
- // By construction, hessian_lm is symmetric and
- // positive-definite.
- delta_x = solve_symmetric(hessian_lm, del_J);
+ try{
+ // By construction, hessian_lm is symmetric and
+ // positive-definite.
+ delta_x = solve_symmetric(hessian_lm, del_J);
+ }catch ( const ArgumentErr& e ) {
+ // This may happen in rare cases, needs a more through investigation.
+ // Fallback to the general solver.
+ std::cout.precision(16);
+ std::cout << "Matrix is not symmetric and positive definite, falling back to the general solver. Matrix: " << hessian_lm << std::endl;
+ delta_x = least_squares(hessian_lm, del_J);
+ }
+
}
// update parameter vector

0 comments on commit 8c8a3e7

Please sign in to comment.
Something went wrong with that request. Please try again.