From ead58c5174e784f0a6d876f051269334f707eadd Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Wed, 25 Sep 2013 17:57:45 +0200 Subject: [PATCH] Improving notations --- src/daComposant/daAlgorithms/ExtendedKalmanFilter.py | 6 +++--- src/daComposant/daAlgorithms/KalmanFilter.py | 6 +++--- src/daComposant/daCore/BasicObjects.py | 11 +++++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py index 7c72996..4b4bc1d 100644 --- a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py @@ -164,9 +164,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if Cm is not None and Un is not None: # Attention : si Cm est aussi dans H, doublon ! d = d - Cm * Un # - K = Pn_predicted * Ha * (R + Ht * Pn_predicted * Ha).I - Xn = Xn_predicted + K * d - Pn = Pn_predicted - K * Ht * Pn_predicted + Kn = Pn_predicted * Ha * (R + Ht * Pn_predicted * Ha).I + Xn = Xn_predicted + Kn * d + Pn = Pn_predicted - Kn * Ht * Pn_predicted # self.StoredVariables["Analysis"].store( Xn.A1 ) if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]: diff --git a/src/daComposant/daAlgorithms/KalmanFilter.py b/src/daComposant/daAlgorithms/KalmanFilter.py index c3f7bfe..dc8fe79 100644 --- a/src/daComposant/daAlgorithms/KalmanFilter.py +++ b/src/daComposant/daAlgorithms/KalmanFilter.py @@ -139,9 +139,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if Cm is not None and Un is not None: # Attention : si Cm est aussi dans H, doublon ! d = d - Cm * Un # - K = Pn_predicted * Ha * (R + Ht * Pn_predicted * Ha).I - Xn = Xn_predicted + K * d - Pn = Pn_predicted - K * Ht * Pn_predicted + Kn = Pn_predicted * Ha * (R + Ht * Pn_predicted * Ha).I + Xn = Xn_predicted + Kn * d + Pn = Pn_predicted - Kn * Ht * Pn_predicted # self.StoredVariables["Analysis"].store( Xn.A1 ) if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]: diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 7a58d23..e774e4f 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -446,6 +446,17 @@ class Covariance: else: return self.__B * numpy.ones(int(msize)) + def asfullmatrix(self, msize=None): + if self.ismatrix(): + return self.__B + elif self.isvector(): + return numpy.matrix( numpy.diag(self.__B), float ) + elif self.isscalar(): + if msize is None: + raise ValueError("the size of the %s covariance matrix has to be given in case of definition as a scalar over the diagonal."%(self.__name,)) + else: + return numpy.matrix( self.__B * numpy.eye(int(msize)), float ) + def trace(self, msize=None): if self.ismatrix(): return numpy.trace(self.__B) -- 2.39.2