34 template <
class Predicate>
40 if (T.rows() < 2)
return true;
42 std::vector<std::pair<int, int>> blocks;
43 blocks.reserve(T.rows());
44 std::vector<int> selected;
45 selected.reserve(T.rows());
47 int subspace_dim_internal = 0;
51 while (row < T.rows())
55 if (row + 1 >= T.rows())
62 if (predicate(T.block(row, row, p, p)))
64 selected.push_back((
int)blocks.size());
65 subspace_dim_internal += p;
68 blocks.emplace_back(row, p);
75 if (subspace_dim) *subspace_dim = 0;
80 for (
int l = 0; l < (
int)selected.size(); ++l)
82 int current_idx = selected[l];
83 for (
int i = current_idx; i >= top + 1; --i)
86 if (!
swap_schur_blocks(T, blocks[i - 1].first, blocks[i - 1].second, blocks[i].second, Q, standardize))
return false;
88 int p_prev = blocks[i - 1].second;
89 blocks[i - 1].second = blocks[i].second;
90 blocks[i].first = blocks[i - 1].first + blocks[i].second;
91 blocks[i].second = p_prev;
96 if (subspace_dim) *subspace_dim = subspace_dim_internal;
bool have_equal_size(const Eigen::MatrixBase< DerivedA > &matrix1, const Eigen::MatrixBase< DerivedB > &matrix2)
Determine if two matrices exhibit equal sizes/dimensions.
bool swap_schur_blocks(Eigen::Ref< Eigen::MatrixXd > T, int ra11, int p, int q, Eigen::Ref< Eigen::MatrixXd > Q, bool standardize)
bool is_square(const Eigen::MatrixBase< Derived > &matrix)
Determine if a given matrix is square.
bool reorder_schur_blocks(Eigen::Ref< Eigen::MatrixXd > T, Eigen::Ref< Eigen::MatrixXd > Q, Predicate predicate, int *subspace_dim, bool standardize)
A matrix or vector expression mapping an existing expression.
bool approx_zero(double val, double epsilon=1e-10)
Check if a double is appoximately zero.
EIGEN_DEVICE_FUNC RowXpr row(Index i)
This is the const version of row(). */.