Fix computeInverseAndDetWithCheck for dynamic result matrices

libeigen/eigen!2312

Closes #2917
This commit is contained in:
Pavel Guzenfeld
2026-03-21 15:38:27 +00:00
committed by Rasmus Munk Larsen
parent cc8c7cf0e6
commit 1d21d62fbc
2 changed files with 28 additions and 3 deletions

View File

@@ -308,8 +308,9 @@ inline void MatrixBase<Derived>::computeInverseAndDetWithCheck(ResultType& inver
typename ResultType::Scalar& determinant,
bool& invertible,
const RealScalar& absDeterminantThreshold) const {
// i'd love to put some static assertions there, but SFINAE means that they have no effect...
EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived, ResultType)
eigen_assert(rows() == cols());
inverse.resize(rows(), cols());
// for 2x2, it's worth giving a chance to avoid evaluating.
// for larger sizes, evaluating has negligible cost and limits code size.
typedef std::conditional_t<RowsAtCompileTime == 2,
@@ -343,8 +344,6 @@ template <typename ResultType>
inline void MatrixBase<Derived>::computeInverseWithCheck(ResultType& inverse, bool& invertible,
const RealScalar& absDeterminantThreshold) const {
Scalar determinant;
// i'd love to put some static assertions there, but SFINAE means that they have no effect...
eigen_assert(rows() == cols());
computeInverseAndDetWithCheck(inverse, determinant, invertible, absDeterminantThreshold);
}