Lodestar
An integrated real-time control package in C++
LinearSystemInverse.hpp
1 //
2 // Created by Hamza El-Kebir on 4/17/21.
3 //
4 
5 #ifndef LODESTAR_LINEARSYSTEMINVERSE_HPP
6 #define LODESTAR_LINEARSYSTEMINVERSE_HPP
7 
8 #include "Lodestar/systems/StateSpace.hpp"
9 
10 namespace ls {
11  namespace analysis {
20  public:
27  template<typename TScalar, int TStateDim, int TInputDim, int TOutputDim>
28  static void
31 
38  template<typename TScalar, int TStateDim, int TInputDim, int TOutputDim>
39  static void
42 
51  inverse(const systems::StateSpace<> *ss);
52 
61  inverse(const systems::StateSpace<> &ss);
62  };
63  }
64 }
65 
66 // TODO: Return status in case system is not invertible or is in discrete-time
67 template<typename TScalar, int TStateDim, int TInputDim, int TOutputDim>
68 void
72 {
73  out->setA((ss->getA()) -
74  (ss->getB()) * (ss->getD()).inverse() * (ss->getC()));
75  out->setB(-(ss->getB()) * (ss->getD()).inverse());
76  out->setC((ss->getD()).inverse() * (ss->getC()));
77  out->setD((ss->getD()).inverse());
78 }
79 
80 template<typename TScalar, int TStateDim, int TInputDim, int TOutputDim>
81 void
85 {
86  inverse(&ss, out);
87 }
88 
89 #endif //LODESTAR_LINEARSYSTEMINVERSE_HPP
ls::systems::StateSpace::getB
const TDInputMatrix & getB() const
Gets the input matrix.
Definition: StateSpace.hpp:488
ls::systems::StateSpace::getD
const TDFeedforwardMatrix & getD() const
Gets the feedforward matrix.
Definition: StateSpace.hpp:557
ls::systems::StateSpace::getA
const TDStateMatrix & getA() const
Gets the state matrix.
Definition: StateSpace.hpp:454
ls::analysis::LinearSystemInverse
Routines for computing the inverse of a continuous-time state space systems.
Definition: LinearSystemInverse.hpp:19
ls::systems::StateSpace::setA
void setA(TDStateMatrix *A)
Sets the state matrix.
Definition: StateSpace.hpp:460
ls::systems::StateSpace::getC
const TDOutputMatrix & getC() const
Gets the output matrix.
Definition: StateSpace.hpp:522
ls::analysis::LinearSystemInverse::inverse
static void inverse(const systems::StateSpace< TScalar, TStateDim, TInputDim, TOutputDim > *ss, systems::StateSpace< TScalar, TStateDim, TOutputDim, TInputDim > *out)
Generates the inverse of a continuous-time state space system.
Definition: LinearSystemInverse.hpp:69
ls
Main Lodestar code.
Definition: BilinearTransformation.hpp:12
ls::systems::StateSpace
Definition: StateSpace.hpp:15
ls::systems::StateSpace::setC
void setC(TDOutputMatrix *C)
Sets the output matrix.
Definition: StateSpace.hpp:529
ls::systems::StateSpace::setD
void setD(TDFeedforwardMatrix *D)
Sets the feedforward matrix.
Definition: StateSpace.hpp:563
ls::systems::StateSpace::setB
void setB(TDInputMatrix *B)
Sets the input matrix.
Definition: StateSpace.hpp:494