MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / predict

Method predict

bayes/src/infRtFlt.cpp:151–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149
150
151Bayes_base::Float
152 Information_root_scheme::predict (Linrz_predict_model& f, const FM::ColMatrix& invFx, bool linear_r)
153/* Linrz Prediction: using precomputed inverse of f.Fx
154 * Precondition:
155 * r(k|k),R(k|k)
156 * Postcondition:
157 * r(k+1|k) computed using QR decomposition see Ref[1]
158 * R(k+1|k)
159 *
160 * r can be computed in two was:
161 * Either directly in the linear form or using extended form via R*f.f(x)
162 *
163 * Requires LAPACK geqrf for QR decomposition (without PIVOTING)
164 */
165{
166 if (!linear_r)
167 update (); // x is required for f(x);
168
169 // Require Root of correlated predict noise (may be semidefinite)
170 Matrix Gqr (f.G);
171 for (Vec::const_iterator qi = f.q.begin(); qi != f.q.end(); ++qi)
172 {
173 if (*qi < 0)
174 error (Numeric_exception("Predict q Not PSD"));
175 column(Gqr, qi.index()) *= std::sqrt(*qi);
176 }
177 // Form Augmented matrix for factorisation
178 const std::size_t x_size = x.size();
179 const std::size_t q_size = f.q.size();
180 // Column major required for LAPACK, also this property is using in indexing
181 DenseColMatrix A(q_size+x_size, q_size+x_size+unsigned(linear_r));
182 FM::identity (A); // Prefill with identity for top left and zero's in off diagonals
183
184 Matrix RFxI (prod(R, invFx));
185 A.sub_matrix(q_size,q_size+x_size, 0,q_size) .assign (prod(RFxI, Gqr));
186 A.sub_matrix(q_size,q_size+x_size, q_size,q_size+x_size) .assign (RFxI);
187 if (linear_r)
188 A.sub_column(q_size,q_size+x_size, q_size+x_size) .assign (r);
189
190 // Calculate factorisation so we have and upper triangular R
191 DenseVec tau(q_size+x_size);
192 int info = LAPACK::geqrf (A, tau);
193 if (info != 0)
194 error (Numeric_exception("Predict no QR factor"));
195 // Extract the roots, junk in strict lower triangle
196 R = UpperTri( A.sub_matrix(q_size,q_size+x_size, q_size,q_size+x_size) );
197 if (linear_r)
198 noalias(r) = A.sub_column(q_size,q_size+x_size, q_size+x_size);
199 else
200 noalias(r) = prod(R,f.f(x)); // compute r using f(x)
201
202 return UCrcond(R); // compute rcond of result
203}
204
205
206Bayes_base::Float

Callers

nothing calls this directly

Calls 13

errorFunction · 0.85
Numeric_exceptionClass · 0.85
identityFunction · 0.85
geqrfFunction · 0.85
UpperTriFunction · 0.85
UCrcondFunction · 0.85
indexMethod · 0.80
assignMethod · 0.80
sub_matrixMethod · 0.80
sub_columnMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected