These are chat archives for symengine/symengine
cosetc. What's the best way to keep it manageable?
sin(x)is called where x is a
RealDoubleor any Number with
x.get_evaluatoris called to get an evaluator whose
sinmethod will be called.
doubleis that it is essentially never exact. In fact, the compiler gives you a warning if you do things like
if (a == 0.0)where
RealDoubleand call std::sin on it
Here is a session in Sage:
sage: sin(1) sin(1) sage: sin(0) 0 sage: sin(0.0) 0.000000000000000 sage: sin(1.0) 0.841470984807897 sage: sin(1.03) 0.857298989188603
So Sage takes a double and just immediately evaluates the function using double precision. We can do the same.
sinC++ function, which decides what to do, would just call
std::sinif the argument is
sinC++ function would have an array of the callbacks, and it looks up the correct callback based on the argument.
RealDoublewould still be scattered all over symengine.
symengine_init()function that would initialize all these internal single dispatch callback tables.
realdouble_init()internally, and then inside this function you register the proper callbacks --- which would work, since all the translation units will be loaded already. But I don't like this too much, I don't think it's very nice to require the user to call these "initialize" functions.
table_eval_doublewhich is initialized using
init_eval_double(). The last function contains all the implementations of the callbacks.
tan_init(), ...., and inside each of these functions we need to register
RealDoublecallback and call
TypeIDand append a callback into the
std::vector, from user code. Things will just work.