1 | <?xml version='1.0' encoding='UTF-8' standalone='no'?> |
---|
2 | <doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.5.6"> |
---|
3 | <compounddef id="tests_2linefit2__c_8cpp" kind="file"> |
---|
4 | <compoundname>linefit2_c.cpp</compoundname> |
---|
5 | <includes local="no">itpp/base/itfile.h</includes> |
---|
6 | <includes refid="arx_8h" local="yes">estim/arx.h</includes> |
---|
7 | <incdepgraph> |
---|
8 | <node id="524"> |
---|
9 | <label>work/mixpp/tests/linefit2_c.cpp</label> |
---|
10 | <link refid="tests/linefit2_c.cpp"/> |
---|
11 | <childnode refid="525" relation="include"> |
---|
12 | </childnode> |
---|
13 | <childnode refid="526" relation="include"> |
---|
14 | </childnode> |
---|
15 | </node> |
---|
16 | <node id="528"> |
---|
17 | <label>../stat/libFN.h</label> |
---|
18 | <link refid="libFN_8h-source"/> |
---|
19 | <childnode refid="527" relation="include"> |
---|
20 | </childnode> |
---|
21 | <childnode refid="529" relation="include"> |
---|
22 | </childnode> |
---|
23 | </node> |
---|
24 | <node id="526"> |
---|
25 | <label>estim/arx.h</label> |
---|
26 | <link refid="arx_8h"/> |
---|
27 | <childnode refid="527" relation="include"> |
---|
28 | </childnode> |
---|
29 | <childnode refid="528" relation="include"> |
---|
30 | </childnode> |
---|
31 | <childnode refid="530" relation="include"> |
---|
32 | </childnode> |
---|
33 | </node> |
---|
34 | <node id="525"> |
---|
35 | <label>itpp/base/itfile.h</label> |
---|
36 | </node> |
---|
37 | <node id="529"> |
---|
38 | <label>libBM.h</label> |
---|
39 | <link refid="libBM_8h"/> |
---|
40 | <childnode refid="527" relation="include"> |
---|
41 | </childnode> |
---|
42 | </node> |
---|
43 | <node id="531"> |
---|
44 | <label>../math/libDC.h</label> |
---|
45 | <link refid="libDC_8h"/> |
---|
46 | <childnode refid="527" relation="include"> |
---|
47 | </childnode> |
---|
48 | </node> |
---|
49 | <node id="527"> |
---|
50 | <label>itpp/itbase.h</label> |
---|
51 | </node> |
---|
52 | <node id="532"> |
---|
53 | <label>../itpp_ext.h</label> |
---|
54 | <link refid="itpp__ext_8h-source"/> |
---|
55 | <childnode refid="527" relation="include"> |
---|
56 | </childnode> |
---|
57 | </node> |
---|
58 | <node id="530"> |
---|
59 | <label>../stat/libEF.h</label> |
---|
60 | <link refid="libEF_8h"/> |
---|
61 | <childnode refid="527" relation="include"> |
---|
62 | </childnode> |
---|
63 | <childnode refid="531" relation="include"> |
---|
64 | </childnode> |
---|
65 | <childnode refid="529" relation="include"> |
---|
66 | </childnode> |
---|
67 | <childnode refid="532" relation="include"> |
---|
68 | </childnode> |
---|
69 | </node> |
---|
70 | </incdepgraph> |
---|
71 | <sectiondef kind="func"> |
---|
72 | <memberdef kind="function" id="tests_2linefit2__c_8cpp_1e66f6b31b5ad750f1fe042a706a4e3d4" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual"> |
---|
73 | <type>int</type> |
---|
74 | <definition>int main</definition> |
---|
75 | <argsstring>()</argsstring> |
---|
76 | <name>main</name> |
---|
77 | <briefdescription> |
---|
78 | </briefdescription> |
---|
79 | <detaileddescription> |
---|
80 | </detaileddescription> |
---|
81 | <inbodydescription> |
---|
82 | </inbodydescription> |
---|
83 | <location file="/home/smidl/work/mixpp/tests/linefit2_c.cpp" line="7" bodyfile="/home/smidl/work/mixpp/tests/linefit2_c.cpp" bodystart="7" bodyend="62"/> |
---|
84 | </memberdef> |
---|
85 | </sectiondef> |
---|
86 | <briefdescription> |
---|
87 | </briefdescription> |
---|
88 | <detaileddescription> |
---|
89 | </detaileddescription> |
---|
90 | <programlisting> |
---|
91 | <codeline lineno="1"><highlight class="preprocessor">#include<sp/><itpp/base/itfile.h></highlight><highlight class="normal"></highlight></codeline> |
---|
92 | <codeline lineno="2"><highlight class="normal"></highlight></codeline> |
---|
93 | <codeline lineno="3"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>"<ref refid="arx_8h" kindref="compound" tooltip="Bayesian Filtering for generalized autoregressive (ARX) model.">estim/arx.h</ref>"</highlight><highlight class="normal"></highlight></codeline> |
---|
94 | <codeline lineno="4"><highlight class="normal"></highlight></codeline> |
---|
95 | <codeline lineno="5"><highlight class="normal"></highlight><highlight class="keyword">using<sp/>namespace<sp/></highlight><highlight class="normal">itpp;</highlight></codeline> |
---|
96 | <codeline lineno="6"><highlight class="normal"></highlight></codeline> |
---|
97 | <codeline lineno="7"><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>(){</highlight></codeline> |
---|
98 | <codeline lineno="8"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>it_file<sp/>inpf(</highlight><highlight class="stringliteral">"Data.it"</highlight><highlight class="normal">);</highlight></codeline> |
---|
99 | <codeline lineno="9"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>Data;</highlight></codeline> |
---|
100 | <codeline lineno="10"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inpf<sp/>>><sp/>Name(</highlight><highlight class="stringliteral">"Data"</highlight><highlight class="normal">)<sp/>>>Data;</highlight></codeline> |
---|
101 | <codeline lineno="11"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(Data.rows()>2)<sp/>Data=Data.T();</highlight></codeline> |
---|
102 | <codeline lineno="12"><highlight class="normal"></highlight></codeline> |
---|
103 | <codeline lineno="13"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ilow<sp/>=<sp/>0;</highlight></codeline> |
---|
104 | <codeline lineno="14"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ihi<sp/>=<sp/>40;</highlight></codeline> |
---|
105 | <codeline lineno="15"><highlight class="normal"></highlight></codeline> |
---|
106 | <codeline lineno="16"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>------------------<sp/>Start<sp/>of<sp/>routine<sp/>---------------------------</highlight><highlight class="normal"></highlight></codeline> |
---|
107 | <codeline lineno="17"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ndat=Data.cols();</highlight></codeline> |
---|
108 | <codeline lineno="18"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>npsi=Data.rows()<sp/>+1;<sp/></highlight><highlight class="comment">//add<sp/>a<sp/>constant</highlight><highlight class="normal"></highlight></codeline> |
---|
109 | <codeline lineno="19"><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/>thr<sp/>(<sp/></highlight><highlight class="stringliteral">"1"</highlight><highlight class="normal">,</highlight><highlight class="stringliteral">"{<sp/>theta_r<sp/>}"</highlight><highlight class="normal">,vec_1<sp/>(<sp/>npsi<sp/>),vec_1<sp/>(<sp/>0<sp/>)<sp/>);</highlight></codeline> |
---|
110 | <codeline lineno="20"><highlight class="normal"></highlight></codeline> |
---|
111 | <codeline lineno="21"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>V0=1e-8*eye<sp/>(<sp/>npsi<sp/>);<sp/>V0<sp/>(<sp/>0,0<sp/>)<sp/>=1.0;</highlight></codeline> |
---|
112 | <codeline lineno="22"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>vec<sp/>rgr<sp/>(<sp/>npsi<sp/>);</highlight></codeline> |
---|
113 | <codeline lineno="23"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">double</highlight><highlight class="normal"><sp/>nu0=3;</highlight></codeline> |
---|
114 | <codeline lineno="24"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>fitting<sp/>a<sp/>linear<sp/>part<sp/>=><sp/>third<sp/>coef<sp/>is<sp/>"1"</highlight><highlight class="normal"></highlight></codeline> |
---|
115 | <codeline lineno="25"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>rgr<sp/>(<sp/>2<sp/>)<sp/>=<sp/>1.0;</highlight></codeline> |
---|
116 | <codeline lineno="26"><highlight class="normal"></highlight></codeline> |
---|
117 | <codeline lineno="27"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>RESULTS</highlight><highlight class="normal"></highlight></codeline> |
---|
118 | <codeline lineno="28"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>mat<sp/>Tlls=zeros<sp/>(<sp/>ihi+1,ihi+1);</highlight></codeline> |
---|
119 | <codeline lineno="29"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>AR<sp/>model</highlight><highlight class="normal"></highlight></codeline> |
---|
120 | <codeline lineno="30"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="classARX" kindref="compound" tooltip="Linear Autoregressive model with Gaussian noise.">ARX</ref><sp/>Ar<sp/>(<sp/>thr,V0,nu0<sp/>);</highlight></codeline> |
---|
121 | <codeline lineno="31"><highlight class="normal"></highlight></codeline> |
---|
122 | <codeline lineno="32"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//Initialize</highlight><highlight class="normal"></highlight></codeline> |
---|
123 | <codeline lineno="33"><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/>i=ilow+2;<sp/>i<ihi-2;<sp/>i++<sp/>)<sp/>{</highlight></codeline> |
---|
124 | <codeline lineno="34"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>rgr.set_subvector<sp/>(<sp/>0,Data.get_col<sp/>(<sp/>i<sp/>)<sp/>);</highlight></codeline> |
---|
125 | <codeline lineno="35"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Ar.bayes<sp/>(<sp/>rgr<sp/>);</highlight></codeline> |
---|
126 | <codeline lineno="36"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
127 | <codeline lineno="37"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>FLATTEN</highlight><highlight class="normal"></highlight></codeline> |
---|
128 | <codeline lineno="38"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Ar.get_parameters<sp/>(<sp/>V0,nu0<sp/>);</highlight></codeline> |
---|
129 | <codeline lineno="39"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>V0<sp/>*=1.0/nu0;<sp/></highlight><highlight class="comment">//<sp/>same<sp/>flattening<sp/>factor<sp/>as<sp/>for<sp/>nu0</highlight><highlight class="normal"></highlight></codeline> |
---|
130 | <codeline lineno="40"><highlight class="normal"></highlight><highlight class="comment">//<sp/><sp/><sp/><sp/><sp/><sp/>V0(0,0)*=1.2;</highlight><highlight class="normal"></highlight></codeline> |
---|
131 | <codeline lineno="41"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nu0=3;</highlight></codeline> |
---|
132 | <codeline lineno="42"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Ar.set_parameters<sp/>(<sp/>V0,nu0<sp/>);</highlight></codeline> |
---|
133 | <codeline lineno="43"><highlight class="normal"></highlight></codeline> |
---|
134 | <codeline lineno="44"><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/>i=ilow;<sp/>i<=ihi;<sp/>i++<sp/>)<sp/>{</highlight></codeline> |
---|
135 | <codeline lineno="45"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Ar.set_parameters<sp/>(<sp/>V0,nu0<sp/>);</highlight></codeline> |
---|
136 | <codeline lineno="46"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><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=i;<sp/>t<=ihi;<sp/>t++<sp/>)<sp/>{</highlight></codeline> |
---|
137 | <codeline lineno="47"><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/>rgr.set_subvector<sp/>(<sp/>0,Data.get_col<sp/>(<sp/>t<sp/>)<sp/>);</highlight></codeline> |
---|
138 | <codeline lineno="48"><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/>Ar.bayes<sp/>(<sp/>rgr<sp/>);</highlight></codeline> |
---|
139 | <codeline lineno="49"><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/>Tlls<sp/>(<sp/>i,t<sp/>)<sp/>=Ar._tll();</highlight></codeline> |
---|
140 | <codeline lineno="50"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
141 | <codeline lineno="51"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline> |
---|
142 | <codeline lineno="52"><highlight class="normal"></highlight></codeline> |
---|
143 | <codeline lineno="53"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>max_index<sp/>(<sp/>Tlls,ilow,ihi<sp/>);</highlight></codeline> |
---|
144 | <codeline lineno="54"><highlight class="normal"></highlight></codeline> |
---|
145 | <codeline lineno="55"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>------------------<sp/>End<sp/>of<sp/>routine<sp/>-----------------------------</highlight><highlight class="normal"></highlight></codeline> |
---|
146 | <codeline lineno="56"><highlight class="normal"></highlight></codeline> |
---|
147 | <codeline lineno="57"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>max_index(Tlls,ilow,ihi);</highlight></codeline> |
---|
148 | <codeline lineno="58"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inpf<sp/><<<sp/>Name(</highlight><highlight class="stringliteral">"T"</highlight><highlight class="normal">)<sp/><<<sp/>Tlls;</highlight></codeline> |
---|
149 | <codeline lineno="59"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inpf<sp/><<<sp/>Name(</highlight><highlight class="stringliteral">"ilow"</highlight><highlight class="normal">)<sp/><<<sp/>ilow+1;</highlight></codeline> |
---|
150 | <codeline lineno="60"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>inpf<sp/><<<sp/>Name(</highlight><highlight class="stringliteral">"ihi"</highlight><highlight class="normal">)<sp/><<<sp/>ihi+1;</highlight></codeline> |
---|
151 | <codeline lineno="61"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline> |
---|
152 | <codeline lineno="62"><highlight class="normal">}</highlight></codeline> |
---|
153 | </programlisting> |
---|
154 | <location file="/home/smidl/work/mixpp/tests/linefit2_c.cpp"/> |
---|
155 | </compounddef> |
---|
156 | </doxygen> |
---|