Skip to content

Kalman filter mex: routine and tests

Normann Rion requested to merge normann/dynare:kalman_mex into master

Speed gains measured on test_kalman_mex.m using a setup embedding an 11th Gen Intel® Core™ i7-11850H @ 2.50GHz × 16 with 32 GB memory:

Test 1: No measurement error
Zflag = 0: Fortran Kalman filter is  2.28 times faster than its Matlab counterpart.
Zflag = 1: Fortran Kalman filter is  1.58 times faster than its Matlab counterpart.
Test 2: measurement error with diagonal variance-covariance matrix
Zflag = 0: Fortran Kalman filter is  1.78 times faster than its Matlab counterpart.
Zflag = 1: Fortran Kalman filter is  1.60 times faster than its Matlab counterpart.
Test 3: measurement error with general variance-covariance matrix
Zflag = 0: Fortran Kalman filter is  2.94 times faster than its Matlab counterpart.
Zflag = 1: Fortran Kalman filter is  2.17 times faster than its Matlab counterpart.

Note that these execution speed wedges are wider when the convergence of the gain matrix demands more iterations to reach. Indeed, when the gain matrix no longer significantly evolves, both the MATLAB and MEX routines call the kalman_filter_ss routine. Thus, the Fortran implementation provides significant time gains compared to the MATLAB implementation as long as the gain matrix is not stable.

Merge request reports