Mercurial > octave-nkf
diff liboctave/mx-inlines.cc @ 13139:aa4a23337a0f
Enable BSX in-place for missing assignment operators
* bsxfun-defs.cc (do_inplace_bsxfun_op): New function.
* bsxfun.h (is_valid_bsxfun): Fix logic, had bug with empty
dimensions. (is_valid_inplace_bsxfun): New function.
* mx-inlines.cc (DEFMXBOOLOPEQ): Add missing function for
vector-by-scalar operation. (do_mm_inplace_op): Call new
inplace_bsxfun functions.
* MArray.cc (MArray::operator+, MArray::operator-, MArray::product_eq,
MArray::quotient_eq): Change calling form for do_mm_in_place_op.
* boolNDArray.cc (boolNDArray::mx_el_and_assign,
boolNDArray::mx_el_or_assign): Ditto
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Thu, 15 Sep 2011 05:11:46 -0500 |
parents | 4061106b1c4b |
children | 6dfebfa334cb |
line wrap: on
line diff
--- a/liboctave/mx-inlines.cc Wed Sep 14 19:59:24 2011 -0400 +++ b/liboctave/mx-inlines.cc Thu Sep 15 05:11:46 2011 -0500 @@ -169,6 +169,9 @@ for (size_t i = 0; i < n; i++) \ r[i] OP logical_value (x[i]); \ } \ +template <class X> \ +inline void F (size_t n, bool *r, X x) throw () \ +{ for (size_t i = 0; i < n; i++) r[i] OP x; } DEFMXBOOLOPEQ (mx_inline_and2, &=) DEFMXBOOLOPEQ (mx_inline_or2, |=) @@ -391,11 +394,18 @@ inline Array<R>& do_mm_inplace_op (Array<R>& r, const Array<X>& x, void (*op) (size_t, R *, const X *) throw (), + void (*op1) (size_t, R *, X) throw (), const char *opname) { dim_vector dr = r.dims (), dx = x.dims (); if (dr == dx) - op (r.length (), r.fortran_vec (), x.data ()); + { + op (r.length (), r.fortran_vec (), x.data ()); + } + else if (is_valid_inplace_bsxfun (dr, dx)) + { + do_inplace_bsxfun_op (r, x, op, op1); + } else gripe_nonconformant (opname, dr, dx); return r;