help-octave
[Top][All Lists]
Advanced

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

Re: Problem with calling one octfile form another octfile


From: Andy Buckle
Subject: Re: Problem with calling one octfile form another octfile
Date: Tue, 26 Apr 2011 20:39:50 +0100

On Mon, Apr 25, 2011 at 9:00 PM, Guido Biele <address@hidden> wrote:
> Hi,
>
> Background:
> In the context of fitting some learning models to behavioral data I am using
> 2 octfiles. octfile (a) organizes a grid search and calls octfile (b) which
> implements a learning model.
>
> Problem:
> The value i get back from file (b) is "funny". I.e. I know that file (b)
> performs as expected. However, when i call (a) multiple times from (b), the
> first value I obtain from (a) is always ok, but all following values are
> incorrect (a constant positive number).
> I suspect I might be doing something wrong when i try to extract a
> double_value from the octave_list which holds the output from (a). Here is
> the relevant portion of the c++ code for octfile (a):
>
> ////////////////// begin code extract //////////////////
>  // define octave function to be used in grid search, the function handle is
> passed as the first argument to the grid-search octfile (a)
>  octave_function *fcn = argv(0).function_value ();
>
> // intitialize octave_value variable to which output of (b) is allocated
> octave_value tmpLLH;
>
> // initialize double variable to pass model-fit (desired output of octfile
> (b))
> double llh;
>
> // call octfile (b) from the grid-search octfile
> tmpLLH = feval(fcn, model_input, nargout);
> // get double from the octave_value variable
> llh = tmpLLH.double_value();
>
> // i could also directly use feval(fcn, model_input,
> nargout)(0).double_value();, but this doesn't change my problem ...
> ////////////////// end code extract //////////////////
>
> (the full file is also attached. I am c++ novice, so please excuse eventual
> oddities or inefficiencies)
>
> The above described problem persists if I simply pass the function that
> needs to be evaluated as a string.
> I do not think that the problem is in octfile (b) which implements the
> learning model, because this file produces fine results as long as I call it
> from a simple octave-m-file.
>
> Any help with this problem would be very much appreciated.
>
> Cheers - guido
>
>
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
>

(I have not had the time to look at your code in detail).

When I have called one oct-file from another, I have implemented a C++
interface to function b, (try to avoid feval). I think this should be
faster. With luck, it will also fix your problem.

-- 
/* andy buckle */


reply via email to

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