[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need help with structures and "eval" function

From: Gerrit Visser
Subject: Need help with structures and "eval" function
Date: Mon, 20 Mar 2000 08:08:58 +0200

Hi All,

I hope I'm sending this to the correct octave help mailing list.

I'm still using 2.0.13 (I think), and if upgrading would help solve my
problems I'll gladly do it. On to my problems:

Is there some way I can either execute the "eval" command from a c++
(.oct) environment or to ask the octave session to evaluate it and return
a result? I've seen something like this in the Matlab .mex method, but
couldn't find anything usefull in the octave help. The source files for
octave isn't much help either, as I do not have a month to trace all the
classes / functions (probably a optimistic estimate of the time!)

The second problem I have is with passing structures to C++. Is there
somewhere in the help files I can find out how to handle them? The
reason I need it is the following: For a certain optimisation problem, the
cost function is a generic one. The cost function needs to call a function
specified in one of it's argument lists, so that it can call the correct
function for evaluation:
function CostVal  = CostFcn (X, FunctionToCall, ArgsForFcn)
% <snip>
RetVal = eval([FunctionToCall, '(X, ArgsForFcn)'];
% <etc>
The "ArgsForFcn" is a structure with some parameters which the
"FunctioToCall" function needs, for example temperature, some gas
constants or some specific operating condition.

In C++ then, the function "FunctionToCall" would the look like the
#include <octave/oct.h>

DEFUN_DLD (FunctionToCall, args, , "Retval = FunctionToCall(X,ARGS)")
   ComplexColumnVector X = args(0).complex_array_value(); 
      // Or whatever

   octave_value_list ArgsToFunctionOVL = args(1);
   octave_struct ArgsToFcn = // Here's where I can't go on
// <snip>
How do I:
1. Convert the structure in the octave_value_list to an octave_struct
2. Extract the specific elements from the octave_struct

Any help would be greatly appreciated.

BTW, is there by any chance a "manual" for developing .oct functions? If
not, I'll be willing to start writing one, and add all the functions I've used
so far.

BTW.2 <grin>. Just for interest's sake: The functions I'm writing are
solving the 1D equations of state for acoustics in pipe systems. (Usefull
for modelling the acoustic behaviour of silencers) The moment I've
finished with them (and checked for mistakes!!) I'll send them in.


Gerrit Visser

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]