[MATH-1033] Fix input parameter check in KalmanFilter. Thanks to Yuan Qu.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1531430 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Thomas Neidhart 2013-10-11 21:39:09 +00:00
parent 1146cf6a60
commit c2801940ef
2 changed files with 12 additions and 7 deletions

View File

@ -51,6 +51,10 @@ If the output is not quite correct, check for invisible trailing spaces!
</properties>
<body>
<release version="x.y" date="TBD" description="TBD">
<action dev="tn" type="fix" issue="MATH-1033" due-to="Yuan Qu">
The "KalmanFilter" wrongly enforced a column dimension of 1 for
the provided control and measurement noise matrix.
</action>
<action dev="tn" type="fix" issue="MATH-1037" due-to="Aleksei Dievskii">
Fix a typo in the "GeometricDistributionTest" and ensure that a meaningful
tolerance value is used when comparing test results with expected values.

View File

@ -182,14 +182,15 @@ public class KalmanFilter {
}
// row dimension of B must be equal to A
// if no control matrix is available, the row and column dimension will be 0
if (controlMatrix != null &&
controlMatrix.getRowDimension() > 0 &&
controlMatrix.getColumnDimension() > 0 &&
(controlMatrix.getRowDimension() != transitionMatrix.getRowDimension() ||
controlMatrix.getColumnDimension() != 1)) {
controlMatrix.getRowDimension() != transitionMatrix.getRowDimension()) {
throw new MatrixDimensionMismatchException(controlMatrix.getRowDimension(),
controlMatrix.getColumnDimension(),
transitionMatrix.getRowDimension(), 1);
transitionMatrix.getRowDimension(),
controlMatrix.getColumnDimension());
}
// Q must be equal to A
@ -204,11 +205,11 @@ public class KalmanFilter {
}
// row dimension of R must be equal to row dimension of H
if (measNoise.getRowDimension() != measurementMatrix.getRowDimension() ||
measNoise.getColumnDimension() != 1) {
if (measNoise.getRowDimension() != measurementMatrix.getRowDimension()) {
throw new MatrixDimensionMismatchException(measNoise.getRowDimension(),
measNoise.getColumnDimension(),
measurementMatrix.getRowDimension(), 1);
measurementMatrix.getRowDimension(),
measNoise.getColumnDimension());
}
}
@ -356,7 +357,7 @@ public class KalmanFilter {
measurementMatrix.getRowDimension());
}
// S = H * P(k) - * H' + R
// S = H * P(k) * H' + R
RealMatrix s = measurementMatrix.multiply(errorCovariance)
.multiply(measurementMatrixT)
.add(measurementModel.getMeasurementNoise());