Mercurial > octave
diff liboctave/bsxfun.h @ 14056:c3d401562410 stable
allow warning (or error) for automatic bsxfun
* liboctave/bsxfun.h (is_valid_bsxfun, is_valid_inplace_bsxfun):
New argument, name. Change all callers. Call warning_with_id_handler.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 15 Dec 2011 11:23:51 -0500 |
parents | aa4a23337a0f |
children | 951eacaf9381 |
line wrap: on
line diff
--- a/liboctave/bsxfun.h Thu Dec 15 10:07:57 2011 -0500 +++ b/liboctave/bsxfun.h Thu Dec 15 11:23:51 2011 -0500 @@ -26,10 +26,12 @@ #include "Array.h" #include "dim-vector.h" +#include "lo-error.h" inline bool -is_valid_bsxfun (const dim_vector& dx, const dim_vector& dy) +is_valid_bsxfun (const std::string& name, const dim_vector& dx, + const dim_vector& dy) { for (int i = 0; i < std::min (dx.length (), dy.length ()); i++) { @@ -38,6 +40,10 @@ if (! ( (xk == yk) || (xk == 1 && yk > 1) || (xk > 1 && yk == 1))) return false; } + + (*current_liboctave_warning_with_id_handler) + ("Octave:auto-bsxfun", "%s: automatic broadcasting operation applied", name.c_str ()); + return true; } @@ -46,7 +52,8 @@ // different here. inline bool -is_valid_inplace_bsxfun (const dim_vector& dr, const dim_vector& dx) +is_valid_inplace_bsxfun (const std::string& name, const dim_vector& dr, + const dim_vector& dx) { octave_idx_type drl = dr.length (), dxl = dx.length (); if (drl < dxl) @@ -60,6 +67,10 @@ if (! ( (rk == xk) || (rk > 1 && xk == 1))) return false; } + + (*current_liboctave_warning_with_id_handler) + ("Octave:auto-bsxfun", "%s: automatic broadcasting operation applied", name.c_str ()); + return true; }