octave-maintainers
[Top][All Lists]
Advanced

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

Re: Testing for function handles


From: Juan Pablo Carbajal
Subject: Re: Testing for function handles
Date: Thu, 10 Nov 2011 00:56:21 +0100

On Wed, Nov 9, 2011 at 10:58 PM, John W. Eaton <address@hidden> wrote:
> On  9-Nov-2011, Juan Pablo Carbajal wrote:
>
> | I could work on the implementation of a function to check for
> | function_handle. I would do something like what is done for ischar,
> | src/strfns.cc line 297. I have noticed that there is already a
> | is_function_hanlde in octave_values, so it is just a matter of
> | defining the function.
>
> Yes, that's what I would do.  The args(0).is_defined () part of that
> function is probably not needed.
>
> | Now, where is the place for such a function? and Would you call it
> | is_function_handle or isfunhandle or something alike?
>
> I think it should be called is_function_handle.  The file
> ov-fcn-handle.cc is probably a good place for it.
>
> jwe
>

jwe, thanks a lot for the pointers... I will need a guiding hand i the
dark for a while :D

So I implemented this trivial function with minimal tests.

Repeating the benchmark gives

n=1e5;
tic;
for i=1:n
is_function_handle(f);
end
toc;

tic;
for i=1:n
strcmp(class(f),'function_handle');
end;
toc

Elapsed time is 0.85 seconds, for is_function_handle
Elapsed time is 2.2 seconds, for strcmp

I guess this are good news. :D

The changeset.patch attached (or shall I upload it somewhere?)

-- 
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/

Attachment: changeset.patch
Description: Text Data


reply via email to

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