mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-06 19:10:36 +08:00
fix a bug in determinant of 4x4 matrices and a small type issue in Inverse
This commit is contained in:
parent
173e582e3c
commit
62bf0bbd59
@ -52,7 +52,7 @@ struct ei_visitor_unroller<Visitor, Derived, 1>
|
||||
template<typename Visitor, typename Derived>
|
||||
struct ei_visitor_unroller<Visitor, Derived, Dynamic>
|
||||
{
|
||||
static void run(const Derived &mat, Visitor& visitor) {}
|
||||
static void run(const Derived &, Visitor&) {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -57,10 +57,10 @@ const typename Derived::Scalar ei_bruteforce_det(const MatrixBase<Derived>& m)
|
||||
case 4:
|
||||
// trick by Martin Costabel to compute 4x4 det with only 30 muls
|
||||
return ei_bruteforce_det4_helper(m,0,1,2,3)
|
||||
+ ei_bruteforce_det4_helper(m,0,2,1,3)
|
||||
- ei_bruteforce_det4_helper(m,0,2,1,3)
|
||||
+ ei_bruteforce_det4_helper(m,0,3,1,2)
|
||||
+ ei_bruteforce_det4_helper(m,1,2,0,3)
|
||||
+ ei_bruteforce_det4_helper(m,1,3,0,2)
|
||||
- ei_bruteforce_det4_helper(m,1,3,0,2)
|
||||
+ ei_bruteforce_det4_helper(m,2,3,0,1);
|
||||
default:
|
||||
assert(false);
|
||||
@ -75,4 +75,4 @@ typename ei_traits<Derived>::Scalar MatrixBase<Derived>::determinant() const
|
||||
else assert(false); // unimplemented for now
|
||||
}
|
||||
|
||||
#endif // EIGEN_DETERMINANT_H
|
||||
#endif // EIGEN_DETERMINANT_H
|
||||
|
@ -98,7 +98,7 @@ template<typename MatrixType, bool CheckExistence> class Inverse : ei_no_assignm
|
||||
|
||||
protected:
|
||||
bool m_exists;
|
||||
MatrixType m_inverse;
|
||||
typename MatrixType::Eval m_inverse;
|
||||
};
|
||||
|
||||
template<typename MatrixType, bool CheckExistence>
|
||||
@ -119,7 +119,7 @@ void Inverse<MatrixType, CheckExistence>
|
||||
|
||||
m_inverse.row(k).swap(m_inverse.row(k+rowOfBiggest));
|
||||
matrix.row(k).swap(matrix.row(k+rowOfBiggest));
|
||||
|
||||
|
||||
const Scalar d = matrix(k,k);
|
||||
m_inverse.block(k+1, 0, size-k-1, size)
|
||||
-= matrix.col(k).end(size-k-1) * (m_inverse.row(k) / d);
|
||||
@ -215,7 +215,7 @@ void Inverse<MatrixType, CheckExistence>::_compute_in_size4_case(const MatrixTyp
|
||||
const XprBlock22 S = matrix.template block<2,2>(2,2);
|
||||
const Block22 X = S - R_times_P_inverse_times_Q;
|
||||
Block22 Y;
|
||||
if(ei_compute_size2_inverse<Block22, CheckExistence>(X, &Y))
|
||||
if(ei_compute_size2_inverse<Block22, CheckExistence>(X, &Y))
|
||||
{
|
||||
m_inverse.template block<2,2>(2,2) = Y;
|
||||
m_inverse.template block<2,2>(2,0) = - Y * R_times_P_inverse;
|
||||
|
Loading…
x
Reference in New Issue
Block a user