24 #if ! defined (octave_bsxfun_defs_h) 25 #define octave_bsxfun_defs_h 1 37 template <
typename R,
typename X,
typename Y>
40 void (*op_vv) (
size_t, R *,
const X *,
const Y *),
41 void (*op_sv) (
size_t, R *, X,
const Y *),
42 void (*op_vs) (
size_t, R *,
const X *, Y))
51 for (
int i = 0;
i < nd;
i++)
57 else if (yk == 1 || xk == yk)
61 (
"bsxfun: nonconformant dimensions: %s and %s",
62 x.dims ().str ().c_str (),
y.dims ().str ().c_str ());
67 const X *xvec =
x.fortran_vec ();
68 const Y *yvec =
y.fortran_vec ();
69 R *rvec =
retval.fortran_vec ();
91 xsing = dvx(
start) == 1;
92 ysing = dvy(
start) == 1;
125 op_sv (ldr, rvec + ridx, xvec[xidx], yvec + yidx);
127 op_vs (ldr, rvec + ridx, xvec + xidx, yvec[yidx]);
129 op_vv (ldr, rvec + ridx, xvec + xidx, yvec + yidx);
138 template <
typename R,
typename X>
141 void (*op_vv) (
size_t, R *,
const X *),
142 void (*op_vs) (
size_t, R *, X))
149 const X *xvec =
x.fortran_vec ();
163 else if (
start == nd)
164 op_vv (r.
numel (), rvec, xvec);
171 xsing = dvx(
start) == 1;
201 op_vs (ldr, rvec + ridx, xvec[xidx]);
203 op_vv (ldr, rvec + ridx, xvec + xidx);
210 #define BSXFUN_OP_DEF(OP, ARRAY) \ 211 ARRAY bsxfun_ ## OP (const ARRAY& x, const ARRAY& y) 213 #define BSXFUN_OP2_DEF(OP, ARRAY, ARRAY1, ARRAY2) \ 214 ARRAY bsxfun_ ## OP (const ARRAY1& x, const ARRAY2& y) 216 #define BSXFUN_REL_DEF(OP, ARRAY) \ 217 boolNDArray bsxfun_ ## OP (const ARRAY& x, const ARRAY& y) 219 #define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP) \ 220 BSXFUN_OP_DEF(OP, ARRAY) \ 221 { return do_bsxfun_op<ARRAY::element_type, ARRAY::element_type, ARRAY::element_type> \ 222 (x, y, LOOP, LOOP, LOOP); } 224 #define BSXFUN_OP2_DEF_MXLOOP(OP, ARRAY, ARRAY1, ARRAY2, LOOP) \ 225 BSXFUN_OP2_DEF(OP, ARRAY, ARRAY1, ARRAY2) \ 226 { return do_bsxfun_op<ARRAY::element_type, ARRAY1::element_type, ARRAY2::element_type> \ 227 (x, y, LOOP, LOOP, LOOP); } 229 #define BSXFUN_REL_DEF_MXLOOP(OP, ARRAY, LOOP) \ 230 BSXFUN_REL_DEF(OP, ARRAY) \ 231 { return do_bsxfun_op<bool, ARRAY::element_type, ARRAY::element_type> \ 232 (x, y, LOOP, LOOP, LOOP); } 234 #define BSXFUN_STDOP_DEFS_MXLOOP(ARRAY) \ 235 BSXFUN_OP_DEF_MXLOOP (add, ARRAY, mx_inline_add) \ 236 BSXFUN_OP_DEF_MXLOOP (sub, ARRAY, mx_inline_sub) \ 237 BSXFUN_OP_DEF_MXLOOP (mul, ARRAY, mx_inline_mul) \ 238 BSXFUN_OP_DEF_MXLOOP (div, ARRAY, mx_inline_div) \ 239 BSXFUN_OP_DEF_MXLOOP (min, ARRAY, mx_inline_xmin) \ 240 BSXFUN_OP_DEF_MXLOOP (max, ARRAY, mx_inline_xmax) 242 #define BSXFUN_STDREL_DEFS_MXLOOP(ARRAY) \ 243 BSXFUN_REL_DEF_MXLOOP (eq, ARRAY, mx_inline_eq) \ 244 BSXFUN_REL_DEF_MXLOOP (ne, ARRAY, mx_inline_ne) \ 245 BSXFUN_REL_DEF_MXLOOP (lt, ARRAY, mx_inline_lt) \ 246 BSXFUN_REL_DEF_MXLOOP (le, ARRAY, mx_inline_le) \ 247 BSXFUN_REL_DEF_MXLOOP (gt, ARRAY, mx_inline_gt) \ 248 BSXFUN_REL_DEF_MXLOOP (ge, ARRAY, mx_inline_ge) 251 #define BSXFUN_POW_MIXED_MXLOOP(INT_TYPE) \ 252 BSXFUN_OP2_DEF_MXLOOP (pow, INT_TYPE, INT_TYPE, NDArray, mx_inline_pow) \ 253 BSXFUN_OP2_DEF_MXLOOP (pow, INT_TYPE, INT_TYPE, FloatNDArray, mx_inline_pow) \ 254 BSXFUN_OP2_DEF_MXLOOP (pow, INT_TYPE, NDArray, INT_TYPE, mx_inline_pow) \ 255 BSXFUN_OP2_DEF_MXLOOP (pow, INT_TYPE, FloatNDArray, INT_TYPE, mx_inline_pow) octave_idx_type compute_index(const octave_idx_type *idx) const
Linear index from an index tuple.
#define OCTAVE_LOCAL_BUFFER_INIT(T, buf, size, value)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
dim_vector cumulative(void) const
Return cumulative dimensions.
void resize(int n, int fill_value=0)
const T * fortran_vec(void) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
int increment_index(octave_idx_type *idx, int start=0) const
Increment a multi-dimensional index tuple, optionally starting from an offset position and return the...
octave_idx_type numel(const octave_value_list &idx)
dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
void do_inplace_bsxfun_op(Array< R > &r, const Array< X > &x, void(*op_vv)(size_t, R *, const X *), void(*op_vs)(size_t, R *, X))
N Dimensional Array with copy-on-write semantics.
charNDArray max(char d, const charNDArray &m)
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
the element is set to zero In other the statement xample y
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type cum_compute_index(const octave_idx_type *idx) const
Compute a linear index from an index tuple.
Vector representing the dimensions (size) of an Array.
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x
Array< R > do_bsxfun_op(const Array< X > &x, const Array< Y > &y, void(*op_vv)(size_t, R *, const X *, const Y *), void(*op_sv)(size_t, R *, X, const Y *), void(*op_vs)(size_t, R *, const X *, Y))