[Top][All Lists]

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

Problem with calling one octfile form another octfile

From: Guido Biele
Subject: Problem with calling one octfile form another octfile
Date: Mon, 25 Apr 2011 22:00:31 +0200
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9


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.

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

Attachment: run_fit_grid.cpp
Description: Text document

reply via email to

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