20 #ifndef UKF_NDIM_STATE_H
21 #define UKF_NDIM_STATE_H
23 #include <gsl/gsl_linalg.h>
24 #include <gsl/gsl_math.h>
25 #include <gsl/gsl_blas.h>
55 s.
xi = gsl_vector_alloc(p.
n);
56 gsl_vector_set_zero(s.
xi);
64 s.
Pxxi = gsl_matrix_alloc(p.
n,p.
n);
65 gsl_matrix_set_identity(s.
Pxxi);
71 s.
Pvvi = gsl_matrix_alloc(p.
n,p.
n);
82 gsl_vector_set_zero(s.
ino_yi);
84 s.
Pyyi = gsl_matrix_alloc(p.
no, p.
no);
85 gsl_matrix_set_zero(s.
Pyyi);
87 s.
Pnni = gsl_matrix_alloc(p.
no,p.
no);
88 gsl_matrix_set_identity(s.
Pnni);
91 s.
Pxyi = gsl_matrix_alloc(p.
n, p.
no);
92 gsl_matrix_set_zero(s.
Pxyi);
115 gsl_vector_set(s.
wm_j, j, 1.0 / (2.0 * (p.
n + p.
lambda)));
116 gsl_vector_set(s.
wc_j, j, 1.0 / (2.0 * (p.
n + p.
lambda)));
130 s.
Ki = gsl_matrix_alloc(p.
n, p.
no);
131 s.
Ki_T = gsl_matrix_alloc(p.
no, p.
n);
134 s.
temp_n = gsl_vector_alloc(p.
n);
151 gsl_vector_free(s.
xi);
154 gsl_matrix_free(s.
Pxxi);
156 gsl_matrix_free(s.
Pvvi);
161 gsl_vector_free(s.
ino_yi);
162 gsl_matrix_free(s.
Pyyi);
163 gsl_matrix_free(s.
Pnni);
165 gsl_matrix_free(s.
Pxyi);
173 gsl_vector_free(s.
wm_j);
174 gsl_vector_free(s.
wc_j);
179 gsl_matrix_free(s.
Ki);
180 gsl_matrix_free(s.
Ki_T);
182 gsl_vector_free(s.
temp_n);
197 template <
typename FunctProcess,
typename FunctObservation>
208 gsl_linalg_cholesky_decomp(s.
cholPxxi);
210 for(j = 0 ; j < p.
n ; j++)
211 for(k = j+1 ; k < p.
n ; k++)
220 for(j = 1 ; j < p.
n+1 ; ++j)
221 for(i = 0 ; i < p.
n ; ++i)
233 gsl_vector_set_zero(s.
xi_mean);
234 gsl_vector_view vec_view;
242 for(i = 0 ; i < p.
n ; ++i)
249 gsl_matrix_set_zero(s.
Pxxi);
252 for(i = 0 ; i < p.
n ; ++i)
264 gsl_matrix_view mat_view;
268 for(j = 0 ; j < p.
n ; ++j)
270 for(i = 0 ; i < p.
n ; ++i)
279 gsl_vector_set_zero(s.
yi_mean);
287 for(i = 0 ; i < p.
no ; ++i)
301 for(i = 0 ; i < p.
no ; ++i)
310 gsl_matrix_set_zero(s.
Pxyi);
313 for(i = 0 ; i < p.
n ; ++i)
316 for(i = 0 ; i < p.
no ; ++i)
330 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0 , s.
Pxyi, s.
temp_no_no, 0, s.
Ki);
335 for(i = 0 ; i < p.
no ; ++i)
336 s.
ino_yi->data[i] = gsl_vector_get(yi, i) - gsl_vector_get(s.
yi_mean, i);
338 gsl_blas_dgemv(CblasNoTrans, 1.0 , s.
Ki, s.
ino_yi, 1.0, s.
xi);
342 gsl_matrix_transpose_memcpy(s.
Ki_T, s.
Ki);
343 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, 1.0 , s.
Ki, s.
Pyyi, 0, s.
temp_n_no);
344 gsl_blas_dgemm(CblasNoTrans, CblasNoTrans, -1.0 , s.
temp_n_no, s.
Ki_T, 1.0, s.
Pxxi);
373 template <
typename FunctProcess,
typename FunctObservation>
384 gsl_linalg_cholesky_decomp(s.
cholPxxi);
386 for(j = 0 ; j < p.
n ; j++)
387 for(k = j+1 ; k < p.
n ; k++)
396 for(j = 1 ; j < p.
n+1 ; ++j)
397 for(i = 0 ; i < p.
n ; ++i)
409 gsl_vector_set_zero(s.
xi_mean);
416 for(i = 0 ; i < p.
n ; ++i)
423 gsl_matrix_set_zero(s.
Pxxi);
426 for(i = 0 ; i < p.
n ; ++i)
440 for(j = 0 ; j < p.
n ; ++j)
442 for(i = 0 ; i < p.
n ; ++i)
451 gsl_vector_set_zero(yi);
458 for(i = 0 ; i < p.
no ; ++i)
466 #endif // UKF_NDIM_STATE_H
gsl_vector * wm_aug_j
Definition: ukf_types.h:618
gsl_matrix * Ki_T
Definition: ukf_types.h:622
void init(ukf_param &p, ukf_state &s)
Definition: ukf_types.h:645
gsl_matrix * temp_n_no
Definition: ukf_types.h:629
double lambda_aug
Definition: ukf_types.h:534
gsl_matrix * sigmaPointsMeasure
Definition: ukf_types.h:613
Structure holding the matrices manipulated by the statistical linearization in the vectorial case for...
Definition: ukf_types.h:589
gsl_vector * wc_j
Definition: ukf_types.h:616
gsl_matrix * temp_n_n
Definition: ukf_types.h:625
int nbSamples
Number of sigma-points
Definition: ukf_types.h:550
gsl_matrix * yi_prediction
Definition: ukf_types.h:601
gsl_matrix * Pyyi
Definition: ukf_types.h:604
double lambda
Definition: ukf_types.h:533
int nbSamplesMeasure
Number of sigma-points
Definition: ukf_types.h:555
gsl_vector * ino_yi
Definition: ukf_types.h:603
gsl_matrix * Pxyi
Definition: ukf_types.h:607
double kpa
, is a good choice. According to van der Merwe, its value is not critical
Definition: ukf_types.h:518
gsl_matrix * Pxxi
Definition: ukf_types.h:596
double gamma
Definition: ukf_types.h:539
gsl_vector * xi_mean
Definition: ukf_types.h:595
void ukf_evaluate(ukf_param &p, ukf_state &s, FunctProcess f, FunctObservation h, gsl_vector *yi)
Evaluation of the output from the sigma points.
Definition: ukf_state_ndim.h:374
void ukf_free(ukf_param &p, ukf_state &s)
Free of memory allocation.
Definition: ukf_state_ndim.h:149
Structure holding the parameters of the statistical linearization.
Definition: ukf_types.h:513
gsl_matrix * sigmaPoints
Definition: ukf_types.h:610
gsl_vector * sigmaPointMeasure
Definition: ukf_types.h:612
gsl_matrix * cholPvvi
Definition: ukf_types.h:599
gsl_matrix * Pvvi
Definition: ukf_types.h:598
gsl_matrix * cholPxxi
Definition: ukf_types.h:597
virtual void updateEvolutionNoise(ukf_param &p, ukf_state &s)=0
gsl_vector * params
Definition: ukf_types.h:591
EvolutionNoise * evolution_noise
Type of process noise.
Definition: ukf_types.h:570
gsl_vector * xi
Definition: ukf_types.h:593
gsl_vector * yi_mean
Definition: ukf_types.h:602
double alpha
: "Size" of sigma-point distribution. Should be small if the function is strongly non-linear ...
Definition: ukf_types.h:523
int no
Dimension of the output : the measurements.
Definition: ukf_types.h:560
gsl_matrix * xi_prediction
Definition: ukf_types.h:594
gsl_matrix * temp_no_1
Definition: ukf_types.h:632
double prior_x
Prior estimate of the covariance matrix of the state.
Definition: ukf_types.h:565
gsl_matrix * temp_no_no
Definition: ukf_types.h:631
gsl_vector * wm_j
Definition: ukf_types.h:615
gsl_matrix * temp_1_n
Definition: ukf_types.h:627
void ukf_iterate(ukf_param &p, ukf_state &s, FunctProcess f, FunctObservation h, gsl_vector *yi)
UKF-additive (zero-mean) noise case, "Kalman Filtering and Neural Networks", p.233.
Definition: ukf_state_ndim.h:198
gsl_matrix * temp_1_no
Definition: ukf_types.h:633
int n
Size of the state vector.
Definition: ukf_types.h:545
gsl_matrix * temp_n_1
Definition: ukf_types.h:626
gsl_vector * wc_aug_j
Definition: ukf_types.h:619
double gamma_aug
Definition: ukf_types.h:540
double beta
Non negative weights used to introduce knowledge about the higher order moments of the distribution...
Definition: ukf_types.h:528
gsl_matrix * Pnni
Definition: ukf_types.h:605
double measurement_noise
Parameter used for the evolution noise.
Definition: ukf_types.h:580
gsl_vector * temp_n
Definition: ukf_types.h:624
gsl_matrix * Ki
Definition: ukf_types.h:621
void ukf_init(ukf_param &p, ukf_state &s)
Allocation of the vectors/matrices and initialization.
Definition: ukf_state_ndim.h:42
gsl_vector * sigmaPoint
Definition: ukf_types.h:609