16 T
determinant(
const Eigen::Matrix<T, rows, cols, option, maxRow, maxCol> &mat)
18 assert(mat.rows() == mat.cols());
22 else if (mat.rows() == 2)
23 return mat(0, 0) * mat(1, 1) - mat(0, 1) * mat(1, 0);
24 else if (mat.rows() == 3)
25 return mat(0, 0) * (mat(1, 1) * mat(2, 2) - mat(1, 2) * mat(2, 1)) - mat(0, 1) * (mat(1, 0) * mat(2, 2) - mat(1, 2) * mat(2, 0)) + mat(0, 2) * (mat(1, 0) * mat(2, 1) - mat(1, 1) * mat(2, 0));
32 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3>
inverse(
const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> &mat)
34 assert(mat.rows() == mat.cols());
38 Eigen::Matrix<T, 1, 1> inv;
39 inv(0, 0) = T(1.) / mat(0);
43 else if (mat.rows() == 2)
45 Eigen::Matrix<T, 2, 2> inv;
47 inv(0, 0) = mat(1, 1) / det;
48 inv(0, 1) = -mat(0, 1) / det;
49 inv(1, 0) = -mat(1, 0) / det;
50 inv(1, 1) = mat(0, 0) / det;
54 else if (mat.rows() == 3)
56 Eigen::Matrix<T, 3, 3> inv;
58 inv(0, 0) = (-mat(1, 2) * mat(2, 1) + mat(1, 1) * mat(2, 2)) / det;
59 inv(0, 1) = (mat(0, 2) * mat(2, 1) - mat(0, 1) * mat(2, 2)) / det;
60 inv(0, 2) = (-mat(0, 2) * mat(1, 1) + mat(0, 1) * mat(1, 2)) / det;
61 inv(1, 0) = (mat(1, 2) * mat(2, 0) - mat(1, 0) * mat(2, 2)) / det;
62 inv(1, 1) = (-mat(0, 2) * mat(2, 0) + mat(0, 0) * mat(2, 2)) / det;
63 inv(1, 2) = (mat(0, 2) * mat(1, 0) - mat(0, 0) * mat(1, 2)) / det;
64 inv(2, 0) = (-mat(1, 1) * mat(2, 0) + mat(1, 0) * mat(2, 1)) / det;
65 inv(2, 1) = (mat(0, 1) * mat(2, 0) - mat(0, 0) * mat(2, 1)) / det;
66 inv(2, 2) = (-mat(0, 1) * mat(1, 0) + mat(0, 0) * mat(1, 1)) / det;
72 Eigen::Matrix<T, 1, 1> inv;
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > inverse(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3 > &mat)