Open anutosh491 opened 6 months ago
Thinking of would a general implementation of is_positive
look like
Can a if-else ladder, where we check the class of the basic variable and then use the respective is_positive
function work ?
number.h
has definitions of these types of tests (queries) that allows an optional Assumptions
object to be used. Various assumptions can be set on symbols in such an object to be passed to the test functions. The implementation of the actual machinery can be found in the test_visitors.cpp
. The main implementation strategy is to use the visitor pattern to traverse the expression tree to figure out if the test is either true, false or indeterminate. Indeterminate means that it is either impossible to know given the assumptions or that the algorithm is currently unable to know.
So for the cwrapper we need to be able to create Assumptions
objects and the rest is simply wrapping the functions.
This is inspired by sympy where usually every assumption maps to a query method
Some core ones which we encounter in all certainty would be 1) is_positive 2) is_negative 3) is_zero 4) is_finite 5) is_infinite
I see we have something like
number_is_positive
etc in the cwrapper https://github.com/symengine/symengine/blob/85d58bb34a6ec6c9396b027cb89d49baf9751d4f/symengine/cwrapper.h#L163-L169Can this be extended to a general form ?