20 Polydeg(
double v,
bool b) : value(v), is_const(b) {
22 bool isnan() {
return std::isnan(value); }
34 else if(fmt ==
"(%s+%s)") {
40 else if (v2.is_const)
return v1;
43 else if(fmt ==
"(%s-%s)") {
49 else if (v2.is_const)
return v1;
52 else if(fmt ==
"(%s*%s)") {
58 else if(v2.is_const)
return v1;
61 else if(fmt ==
"(%s/%s)") {
67 else if(v2.is_const)
return v1;
70 else if(fmt ==
"(%s^%s)" or fmt ==
"pow_abs(%s,%s)") {
76 else if(v2.is_const)
return Polydeg(std::abs(v1.
value)*v2.value,
false);
79 else if(fmt ==
"(-%s)") {
86 (fmt[0] ==
'%' and fmt[1]==
's' and fmt.size()<=4) or
87 (fmt[0] ==
'x' and fmt.size() == 2)) {
91 return Polydeg(constants.at(cidx++).get_value(),
true);
102 else if(fmt ==
"0.5") {
105 else if(fmt ==
"pi") {
108 else if(fmt ==
"tau") {
111 else if(fmt ==
"log(%s)") {
117 else if(fmt ==
"exp(%s)") {
123 else if(fmt ==
"expm(%s)") {
129 else if(fmt ==
"asin(%s)") {
135 else if(fmt ==
"sin(%s)") {
141 else if(fmt ==
"cos(%s)") {
147 else if(fmt ==
"sq(%s)") {
153 else if(fmt ==
"sqrt_abs(%s)") {
159 else if(fmt ==
"pow_abs(%s,2)") {
165 else if(fmt ==
"pow_abs(%s,3)") {
172 print(
"In format string: ", fmt);
173 assert(
false &&
"*** Unmatched format string by polynomial. Did you change the primitives and not update this?");
Polydeg(double v, bool b)
Definition: Polynomial.h:20
double get_polynomial_degree(const Node &n, const std::vector< Constant > &constants)
Definition: Polynomial.h:177
bool isnan()
Definition: Polynomial.h:22
double value
Definition: Polynomial.h:18
void print(FIRST f, ARGS... args)
Lock output_lock and print to std:cout.
Definition: IO.h:53
std::string format
Definition: Rule.h:28
this_t & child(const size_t i)
Definition: BaseNode.h:175
const Rule * rule
Definition: Node.h:32
Polydeg get_polynomial_degree_rec(const Node &n, const std::vector< Constant > &constants, size_t cidx)
Definition: Polynomial.h:26
constexpr double NaN
Definition: Numerics.h:21
Definition: Polynomial.h:16
bool is_const
Definition: Polynomial.h:19
size_t nchildren() const
Definition: BaseNode.h:208