On 25-Jun-2009, Jaroslav Hajek wrote:
| On Thu, Jun 25, 2009 at 9:46 AM, Judd Storrs<
address@hidden> wrote:
|
| > Is there any reason why bsxfun style singleton dimension expansion shouldn't
| > be the *default* behavior for the builtin element-wise operators (.*, .+,
| > .-) in octave? bsxfun also seems like the logical extension of the scalar
| > with matrix cases.
| >
| > Matlab compatibility could be a reason, but I don't think it would break any
| > working Matlab code (unless perhaps some strange code is relying on the
| > error handling). I think the gain in expressivity and simplicity for octave
| > code could very well be worth it?
| >
| > Getting back to the original problem about scaling the matrix by row or by
| > column sums if "./" behaved like bsxfun but avoided the repeated function
| > evaluations then the blatently obvious _expression_ of the algorithm would
| > both work and be at least as fast as using diag,
|
| Probably almost exactly as fast as diag, at least without repmat.
|
| > while also scaling to
| > higher dimensions sanely:
| >
| > X ./ sum(X,1)
| > X ./ sum(X,2)
| > X ./ sum(X,3)
| > etc
| >
|
| I think the idea has been brought up multiple times in the past. A
| major problem is implementation: somebody has to do it. Other minor
| problems may include incorrect code that suddenly does some "magic"
| rather than fail, and incompatibility with Matlab - some Octave users
| limit themselves to Matlab-compatible subset. Scaling using diag, for
| instance, has the advantage that it does work in Matlab.
| But on general, I have no objections to that idea. However, in my
| working, scaling/unscaling matrices is by far the most common
| operation of this kind, and that is now solved elegantly using
| diagonal matrices (which also work with sparse matrices efficiently),
| so I have little motivation to actually do it.
I'd be careful about making the .-ops do row/column scaling. I think