1 #ifndef STAN__OPTIMIZATION__BFGS_UPDATE_HPP
2 #define STAN__OPTIMIZATION__BFGS_UPDATE_HPP
7 namespace optimization {
8 template<
typename Scalar = double,
9 int DimAtCompile = Eigen::Dynamic>
12 typedef Eigen::Matrix<Scalar,DimAtCompile,1>
VectorT;
13 typedef Eigen::Matrix<Scalar,DimAtCompile,DimAtCompile>
HessianT;
28 Scalar rhok, skyk, B0fact;
34 Hupd.noalias() = HessianT::Identity(yk.size(),yk.size())
35 - rhok*sk*yk.transpose();
37 B0fact = yk.squaredNorm()/skyk;
38 _Hk.noalias() = ((1.0/B0fact)*Hupd)*Hupd.transpose();
42 _Hk = Hupd*_Hk*Hupd.transpose();
44 _Hk.noalias() += rhok*sk*sk.transpose();
57 pk.noalias() = -(_Hk*gk);
Eigen::Matrix< Scalar, DimAtCompile, DimAtCompile > HessianT
void search_direction(VectorT &pk, const VectorT &gk) const
Compute the search direction based on the current (inverse) Hessian approximation and given gradient...
Eigen::Matrix< Scalar, DimAtCompile, 1 > VectorT
Scalar update(const VectorT &yk, const VectorT &sk, bool reset=false)
Update the inverse Hessian approximation.