[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: POC for automatic bsxfun
From: |
Levente Torok |
Subject: |
Re: POC for automatic bsxfun |
Date: |
Wed, 17 Aug 2011 18:08:24 +0200 |
I can agree to have configurable warning or show stopper error but it
could be dangerous for people living with the custom of
relying on this size mismatch check.
But, Jordi ... this is very very useful, indeed.
Cheers,
Lev
2011/8/17 Michael D Godfrey <address@hidden>:
> On 08/17/2011 12:12 AM, Jordi Gutiérrez Hermoso wrote:
>
> The attached patch makes bsxfun automatic for most binary operators.
> The power operator seems to be the only one that is treated
> differently, so it's not covered by this patch.
>
> I'm not pushing this patch since it's potentially quite contentious,
> but I enjoy that e.g. it's now quite easy to get the matrix of all
> pairwise differences of a vector:
>
> x = rand(5,1);
> d = x - x';
>
> which I think is a definite improvement over
>
> d = bsxfun(@minus, x, x');
>
> not to mention less obscure and more likely to be discovered with
> experimentation. If this idea sticks, I would like to write additions
> to the manual to explain this behaviour, how it differs from Matlab,
> when to use it, and when to avoid it.
>
> What do you guys think?
>
> - Jordi G. H.
>
> This capability is very useful. The only question is: is it "too
> dangerous."
> I vote for doing it, but full documentation is surely needed. And, some
> diagnostic modes should be considered. Or even, if people insist, a way
> of if effect disabling it. At least a "warning-on" mode.
>
> But, do not just decide not to do it. The general idea of "replication of
> dimensions"
> has been used in other contexts and is very effective.
>
> Michael
>
>