mirror of
https://github.com/apache/commons-math.git
synced 2025-02-12 13:06:06 +00:00
[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:
parent
1146cf6a60
commit
c2801940ef
@ -51,6 +51,10 @@ If the output is not quite correct, check for invisible trailing spaces!
|
|||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="x.y" date="TBD" description="TBD">
|
<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">
|
<action dev="tn" type="fix" issue="MATH-1037" due-to="Aleksei Dievskii">
|
||||||
Fix a typo in the "GeometricDistributionTest" and ensure that a meaningful
|
Fix a typo in the "GeometricDistributionTest" and ensure that a meaningful
|
||||||
tolerance value is used when comparing test results with expected values.
|
tolerance value is used when comparing test results with expected values.
|
||||||
|
@ -182,14 +182,15 @@ public class KalmanFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// row dimension of B must be equal to A
|
// 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 &&
|
if (controlMatrix != null &&
|
||||||
controlMatrix.getRowDimension() > 0 &&
|
controlMatrix.getRowDimension() > 0 &&
|
||||||
controlMatrix.getColumnDimension() > 0 &&
|
controlMatrix.getColumnDimension() > 0 &&
|
||||||
(controlMatrix.getRowDimension() != transitionMatrix.getRowDimension() ||
|
controlMatrix.getRowDimension() != transitionMatrix.getRowDimension()) {
|
||||||
controlMatrix.getColumnDimension() != 1)) {
|
|
||||||
throw new MatrixDimensionMismatchException(controlMatrix.getRowDimension(),
|
throw new MatrixDimensionMismatchException(controlMatrix.getRowDimension(),
|
||||||
controlMatrix.getColumnDimension(),
|
controlMatrix.getColumnDimension(),
|
||||||
transitionMatrix.getRowDimension(), 1);
|
transitionMatrix.getRowDimension(),
|
||||||
|
controlMatrix.getColumnDimension());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Q must be equal to A
|
// 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
|
// row dimension of R must be equal to row dimension of H
|
||||||
if (measNoise.getRowDimension() != measurementMatrix.getRowDimension() ||
|
if (measNoise.getRowDimension() != measurementMatrix.getRowDimension()) {
|
||||||
measNoise.getColumnDimension() != 1) {
|
|
||||||
throw new MatrixDimensionMismatchException(measNoise.getRowDimension(),
|
throw new MatrixDimensionMismatchException(measNoise.getRowDimension(),
|
||||||
measNoise.getColumnDimension(),
|
measNoise.getColumnDimension(),
|
||||||
measurementMatrix.getRowDimension(), 1);
|
measurementMatrix.getRowDimension(),
|
||||||
|
measNoise.getColumnDimension());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,7 +357,7 @@ public class KalmanFilter {
|
|||||||
measurementMatrix.getRowDimension());
|
measurementMatrix.getRowDimension());
|
||||||
}
|
}
|
||||||
|
|
||||||
// S = H * P(k) - * H' + R
|
// S = H * P(k) * H' + R
|
||||||
RealMatrix s = measurementMatrix.multiply(errorCovariance)
|
RealMatrix s = measurementMatrix.multiply(errorCovariance)
|
||||||
.multiply(measurementMatrixT)
|
.multiply(measurementMatrixT)
|
||||||
.add(measurementModel.getMeasurementNoise());
|
.add(measurementModel.getMeasurementNoise());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user