lyap.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createLyap = void 0;
  6. var _factory = require("../../utils/factory.js");
  7. var name = 'lyap';
  8. var dependencies = ['typed', 'matrix', 'sylvester', 'multiply', 'transpose'];
  9. var createLyap = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  10. var typed = _ref.typed,
  11. matrix = _ref.matrix,
  12. sylvester = _ref.sylvester,
  13. multiply = _ref.multiply,
  14. transpose = _ref.transpose;
  15. /**
  16. *
  17. * Solves the Continuous-time Lyapunov equation AP+PA'+Q=0 for P, where
  18. * Q is an input matrix. When Q is symmetric, P is also symmetric. Notice
  19. * that different equivalent definitions exist for the Continuous-time
  20. * Lyapunov equation.
  21. * https://en.wikipedia.org/wiki/Lyapunov_equation
  22. *
  23. * Syntax:
  24. *
  25. * math.lyap(A, Q)
  26. *
  27. * Examples:
  28. *
  29. * const A = [[-2, 0], [1, -4]]
  30. * const Q = [[3, 1], [1, 3]]
  31. * const P = math.lyap(A, Q)
  32. *
  33. * See also:
  34. *
  35. * sylvester, schur
  36. *
  37. * @param {Matrix | Array} A Matrix A
  38. * @param {Matrix | Array} Q Matrix Q
  39. * @return {Matrix | Array} Matrix P solution to the Continuous-time Lyapunov equation AP+PA'=Q
  40. */
  41. return typed(name, {
  42. 'Matrix, Matrix': function MatrixMatrix(A, Q) {
  43. return sylvester(A, transpose(A), multiply(-1, Q));
  44. },
  45. 'Array, Matrix': function ArrayMatrix(A, Q) {
  46. return sylvester(matrix(A), transpose(matrix(A)), multiply(-1, Q));
  47. },
  48. 'Matrix, Array': function MatrixArray(A, Q) {
  49. return sylvester(A, transpose(matrix(A)), matrix(multiply(-1, Q)));
  50. },
  51. 'Array, Array': function ArrayArray(A, Q) {
  52. return sylvester(matrix(A), transpose(matrix(A)), matrix(multiply(-1, Q))).toArray();
  53. }
  54. });
  55. });
  56. exports.createLyap = createLyap;