Mercurial > hg > octave-avbm
diff liboctave/bsxfun.h @ 13004:d9d65c3017c3
Make bsxfun automatic for most binary operators.
* MArray.cc: Give do_mm_binary_op two extra loop arguments so it can
pass them to bsxfun.
* MDiagArray2.cc: Ditto.
* mx-op-defs.h: Ditto.
* bsxfun.h: New file.
* Makefile.am: Add bsxfun.h to includes.
* mx-inlines.cc: Call do_bsxfun_op when appropriate.
author | Jordi GutiƩrrez Hermoso <jordigh@gmail.com> |
---|---|
date | Wed, 24 Aug 2011 23:06:59 -0500 (2011-08-25) |
parents | |
children | 4061106b1c4b |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/liboctave/bsxfun.h @@ -0,0 +1,40 @@ +/* + +Copyright (C) 2011 Jordi GutiƩrrez Hermoso <jordigh@octave.org> + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +<http://www.gnu.org/licenses/>. + +*/ + +#include <algorithm> + +#include "Array.h" +#include "dim-vector.h" + +#include "bsxfun-defs.cc" + +inline +bool +is_valid_bsxfun (const dim_vector& dx, const dim_vector& dy) +{ + for (int i = 0; i < std::min (dx.length (), dy.length ()); i++) + { + if ( dx(i) > 1 && dy(i) > 1 && dx(i) != dy(i)) + return false; + } + return true; +}