[GiNaC-devel] A smarter relational to Boolean conversion

Richard B. Kreckel kreckel at in.terlu.de
Sat Jun 5 22:14:33 CEST 2021


Dear Vladimir,

On 04.06.21 10:31, Vladimir V. Kisil wrote:
> 	I am attaching a small patch. With it the following conversions
>   from relational to Boolean will become "true" from the current "false":
> 
>   realsymbol x("x");
>   possymbol p("p");
>   cout << bool(p>0) << endl;
>   cout << bool(abs(x)>=0) << endl;

Thank you for submitting this patch!

What is the reason to call .normal() in the symbolic case? Generally, we
never do automatic evaluation of expressions with complexity worse than
O(n log n). See section 4.2 of the tutorial.

The reason we don't do this is to not surprise the user with
skyrocketing run-times, especially when expressions get longer or
nested. It is a different story when the user calls a special
transformation explicitly.

Admittedly, this case here is not exactly automatic evaluation. But
still, it is a normal() hidden deep inside a seemingly innocent coercion
to Boolean. I think it would be more appropriate to let the user call
.normal() explicitly, it that is desired.

May I suggest to remove this one line?

All my best,
  -richy.
-- 

Richard B. Kreckel

<https://in.terlu.de/~kreckel/>



More information about the GiNaC-devel mailing list