function sr_kfStepMatrices2
extends Modelica.Icons.Function;
import Modelica;
import Modelica_LinearSystems2;
import Modelica_LinearSystems2.Math.Matrices.LAPACK;
import Modelica_LinearSystems2.Math.Matrices;
input Real A[:, size(A, 1)] "Transition matrix of the discrete system";
input Real C[:, size(A, 1)] "Output matrix of the discrete system";
input Real S[size(A, 1), size(A, 1)] "Cholesky factor of the state covariance matrix of the previous instant";
input Real Cq[size(A, 1), size(A, 1)] "Cholesky factor of input or process noise covariance matrix of the previous instant";
input Real Cr[size(C, 1), size(C, 1)] "Cholesky factor or measurement noise covariance matrix of the previous instant";
output Real K[size(A, 1), size(C, 1)] "Kalman filter gain matrix";
output Real S_new[size(A, 1), size(A, 1)] "Updated state covariance matrix";
output Real Cr_new[size(C, 1), size(C, 1)] "Modified Cholesky output or measurement noise covariance matrix";
output Real M[size(C, 1) + size(A, 1), size(C, 1) + size(A, 1) + size(Cq, 2)];
end sr_kfStepMatrices2;