22 T
determinant(
const Eigen::Matrix<T, rows, cols, option, maxRow, maxCol> &mat)
24 assert(mat.rows() == mat.cols());
28 else if (mat.rows() == 2)
29 return mat(0, 0) * mat(1, 1) - mat(0, 1) * mat(1, 0);
30 else if (mat.rows() == 3)
31 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));
38 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3>
inverse(
const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, 0, 3, 3> &mat)
40 assert(mat.rows() == mat.cols());
44 Eigen::Matrix<T, 1, 1> inv;
45 inv(0, 0) = T(1.) / mat(0);
49 else if (mat.rows() == 2)
51 Eigen::Matrix<T, 2, 2> inv;
53 inv(0, 0) = mat(1, 1) / det;
54 inv(0, 1) = -mat(0, 1) / det;
55 inv(1, 0) = -mat(1, 0) / det;
56 inv(1, 1) = mat(0, 0) / det;
60 else if (mat.rows() == 3)
62 Eigen::Matrix<T, 3, 3> inv;
64 inv(0, 0) = (-mat(1, 2) * mat(2, 1) + mat(1, 1) * mat(2, 2)) / det;
65 inv(0, 1) = (mat(0, 2) * mat(2, 1) - mat(0, 1) * mat(2, 2)) / det;
66 inv(0, 2) = (-mat(0, 2) * mat(1, 1) + mat(0, 1) * mat(1, 2)) / det;
67 inv(1, 0) = (mat(1, 2) * mat(2, 0) - mat(1, 0) * mat(2, 2)) / det;
68 inv(1, 1) = (-mat(0, 2) * mat(2, 0) + mat(0, 0) * mat(2, 2)) / det;
69 inv(1, 2) = (mat(0, 2) * mat(1, 0) - mat(0, 0) * mat(1, 2)) / det;
70 inv(2, 0) = (-mat(1, 1) * mat(2, 0) + mat(1, 0) * mat(2, 1)) / det;
71 inv(2, 1) = (mat(0, 1) * mat(2, 0) - mat(0, 0) * mat(2, 1)) / det;
72 inv(2, 2) = (-mat(0, 1) * mat(1, 0) + mat(0, 0) * mat(1, 1)) / det;
78 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)