lu_lagrange.h 2.2 KB

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