<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.5.6">
  <compounddef id="pmsm__unkQpf_8cpp" kind="file">
    <compoundname>pmsm_unkQpf.cpp</compoundname>
    <includes local="no">itpp/itbase.h</includes>
    <includes refid="libKF_8h" local="no">estim/libKF.h</includes>
    <includes refid="libPF_8h" local="no">estim/libPF.h</includes>
    <includes refid="libFN_8h" local="no">stat/libFN.h</includes>
    <includes refid="pmsm_8h" local="yes">pmsm.h</includes>
    <incdepgraph>
      <node id="643">
        <label>libBM.h</label>
        <link refid="libBM_8h"/>
        <childnode refid="640" relation="include">
        </childnode>
      </node>
      <node id="639">
        <label>work/git/mixpp/pmsm/pmsm_unkQpf.cpp</label>
        <link refid="pmsm_unkQpf.cpp"/>
        <childnode refid="640" relation="include">
        </childnode>
        <childnode refid="641" relation="include">
        </childnode>
        <childnode refid="648" relation="include">
        </childnode>
        <childnode refid="642" relation="include">
        </childnode>
        <childnode refid="649" relation="include">
        </childnode>
      </node>
      <node id="649">
        <label>pmsm.h</label>
        <link refid="pmsm_8h-source"/>
        <childnode refid="642" relation="include">
        </childnode>
      </node>
      <node id="646">
        <label>../itpp_ext.h</label>
        <link refid="itpp__ext_8h-source"/>
        <childnode refid="640" relation="include">
        </childnode>
      </node>
      <node id="644">
        <label>../stat/libEF.h</label>
        <link refid="libEF_8h"/>
        <childnode refid="640" relation="include">
        </childnode>
        <childnode refid="645" relation="include">
        </childnode>
        <childnode refid="643" relation="include">
        </childnode>
        <childnode refid="646" relation="include">
        </childnode>
      </node>
      <node id="648">
        <label>estim/libPF.h</label>
        <link refid="libPF_8h"/>
        <childnode refid="640" relation="include">
        </childnode>
        <childnode refid="644" relation="include">
        </childnode>
        <childnode refid="645" relation="include">
        </childnode>
      </node>
      <node id="642">
        <label>../stat/libFN.h</label>
        <link refid="libFN_8h-source"/>
        <childnode refid="640" relation="include">
        </childnode>
        <childnode refid="643" relation="include">
        </childnode>
      </node>
      <node id="640">
        <label>itpp/itbase.h</label>
      </node>
      <node id="647">
        <label>../math/chmat.h</label>
        <link refid="chmat_8h"/>
        <childnode refid="640" relation="include">
        </childnode>
        <childnode refid="645" relation="include">
        </childnode>
        <childnode refid="646" relation="include">
        </childnode>
      </node>
      <node id="641">
        <label>estim/libKF.h</label>
        <link refid="libKF_8h"/>
        <childnode refid="640" relation="include">
        </childnode>
        <childnode refid="642" relation="include">
        </childnode>
        <childnode refid="644" relation="include">
        </childnode>
        <childnode refid="647" relation="include">
        </childnode>
      </node>
      <node id="645">
        <label>../math/libDC.h</label>
        <link refid="libDC_8h"/>
        <childnode refid="640" relation="include">
        </childnode>
      </node>
    </incdepgraph>
    <innerclass refid="classEKF__unQ" prot="public">EKF_unQ</innerclass>
      <sectiondef kind="func">
      <memberdef kind="function" id="pmsm__unkQpf_8cpp_1e66f6b31b5ad750f1fe042a706a4e3d4" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
        <type>int</type>
        <definition>int main</definition>
        <argsstring>()</argsstring>
        <name>main</name>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/home/smidl/work/git/mixpp/pmsm/pmsm_unkQpf.cpp" line="34" bodyfile="/home/smidl/work/git/mixpp/pmsm/pmsm_unkQpf.cpp" bodystart="34" bodyend="116"/>
      </memberdef>
      </sectiondef>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"><highlight class="comment">/*</highlight></codeline>
