10 #include <eigen3/Eigen/Core>
17 template<
typename Coeff>
23 std::vector<Coeff> res(p + 1);
25 for(std::size_t i = 1; i <= p; i++) {
27 for (std::size_t j = 1; j <= i; j++) {
36 template<
typename Coeff>
37 using CoeffMatrix = Eigen::Matrix<Coeff, Eigen::Dynamic, Eigen::Dynamic>;
39 template<
typename Coeff>
41 for (Eigen::Index i = 0; i < m.rows(); i++) {
42 for (Eigen::Index j = 0; j < m.cols(); j++) {
43 std::cout << m(i, j) <<
"\t";
45 std::cout << std::endl;
50 template<
typename Coeff>
53 Eigen::Index n = m.cols();
54 CARL_LOG_ASSERT(
"carl.thom.tarski", n == m.rows(),
"can only compute characteristic polynomial of square matrix");
55 CARL_LOG_INFO(
"carl.thom.tarski",
"input has size " << n <<
"x" << n);
59 if (r*r == std::size_t(n)) r++;
63 std::vector<CoeffMatrix<Coeff>> B;
64 std::vector<Coeff>
N((r * r),
Coeff(0));
66 N[0] =
static_cast<Coeff>(n);
67 for(std::size_t i = 0; i < r - 1; i++) {
68 B.push_back(m * B.back());
69 N[i+1] = B.back().trace();
73 std::vector<CoeffMatrix<Coeff>> C;
74 C.push_back(m * B.back());
75 N[r] = C.back().trace();
76 for(std::size_t j = 1; j < r - 1; j++) {
77 C.push_back(C.front() * C.back());
78 N[(j + 1) * r] = C.back().trace();
82 for(std::size_t i = 1; i < r; i++) {
83 for(std::size_t j = 1; j < r; j++) {
85 N[j*r + i] = tmp.trace();
88 N.resize(std::size_t(n) + 1);
90 CARL_LOG_INFO(
"carl.thom.tarski",
"done computing the char pol ... ");
#define CARL_LOG_FUNC(channel, args)
#define CARL_LOG_ASSERT(channel, condition, msg)
#define CARL_LOG_INFO(channel, msg)
carl is the main namespace for the library.
Interval< Number > ceil(const Interval< Number > &_in)
Method which returns the next larger integer of the passed number or the number itself,...
void printMatrix(const CoeffMatrix< Coeff > &m)
Eigen::Matrix< Coeff, Eigen::Dynamic, Eigen::Dynamic > CoeffMatrix
std::vector< Coeff > newtonSums(const std::vector< Coeff > &newtonSums)
Interval< Number > sqrt(const Interval< Number > &i)
typename UnderlyingNumberType< P >::type Coeff
std::vector< Coeff > charPol(const CoeffMatrix< Coeff > &m)