octave-maintainers
[Top][All Lists]
Advanced

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

Re: Removing broadcasting from Octave


From: John W. Eaton
Subject: Re: Removing broadcasting from Octave
Date: Wed, 14 Dec 2011 20:37:26 -0500

On 14-Dec-2011, Michael Godfrey wrote:

| Another obvious remark: broadcasting does not introduce any new
| problems for porting Matlab code to Octave.  And, Octave code 
| which obeys Matlab rules about dimensional matching will port to
| Matlab regardless of broadcasting.

Right.

I was going to post and say that I wasn't sure about overloading .* vs
*, but then I thought more about it and it is obvious we can't
overload * for autobsxfun because that does lead to a conflict between
regular M*v matrix-vector multiplication and M*v row scaling.  So .*,
.+, etc. it has to be.  I also don't see a problem with having .+ and
+ both doing autobsxfun because there really isn't a .+ operator.  I
just added that for symmetry, and it is converted early in the lexer
just be identical to +.

I'm comfortable enough with it to include it in 3.6, but I'm still
willing to listen to other opinions.  If we decide that we really
don't have enough experience with this new feature, then I think we
should disable it by default for 3.6.  Fortunately, I think that is
simple to do, and does not require backing out any changesets.
Instead, I think the following change will be sufficient.  Then it's a
simple matter to leave the feature enabled for the development sources
where we can gain more experience with it and decide whether we should
keep it before the next major release.

Jordi, do you agree that the patch below is enough to disable the
feature, or is there something else that needs to be done?

jwe

diff --git a/liboctave/bsxfun.h b/liboctave/bsxfun.h
--- a/liboctave/bsxfun.h
+++ b/liboctave/bsxfun.h
@@ -31,6 +31,7 @@
 bool
 is_valid_bsxfun (const dim_vector& dx, const dim_vector& dy)
 {
+#if defined ENABLE_AUTO_BSXFUN
   for (int i = 0; i < std::min (dx.length (), dy.length ()); i++)
     {
       octave_idx_type xk = dx(i), yk = dy(i);
@@ -39,6 +40,9 @@
         return false;
     }
   return true;
+#else
+  return false;
+#endif
 }
 
 // since we can't change the size of the assigned-to matrix, we cannot
@@ -48,6 +52,7 @@
 bool
 is_valid_inplace_bsxfun (const dim_vector& dr, const dim_vector& dx)
 {
+#if defined ENABLE_AUTO_BSXFUN
   octave_idx_type drl = dr.length (), dxl = dx.length ();
   if (drl < dxl)
     return false;
@@ -61,6 +66,9 @@
         return false;
     }
   return true;
+#else
+  return false;
+#endif
 }
 
 #include "bsxfun-defs.cc"

reply via email to

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