carl  24.04
Computer ARithmetic Library
MultivariateTarskiQuery.h
Go to the documentation of this file.
1 /*
2  * File: MultivariateTarskiQuery.h
3  * Author: tobias
4  *
5  * Created on 11. Juni 2016, 11:45
6  */
7 
8 #pragma once
9 
10 #include <carl-arith/core/Sign.h>
11 #include "CharPol.h"
12 #include "MultiplicationTable.h"
13 
14 namespace carl {
15 
16 
17 template<typename Number>
19  CARL_LOG_FUNC("carl.thom.tarski", "Q = " << Q);
21  std::vector<typename MultiplicationTable<Number>::Monomial> base = table.getBase();
22  // compute the traces...
23  CoeffMatrix<Number> m(base.size(), base.size());
24  CARL_LOG_INFO("carl.thom.tarski", "base size is " << base.size());
25  CARL_LOG_INFO("carl.thom.tarski", "setting up the matrix now ...");
26  for(const auto& entry : table) {
27  BaseRepresentation<Number> Qc = table.multiply(q, entry.second.br);
28  Number t = table.trace(Qc);
29  for (const auto& pair : entry.second.pairs) {
30  m(long(pair.first), long(pair.second)) = t;
31  }
32  }
33 
34  /*
35  for(uint i = 0; i < base.size(); i++) {
36  for(uint j = i; j < base.size(); j++) {
37  BaseRepresentation<Number> prod = table.getEntry(base[i] * base[j]).br;
38  BaseRepresentation<Number> Qc = table.multiply(q, prod);
39  //BaseRepresentation<Number> Qc = table.reduce(base[i] * base[j] * Q);
40  Number t = table.trace(Qc);
41  m(i, j) = t;
42  m(j, i) = t;
43  }
44  }
45  */
46  /*
47  for(uint i = 0; i < base.size(); i++) {
48  for(uint j = i; j < base.size(); j++) {
49  std::cout << m(i, j) << "\t\t";
50  }
51  std::cout << std::endl;
52  }
53  std::cout << std::endl;
54  */
55 
56  CARL_LOG_INFO("carl.thom.tarski", "... done setting up matrix.");
57  std::vector<Number> cp = charPol(m);
58  CARL_LOG_TRACE("carl.thom.tarski", "char pol: " << cp);
59  int v1 = int(sign_variations(cp.begin(), cp.end(), sgn<Number>));
60  for(uint i = 1; i < cp.size(); i += 2) {
61  cp[i] *= -Number(1);
62  }
63  CARL_LOG_TRACE("carl.thom.tarski", "char pol': " << cp);
64  int v2 = int(sign_variations(cp.begin(), cp.end(), sgn<Number>));
65 
66  CARL_LOG_TRACE("carl.thom.tarski", "result = " << v1 - v2);
67  return v1 - v2;
68 }
69 
70 } // namespace carl
#define CARL_LOG_FUNC(channel, args)
Definition: carl-logging.h:46
#define CARL_LOG_TRACE(channel, msg)
Definition: carl-logging.h:44
#define CARL_LOG_INFO(channel, msg)
Definition: carl-logging.h:42
carl is the main namespace for the library.
std::uint64_t uint
Definition: numbers.h:16
Eigen::Matrix< Coeff, Eigen::Dynamic, Eigen::Dynamic > CoeffMatrix
Definition: CharPol.h:37
std::size_t sign_variations(InputIterator begin, InputIterator end)
Counts the number of sign variations in the given object range.
Definition: Sign.h:69
int multivariateTarskiQuery(const MultivariatePolynomial< Number > &Q, const MultiplicationTable< Number > &table)
std::vector< Coeff > charPol(const CoeffMatrix< Coeff > &m)
Definition: CharPol.h:51
BaseRepresentation< Number > multiply(const BaseRepresentation< Number > &f, const BaseRepresentation< Number > &g) const
BaseRepresentation< Number > reduce(const MultivariatePolynomial< Number > &p) const
Number trace(const BaseRepresentation< Number > &f) const
const std::vector< Monomial > & getBase() const noexcept