mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Remove redundant transposes on symmetric matrices (#8131)
This likely won't have a performance impact since it only affects matrix traversal order, but it does simplify the code.
This commit is contained in:
@@ -372,7 +372,11 @@ public class ExtendedKalmanFilter<States extends Num, Inputs extends Num, Output
|
||||
//
|
||||
// Kᵀ = Sᵀ.solve(CPᵀ)
|
||||
// K = (Sᵀ.solve(CPᵀ))ᵀ
|
||||
final Matrix<States, Rows> K = S.transpose().solve(C.times(m_P.transpose())).transpose();
|
||||
//
|
||||
// Drop the transposes on symmetric matrices S and P.
|
||||
//
|
||||
// K = (S.solve(CP))ᵀ
|
||||
final Matrix<States, Rows> K = S.solve(C.times(m_P)).transpose();
|
||||
|
||||
// x̂ₖ₊₁⁺ = x̂ₖ₊₁⁻ + K(y − h(x̂ₖ₊₁⁻, uₖ₊₁))
|
||||
m_xHat = addFuncX.apply(m_xHat, K.times(residualFuncY.apply(y, h.apply(m_xHat, u))));
|
||||
|
||||
@@ -230,7 +230,11 @@ public class KalmanFilter<States extends Num, Inputs extends Num, Outputs extend
|
||||
//
|
||||
// Kᵀ = Sᵀ.solve(CPᵀ)
|
||||
// K = (Sᵀ.solve(CPᵀ))ᵀ
|
||||
final Matrix<States, Outputs> K = S.transpose().solve(C.times(m_P.transpose())).transpose();
|
||||
//
|
||||
// Drop the transposes on symmetric matrices S and P.
|
||||
//
|
||||
// K = (S.solve(CP))ᵀ
|
||||
final Matrix<States, Outputs> K = S.solve(C.times(m_P)).transpose();
|
||||
|
||||
// x̂ₖ₊₁⁺ = x̂ₖ₊₁⁻ + K(y − (Cx̂ₖ₊₁⁻ + Duₖ₊₁))
|
||||
m_xHat = m_xHat.plus(K.times(y.minus(C.times(m_xHat).plus(D.times(u)))));
|
||||
|
||||
@@ -100,9 +100,11 @@ public class SteadyStateKalmanFilter<States extends Num, Inputs extends Num, Out
|
||||
//
|
||||
// Kᵀ = Sᵀ.solve(CPᵀ)
|
||||
// K = (Sᵀ.solve(CPᵀ))ᵀ
|
||||
m_K =
|
||||
new Matrix<>(
|
||||
S.transpose().getStorage().solve(C.times(P.transpose()).getStorage()).transpose());
|
||||
//
|
||||
// Drop the transposes on symmetric matrices S and P.
|
||||
//
|
||||
// K = (S.solve(CP))ᵀ
|
||||
m_K = new Matrix<>(S.getStorage().solve(C.times(P).getStorage()).transpose());
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user