Bayes++ Bayesian Filtering Classes  Release 2014.5 - Copyright (c) 2003,2004,2005,2006,2011,2012,2014 Michael Stevens
UDFlt.hpp
Go to the documentation of this file.
1 #ifndef _BAYES_FILTER_UD
2 #define _BAYES_FILTER_UD
3 /*
4  * Bayes++ the Bayesian Filtering Library
5  * Copyright (c) 2002 Michael Stevens
6  * See accompanying Bayes++.htm for terms and conditions of use.
7  *
8  * $Id$
9  */
10 
11 /*
12  * UdU' Factorisation of covariance Filter Scheme.
13  * Implementation of a 'Square-root' linearised Kalman filter
14  *
15  * Bierman's UD factorisatised update algorithm using Agee-Turner UdU' factorisation rank 1 update
16  * Thornton's MWG-S factorisation predict algorithm
17  * References
18  * [1] "Factorisation Methods for Discrete Sequential Estimation" Gerald J. Bierman ISBN 0-12-097350-2
19  * [2] "Kalman Filtering, Theory and Practice", Mohinder S. Grewal, Angus P. Andrews ISBN 0-13-211335-X
20  *
21  * A initial observation size may also be specified for efficiency.
22  *
23  * The filter is operated by performing a
24  * predict, observe
25  * cycle defined by the base class
26  */
27 #include "bayesFlt.hpp"
28 
29 /* Filter namespace */
30 namespace Bayesian_filter
31 {
32 
34 {
35 public:
36  UD_sequential_observe_model (std::size_t x_size, std::size_t z_size) :
37  Linrz_uncorrelated_observe_model(x_size, z_size), Hx_o(x_size)
38  {}
39  virtual const FM::Vec& ho (const FM::Vec& x, const std::size_t o) = 0;
40  /* Supplied model (h) for observation using state x, z allows normalisation and model variation
41  Fast model of a single element (o) in observation model
42  Precondition: Hx_o is conformantly dimensioned
43  Postcondition:
44  z(k|k-1) = h(x(k|k-1)
45  Hx_o(x(k-1|k-1) = Jacobian of h with respect to state x (row o)
46  */
48 };
49 
50 
52 {
53 private:
54  std::size_t q_max; // Maxiumum size allocated for noise model, constructed before UD
55 public:
56  FM::Matrix UD; // UDU factorisation of X with D on diagonal
57  // Lower triangle used as workspace
58  FM::Vec s; // Innovation
59  FM::Vec Sd; // Innovation Covariance
60 
61  UD_scheme (std::size_t x_size, std::size_t q_maxsize, std::size_t z_initialsize = 0);
62  UD_scheme& operator= (const UD_scheme&);
63  // Optimise copy assignment to only copy filter state
64 
65  void init ();
66  void update ();
67  Float predict (Linrz_predict_model& f);
68 
69  Float observe (Linrz_correlated_observe_model& h, const FM::Vec& z);
70  /* No solution for Correlated noise and Linrz model */
71  Float observe (Linrz_uncorrelated_observe_model& h, const FM::Vec& z);
72  /* General observe */
73 
74  Float observe (Linear_correlated_observe_model& h, const FM::Vec& z);
75  /* Special Linear observe for correlated Z, fast Z decorrelation */
76  Float observe (UD_sequential_observe_model& h, const FM::Vec& z);
77  /* Special Linrz observe using fast sequential model */
78 
79 protected:
80  Float predictGq (const FM::Matrix& Fx, const FM::Matrix& G, const FM::Vec& q);
81  FM::Vec d, dv, v; // predictGQ temporaries
82  Float observeUD (FM::Vec& gain, Float& alpha, const FM::Vec& h, const Float r);
83  FM::Vec a, b; // observeUD temporaries
84  // Observation temporaies
85  void observe_size (std::size_t z_size);
86  std::size_t last_z_size;
87  FM::Vec h1; // Single Observation model
88  FM::Vec w; // Single Gain
89  FM::Vec znorm; // Normalised innovation
90  FM::Vec zpdecol; // Decorrelated zp
91  FM::Matrix Gz; // Z coupling
92  FM::Matrix GIHx; // Modified Model for linear decorrelation
93 };
94 
95 
96 }//namespace
97 #endif
FM::Matrix UD
Definition: UDFlt.hpp:56
FM::Matrix GIHx
Definition: UDFlt.hpp:92
FM::Vec s
Definition: UDFlt.hpp:58
FM::Vec Hx_o
Definition: UDFlt.hpp:47
Definition: bayesFlt.hpp:588
FM::Vec v
Definition: UDFlt.hpp:81
FM::Vec h1
Definition: UDFlt.hpp:87
Definition: bayesException.hpp:20
FM::Vec zpdecol
Definition: UDFlt.hpp:90
FM::Vec znorm
Definition: UDFlt.hpp:89
FMVec< detail::BaseVector > Vec
Definition: uBLASmatrix.hpp:323
Definition: UDFlt.hpp:51
RowMatrix Matrix
Definition: uBLASmatrix.hpp:325
FM::Vec Sd
Definition: UDFlt.hpp:59
Bayesian_filter_matrix::Float Float
Definition: bayesFlt.hpp:39
UD_sequential_observe_model(std::size_t x_size, std::size_t z_size)
Definition: UDFlt.hpp:36
FM::Matrix Gz
Definition: UDFlt.hpp:91
std::size_t last_z_size
Definition: UDFlt.hpp:86
virtual const FM::Vec & ho(const FM::Vec &x, const std::size_t o)=0
Definition: bayesFlt.hpp:177
virtual const FM::Vec & h(const FM::Vec &x) const =0
FM::Vec w
Definition: UDFlt.hpp:88
FM::Vec b
Definition: UDFlt.hpp:83