These are chat archives for symengine/symengine

May 2015
Isuru Fernando
May 14 2015 05:20

@certik, I tried several methods,

1 - table as in eval_double_single_dispatch for one argument function
2 - Virtual function returning a lambda function that calls eval_double with Sin(arg) and wraps the double in a RealDouble

    virtual eval_function get_eval_function() const {
        return [](const Basic &x) {
            return rcp(new RealDouble(eval_double(x)));

3 - Virtual function returning an Evaluator object that has a method sin

    class EvaluateDouble : public Evaluate {
    public :
        RCP<const Basic> sin(const Basic &x) const {
            return rcp(new RealDouble(std::sin(static_cast<const RealDouble &>(x).i)));

2 is slow. 1 and 3 have the same minimum times, but 1 is faster on average.
I think 3 is the best way forward since it gives us an easier way to use it for functions that has 2 or more arguments

Isuru Fernando
May 14 2015 09:26
Made a mistake in getting the timings. 1 and 3 have the same times on average
Ondřej Čertík
May 14 2015 14:46
Thanks @isuruf. Yes, 3. looks good, so does 1.
I am keeping the door open for 1, as I think it might get substantially faster if we put TypeID as a member variable. But maybe not, so I need to try it.
I think it's fine if you use 3, that looks like a clean approach as well.
Isuru Fernando
May 14 2015 15:06
Yeah, If we have TypeID as a member variable, it's going to to faster.