c++ - Assembling a function as needed and computing it fast -
there interpreted languages out there, such lisp, tcl, perl, etc., make easy define lambda/proc/sub within code during runtime , evaluate within same session.
there compiled languages out there, such c++, execute faster interpreted ones, yet defining function within compiled program during runtime , executing not easy, if @ possible.
the problem here following:
define function during runtime: example, based on initial input data derive analytic model of data.
execute above function fast in loop: example, apply derived analytic model analysing incoming data.
one solution saw not pretty:
a procedure representing analytic model derived in embedded tcl based on initial input data.
a lookup table created evaluating procedure in tcl on array of sample points that, optimistically speaking, cover applicability range.
the lookup table passed tcl interpreter binary (which developed in c++).
then incoming data analysed interpolating between "close enough" values in lookup table.
the above solution works, has quite few problems, both conceptual , computational. question: possible define function purely within c++ , make available execution within same runtime session?
conceptually speaking, possible create function string, compile in-memory, , somehow link binary that's being executed?
if want working right out of box have @ exprtk. if want write expression parser check out boost spirit.
an alternative create c++ code on fly, compile shared library (plugin) , load @ runtime. fastest solution.
Comments
Post a Comment