JimHokanson / matlab_standard_library

Standard Library for my Matlab Projects
MIT License
8 stars 10 forks source link

Optimized cellfun and arrayfun for constants #34

Open JimHokanson opened 7 years ago

JimHokanson commented 7 years ago

Use of anonymous functions in arrayfun and cellfun seems to hurt performance. The suggested improvement is to create a mex interface which performs arrayfun or cellfun using a notation like the following:

mex_arrayfun(function_handle,n_arrays,n_constants,is_uniform_bool,array_1,array_2,etc., constant_1

This would allow transforming of something like this:

arrayfun(@(x) my_function(x,'testing'),my_array_data)

into

mex_arrayfun(function_handle, 1, 1, true, my_array_data,'testing')

The notation isn't necessarily any nicer, but ideally the performance can be made a lot better.