line_search.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Michael Rabinovich
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_LINE_SEARCH_H
  9. #define IGL_LINE_SEARCH_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. /// Implement a bisection linesearch to minimize a mesh-based energy on vertices given at 'x' at a search direction 'd',
  15. /// with initial step size. Stops when a point with lower energy is found, or after maximal iterations have been reached.
  16. ///
  17. /// @param[in] x #X by dim list of variables
  18. /// @param[in] d #X by dim list of a given search direction
  19. /// @param[in] i_step_size initial step size
  20. /// @param[in] energy A function to compute the mesh-based energy (return an energy that is bigger than 0)
  21. /// @param[out] x #X by dim list of variables at the new location
  22. /// @param[in] cur_energy(OPTIONAL) The energy at the given point. Helps save redundant computations.
  23. /// This is optional. If not specified, the function will compute it.
  24. /// @return the energy at the new point 'x'
  25. IGL_INLINE double line_search(
  26. Eigen::MatrixXd& x,
  27. const Eigen::MatrixXd& d,
  28. double i_step_size,
  29. std::function<double(Eigen::MatrixXd&)> energy,
  30. double cur_energy = -1);
  31. }
  32. #ifndef IGL_STATIC_LIBRARY
  33. # include "line_search.cpp"
  34. #endif
  35. #endif