passing global variables when embedding octave

Soeren Sonnenburg octave-ml at nn7.de
Mon Mar 2 02:01:09 CST 2009


Dear all,

I've written a script to call python functions from within octave that
passes variables to python and results back to octave (avoiding disk
io). To this end I embedded python within octave context. (*)

Now I would like to do the same for python, i.e. run a octave function
from within python and pass all the variables to octave. So I need to
embed the octave interpreter. The octave_embed example (from
octave_embed.tar.gz ) shows how to run a script but not how to implant
global variables/access variables in either direction.

Could someone give an insight on how I can push a global variable to
octave and also get the variable back?

would be enough to show how 
octave_value x = octave_scalar(42);

is made visible in octave context and incremented +1 and result
transferred back...

Thanks a lot!
Soeren

(*) This will be in the shogun toolbox (http://www.shogun-toolbox.org),
currently things like

A=[[1,2,3];[4,5,6]];
B=[[1,1,1];[0,0,0]];
pythoncode=sprintf('import numpy\nresults=(A+B, 2*B, [ "bla1", "bla2" ])\n');
[A2,B2,bla]=elwms('run_python', 'A',A, 'B',B, 'pythoncode', pythoncode)

work.


More information about the Help-octave mailing list