Mercurial > hg > octave-jordi
changeset 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 | 4000ad5fe0f6 |
children | 7e60182e6a1c |
files | liboctave/bsxfun.h liboctave/mx-inlines.cc liboctave/oct-binmap.h src/OPERATORS/op-int.h src/xpow.cc |
diffstat | 5 files changed, 29 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/bsxfun.h +++ b/liboctave/bsxfun.h @@ -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; }
--- a/liboctave/mx-inlines.cc +++ b/liboctave/mx-inlines.cc @@ -372,7 +372,7 @@ op (r.length (), r.fortran_vec (), x.data (), y.data ()); return r; } - else if (is_valid_bsxfun (dx, dy)) + else if (is_valid_bsxfun (opname, dx, dy)) { return do_bsxfun_op (x, y, op, op1, op2); } @@ -415,7 +415,7 @@ { op (r.length (), r.fortran_vec (), x.data ()); } - else if (is_valid_inplace_bsxfun (dr, dx)) + else if (is_valid_inplace_bsxfun (opname, dr, dx)) { do_inplace_bsxfun_op (r, x, op, op1); }
--- a/liboctave/oct-binmap.h +++ b/liboctave/oct-binmap.h @@ -174,7 +174,7 @@ return binmap<U, T, R, F> (xa, ya(0), fcn); else if (xad != yad) { - if (is_valid_bsxfun (xad, yad)) + if (is_valid_bsxfun (name, xad, yad)) { bsxfun_wrapper<U, T, R, F>::set_f(fcn); return do_bsxfun_op (xa, ya,
--- a/src/OPERATORS/op-int.h +++ b/src/OPERATORS/op-int.h @@ -704,7 +704,7 @@ dim_vector b_dims = b.dims (); \ if (a_dims != b_dims) \ { \ - if (is_valid_bsxfun (a_dims, b_dims)) \ + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \ { \ return bsxfun_pow (a, b); \ } \ @@ -730,7 +730,7 @@ dim_vector b_dims = b.dims (); \ if (a_dims != b_dims) \ { \ - if (is_valid_bsxfun (a_dims, b_dims)) \ + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \ { \ return bsxfun_pow (a, b); \ } \ @@ -756,7 +756,7 @@ dim_vector b_dims = b.dims (); \ if (a_dims != b_dims) \ { \ - if (is_valid_bsxfun (a_dims, b_dims)) \ + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \ { \ return bsxfun_pow (a, b); \ } \ @@ -782,7 +782,7 @@ dim_vector b_dims = b.dims (); \ if (a_dims != b_dims) \ { \ - if (is_valid_bsxfun (a_dims, b_dims)) \ + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \ { \ return bsxfun_pow (a, b); \ } \ @@ -808,7 +808,7 @@ dim_vector b_dims = b.dims (); \ if (a_dims != b_dims) \ { \ - if (is_valid_bsxfun (a_dims, b_dims)) \ + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \ { \ return bsxfun_pow (a, b); \ } \
--- a/src/xpow.cc +++ b/src/xpow.cc @@ -1245,7 +1245,7 @@ if (a_dims != b_dims) { - if (is_valid_bsxfun (a_dims, b_dims)) + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) { //Potentially complex results NDArray xa = octave_value_extract<NDArray> (a); @@ -1333,7 +1333,7 @@ if (a_dims != b_dims) { - if (is_valid_bsxfun (a_dims, b_dims)) + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) { return bsxfun_pow (a, b); } @@ -1432,7 +1432,7 @@ if (a_dims != b_dims) { - if (is_valid_bsxfun (a_dims, b_dims)) + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) { return bsxfun_pow (a, b); } @@ -1482,7 +1482,7 @@ if (a_dims != b_dims) { - if (is_valid_bsxfun (a_dims, b_dims)) + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) { return bsxfun_pow (a, b); } @@ -2598,7 +2598,7 @@ if (a_dims != b_dims) { - if (is_valid_bsxfun (a_dims, b_dims)) + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) { //Potentially complex results FloatNDArray xa = octave_value_extract<FloatNDArray> (a); @@ -2686,7 +2686,7 @@ if (a_dims != b_dims) { - if (is_valid_bsxfun (a_dims, b_dims)) + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) { return bsxfun_pow (a, b); } @@ -2785,7 +2785,7 @@ if (a_dims != b_dims) { - if (is_valid_bsxfun (a_dims, b_dims)) + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) { return bsxfun_pow (a, b); } @@ -2835,7 +2835,7 @@ if (a_dims != b_dims) { - if (is_valid_bsxfun (a_dims, b_dims)) + if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) { return bsxfun_pow (a, b); }