bool hasInf(const MatrixBase& expr) { for (int i = 0; i != expr.cols(); ++i) { for (int j = 0; j != expr.rows(); ++j) { if (std::isinf(expr.coeff(j, i))) return true; } } return false; }
bool hasNaN(const MatrixBase& expr) { for (int j = 0; j != expr.cols(); ++j) { for (int i = 0; i != expr.rows(); ++i) { if (std::isnan(expr.coeff(i, j))) return true; } } return false; }