On Mon, Mar 22, 2010 at 5:44 PM, Søren Hauberg <so...@hauberg.org> wrote:
> man, 22 03 2010 kl. 10:21 +0100, skrev Michael Creel:
>
> > Besides this, I also added checks for ensuring that the
> > function
> > actually returns 'double's.
> >
> > There are quite a few such checks. Don't you think that just the first
> > would be sufficient? If the function returns a double at x, it will
> > pretty much for sure return a double at x plus or minus a small delta.
> > Maybe a check at the end, making sure that 'derivative' is a matrix of
> > doubles would be ok.
>
> In 99.9% of the cases it will be just fine to only check once. The
> potential problem is due bad user functions, such as
>
> function retval = myhessian (x)
> if (x > 0)
> retval = 1;
> else
> retval = [0, 1];
> endfunction
>
> In such silly cases I guess you need the error checks. Perhaps it can be
> done more efficiently than what I did, though.
>
Even in a case like this it would only bite if x were very close to 1. I
think that the first check should be sufficient.
>
> BTW. why is this function implemented in C++? Does it provide superior
> speed compared to an m-file implementation?
>
It is essentially a double loop with a function evaluation inside. Normally,
Octave is not great with loops. I'm pretty sure that this is the case here,
but I wrote this so long ago that I don't remember the performance gain in
going from .m to .oct.
Michael
------------------------------------------------------------------------------
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