octave-maintainers
[Top][All Lists]
Advanced

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

Re: mapper functions vs. cell arrays


From: David Bateman
Subject: Re: mapper functions vs. cell arrays
Date: Fri, 01 Sep 2006 14:12:51 +0200
User-agent: Thunderbird 1.5.0.5 (X11/20060817)

John W. Eaton wrote:
> On 31-Aug-2006, David Bateman wrote:
>
> | John W. Eaton wrote:
> | > Should we be bug-for-bug compatible here, or should we do something
> | > that is more consistent?  I think we should do one of the following:
> | >
> | >   * Change all the mapper functions so that
> | >
> | >       mapper (CELL) == cellfun (@MAPPER, CELL)
> | >
> | >   
> | I prefer this solution. Programs that work in matlab then work in octave
> | and we have a consistent interface...
>
> OK.
>
> Well, the current implementation of cellfun in Matlab is more complex
> than what we have in Octave.  For example,
>
> Matlab gives an error for this
>
>   cellfun (@upper, {'foo'; 'foobar'})
>
> but not this
>
>   cellfun (@upper, {'foo'; 'foobar'}, 'UniformOutput', false)
>
> and both of these
>
>   cellfun (@upper, {'f', 'o', 'o'})
>   cellfun (@upper, {'f', 'o', 'o'}, 'UniformOutput', true)
>
> return
>
>   "FOO"
>
> while
>
>   cellfun (@upper, {'f', 'o', 'o'}, 'UniformOutput', true)
>
> returns a cell array of characters.
>
> There is also a new ErrorHandler parameter that allows one to specify
> a function to call if the mapper fails.
>
> Ugh.  Is there any function in Matlab that is not aqcuiring a lot of
> twisty little features?
>
> jwe
>
>   

Thinking about this a bit more, the octave cellfun effectively assumes
that "UniformOutput" is false and so all results are given in a cell
array. "UniformOutput" being "true" equivalent in octave would be

cell2mat(cellfun (@upper, {'f', 'o', 'o'}))

So matlab just made the default output of cellfun different from octave
so the output is incompatible. If we want to make cellfun compatible
then the want we might do is make cell2mat and oct-file in cellfun.cc
and call it on the outputs if "UniformOutput" is "true".

I'll make a cellfun that is matlab compatible if you want it... I'll do
it after work today...

D.

-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



reply via email to

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