lu_lagrange.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef IGL_LU_LAGRANGE_H
  2. #define IGL_LU_LAGRANGE_H
  3. #include "igl_inline.h"
  4. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  5. #include <Eigen/Dense>
  6. #include <Eigen/Sparse>
  7. namespace igl
  8. {
  9. // LU_LAGRANGE Compute a LU decomposition for a special type of
  10. // matrix Q that is symmetric but not positive-definite:
  11. // Q = [A'*A C
  12. // C' 0];
  13. // where A'*A, or ATA, is given as a symmetric positive definite matrix and C
  14. // has full column-rank(?)
  15. //
  16. // [J] = lu_lagrange(ATA,C)
  17. //
  18. // Templates:
  19. // T should be a eigen matrix primitive type like int or double
  20. // Inputs:
  21. // ATA n by n square, symmetric, positive-definite system matrix, usually
  22. // the quadratic coefficients corresponding to the original unknowns in a
  23. // system
  24. // C n by m rectangular matrix corresponding the quadratic coefficients of
  25. // the original unknowns times the lagrange multipliers enforcing linear
  26. // equality constraints
  27. // Outputs:
  28. // L lower triangular matrix such that Q = L*U
  29. // U upper triangular matrix such that Q = L*U
  30. // Returns true on success, false on error
  31. //
  32. // Note: C should *not* have any empty columns. Typically C is the slice of
  33. // the linear constraints matrix Aeq concerning the unknown variables of a
  34. // quadratic optimization. Generally constraints may deal with unknowns as
  35. // well as knowns. Each linear constraint corresponds to a column of Aeq. As
  36. // long as each constraint concerns at least one unknown then the
  37. // corresponding column in C will have at least one non zero entry. If a
  38. // constraint concerns *no* unknowns, you should double check that this is a
  39. // valid constraint. How can you constrain known values to each other? This
  40. // is either a contradiction to the knowns' values or redundent. In either
  41. // case, it's not this functions responsiblilty to handle empty constraints
  42. // so you will get an error.
  43. //
  44. template <typename T>
  45. IGL_INLINE bool lu_lagrange(
  46. const Eigen::SparseMatrix<T> & ATA,
  47. const Eigen::SparseMatrix<T> & C,
  48. Eigen::SparseMatrix<T> & L,
  49. Eigen::SparseMatrix<T> & U);
  50. }
  51. #ifdef IGL_HEADER_ONLY
  52. # include "lu_lagrange.cpp"
  53. #endif
  54. #endif