evaluating math w/o recompile
anthony zador
zador-anthony at CS.YALE.EDU
Fri Sep 15 03:35:26 AEST 1989
I have functions of the form
double f(V,t)
double V,t;
{
return (some math function involving about a
line of exp, division, mult and add
on V, t)
}
I use these functions to construct a table:
Table(f, table_array)
ptr_to_fun f;
double_array table_array;
{
construct table_array by evaluating f[n]
}
I would like to be able to specify the form of the function f
at *run time* (no recompiles). That is, i would like
to place a line of math
in some file and have the program read it in and evaluate it.
For example, my fnct could be
1.6/(1+exp(-0.072*(V-5.0)))
or
0.02*(V+8.69)/(exp((V+8.69)/5.36)-1)
I have played around with "hoc", the high order calculator
described in the Unix Programming Environment by K&P, but that seems
like overkill for this task. Is there a simpler way?
I'd appreciate any ideas.
--Tony Zador
zador at yale-sun3-nebula.arpa
zador at nebula.sun3.cs.yale.edu
More information about the Comp.lang.c
mailing list