NAG CL Interface
g13ecc (kalman_​sqrt_​filt_​info_​var)

Settings help

CL Name Style:


1 Purpose

g13ecc performs a combined measurement and time update of one iteration of the time-varying Kalman filter. The method employed for this update is the square root information filter with the system matrices in their original form.

2 Specification

#include <nag.h>
void  g13ecc (Integer n, Integer m, Integer p, Nag_ab_input inp_ab, double t[], Integer tdt, const double ainv[], Integer tda, const double b[], Integer tdb, const double rinv[], Integer tdr, const double c[], Integer tdc, const double qinv[], Integer tdq, double x[], const double rinvy[], const double z[], double tol, NagError *fail)
The function may be called by the names: g13ecc, nag_tsa_kalman_sqrt_filt_info_var or nag_kalman_sqrt_filt_info_var.

3 Description

For the state space system defined by
X i+1 = A i X i + B i W i var( W i ) = Q i Y i = C i X i + V i var( V i ) = R i  
the estimate of X i given observations Y 1 to Y i-1 is denoted by X ^ ii - 1 with var( X ^ ii - 1 ) = P ii - 1 = S i SiT . The function performs one recursion of the square root information filter algorithm, summarised as follows:
U 1 ( Q i - 1 / 2 0 Q i - 1 / 2 w ¯ i S i −1 A i −1 B i S i −1 A i −1 S i −1 X ^ ii 0 R i+1 - 1 / 2 C i+1 R i+1 - 1 / 2 Y i+1 ) = ( F i+1 - 1 / 2 * * 0 S i+1 −1 ξ i + 1i + 1 0 0 E i+1 ) (Pre-array) (Post-array)  
where U 1 is an orthogonal transformation triangularizing the pre-array. The triangularization is done entirely via Householder transformations exploiting the zero pattern of the pre-array. The term w ¯ i is the mean process noise and E i+1 is the estimated error at instant i+1 . The inverse of the state covariance matrix P ii is factored as follows
P ii −1 = ( S i −1 ) T S i −1  
where P ii = S i SiT ( S i is lower triangular).
The new state filtered state estimate is computed via
X ^ i + 1i + 1 = S i+1 ξ i + 1i + 1  
The function returns S i+1 −1 and X ^ i + 1i + 1 (see the G13 Chapter Introduction for more information concerning the information filter).

4 References

Anderson B D O and Moore J B (1979) Optimal Filtering Prentice–Hall
Vanbegin M, van Dooren P and Verhaegen M H G (1989) Algorithm 675: FORTRAN subroutines for computing the square root covariance filter and square root information filter in dense or Hessenberg forms ACM Trans. Math. Software 15 243–256
Verhaegen M H G and van Dooren P (1986) Numerical aspects of different Kalman filter implementations IEEE Trans. Auto. Contr. AC-31 907–917

5 Arguments

