line_search.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // Inputs:
  18. // x #X by dim list of variables
  19. // d #X by dim list of a given search direction
  20. // i_step_size initial step size
  21. // energy A function to compute the mesh-based energy (return an energy that is bigger than 0)
  22. // 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. // Outputs:
  25. // x #X by dim list of variables at the new location
  26. // Returns the energy at the new point 'x'
  27. IGL_INLINE double line_search(
  28. Eigen::MatrixXd& x,
  29. const Eigen::MatrixXd& d,
  30. double i_step_size,
  31. std::function<double(Eigen::MatrixXd&)> energy,
  32. double cur_energy = -1);
  33. }
  34. #ifndef IGL_STATIC_LIBRARY
  35. # include "line_search.cpp"
  36. #endif
  37. #endif