1
// $Id: rauchtungstriebel.cpp 6736 2006-12-22 11:24:42Z tdelaet $
2
// Copyright (C) 2006 Tinne De Laet <first dot last at mech dot kuleuven dot be>
4
// This program is free software; you can redistribute it and/or modify
5
// it under the terms of the GNU Lesser General Public License as published by
6
// the Free Software Foundation; either version 2.1 of the License, or
7
// (at your option) any later version.
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
// GNU Lesser General Public License for more details.
14
// You should have received a copy of the GNU Lesser General Public License
15
// along with this program; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
#include "rauchtungstriebel.h"
23
using namespace MatrixWrapper;
25
#define AnalyticSys AnalyticSystemModelGaussianUncertainty
27
RauchTungStriebel::RauchTungStriebel(Gaussian * prior)
28
: BackwardFilter<ColumnVector>(prior)
29
, _x(prior->DimensionGet())
30
, _xf(prior->DimensionGet())
31
, _xpred(prior->DimensionGet())
32
, _xsmooth(prior->DimensionGet())
33
, _F(prior->DimensionGet(),prior->DimensionGet())
34
, _Ppred(prior->DimensionGet(),prior->DimensionGet())
35
, _Pxx(prior->DimensionGet(),prior->DimensionGet())
36
, _K(prior->DimensionGet(),prior->DimensionGet())
37
, _Psmooth(prior->DimensionGet(),prior->DimensionGet())
38
, _Q(prior->DimensionGet())
39
, _Sigma_new(prior->DimensionGet())
41
// create posterior dencity
42
_post = new Gaussian(*prior);
45
RauchTungStriebel::~RauchTungStriebel()
51
RauchTungStriebel::SysUpdate(SystemModel<ColumnVector>* const sysmodel, const ColumnVector& u, Pdf<ColumnVector>* const filtered_post)
53
_x = _post->ExpectedValueGet();
54
_xf = filtered_post->ExpectedValueGet();
55
_F = ((AnalyticSys*)sysmodel)->df_dxGet(u,_x);
56
_Q = ((AnalyticSys*)sysmodel)->CovarianceGet(u,_x);
58
_Ppred = _F * (Matrix)filtered_post->CovarianceGet() * _F.transpose() + (Matrix)_Q;
59
_Pxx = (Matrix)filtered_post->CovarianceGet() * _F.transpose();
60
_K = _Pxx * _Ppred.inverse();
61
_xpred = ((AnalyticSys*)sysmodel)->PredictionGet(u,_xf);
62
_xsmooth = _xf + _K * (_x - _xpred);
64
_Psmooth = (Matrix)filtered_post->CovarianceGet() - _K * ( _Ppred - (Matrix)_post->CovarianceGet() ) * _K.transpose();
65
_Psmooth.convertToSymmetricMatrix(_Sigma_new);
67
// set new state gaussian
68
PostMuSet ( _xsmooth );
69
PostSigmaSet( _Sigma_new );
73
RauchTungStriebel::UpdateInternal(SystemModel<ColumnVector>* const sysmodel, const ColumnVector& u,Pdf<ColumnVector>* const filtered_post)
75
SysUpdate(sysmodel,u,(Gaussian*)filtered_post);
80
RauchTungStriebel::PostSigmaSet( const SymmetricMatrix& s)
82
dynamic_cast<Gaussian *>(_post)->CovarianceSet(s);
86
RauchTungStriebel::PostMuSet( const ColumnVector& c)
88
dynamic_cast<Gaussian *>(_post)->ExpectedValueSet(c);