1: n Integer Input
On entry: the actual state dimension, n , i.e., the order of the matrices S i and A i −1 .
Constraint: n1 .
2: m Integer Input
On entry: the actual input dimension, m , i.e., the order of the matrix Q i - 1 / 2 .
Constraint: m1 .
3: p Integer Input
On entry: the actual output dimension, p , i.e., the order of the matrix R i+1 - 1 / 2 .
Constraint: p1 .
4: inp_ab Nag_ab_input Input
On entry: indicates how the matrix B i is to be passed to the function.
inp_ab=Nag_ab_prod
Array b must contain the product A i −1 B i .
inp_ab=Nag_ab_sep
Then array b must contain B i .
5: t[n×tdt] double Input/Output
Note: the (i,j)th element of the matrix T is stored in t[(i-1)×tdt+j-1].
On entry: the leading n × n upper triangular part of this array must contain S i −1 the square root of the inverse of the state covariance matrix P ii .
On exit: the leading n × n upper triangular part of this array contains S i+1 −1 , the square root of the inverse of the of the state covariance matrix P i + 1i + 1 .
6: tdt Integer Input
On entry: the stride separating matrix column elements in the array t.
Constraint: tdtn .
7: ainv[n×tda] const double Input
Note: the (i,j)th element of the matrix is stored in ainv[(i-1)×tda+j-1].
On entry: the leading n × n part of this array must contain A i −1 the inverse of the state transition matrix.
8: tda Integer Input
On entry: the stride separating matrix column elements in the array ainv.
Constraint: tdan .
9: b[n×tdb] const double Input
Note: the (i,j)th element of the matrix B is stored in b[(i-1)×tdb+j-1].
On entry: the leading n × m part of this array must contain B i (if inp_ab=Nag_ab_sep) or its product with A i −1 (if inp_ab=Nag_ab_prod).
10: tdb Integer Input
On entry: the stride separating matrix column elements in the array b.
Constraint: tdbm .
11: rinv[p×tdr] const double Input
Note: the (i,j)th element of the matrix is stored in rinv[(i-1)×tdr+j-1].
On entry: if the measurement noise covariance matrix is to be supplied separately from the output weight matrix, then the leading p × p upper triangular part of this array must contain R i+1 - 1 / 2 , the right Cholesky factor of the inverse of the measurement noise covariance matrix. If this information is not to be input separately from the output weight matrix (see below) then the array rinv must be set to NULL.
12: tdr Integer Input
On entry: the stride separating matrix column elements in the array rinv.
Constraint: tdrp if rinv is defined.
13: c[p×tdc] const double Input
Note: the (i,j)th element of the matrix C is stored in c[(i-1)×tdc+j-1].
On entry: if the array rinv has been set to NULL then the leading p × n part of this array must contain C i+1 , the output weight matrix (or its product with R i+1 - 1 / 2 ) of the discrete system at instant i+1 .
14: tdc Integer Input
On entry: the stride separating matrix column elements in the array c.
Constraint: tdcn .
15: qinv[m×tdq] const double Input
Note: the (i,j)th element of the matrix is stored in qinv[(i-1)×tdq+j-1].
On entry: the leading m × m upper triangular part of this array must contain Q i - 1 / 2 the right Cholesky factor of the inverse of the process noise covariance matrix.
16: tdq Integer Input
On entry: the stride separating matrix column elements in the array qinv.
Constraint: tdqm .
17: x[n] double Input/Output
On entry: this array must contain the estimated state X ^ ii
On exit: the estimated state X ^ i + 1i + 1 .
18: rinvy[p] const double Input
On entry: this array must contain R i+1 - 1 / 2 Y i+1 , the product of the upper triangular matrix R i+1 - 1 / 2 and the measured output Y i+1 .
19: z[m] const double Input
On entry: this array must contain w ¯ i , the mean value of the state process noise.
20: tol double Input
On entry: tol is used to test for near singularity of the matrix S i+1 −1 . If you set tol to be less than n 2 × ε then the tolerance is taken as n 2 × ε , where ε is the machine precision.
21: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, tda=value while n=value . These arguments must satisfy tdan .
On entry, tdb=value while m=value . These arguments must satisfy tdbm .
On entry, tdc=value while n=value . These arguments must satisfy tdcn .
On entry, tdq=value while m=value . These arguments must satisfy tdqm .
On entry, tdr=value while p=value . These arguments must satisfy tdrp .
On entry, tdt=value while n=value . These arguments must satisfy tdtn .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_BAD_PARAM
On entry, argument inp_ab had an illegal value.
NE_INT_ARG_LT
On entry, m=value.
Constraint: m1.
On entry, n=value.
Constraint: n1.
On entry, p=value.
Constraint: p1.
NE_MAT_SINGULAR
The matrix inverse(S) is singular.

7 Accuracy

The use of the square root algorithm improves the stability of the computations.

8 Parallelism and Performance

g13ecc makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

The algorithm requires approximately 7 6 n 3 + n 2 ( 7 2 m+p) + n ( 1 2 p 2 + m 2 ) operations and is backward stable (see Verhaegen and van Dooren (1986)).

10 Example

To apply three iterations of the Kalman filter (in square root information form) to the system ( A i −1 , A i −1 B i , C i+1 ) . The same data is used for all three iterative steps.

10.1 Program Text

Program Text (g13ecce.c)

10.2 Program Data

Program Data (g13ecce.d)

10.3 Program Results

Program Results (g13ecce.r)