carl  24.04
Computer ARithmetic Library
Bitsize.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../MultivariatePolynomial.h"
4 
5 namespace carl {
6 
7 /**
8  * @return An approximation of the bitsize of this monomial.
9  */
10 inline std::size_t bitsize(const Monomial& m) {
11  return 0;
12 }
13 
14 /**
15  * @return An approximation of the bitsize of this term.
16  */
17 template<typename Coeff>
18 std::size_t bitsize(const Term<Coeff>& t) {
19  if (!t.monomial()) return bitsize(t.coeff());
20  return bitsize(*t.monomial()) + bitsize(t.coeff());
21 }
22 
23 /**
24  * @return An approximation of the bitsize of this polynomial.
25  */
26 template<typename Coeff, typename Ordering, typename Policies>
28  return std::accumulate(p.begin(), p.end(), static_cast<std::size_t>(0),
29  [](std::size_t cur, const auto& t){ return cur + bitsize(t); }
30  );
31 }
32 
33 }
carl is the main namespace for the library.
std::size_t bitsize(const cln::cl_I &n)
Get the bit size of the representation of a integer.
Definition: operations.h:96
The general-purpose multivariate polynomial class.
The general-purpose monomials.
Definition: Monomial.h:59
Coefficient & coeff()
Get the coefficient.
Definition: Term.h:80
Monomial::Arg & monomial()
Get the monomial.
Definition: Term.h:91