octave-maintainers
[Top][All Lists]
Advanced

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

Automatic bsxfun almost everywhere


From: Jordi Gutiérrez Hermoso
Subject: Automatic bsxfun almost everywhere
Date: Thu, 25 Aug 2011 04:24:04 -0500

I have pushed the following three experimental changesets that enable
bsxfun automatically for almost all binary operations except for those
on sparse matrices. This includes things like rem, min, and hypot
(basically, anything that calls binmap is also covered), along with
basic arithmetic and logical operators:

     http://hg.savannah.gnu.org/hgweb/octave/rev/d9d65c3017c3
     http://hg.savannah.gnu.org/hgweb/octave/rev/4061106b1c4b
     http://hg.savannah.gnu.org/hgweb/octave/rev/61be447052c3

I didn't attempt to refactor the code to get rid of some macros. That
seemed like it required deeper surgery than I wanted to do.

I noticed that in some cases my implementations disagree a little with
what bsxfun does. For example,

     bsxfun(@power, uint8(rand(2)), rand(2,1))

casts everything to double whereas

     uint8(rand(2)) .^ rand(2,1)

casts to uint8. I'm not sure which one is more correct, but I think it
makes more sense to keep the one with smaller precision. I understand
Matlab just refuses to do bsxfun arithmetic (or arithmetic in
general?) with mixed types.

I noticed that bsxfun seems to just cast sparse matrices into full
matrices. I didn't implement anything at all for sparse matrices. If
there's interest, I could keep going.

HTH,
- Jordi G. H.


reply via email to

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