43 typename Matrix::Scalar {
45 using scalar_type =
typename Matrix::Scalar;
46 using vector_type = Eigen::VectorX<scalar_type>;
47 vector_type vec = vector_type::Random(rows);
50 vector_type mul_vec = matrix * matrix.transpose() * vec;
51 scalar_type eigen = vec.dot(mul_vec) / vec.squaredNorm();
53 for (
index_type i = 0; i < num_iterations; ++i) {
54 const scalar_type eigen_before = eigen;
55 vec = mul_vec.normalized();
56 mul_vec = matrix * matrix.transpose() * vec;
57 eigen = vec.dot(mul_vec) / vec.squaredNorm();
59 constexpr auto tol_update =
static_cast<scalar_type
>(1e-4);
60 if (abs(eigen - eigen_before) / abs(eigen) < tol_update) {