help-octave
[Top][All Lists]
Advanced

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

Re: how to define a function handle in oct-files


From: Evan
Subject: Re: how to define a function handle in oct-files
Date: Sat, 12 Jan 2008 21:52:39 +0800

On Jan 10, 2008 7:50 PM, Muthiah Annamalai <address@hidden> wrote:
> Evan wrote:
> > On Jan 10, 2008 9:24 PM, Evan <address@hidden> wrote:
> >
> >> I want to define a function like the following in an oct-file
> >>
> >> function y=fun(f)
> >>   g=@(x) 1./f(x);
> >>   y=quad(g, 0, 1);
> >> endfunction
> >>
> >> what should I write for the sentence "g=@(x) 1./f(x);"?
> >> thanks in advance
> >>
> >>
> >
> > I still don't know if there is any standard method to do this, but
> > after look through the head files of Octave, I figure out a way as
> > follows
> >
> >       octave_value_list f = feval("func2str", args(0), 1);
> >       std::string fcn = f(0).string_value ();
> >       std::string newfcn = "@(x) 1./( (" + fcn + ")(x))";
> >       int status;
> >       octave_value_list nf = eval_string (newfcn, true, status, 1);
> >
> >
> This is self-defeating, as I think you must use the Delauny
> by invoking Fortran, as otherwise you will not gain much
> speed by doing this in an OCT file.

It's really self-defeating.

"feval" and "eval_string" is very slow in oct-files. For my program,
the oct-file is even slower than the Octave script.


reply via email to

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