Michael Creel wrote:
> Internally, __bfgsmin.c uses feval to compute the function value. Perhaps
> that could be changed to work with anonymous functions. I think that this
> would be the hardest part of making the change.
>
>   
Here is a code snippet that is needed to accept a function as the first 
argument in an oct-file as a function handle or inline functio. String 
functions are accepted and converted internally into an anonymous 
function handle. The code then calls the function on an internally 
created list of arguments and gets the results in another 
octave_value_list.. If a string was passed, the internally created 
function handle is cleared when you leave the oct-file..


      octave_function *opt_fcn;
      std::string fcn_name;

      .....

      if (args(0).is_function_handle () || args(0).is_inline_function ())
        opt_fcn = args(0).function_value ();
      else
        {
          fcn_name = unique_symbol_name ("__opt_fcn_");
          std::string fname = "function y = ";
          fname.append (fcn_name);
          fname.append ("(x) y = ");
          opt_fcn = extract_function (args(0), "mle_estimate", fcn_name, 
fname,
                                       "; endfunction");
        }

        .....

       octave_value_list in_args;
       in_args(0) = x;
       octave_value_list out_args = opt_fcn->do_multi_index_op (1, in_args);
      
       ....

       if (fcn_name.length ())
           clear_unction (fcn_name);
      

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev

Reply via email to