21 template<
typename Number>
 
   29         for(
const auto& term : p) {
 
   30             for(
uint i = 0; i < base.size(); i++) {
 
   31                 if(term.monomial() == base[i].monomial()) {
 
   32                     this->insert(std::make_pair(i, term.coeff()));
 
   38     bool is_zero()
 const { 
return this->empty(); }
 
   39     bool contains(
uint i)
 const { 
return this->find(i) != this->end(); }
 
   41         auto it = this->find(index);
 
   42         if(it == this->end()) 
return Number(0);
 
   43         else return it->second;
 
   56 template<
typename Number>
 
   61     using IndexPairs = std::forward_list<std::pair<uint, uint>>;
 
   71     std::unordered_map<Monomial, TableContent> 
mTable;
 
   86         CARL_LOG_TRACE(
"carl.thom.tarski.table", 
"done setting up multiplication table:\n" << *
this);
 
   89     typename std::unordered_map<Monomial, TableContent>::const_iterator 
begin()
 const { 
return mTable.cbegin(); }
 
   90     typename std::unordered_map<Monomial, TableContent>::const_iterator 
end()
 const { 
return mTable.cend(); }
 
   91     typename std::unordered_map<Monomial, TableContent>::const_iterator 
cbegin()
 const { 
return mTable.cbegin(); }
 
   92     typename std::unordered_map<Monomial, TableContent>::const_iterator 
cend()
 const { 
return mTable.cend(); }
 
   99     const std::vector<Monomial>& 
getBase() const noexcept {
 
  108         auto it = 
mTable.find(mon);
 
  109         assert(it != 
mTable.end());
 
  115         for(
const auto& entry : baseRepr) {
 
  116             res += entry.second * this->mBase[entry.first];
 
  123         for(
const auto& entry : this->mTable) {
 
  124             if(entry.second.br.is_zero()) 
continue;
 
  125             for(
const auto& index_coeff : entry.second.br) {
 
  127                 for(
const auto& pair : entry.second.pairs) {
 
  128                     newCoeff += f.
get(pair.first) * g.
get(pair.second);
 
  131                     res[index_coeff.first] += newCoeff * index_coeff.second;
 
  141         for(
const auto& index_coeff : f) {
 
  145                 res += index_coeff.second * prod_br.
get(i);
 
  162                     res.push_front(std::make_pair(i, j));
 
  163                     if(i != j) res.push_front(std::make_pair(j, i));
 
  174         std::vector<Monomial> Cor = gb.
cor();
 
  175         std::vector<Monomial> Bor = gb.
bor();
 
  176         std::vector<Monomial> Mon = gb.
mon();
 
  180         std::sort(Mon.begin(), Mon.end());
 
  184         std::sort(Bor.begin(), Bor.end());
 
  188         for(
uint i = 0; i < Mon.size(); i++) {
 
  190             baseRepr[i] = Number(1); 
 
  196         for(
const auto& m : Bor) {
 
  197             if(std::find(Cor.begin(), Cor.end(), m) != Cor.end()) {
 
  198                 CARL_LOG_TRACE(
"carl.thom.tarski.table", 
"in bor and also in cor: " << m);
 
  202                 for(
const auto& p : gb.
get()) {
 
  216                 mTable[m] = {baseRepr, pairs};
 
  221                 CARL_LOG_TRACE(
"carl.thom.tarski.table", 
"not in cor but in bor: " << m);
 
  222                 auto it = vars.begin();
 
  225                 while(!
try_divide(m, var, x_beta) || (std::find(Bor.begin(), Bor.end(), x_beta) == Bor.end())) {                    
 
  230                 CARL_LOG_ASSERT(
"carl.thom.tarski.table", std::find(Bor.begin(), Bor.end(), x_beta) != Bor.end(), 
"");
 
  240                 CARL_LOG_TRACE(
"carl.thom.tarski.table", 
"nf_x_beta" << nf_x_beta);
 
  241                 for(
const auto& entry_beta : nf_x_beta) {
 
  242                     Monomial x_gamma_prime = var * Mon[entry_beta.first];
 
  246                     CARL_LOG_TRACE(
"carl.thom.tarski.table", 
"nf_x_gamma_prime" << nf_x_gamma_prime);
 
  247                     for(
const auto& entry_gamma : nf_x_gamma_prime) {
 
  249                         prod = prod * nf_x_gamma_prime[entry_gamma.first];
 
  250                         prod = prod * Mon[entry_gamma.first];
 
  259                 mTable[m] = {baseRepr, pairs};
 
  269         std::list<Monomial> tabmon;
 
  270         for(
const auto& m1 : Mon) {
 
  271             for(
const auto& m2 : Mon) {
 
  273                 if(std::find(tabmon.begin(), tabmon.end(), prod) == tabmon.end()) {
 
  274                     tabmon.push_back(prod);
 
  279         for(
const auto& m : tabmon) {
 
  282                 CARL_LOG_TRACE(
"carl.thom.tarski.table", 
"still to compute: normal form for " << m);
 
  292                 mTable[m] = {baseRepr, pairs};
 
  300     o << 
"Base = " << table.
mBase << std::endl;
 
  301     o << 
"Length = " << table.
mTable.size() << std::endl;
 
  302     for (
const auto& entry: table.
mTable) {
 
  303         o << entry.first << 
"\t" << entry.second.br << 
"\t" << entry.second.pairs << std::endl;
 
#define CARL_LOG_FUNC(channel, args)
#define CARL_LOG_TRACE(channel, msg)
#define CARL_LOG_ASSERT(channel, condition, msg)
carl is the main namespace for the library.
bool try_divide(const Term< Coeff > &t, const Coeff &c, Term< Coeff > &res)
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
bool is_zero(const Interval< Number > &i)
Check if this interval is a point-interval containing 0.
A Variable represents an algebraic variable that can be used throughout carl.
MultivariatePolynomial & strip_lterm()
Drops the leading term.
Represents a single term, that is a numeric coefficient and a monomial.
std::set< Variable > gatherVariables() const
bool hasFiniteMon() const
std::vector< Monomial > bor() const
std::vector< Monomial > cor() const
std::vector< Monomial > mon() const
const std::vector< Polynomial > & get() const
bool contains(uint i) const
Number get(uint index) const
BaseRepresentation()=default
BaseRepresentation(const std::vector< Monomial > &base, const MultivariatePolynomial< Number > &p)
std::forward_list< std::pair< uint, uint > > IndexPairs
std::unordered_map< Monomial, TableContent > mTable
MultiplicationTable(const GroebnerBase< Number > &gb)
std::unordered_map< Monomial, TableContent >::const_iterator cbegin() const
BaseRepresentation< Number > multiply(const BaseRepresentation< Number > &f, const BaseRepresentation< Number > &g) const
void init(const GroebnerBase< Number > &gb)
std::unordered_map< Monomial, TableContent >::const_iterator end() const
const TableContent & getEntry(const Monomial &mon) const
bool contains(const Monomial &m) const
std::unordered_map< Monomial, TableContent >::const_iterator cend() const
MultivariatePolynomial< Number > baseReprToPolynomial(const BaseRepresentation< Number > &baseRepr) const
std::vector< Monomial > mBase
GroebnerBase< Number > mGb
BaseRepresentation< Number > reduce(const MultivariatePolynomial< Number > &p) const
friend std::ostream & operator<<(std::ostream &o, const MultiplicationTable< C > &table)
Number trace(const BaseRepresentation< Number > &f) const
IndexPairs indexPairs(const Monomial &c) const
std::unordered_map< Monomial, TableContent >::const_iterator begin() const
const std::vector< Monomial > & getBase() const noexcept
BaseRepresentation< Number > br