Fix warning: ‘beta’ may be used uninitialized in this function
parent
d48b1fc840
commit
8bd4738f47
|
@ -21,6 +21,8 @@
|
||||||
#include <gtsam/base/Manifold.h>
|
#include <gtsam/base/Manifold.h>
|
||||||
#include <gtsam/nonlinear/NonlinearOptimizer.h>
|
#include <gtsam/nonlinear/NonlinearOptimizer.h>
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
/// Fletcher-Reeves formula for computing β, the direction of steepest descent.
|
/// Fletcher-Reeves formula for computing β, the direction of steepest descent.
|
||||||
|
@ -247,6 +249,9 @@ std::tuple<V, int> nonlinearConjugateGradient(
|
||||||
case DirectionMethod::DaiYuan:
|
case DirectionMethod::DaiYuan:
|
||||||
beta = DaiYuan(currentGradient, prevGradient, direction);
|
beta = DaiYuan(currentGradient, prevGradient, direction);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw std::runtime_error(
|
||||||
|
"NonlinearConjugateGradientOptimizer: Invalid directionMethod");
|
||||||
}
|
}
|
||||||
|
|
||||||
direction = currentGradient + (beta * direction);
|
direction = currentGradient + (beta * direction);
|
||||||
|
|
Loading…
Reference in New Issue