24 #if ! defined (octave_bsxfun_defs_h)
25 #define octave_bsxfun_defs_h 1
40 template <
typename R,
typename X,
typename Y>
43 void (*op_vv) (
size_t, R *,
const X *,
const Y *),
44 void (*op_sv) (
size_t, R *, X,
const Y *),
45 void (*op_vs) (
size_t, R *,
const X *,
Y))
54 for (
int i = 0;
i < nd;
i++)
60 else if (yk == 1 || xk == yk)
64 (
"bsxfun: nonconformant dimensions: %s and %s",
76 for (start = 0; start < nd; start++)
78 if (dvx(start) != dvy(start))
86 op_vv (retval.
numel (), rvec, xvec, yvec);
94 xsing = dvx(start) == 1;
95 ysing = dvy(start) == 1;
98 ldr *= dvx(start) * dvy(start);
128 op_sv (ldr, rvec + ridx, xvec[xidx], yvec + yidx);
130 op_vs (ldr, rvec + ridx, xvec + xidx, yvec[yidx]);
132 op_vv (ldr, rvec + ridx, xvec + xidx, yvec + yidx);
141 template <
typename R,
typename X>
144 void (*op_vv) (
size_t, R *,
const X *),
145 void (*op_vs) (
size_t, R *, X))
157 for (start = 0; start < nd; start++)
159 if (dvr(start) != dvx(start))
166 else if (start == nd)
167 op_vv (r.
numel (), rvec, xvec);
174 xsing = dvx(start) == 1;
177 ldr *= dvr(start) * dvx(start);
204 op_vs (ldr, rvec + ridx, xvec[xidx]);
206 op_vv (ldr, rvec + ridx, xvec + xidx);
213 #define BSXFUN_OP_DEF(OP, ARRAY) \
214 ARRAY bsxfun_ ## OP (const ARRAY& x, const ARRAY& y)
216 #define BSXFUN_OP2_DEF(OP, ARRAY, ARRAY1, ARRAY2) \
217 ARRAY bsxfun_ ## OP (const ARRAY1& x, const ARRAY2& y)
219 #define BSXFUN_REL_DEF(OP, ARRAY) \
220 boolNDArray bsxfun_ ## OP (const ARRAY& x, const ARRAY& y)
222 #define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP) \
223 BSXFUN_OP_DEF(OP, ARRAY) \
224 { return do_bsxfun_op<ARRAY::element_type, ARRAY::element_type, ARRAY::element_type> \
225 (x, y, LOOP, LOOP, LOOP); }
227 #define BSXFUN_OP2_DEF_MXLOOP(OP, ARRAY, ARRAY1, ARRAY2, LOOP) \
228 BSXFUN_OP2_DEF(OP, ARRAY, ARRAY1, ARRAY2) \
229 { return do_bsxfun_op<ARRAY::element_type, ARRAY1::element_type, ARRAY2::element_type> \
230 (x, y, LOOP, LOOP, LOOP); }
232 #define BSXFUN_REL_DEF_MXLOOP(OP, ARRAY, LOOP) \
233 BSXFUN_REL_DEF(OP, ARRAY) \
234 { return do_bsxfun_op<bool, ARRAY::element_type, ARRAY::element_type> \
235 (x, y, LOOP, LOOP, LOOP); }
237 #define BSXFUN_STDOP_DEFS_MXLOOP(ARRAY) \
238 BSXFUN_OP_DEF_MXLOOP (add, ARRAY, mx_inline_add) \
239 BSXFUN_OP_DEF_MXLOOP (sub, ARRAY, mx_inline_sub) \
240 BSXFUN_OP_DEF_MXLOOP (mul, ARRAY, mx_inline_mul) \
241 BSXFUN_OP_DEF_MXLOOP (div, ARRAY, mx_inline_div) \
242 BSXFUN_OP_DEF_MXLOOP (min, ARRAY, mx_inline_xmin) \
243 BSXFUN_OP_DEF_MXLOOP (max, ARRAY, mx_inline_xmax)
245 #define BSXFUN_STDREL_DEFS_MXLOOP(ARRAY) \
246 BSXFUN_REL_DEF_MXLOOP (eq, ARRAY, mx_inline_eq) \
247 BSXFUN_REL_DEF_MXLOOP (ne, ARRAY, mx_inline_ne) \
248 BSXFUN_REL_DEF_MXLOOP (lt, ARRAY, mx_inline_lt) \
249 BSXFUN_REL_DEF_MXLOOP (le, ARRAY, mx_inline_le) \
250 BSXFUN_REL_DEF_MXLOOP (gt, ARRAY, mx_inline_gt) \
251 BSXFUN_REL_DEF_MXLOOP (ge, ARRAY, mx_inline_ge)
254 #define BSXFUN_POW_MIXED_MXLOOP(INT_TYPE) \
255 BSXFUN_OP2_DEF_MXLOOP (pow, INT_TYPE, INT_TYPE, NDArray, mx_inline_pow) \
256 BSXFUN_OP2_DEF_MXLOOP (pow, INT_TYPE, INT_TYPE, FloatNDArray, mx_inline_pow) \
257 BSXFUN_OP2_DEF_MXLOOP (pow, INT_TYPE, NDArray, INT_TYPE, mx_inline_pow) \
258 BSXFUN_OP2_DEF_MXLOOP (pow, INT_TYPE, FloatNDArray, INT_TYPE, mx_inline_pow)
bool is_empty(void) const
std::string str(char sep= 'x') const
#define OCTAVE_LOCAL_BUFFER_INIT(T, buf, size, value)
octave_idx_type numel(void) const
Number of elements in the array.
dim_vector cumulative(void) const
Return cumulative dimensions.
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
void resize(int n, int fill_value=0)
octave_idx_type cum_compute_index(const octave_idx_type *idx) const
Compute a linear index from an index tuple.
int increment_index(octave_idx_type *idx, int start=0) const
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup calculate Y_a and Y _d item Given Y
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
dim_vector redim(int n) const
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 compute_index(const octave_idx_type *idx) const
Linear index from an index tuple.
=val(i)}if ode{val(i)}occurs in table i
the element is set to zero In other the statement xample y
const T * fortran_vec(void) const
Vector representing the dimensions (size) of an Array.
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &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))