When this week started, most of the work up to week 7 were done. In the first couple of days this week, code for parsing was merged, and I started looking into wrapping lambdification of SymEngine Basic expressions.
This was a seemingly easy task, with two options ahead of me. One was to directly wrap C++’s lambdify_double method, while the other was to create Ruby lambdas directly.
After considering various aspects, and with feedback from other contributors, I decided to go ahead with writing them directly in Ruby.
It is now completed, and undergoing review.
The code implemented allows lamdifying SymEngine::Basic expressions with free symbols.
i.e. let, f = x + y, where x and y are SymEngine::Symbols,
a lambda is expected, such that it can be called, f_lambda.call(3, 4) which would return 7.
For expressions with single or multiple symbols, it works as following:
f = x + y f_lambda = SymEngine::lambdify(f, [x, y])
For expressions with a single symbol, it can be used through the to_proc method, using a & call.
f_diam = 2 * SymEngine::PI * r radii = [2, 3, 4] diams = radii.map(&f_diam)
With another day left already, I am looking at Exception Handling, which I expect to be complicated in implementing.
See you next week!