roots.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #ifndef IGL_CYCODEBASE_ROOTS_H
  2. #define IGL_CYCODEBASE_ROOTS_H
  3. #include "../igl_inline.h"
  4. #include <Eigen/Core>
  5. namespace igl {
  6. namespace cycodebase {
  7. /// Compute the real roots of a polynomial with given coefficients within a
  8. /// given interval [xmin, xmax].
  9. ///
  10. /// @param[in] coef Vector of polynomial coefficients in increasing order
  11. /// of degree (i.e., coef[0] + coef[1]*x + coef[2]*x^2 + ... )
  12. /// @param[in] xmin Minimum x value of the interval
  13. /// @param[in] xmax Maximum x value of the interval
  14. /// @param[out] R Vector of real roots within [xmin, xmax]
  15. /// @return Number of real roots found within [xmin, xmax]
  16. template <
  17. typename Derivedcoef,
  18. typename DerivedR>
  19. IGL_INLINE int roots(
  20. const Eigen::MatrixBase<Derivedcoef>& coef,
  21. const typename Derivedcoef::Scalar xmin,
  22. const typename Derivedcoef::Scalar xmax,
  23. Eigen::PlainObjectBase<DerivedR>& R);
  24. }
  25. }
  26. #ifndef IGL_STATIC_LIBRARY
  27. #include "roots.cpp"
  28. #endif
  29. #endif