Alex Pirciu
/
BFMC
a
include/SystemModels/systemmodels.inl@1:ceee5a608e7c, 2019-03-28 (annotated)
- Committer:
- alexpirciu
- Date:
- Thu Mar 28 07:44:42 2019 +0000
- Revision:
- 1:ceee5a608e7c
assa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
alexpirciu | 1:ceee5a608e7c | 1 | /******************************************************************************/ |
alexpirciu | 1:ceee5a608e7c | 2 | /** \brief CDiscreteTransferFucntion class constructor |
alexpirciu | 1:ceee5a608e7c | 3 | * |
alexpirciu | 1:ceee5a608e7c | 4 | * Constructor method |
alexpirciu | 1:ceee5a608e7c | 5 | */ |
alexpirciu | 1:ceee5a608e7c | 6 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 7 | systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::CDiscreteTransferFucntion() |
alexpirciu | 1:ceee5a608e7c | 8 | :m_num(CNumType::zeros()) |
alexpirciu | 1:ceee5a608e7c | 9 | ,m_den(CDenModType::zeros()) |
alexpirciu | 1:ceee5a608e7c | 10 | ,m_denCoef(1) |
alexpirciu | 1:ceee5a608e7c | 11 | ,m_memInput() |
alexpirciu | 1:ceee5a608e7c | 12 | ,m_memOutput() |
alexpirciu | 1:ceee5a608e7c | 13 | { |
alexpirciu | 1:ceee5a608e7c | 14 | } |
alexpirciu | 1:ceee5a608e7c | 15 | |
alexpirciu | 1:ceee5a608e7c | 16 | |
alexpirciu | 1:ceee5a608e7c | 17 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 18 | systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::CDiscreteTransferFucntion(const CNumType& f_num,const CDenType& f_den) |
alexpirciu | 1:ceee5a608e7c | 19 | :m_num(CNumType::zeros()) |
alexpirciu | 1:ceee5a608e7c | 20 | ,m_den(CDenModType::zeros()) |
alexpirciu | 1:ceee5a608e7c | 21 | ,m_denCoef(1) |
alexpirciu | 1:ceee5a608e7c | 22 | ,m_memInput() |
alexpirciu | 1:ceee5a608e7c | 23 | ,m_memOutput() |
alexpirciu | 1:ceee5a608e7c | 24 | { |
alexpirciu | 1:ceee5a608e7c | 25 | this->setNum(f_num); |
alexpirciu | 1:ceee5a608e7c | 26 | this->setDen(f_den); |
alexpirciu | 1:ceee5a608e7c | 27 | } |
alexpirciu | 1:ceee5a608e7c | 28 | |
alexpirciu | 1:ceee5a608e7c | 29 | |
alexpirciu | 1:ceee5a608e7c | 30 | /** \brief Clear memory |
alexpirciu | 1:ceee5a608e7c | 31 | * |
alexpirciu | 1:ceee5a608e7c | 32 | * |
alexpirciu | 1:ceee5a608e7c | 33 | * |
alexpirciu | 1:ceee5a608e7c | 34 | */ |
alexpirciu | 1:ceee5a608e7c | 35 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 36 | void systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::clearMemmory() |
alexpirciu | 1:ceee5a608e7c | 37 | { |
alexpirciu | 1:ceee5a608e7c | 38 | m_memInput=CInputMem::zeros(); |
alexpirciu | 1:ceee5a608e7c | 39 | m_memOutput=COutputMem::zeros(); |
alexpirciu | 1:ceee5a608e7c | 40 | } |
alexpirciu | 1:ceee5a608e7c | 41 | |
alexpirciu | 1:ceee5a608e7c | 42 | /** \brief Clear memory |
alexpirciu | 1:ceee5a608e7c | 43 | * |
alexpirciu | 1:ceee5a608e7c | 44 | * @param f_input reference to input |
alexpirciu | 1:ceee5a608e7c | 45 | * @return l_output |
alexpirciu | 1:ceee5a608e7c | 46 | */ |
alexpirciu | 1:ceee5a608e7c | 47 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 48 | T systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::operator()(const T& f_input) |
alexpirciu | 1:ceee5a608e7c | 49 | { |
alexpirciu | 1:ceee5a608e7c | 50 | shiftMemory<NNum>(m_memInput); |
alexpirciu | 1:ceee5a608e7c | 51 | m_memInput[0][0]=f_input; |
alexpirciu | 1:ceee5a608e7c | 52 | T l_output=((m_memInput*m_num-m_memOutput*m_den)[0][0])/m_denCoef; |
alexpirciu | 1:ceee5a608e7c | 53 | shiftMemory<NDen-1>(m_memOutput); |
alexpirciu | 1:ceee5a608e7c | 54 | m_memOutput[0][0]=l_output; |
alexpirciu | 1:ceee5a608e7c | 55 | return l_output; |
alexpirciu | 1:ceee5a608e7c | 56 | } |
alexpirciu | 1:ceee5a608e7c | 57 | |
alexpirciu | 1:ceee5a608e7c | 58 | /** \brief Set num |
alexpirciu | 1:ceee5a608e7c | 59 | * |
alexpirciu | 1:ceee5a608e7c | 60 | * @param f_num reference to nominator |
alexpirciu | 1:ceee5a608e7c | 61 | * |
alexpirciu | 1:ceee5a608e7c | 62 | */ |
alexpirciu | 1:ceee5a608e7c | 63 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 64 | void systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::setNum(const CNumType& f_num) |
alexpirciu | 1:ceee5a608e7c | 65 | { |
alexpirciu | 1:ceee5a608e7c | 66 | for(uint32_t i=0;i<NNum;++i) |
alexpirciu | 1:ceee5a608e7c | 67 | { |
alexpirciu | 1:ceee5a608e7c | 68 | m_num[i][0]=f_num[i][0]; |
alexpirciu | 1:ceee5a608e7c | 69 | } |
alexpirciu | 1:ceee5a608e7c | 70 | } |
alexpirciu | 1:ceee5a608e7c | 71 | |
alexpirciu | 1:ceee5a608e7c | 72 | /** \brief Set den |
alexpirciu | 1:ceee5a608e7c | 73 | * |
alexpirciu | 1:ceee5a608e7c | 74 | * @param f_den reference to denominator |
alexpirciu | 1:ceee5a608e7c | 75 | * |
alexpirciu | 1:ceee5a608e7c | 76 | */ |
alexpirciu | 1:ceee5a608e7c | 77 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 78 | void systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::setDen(const CDenType& f_den) |
alexpirciu | 1:ceee5a608e7c | 79 | { |
alexpirciu | 1:ceee5a608e7c | 80 | for(uint32_t i=1;i<NDen;++i) |
alexpirciu | 1:ceee5a608e7c | 81 | { |
alexpirciu | 1:ceee5a608e7c | 82 | m_den[i-1][0]=f_den[i][0]; |
alexpirciu | 1:ceee5a608e7c | 83 | } |
alexpirciu | 1:ceee5a608e7c | 84 | m_denCoef = f_den[0][0]; |
alexpirciu | 1:ceee5a608e7c | 85 | } |
alexpirciu | 1:ceee5a608e7c | 86 | |
alexpirciu | 1:ceee5a608e7c | 87 | /** \brief Get output |
alexpirciu | 1:ceee5a608e7c | 88 | * |
alexpirciu | 1:ceee5a608e7c | 89 | * |
alexpirciu | 1:ceee5a608e7c | 90 | * @return Output memory |
alexpirciu | 1:ceee5a608e7c | 91 | */ |
alexpirciu | 1:ceee5a608e7c | 92 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 93 | T systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::getOutput() |
alexpirciu | 1:ceee5a608e7c | 94 | { |
alexpirciu | 1:ceee5a608e7c | 95 | return m_memOutput[0][0]; |
alexpirciu | 1:ceee5a608e7c | 96 | } |
alexpirciu | 1:ceee5a608e7c | 97 | |
alexpirciu | 1:ceee5a608e7c | 98 | /** \brief Shift memory |
alexpirciu | 1:ceee5a608e7c | 99 | * |
alexpirciu | 1:ceee5a608e7c | 100 | * @param f_mem reference to memory matrix |
alexpirciu | 1:ceee5a608e7c | 101 | * @return none |
alexpirciu | 1:ceee5a608e7c | 102 | */ |
alexpirciu | 1:ceee5a608e7c | 103 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 104 | template<uint32_t N> |
alexpirciu | 1:ceee5a608e7c | 105 | void systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::shiftMemory(linalg::CMatrix<T,1,N>& f_mem) |
alexpirciu | 1:ceee5a608e7c | 106 | { |
alexpirciu | 1:ceee5a608e7c | 107 | for(uint32_t i=N-1;i>0;--i) |
alexpirciu | 1:ceee5a608e7c | 108 | { |
alexpirciu | 1:ceee5a608e7c | 109 | f_mem[0][i]=f_mem[0][i-1]; |
alexpirciu | 1:ceee5a608e7c | 110 | } |
alexpirciu | 1:ceee5a608e7c | 111 | } |
alexpirciu | 1:ceee5a608e7c | 112 | |
alexpirciu | 1:ceee5a608e7c | 113 | /******************************************************************************/ |
alexpirciu | 1:ceee5a608e7c | 114 | /** \brief CDiscreteTimeSystemModel class constructor |
alexpirciu | 1:ceee5a608e7c | 115 | * |
alexpirciu | 1:ceee5a608e7c | 116 | * Constructor method |
alexpirciu | 1:ceee5a608e7c | 117 | * |
alexpirciu | 1:ceee5a608e7c | 118 | * @param f_dt Time step |
alexpirciu | 1:ceee5a608e7c | 119 | */ |
alexpirciu | 1:ceee5a608e7c | 120 | template <class T,uint32_t NA, uint32_t NB,uint32_t NC> |
alexpirciu | 1:ceee5a608e7c | 121 | systemmodels::nlti::mimo::CDiscreteTimeSystemModel<T,NA,NB,NC>::CDiscreteTimeSystemModel(const double f_dt) |
alexpirciu | 1:ceee5a608e7c | 122 | : m_states() |
alexpirciu | 1:ceee5a608e7c | 123 | , m_dt(f_dt) |
alexpirciu | 1:ceee5a608e7c | 124 | { |
alexpirciu | 1:ceee5a608e7c | 125 | } |
alexpirciu | 1:ceee5a608e7c | 126 | |
alexpirciu | 1:ceee5a608e7c | 127 | /** \brief CDiscreteTimeSystemModel class constructor |
alexpirciu | 1:ceee5a608e7c | 128 | * |
alexpirciu | 1:ceee5a608e7c | 129 | * Constructor method |
alexpirciu | 1:ceee5a608e7c | 130 | * |
alexpirciu | 1:ceee5a608e7c | 131 | * @param f_states States |
alexpirciu | 1:ceee5a608e7c | 132 | * @param f_dt Time step |
alexpirciu | 1:ceee5a608e7c | 133 | */ |
alexpirciu | 1:ceee5a608e7c | 134 | template <class T,uint32_t NA, uint32_t NB,uint32_t NC> |
alexpirciu | 1:ceee5a608e7c | 135 | systemmodels::nlti::mimo::CDiscreteTimeSystemModel<T,NA,NB,NC>::CDiscreteTimeSystemModel( |
alexpirciu | 1:ceee5a608e7c | 136 | const CStatesType& f_states |
alexpirciu | 1:ceee5a608e7c | 137 | ,const double f_dt) |
alexpirciu | 1:ceee5a608e7c | 138 | : m_states(f_states) |
alexpirciu | 1:ceee5a608e7c | 139 | , m_dt(f_dt) |
alexpirciu | 1:ceee5a608e7c | 140 | { |
alexpirciu | 1:ceee5a608e7c | 141 | } |
alexpirciu | 1:ceee5a608e7c | 142 | |
alexpirciu | 1:ceee5a608e7c | 143 | |
alexpirciu | 1:ceee5a608e7c | 144 | |
alexpirciu | 1:ceee5a608e7c | 145 | /** \brief Getter numitor |
alexpirciu | 1:ceee5a608e7c | 146 | * |
alexpirciu | 1:ceee5a608e7c | 147 | * @return const reference to numitor |
alexpirciu | 1:ceee5a608e7c | 148 | */ |
alexpirciu | 1:ceee5a608e7c | 149 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 150 | const typename systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::CNumType& systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::getNum(){ |
alexpirciu | 1:ceee5a608e7c | 151 | return m_num; |
alexpirciu | 1:ceee5a608e7c | 152 | } |
alexpirciu | 1:ceee5a608e7c | 153 | |
alexpirciu | 1:ceee5a608e7c | 154 | /** \brief Getter denomitor |
alexpirciu | 1:ceee5a608e7c | 155 | * Return the denomitor without the first coefficeint. |
alexpirciu | 1:ceee5a608e7c | 156 | * |
alexpirciu | 1:ceee5a608e7c | 157 | * @return const reference to denomitor |
alexpirciu | 1:ceee5a608e7c | 158 | */ |
alexpirciu | 1:ceee5a608e7c | 159 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 160 | const typename systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::CDenModType& systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::getDen(){ |
alexpirciu | 1:ceee5a608e7c | 161 | return m_den; |
alexpirciu | 1:ceee5a608e7c | 162 | } |
alexpirciu | 1:ceee5a608e7c | 163 | |
alexpirciu | 1:ceee5a608e7c | 164 | /** \brief Getter denomitor first coefficeint |
alexpirciu | 1:ceee5a608e7c | 165 | * |
alexpirciu | 1:ceee5a608e7c | 166 | * @return value of the denomitor first coefficeint |
alexpirciu | 1:ceee5a608e7c | 167 | */ |
alexpirciu | 1:ceee5a608e7c | 168 | template <class T,uint32_t NNum,uint32_t NDen> |
alexpirciu | 1:ceee5a608e7c | 169 | float systemmodels::lti::siso::CDiscreteTransferFucntion<T,NNum,NDen>::getDenCurrent(){ |
alexpirciu | 1:ceee5a608e7c | 170 | return m_denCoef; |
alexpirciu | 1:ceee5a608e7c | 171 | } |