Closed Cfather closed 2 years ago
Thanks for bringing this up. Right now the package does not support this, but it would be a very nice feature to add. Instead of parsing and converting the string representation in some hacky way, I would propose starting with the internally stored "recipe" (as i call it in this context). This is an array representation of all the operations which need to be performed for evaluating the polynomial. This is the function performing the evaluation of a recipe: https://github.com/jannikmi/multivar_horner/blob/da27c954414960884d68fcfecc9c6817aaec3fd7/multivar_horner/helpers_fcts_numba.py#L48 Perhaps you could rewrite this function into compiling a string of operations in C syntax and exporting that into a .c file. I would really appreciate a PR for this as this would surely increase the evaluation performance. Feel free to ask questions if you have any doubts.
@Cfather have you started working on this? I might look into this soon, when I find time. A PR (even if incomplete) could help me get going. Let me know
I'm sorry I finally switched to another route to evaluate my polynomials. So I haven't been working on that. But I'm very interested in this problem and believe it could be really useful in many areas. Please let me know if you need anything.
No worries. From your GitHub name I guess you are more than familiar with C
so I'll let you review the code (and .c files i generate) :blush:
here is my current progress on this: https://github.com/jannikmi/multivar_horner/pull/24
evaluation already works with an automatically compiled C
file (if gcc compiler is installed)
and with poly.get_c_instructions()
you can fetch the content of the corresponding file
Thank you very much for your update!!! I will try my best to take a look when I have the time. Sorry, it's near the end of a crazy semester right now.
No worries. Just post here whenever you have time. The functionality is now fully implemented. Looking forward to any criticism or suggestions!
Hi, I wonder if there's any way to convert the string representation of a found horner factorisation to codes. To be more specific, I'm looking for some functions similar to 'ccode' in Matlab or 'export' in Mathematica. For example, 'x_1 (x_1 (x_1 (1.0 x_2) + 2.0 x_3) + 3.0 x_2 x_3) + 5.0' can give me
t1 = x_2 x_3; t2 = x_1 x_2 + 2.0 x_3; t3 = x_1 t2 + 3.0 t1; res = x_1 t3 + 5.0;
which I can compile it in C.