Walter, thank you for your reply.
First, I don't care if the data are binary or not - "external function" is
implemented by me. I can output whatever needed, be it text, binary,
What I do need is probably a bidirectional interprocess communication.
Gnuplot (splot) sends the argument list for each grid point and my program
sends back the function evaluated for these arguments.
<a> popen() is 1-way
<b> I don't know how to invoke popen from gnuplot
The function can not be effectively precomputed because the data range
is not specified beforehand. And actually contour plotting requires a
grid, and if I understand correctly (?) a grid can not be stored in the
data file, this requires explicit (resource-expensive) conversion.
For example, this works:
f(x,y)=real(system(sprintf("./func %f %f",y,x)))
where the external program func is below:
main(int argc, char **argv)
I only want to speed it up. Possible?
wh> I am not sure that i understand what you are trying to archive
wh> Writing the data to a file and reading that as matrix should be pretty fast.
wh> I assume you are aware that you can use binary data ? (http://gnuplot.sourceforge.net/demo_4.6/binary.html)
wh> if you can write a gnuplot script you can uses popen() that should be
wh> much better that system().
wh> Am 30.07.2012 22:42, schrieb Lev A. Melnikovsky:
wh> > Hi,
wh> > the function I need to plot is a result of nontrivial computation (each data
wh> > point is obtained by solving an ODE). I have implemented it in C, but executing
wh> > the program with
wh> > real(system(sprintf("somecommand %f %f", x, y)))
wh> > once for each data point (this is a 3d surface) implies a significant overhead.
wh> > My program is statically linked, still this is too slow. I need grid data (to
wh> > create contours), so building the datafile is inefficient.
wh> > Ideally I'd like to see an option to open a pipe and write the arguments to it
wh> > and read the results from it. My program would be glad to work in this mode. Is
wh> > this possible?
wh> > I'm using Linux if this matters.