20 #ifndef UKF_PARAMETER_NDIM_H
21 #define UKF_PARAMETER_NDIM_H
23 #include <gsl/gsl_linalg.h>
24 #include <gsl/gsl_math.h>
25 #include <gsl/gsl_blas.h>
46 s.
Kk = gsl_matrix_alloc(p.
n,p.
no);
47 gsl_matrix_set_zero(s.
Kk);
49 s.
Kk_T = gsl_matrix_alloc(p.
no,p.
n);
50 gsl_matrix_set_zero(s.
Kk_T);
52 s.
Pwdk = gsl_matrix_alloc(p.
n,p.
no);
53 gsl_matrix_set_zero(s.
Pwdk);
56 s.
Prrk = gsl_matrix_alloc(p.
n,p.
n);
60 s.
Peek = gsl_matrix_alloc(p.
no,p.
no);
61 gsl_matrix_set_identity(s.
Peek);
64 s.
Pddk = gsl_matrix_alloc(p.
no, p.
no);
65 gsl_matrix_set_zero(s.
Pddk);
67 s.
w = gsl_vector_alloc(p.
n);
68 gsl_vector_set_zero(s.
w);
70 s.
wk = gsl_vector_alloc(p.
n);
71 gsl_vector_set_zero(s.
wk);
73 s.
Pk = gsl_matrix_alloc(p.
n,p.
n);
74 gsl_matrix_set_identity(s.
Pk);
77 s.
Sk = gsl_matrix_alloc(p.
n,p.
n);
79 gsl_matrix_memcpy(s.
Sk, s.
Pk);
80 gsl_linalg_cholesky_decomp(s.
Sk);
82 for(
int k = 0 ; k < p.
n ; k++)
83 for(
int j = 0 ; j < k ; j++)
84 gsl_matrix_set(s.
Sk,j,k,0.0);
86 s.
cSk = gsl_vector_alloc(p.
n);
87 gsl_vector_set_zero(s.
cSk);
97 gsl_vector_set(s.
wm, j, 1.0 / (2.0 * (p.
n + p.
lambda)));
98 gsl_vector_set(s.
wc, j, 1.0 / (2.0 * (p.
n + p.
lambda)));
102 gsl_matrix_set_zero(s.
dk);
105 gsl_vector_set_zero(s.
ino_dk);
108 gsl_vector_set_zero(s.
d_mean);
132 gsl_matrix_free(s.
Kk);
133 gsl_matrix_free(s.
Kk_T);
134 gsl_matrix_free(s.
Pwdk);
135 gsl_matrix_free(s.
Pddk);
136 gsl_matrix_free(s.
Peek);
137 gsl_matrix_free(s.
Prrk);
139 gsl_vector_free(s.
w);
140 gsl_vector_free(s.
wk);
142 gsl_matrix_free(s.
Pk);
143 gsl_matrix_free(s.
Sk);
144 gsl_vector_free(s.
cSk);
146 gsl_vector_free(s.
wm);
147 gsl_vector_free(s.
wc);
149 gsl_matrix_free(s.
dk);
150 gsl_vector_free(s.
ino_dk);
151 gsl_vector_free(s.
d_mean);
172 template <
typename FunctObj>
183 gsl_matrix_add(s.
Pk, s.
Prrk);
194 gsl_matrix_memcpy(s.
Sk, s.
Pk);
195 gsl_linalg_cholesky_decomp(s.
Sk);
197 for(
int k = 0 ; k < p.
n ; ++k)
198 for(
int j = 0 ; j < k ; ++j)
199 gsl_matrix_set(s.
Sk,j,k,0.0);
202 for(
int j = 1 ; j < p.
n+1 ; ++j)
203 for(
int i = 0 ; i < p.
n ; ++i)
204 gsl_matrix_set(s.
sigmaPoints, i, j, gsl_vector_get(s.
w, i) + p.
gamma * gsl_matrix_get(s.
Sk,i,j-1));
207 for(
int i = 0 ; i < p.
n ; ++i)
208 gsl_matrix_set(s.
sigmaPoints, i, j, gsl_vector_get(s.
w, i) - p.
gamma * gsl_matrix_get(s.
Sk,i,j-(p.
n+1)));
218 gsl_vector_set_zero(s.
d_mean);
236 gsl_matrix_set_zero(s.
Pwdk);
243 gsl_vector_sub(s.
wk, s.
w);
293 for(
int i = 0 ; i < p.
no; ++i)
295 gsl_blas_dgemv(CblasNoTrans, 1.0, s.
Kk, s.
ino_dk, 1.0, s.
w);
312 template <
typename FunctObj>
327 for(
int k = 0 ; k < p.
n ; ++k)
328 for(
int j = 0 ; j < k ; ++j)
332 for(
int j = 1 ; j < p.
n+1 ; ++j)
333 for(
int i = 0 ; i < p.
n ; ++i)
337 for(
int i = 0 ; i < p.
n ; ++i)
347 gsl_vector_set_zero(dk);
381 for(
int k = 0 ; k < p.
n ; ++k)
382 for(
int j = 0 ; j < k ; ++j)
385 gsl_matrix_set_col(sigmaPoints,0, s.
w);
386 for(
int j = 1 ; j < p.
n+1 ; ++j)
387 for(
int i = 0 ; i < p.
n ; ++i)
388 gsl_matrix_set(sigmaPoints, i, j, gsl_vector_get(s.
w, i) + p.
gamma * gsl_matrix_get(s.
mat_temp_n_n,i,j-1));
391 for(
int i = 0 ; i < p.
n ; ++i)
392 gsl_matrix_set(sigmaPoints, i, j, gsl_vector_get(s.
w, i) - p.
gamma * gsl_matrix_get(s.
mat_temp_n_n,i,j-(p.
n+1)));
399 #endif // SL_PARAMETER_NDIM_H
void ukf_iterate(ukf_param &p, ukf_state &s, FunctObj g, gsl_vector *xk, gsl_vector *dk)
Iteration for the statistical linearization.
Definition: ukf_parameter_ndim.h:173
EvolutionNoise * evolution_noise
Parameter used for the evolution noise.
Definition: ukf_types.h:96
gsl_vector * wc
Weights used to update the covariance matrices.
Definition: ukf_types.h:318
void ukf_free(ukf_param &p, ukf_state &s)
Free of memory allocation.
Definition: ukf_parameter_ndim.h:130
gsl_matrix * mat_temp_1_output
Temporary matrix of size .
Definition: ukf_types.h:368
gsl_matrix * Pddk
Covariance of the output, a matrix of size .
Definition: ukf_types.h:269
double kpa
, is a good choice. According to van der Merwe, its value is not critical
Definition: ukf_types.h:60
double observation_noise
Covariance of the observation noise.
Definition: ukf_types.h:101
gsl_matrix * mat_temp_output_1
Temporary matrix of size .
Definition: ukf_types.h:373
gsl_matrix * sigmaPoints
Matrix holding the sigma points in the columns, of size .
Definition: ukf_types.h:338
void getSigmaPoints(ukf_param &p, ukf_state &s, gsl_matrix *sigmaPoints)
Returns a set of sigma points.
Definition: ukf_parameter_ndim.h:365
gsl_matrix * Kk
Kalman gain, a matrix of size .
Definition: ukf_types.h:254
Structure holding the parameters of the Unscented Kalman Filter.
Definition: ukf_types.h:55
gsl_vector * ino_dk
Vector holding the inovation, of size ŝ
Definition: ukf_types.h:333
double beta
Non negative weights used to introduce knowledge about the higher order moments of the distribution...
Definition: ukf_types.h:70
gsl_matrix * mat_temp_output_output
Temporary matrix of size .
Definition: ukf_types.h:378
gsl_vector * d_mean
Vector holding the mean of the sigma points image, of size ŝ
Definition: ukf_types.h:328
gsl_vector * wk
Temporary vector holding one sigma point, of size .
Definition: ukf_types.h:289
int n
Number of parameters to estimate.
Definition: ukf_types.h:111
gsl_vector * w
Parameter vector, of size .
Definition: ukf_types.h:284
gsl_matrix * dk
Temporary matrix holding the image of the sigma points, of size .
Definition: ukf_types.h:323
void ukf_init(ukf_param &p, ukf_state &s)
Allocation of the vectors/matrices and initialization.
Definition: ukf_parameter_ndim.h:38
void init(ukf_param &p, ukf_state &s)
Definition: ukf_types.h:395
gsl_matrix * mat_temp_n_1
Temporary matrix of size .
Definition: ukf_types.h:353
gsl_matrix * Peek
Covariance of the observation noise, of size .
Definition: ukf_types.h:274
int no
Dimension of the output.
Definition: ukf_types.h:121
gsl_vector * cSk
Vector holding one column of Sk, of size .
Definition: ukf_types.h:304
double alpha
: "Size" of sigma-point distribution. Should be small if the function is strongly non-linear ...
Definition: ukf_types.h:65
gsl_matrix * Pk
Covariance matrix of the parameters, of size .
Definition: ukf_types.h:294
gsl_vector * vec_temp_n
Temporary vector of size .
Definition: ukf_types.h:343
gsl_matrix * mat_temp_n_output
Temporary matrix of size .
Definition: ukf_types.h:358
gsl_matrix * Pwdk
Covariance of : , of size .
Definition: ukf_types.h:264
double lambda
Definition: ukf_types.h:75
gsl_matrix * Prrk
Covariance of the evolution noise, of size .
Definition: ukf_types.h:279
virtual void updateEvolutionNoise(ukf_param &p, ukf_state &s)=0
Structure holding the matrices manipulated by the unscented kalman filter in the vectorial case...
Definition: ukf_types.h:249
gsl_matrix * mat_temp_n_n
Temporary matrix of size .
Definition: ukf_types.h:383
gsl_matrix * Kk_T
The tranposed Kalman gain, a vector of size .
Definition: ukf_types.h:259
void ukf_evaluate(ukf_param &p, ukf_state &s, FunctObj g, gsl_vector *xk, gsl_vector *dk)
Evaluation of the output from the sigma points.
Definition: ukf_parameter_ndim.h:313
double prior_pi
Prior estimate of the covariance matrix.
Definition: ukf_types.h:106
gsl_matrix * Sk
Matrix holding the Cholesky decomposition of , of size .
Definition: ukf_types.h:299
gsl_vector * vec_temp_output
Temporary vector of size .
Definition: ukf_types.h:348
double gamma
Definition: ukf_types.h:80
gsl_vector * wm
Weights used to compute the mean of the sigma points' images.
Definition: ukf_types.h:311
gsl_matrix * mat_temp_output_n
Temporary matrix of size .
Definition: ukf_types.h:363
int nbSamples
Number of sigma-points
Definition: ukf_types.h:116