<codeline lineno="2"><highlight class="comment"><sp/><sp/>\file</highlight></codeline>
<codeline lineno="3"><highlight class="comment"><sp/><sp/>\brief<sp/>Models<sp/>for<sp/>synchronous<sp/>electric<sp/>drive<sp/>using<sp/>IT++<sp/>and<sp/>BDM</highlight></codeline>
<codeline lineno="4"><highlight class="comment"><sp/><sp/>\author<sp/>Vaclav<sp/>Smidl.</highlight></codeline>
<codeline lineno="5"><highlight class="comment"></highlight></codeline>
<codeline lineno="6"><highlight class="comment"><sp/><sp/>-----------------------------------</highlight></codeline>
<codeline lineno="7"><highlight class="comment"><sp/><sp/>BDM++<sp/>-<sp/>C++<sp/>library<sp/>for<sp/>Bayesian<sp/>Decision<sp/>Making<sp/>under<sp/>Uncertainty</highlight></codeline>
<codeline lineno="8"><highlight class="comment"></highlight></codeline>
<codeline lineno="9"><highlight class="comment"><sp/><sp/>Using<sp/>IT++<sp/>for<sp/>numerical<sp/>operations</highlight></codeline>
<codeline lineno="10"><highlight class="comment"><sp/><sp/>-----------------------------------</highlight></codeline>
<codeline lineno="11"><highlight class="comment">*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="12"><highlight class="normal"></highlight></codeline>
<codeline lineno="13"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;itpp/itbase.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="14"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="libKF_8h" kindref="compound" tooltip="Bayesian Filtering for linear Gaussian models (Kalman Filter) and extensions.">estim/libKF.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="15"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;<ref refid="libPF_8h" kindref="compound" tooltip="Bayesian Filtering using stochastic sampling (Particle Filters).">estim/libPF.h</ref>&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="16"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;stat/libFN.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="17"><highlight class="normal"></highlight></codeline>
<codeline lineno="18"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;pmsm.h&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="19"><highlight class="normal"></highlight></codeline>
<codeline lineno="20"><highlight class="normal"></highlight><highlight class="keyword">using<sp/>namespace<sp/></highlight><highlight class="normal">itpp;</highlight></codeline>
<codeline lineno="21"><highlight class="normal"></highlight></codeline>
<codeline lineno="23"><highlight class="keyword">class<sp/></highlight><highlight class="normal"><ref refid="classEKF__unQ" kindref="compound" tooltip="Extended Kalman filter with unknown Q.">EKF_unQ</ref><sp/>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/><ref refid="classEKFCh" kindref="compound" tooltip="Extended Kalman Filter in Square root.">EKFCh</ref><sp/>,<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/><ref refid="classBMcond" kindref="compound" tooltip="Conditional Bayesian Filter.">BMcond</ref><sp/>{</highlight></codeline>
<codeline lineno="24"><highlight class="normal"></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline>
<codeline lineno="26" refid="classEKF__unQ_1159eaaa5a05c5ceecdaa20956a307244" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classEKF__unQ_1159eaaa5a05c5ceecdaa20956a307244" kindref="member" tooltip="Default constructor.">EKF_unQ</ref><sp/>(<sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>rx,<sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>ry,<ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>ru,<ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>rQ<sp/>)<sp/>:<ref refid="classEKFCh" kindref="compound" tooltip="Extended Kalman Filter in Square root.">EKFCh</ref><sp/>(<sp/>rx,ry,ru<sp/>),<ref refid="classBMcond" kindref="compound" tooltip="Conditional Bayesian Filter.">BMcond</ref><sp/>(<sp/>rQ<sp/>)<sp/>{};</highlight></codeline>
<codeline lineno="27" refid="classEKF__unQ_1cd06a8c662da244cf61bb5bd39688c99" refkind="member"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="classEKF__unQ_1cd06a8c662da244cf61bb5bd39688c99" kindref="member" tooltip="Substitute val for rvc.">condition</ref><sp/>(<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>vec<sp/>&amp;Q0<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="28"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classKalman_19b69015c800eb93f3ee49da23a6f55d9" kindref="member" tooltip="Matrix Q in square-root form.">Q</ref>.<ref refid="classchmat_1a4fc7f9b0539b97c414442a22f3db6e8" kindref="member" tooltip="Access functions.">setD</ref><sp/>(<sp/>Q0,0<sp/>);</highlight></codeline>
<codeline lineno="29"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//from<sp/>EKF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="30"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classKalmanCh_194ee9da75b0e0f632e4a354988ca3798" kindref="member" tooltip="pre array (triangular matrix)">preA</ref>.set_submatrix<sp/>(<sp/><ref refid="classKalman_1ba17b956df1e38b31fbbc299c8213b6a" kindref="member" tooltip="cache of rvy.count()">dimy</ref>+<ref refid="classKalman_139c8c403b46fa3b8c7da77cb2e3729eb" kindref="member" tooltip="cache of rv.count()">dimx</ref>,<ref refid="classKalman_1ba17b956df1e38b31fbbc299c8213b6a" kindref="member" tooltip="cache of rvy.count()">dimy</ref>,<ref refid="classKalman_19b69015c800eb93f3ee49da23a6f55d9" kindref="member" tooltip="Matrix Q in square-root form.">Q</ref>.<ref refid="classchmat_19c50d31c999d85d8e9d8cf2b69b6ac8c" kindref="member" tooltip="Access function.">_Ch</ref>()<sp/>);</highlight></codeline>
<codeline lineno="31"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>};<sp/></highlight></codeline>
<codeline lineno="32"><highlight class="normal">};</highlight></codeline>
<codeline lineno="33"><highlight class="normal"></highlight></codeline>
<codeline lineno="34"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><ref refid="sim__var_8cpp_1e66f6b31b5ad750f1fe042a706a4e3d4" kindref="member" tooltip="Extended Kalman filter with unknown Q.">main</ref>()<sp/>{</highlight></codeline>
<codeline lineno="35"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Kalman<sp/>filter</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="36"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>Ndat<sp/>=<sp/>10000;</highlight></codeline>
<codeline lineno="37"><highlight class="normal"></highlight></codeline>
<codeline lineno="38"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>cout<sp/>&lt;&lt;<sp/>KF;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="39"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>internal<sp/>model</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="40"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classIMpmsm" kindref="compound" tooltip="State evolution model for a PMSM drive and its derivative with respect to $.">IMpmsm</ref><sp/>fxu;</highlight></codeline>
<codeline lineno="41"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Rs<sp/><sp/><sp/><sp/>Ls<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>dt<sp/><sp/><sp/><sp/><sp/><sp/><sp/>Fmag(Ypm)<sp/>kp<sp/><sp/><sp/>p<sp/><sp/><sp/><sp/>J<sp/><sp/><sp/><sp/><sp/>Bf(Mz)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="42"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>fxu.<ref refid="classIMpmsm_142818f3426d99fecb7e97be8ffe2e228" kindref="member" tooltip="Set mechanical and electrical variables.">set_parameters</ref><sp/>(<sp/>0.28,<sp/>0.003465,<sp/>20*1e-6,<sp/>0.1989,<sp/><sp/><sp/>1.5<sp/>,4.0,<sp/>0.04,<sp/>0.0<sp/>);</highlight></codeline>
<codeline lineno="43"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>observation<sp/>model</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="44"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classOMpmsm" kindref="compound" tooltip="Observation model for PMSM drive and its derivative with respect to .">OMpmsm</ref><sp/>hxu;</highlight></codeline>
<codeline lineno="45"><highlight class="normal"></highlight></codeline>
<codeline lineno="46"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>mu0=<sp/></highlight><highlight class="stringliteral">&quot;100<sp/>100<sp/>100<sp/>1&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="47"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>Qdiag<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;0.1<sp/>0.1<sp/>0.01<sp/>0.00001&quot;</highlight><highlight class="normal"><sp/>);</highlight></codeline>
<codeline lineno="48"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>Rdiag<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;0.02<sp/>0.02&quot;</highlight><highlight class="normal"><sp/>);</highlight></codeline>
<codeline lineno="49"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>vQ<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;0.01:0.01:100&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="50"><highlight class="normal"></highlight></codeline>
<codeline lineno="51"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classchmat" kindref="compound" tooltip="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</ref><sp/>Q<sp/>(<sp/>Qdiag<sp/>);</highlight></codeline>
<codeline lineno="52"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classchmat" kindref="compound" tooltip="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</ref><sp/>R<sp/>(<sp/>Rdiag<sp/>);</highlight></codeline>
<codeline lineno="53"><highlight class="normal"></highlight></codeline>
<codeline lineno="54"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classRV" kindref="compound" tooltip="Class representing variables, most often random variables.">RV</ref><sp/>rQ<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;{Q}&quot;</highlight><highlight class="normal">,</highlight><highlight class="stringliteral">&quot;2&quot;</highlight><highlight class="normal"><sp/>);</highlight></codeline>
<codeline lineno="55"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classEKF__unQ" kindref="compound" tooltip="Extended Kalman filter with unknown Q.">EKF_unQ</ref><sp/>KFE<sp/>(<sp/>rx,ry,ru,rQ<sp/>);</highlight></codeline>
<codeline lineno="56"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>KFE.set_parameters<sp/>(<sp/>&amp;fxu,&amp;hxu,Q,R<sp/>);</highlight></codeline>
<codeline lineno="57"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>KFE.set_est<sp/>(<sp/>mu0,<sp/><ref refid="classchmat" kindref="compound" tooltip="Symmetric matrix stored in square root decomposition using upper cholesky.">chmat</ref><sp/>(<sp/>1000*ones<sp/>(<sp/>4<sp/>)<sp/>)<sp/>);</highlight></codeline>
<codeline lineno="58"><highlight class="normal"></highlight></codeline>
<codeline lineno="59"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classmgamma" kindref="compound" tooltip="Gamma random walk.">mgamma</ref><sp/>evolQ<sp/>(<sp/>rQ,rQ<sp/>);</highlight></codeline>
<codeline lineno="60"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//evolQ.set_parameters<sp/>(<sp/>10000.0<sp/>);<sp/>//sigma<sp/>=<sp/>1/10<sp/>mu</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="61"><highlight class="normal"></highlight></codeline>
<codeline lineno="62"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classMPF" kindref="compound" tooltip="Marginalized Particle filter.">MPF&lt;EKF_unQ&gt;</ref><sp/>M<sp/>(<sp/>rx,rQ,evolQ,evolQ,100,KFE<sp/>);</highlight></codeline>
<codeline lineno="63"><highlight class="normal"></highlight></codeline>
<codeline lineno="64"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>&amp;<sp/>KFEep<sp/>=<sp/>KFE._epdf();</highlight></codeline>
<codeline lineno="65"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>&amp;<sp/>Mep<sp/>=<sp/>M._epdf();</highlight></codeline>
<codeline lineno="66"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>initialize</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="67"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>evolQ.set_parameters<sp/>(<sp/>1.0<sp/>);<sp/></highlight><highlight class="comment">//sigma<sp/>=<sp/>1/10<sp/>mu</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="68"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>evolQ.condition<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;0.5<sp/>0.5&quot;</highlight><highlight class="normal"><sp/>);</highlight></codeline>
<codeline lineno="69"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classepdf" kindref="compound" tooltip="Probability density function with numerical statistics, e.g. posterior density.">epdf</ref>&amp;<sp/>pfinit=evolQ._epdf();</highlight></codeline>
<codeline lineno="70"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>M.set_est<sp/>(<sp/>pfinit<sp/>);</highlight></codeline>
<codeline lineno="71"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>evolQ.set_parameters<sp/>(<sp/>1000.0<sp/>);<sp/></highlight><highlight class="comment">//sigma<sp/>=<sp/>1/10<sp/>mu</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="72"><highlight class="normal"></highlight></codeline>
<codeline lineno="73"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//simulator<sp/>values</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="74"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>dt<sp/>(<sp/>2<sp/>);<sp/></highlight><highlight class="comment">//<sp/>output<sp/>(isa<sp/>isb)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="75"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>wt<sp/>(<sp/>2<sp/>);<sp/></highlight><highlight class="comment">//<sp/>noise<sp/>on<sp/>dt</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="76"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>ut<sp/>(<sp/>2<sp/>);<sp/></highlight><highlight class="comment">//</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="77"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>xt=mu0;<sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>initial<sp/>state</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="78"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>et<sp/>(<sp/>4<sp/>);<sp/></highlight><highlight class="comment">//<sp/>noise<sp/>on<sp/>xt</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="79"><highlight class="normal"></highlight></codeline>
<codeline lineno="80"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>Xt=zeros<sp/>(<sp/>4,Ndat<sp/>);<sp/></highlight><highlight class="comment">//<sp/>True<sp/>trajetory<sp/>of<sp/>xt</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="81"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>XtE=zeros<sp/>(<sp/>4,Ndat<sp/>);<sp/></highlight><highlight class="comment">//<sp/>Estimate<sp/>of<sp/>xt<sp/>using<sp/>EKF<sp/>(known<sp/>Q)</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="82"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>XtM=zeros<sp/>(<sp/>6,Ndat<sp/>);<sp/></highlight><highlight class="comment">//<sp/>Estimate<sp/>of<sp/>xt<sp/>using<sp/>EKF-MPF</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="83"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Xt.set_col<sp/>(<sp/>0,mu0<sp/>);</highlight></codeline>
<codeline lineno="84"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>XtM.set_col<sp/>(<sp/>0,Mep.<ref refid="classepdf_1bf0a070a8f3e67a93604ca724638b870" kindref="member" tooltip="return expected value">mean</ref>()<sp/>);</highlight></codeline>
<codeline lineno="85"><highlight class="normal"></highlight></codeline>
<codeline lineno="86"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>t=1;t&lt;Ndat;t++<sp/>)<sp/>{</highlight></codeline>
<codeline lineno="87"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//simulator</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="88"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>UniRNG.sample_vector<sp/>(<sp/>2,wt<sp/>);</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="89"><highlight class="normal"></highlight></codeline>
<codeline lineno="90"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(<sp/>rem<sp/>(<sp/>t,500<sp/>)<sp/>&lt;200<sp/>)<sp/>ut<sp/>=<sp/>rem<sp/>(<sp/>t,500<sp/>)<sp/>*ones<sp/>(<sp/>2<sp/>);</highlight></codeline>
<codeline lineno="91"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="92"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>ut=zeros<sp/>(<sp/>2<sp/>);</highlight></codeline>
<codeline lineno="93"><highlight class="normal"></highlight></codeline>
<codeline lineno="94"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>NorRNG.sample_vector<sp/>(<sp/>4,et<sp/>);</highlight></codeline>
<codeline lineno="95"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>NorRNG.sample_vector<sp/>(<sp/>2,wt<sp/>);</highlight></codeline>
<codeline lineno="96"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>xt<sp/>=<sp/>fxu.<ref refid="classIMpmsm_145785869d978dda42828a072ec2caebe" kindref="member" tooltip="Evaluates .">eval</ref><sp/>(<sp/>xt,ut<sp/>)<sp/>+<sp/>Q.sqrt_mult<sp/>(<sp/>et<sp/>);</highlight></codeline>
<codeline lineno="97"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>dt<sp/>=<sp/>hxu.<ref refid="classOMpmsm_18e32392c9c635584606287b8c0e8c9da" kindref="member" tooltip="Evaluates .">eval</ref><sp/>(<sp/>xt,ut<sp/>)<sp/>+<sp/>R.sqrt_mult<sp/>(<sp/>wt<sp/>);</highlight></codeline>
<codeline lineno="98"><highlight class="normal"></highlight></codeline>
<codeline lineno="99"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//estimator</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="100"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>KFE.bayes<sp/>(<sp/>concat<sp/>(<sp/>dt,ut<sp/>)<sp/>);</highlight></codeline>
<codeline lineno="101"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>M.bayes<sp/>(<sp/>concat<sp/>(<sp/>dt,ut<sp/>)<sp/>);</highlight></codeline>
<codeline lineno="102"><highlight class="normal"></highlight></codeline>
<codeline lineno="103"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Xt.set_col<sp/>(<sp/>t,xt<sp/>);</highlight></codeline>
<codeline lineno="104"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>XtE.set_col<sp/>(<sp/>t,KFEep.<ref refid="classepdf_1bf0a070a8f3e67a93604ca724638b870" kindref="member" tooltip="return expected value">mean</ref>()<sp/>);</highlight></codeline>
<codeline lineno="105"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>XtM.set_col<sp/>(<sp/>t,Mep.<ref refid="classepdf_1bf0a070a8f3e67a93604ca724638b870" kindref="member" tooltip="return expected value">mean</ref>()<sp/>);</highlight></codeline>
<codeline lineno="106"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="107"><highlight class="normal"></highlight></codeline>
<codeline lineno="108"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>it_file<sp/>fou<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;pmsm.it&quot;</highlight><highlight class="normal"><sp/>);</highlight></codeline>
<codeline lineno="109"><highlight class="normal"></highlight></codeline>
<codeline lineno="110"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>fou<sp/>&lt;&lt;<sp/>Name<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;xth&quot;</highlight><highlight class="normal"><sp/>)<sp/>&lt;&lt;<sp/>Xt;</highlight></codeline>
<codeline lineno="111"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>fou<sp/>&lt;&lt;<sp/>Name<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;xthE&quot;</highlight><highlight class="normal"><sp/>)<sp/>&lt;&lt;<sp/>XtE;</highlight></codeline>
<codeline lineno="112"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>fou<sp/>&lt;&lt;<sp/>Name<sp/>(<sp/></highlight><highlight class="stringliteral">&quot;xthM&quot;</highlight><highlight class="normal"><sp/>)<sp/>&lt;&lt;<sp/>XtM;</highlight></codeline>
<codeline lineno="113"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//Exit<sp/>program:</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="114"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="115"><highlight class="normal"></highlight></codeline>
<codeline lineno="116"><highlight class="normal">}</highlight></codeline>
    </programlisting>
    <location file="/home/smidl/work/git/mixpp/pmsm/pmsm_unkQpf.cpp"/>
  </compounddef>
</doxygen>
