26 #if ! defined (octave_oct_binmap_h)
27 #define octave_oct_binmap_h 1
29 #include "octave-config.h"
68 template <
typename R,
typename X,
typename Y,
typename F>
84 op_mm (std::size_t
n, R *
r,
const X *
x,
const Y *y)
86 for (std::size_t i = 0; i <
n; i++)
87 r[i] = s_fcn (
x[i], y[i]);
93 for (std::size_t i = 0; i <
n; i++)
94 r[i] = s_fcn (
x, y[i]);
100 for (std::size_t i = 0; i <
n; i++)
101 r[i] = s_fcn (
x[i], y);
106 template <
typename R,
typename X,
typename Y,
typename F>
110 template <
typename U,
typename T,
typename R,
typename F>
116 const R *y = ya.
data ();
122 for (i = 0; i <
len - 3; i += 4)
126 p[i] = fcn (
x, y[i]);
127 p[i+1] = fcn (
x, y[i+1]);
128 p[i+2] = fcn (
x, y[i+2]);
129 p[i+3] = fcn (
x, y[i+3]);
135 p[i] = fcn (
x, y[i]);
141 template <
typename U,
typename T,
typename R,
typename F>
147 const R *
x = xa.
data ();
153 for (i = 0; i <
len - 3; i += 4)
157 p[i] = fcn (
x[i], y);
158 p[i+1] = fcn (
x[i+1], y);
159 p[i+2] = fcn (
x[i+2], y);
160 p[i+3] = fcn (
x[i+3], y);
166 p[i] = fcn (
x[i], y);
172 template <
typename U,
typename T,
typename R,
typename F>
178 if (xa.
numel () == 1)
179 return binmap<U, T, R, F> (xa(0), ya, fcn);
180 else if (ya.
numel () == 1)
181 return binmap<U, T, R, F> (xa, ya(0), fcn);
196 const T *
x = xa.
data ();
197 const T *y = ya.
data ();
203 for (i = 0; i <
len - 3; i += 4)
207 p[i] = fcn (
x[i], y[i]);
208 p[i+1] = fcn (
x[i+1], y[i+1]);
209 p[i+2] = fcn (
x[i+2], y[i+2]);
210 p[i+3] = fcn (
x[i+3], y[i+3]);
216 p[i] = fcn (
x[i], y[i]);
222 template <
typename U,
typename T,
typename R,
typename F>
227 U fz = fcn (
x, yzero);
233 std::copy (ys.
ridx (), ys.
ridx () + nz, retval.
ridx ());
253 template <
typename U,
typename T,
typename R,
typename F>
258 U fz = fcn (xzero, y);
264 std::copy (xs.
ridx (), xs.
ridx () + nz, retval.
ridx ());
284 template <
typename U,
typename T,
typename R,
typename F>
288 if (xs.
rows () == 1 && xs.
cols () == 1)
289 return binmap<U, T, R, F> (xs(0, 0), ys, fcn);
290 else if (ys.
rows () == 1 && ys.
cols () == 1)
291 return binmap<U, T, R, F> (xs, ys(0, 0), fcn);
297 U fz = fcn (xzero, yzero);
313 bool jx_lt_max = jx < jx_max;
317 bool jy_lt_max = jy < jy_max;
319 while (jx_lt_max || jy_lt_max)
322 || (jx_lt_max && (xs.
ridx (jx) < ys.
ridx (jy))))
325 retval.
xdata (nz) = fcn (xs.
data (jx), yzero);
327 jx_lt_max = jx < jx_max;
330 || (jy_lt_max && (ys.
ridx (jy) < xs.
ridx (jx))))
333 retval.
xdata (nz) = fcn (xzero, ys.
data (jy));
335 jy_lt_max = jy < jy_max;
342 jx_lt_max = jx < jx_max;
344 jy_lt_max = jy < jy_max;
348 retval.
xcidx (j+1) = nz;
363 template <
typename U,
typename T,
typename R>
367 {
return binmap<U, T, R, U (*) (T, R)> (xa, ya, fcn, name); }
369 template <
typename U,
typename T,
typename R>
372 {
return binmap<U, T, R, U (*) (T, R)> (
x, ya, fcn); }
374 template <
typename U,
typename T,
typename R>
377 {
return binmap<U, T, R, U (*) (T, R)> (xa, y, fcn); }
379 template <
typename U,
typename T,
typename R>
383 {
return binmap<U, T, R, U (*) (T, R)> (xa, ya, fcn, name); }
385 template <
typename U,
typename T,
typename R>
388 {
return binmap<U, T, R, U (*) (T, R)> (
x, ya, fcn); }
390 template <
typename U,
typename T,
typename R>
393 {
return binmap<U, T, R, U (*) (T, R)> (xa, y, fcn); }
397 template <
typename U,
typename T,
typename R>
401 {
return binmap<U, T, R, U (*) (const T&, const R&)> (xa, ya, fcn, name); }
403 template <
typename U,
typename T,
typename R>
406 {
return binmap<U, T, R, U (*) (const T&, const R&)> (
x, ya, fcn); }
408 template <
typename U,
typename T,
typename R>
411 {
return binmap<U, T, R, U (*) (const T&, const R&)> (xa, y, fcn); }
413 template <
typename U,
typename T,
typename R>
417 {
return binmap<U, T, R, U (*) (const T&, const R&)> (xa, ya, fcn, name); }
419 template <
typename U,
typename T,
typename R>
422 {
return binmap<U, T, R, U (*) (const T&, const R&)> (
x, ya, fcn); }
424 template <
typename U,
typename T,
typename R>
427 {
return binmap<U, T, R, U (*) (const T&, const R&)> (xa, y, fcn); }
431 template <
typename U,
typename T,
typename R>
435 {
return binmap<U, T, R, U (*) (const T&, R)> (xa, ya, fcn, name); }
437 template <
typename U,
typename T,
typename R>
440 {
return binmap<U, T, R, U (*) (const T&, R)> (
x, ya, fcn); }
442 template <
typename U,
typename T,
typename R>
445 {
return binmap<U, T, R, U (*) (const T&, R)> (xa, y, fcn); }
447 template <
typename U,
typename T,
typename R>
451 {
return binmap<U, T, R, U (*) (const T&, R)> (xa, ya, fcn, name); }
453 template <
typename U,
typename T,
typename R>
456 {
return binmap<U, T, R, U (*) (const T&, R)> (
x, ya, fcn); }
458 template <
typename U,
typename T,
typename R>
461 {
return binmap<U, T, R, U (*) (const T&, R)> (xa, y, fcn); }
465 template <
typename U,
typename T,
typename R>
469 {
return binmap<U, T, R, U (*) (T, const R&)> (xa, ya, fcn, name); }
471 template <
typename U,
typename T,
typename R>
474 {
return binmap<U, T, R, U (*) (T, const R&)> (
x, ya, fcn); }
476 template <
typename U,
typename T,
typename R>
479 {
return binmap<U, T, R, U (*) (T, const R&)> (xa, y, fcn); }
481 template <
typename U,
typename T,
typename R>
485 {
return binmap<U, T, R, U (*) (T, const R&)> (xa, ya, fcn, name); }
487 template <
typename U,
typename T,
typename R>
490 {
return binmap<U, T, R, U (*) (T, const R&)> (
x, ya, fcn); }
492 template <
typename U,
typename T,
typename R>
495 {
return binmap<U, T, R, U (*) (T, const R&)> (xa, y, fcn); }
Array< R > do_bsxfun_op(const Array< X > &x, const Array< Y > &y, void(*op_vv)(std::size_t, R *, const X *, const Y *), void(*op_sv)(std::size_t, R *, X, const Y *), void(*op_vs)(std::size_t, R *, const X *, Y))
bool is_valid_bsxfun(const std::string &name, const dim_vector &xdv, const dim_vector &ydv)
N Dimensional Array with copy-on-write semantics.
T * fortran_vec()
Size of the specified dimension.
const T * data() const
Size of the specified dimension.
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
octave_idx_type numel() const
Number of elements in the array.
octave_idx_type cols() const
octave_idx_type * xcidx()
Array< T > array_value() const
Sparse< T, Alloc > maybe_compress(bool remove_zeros=false)
octave_idx_type nnz() const
Actual number of nonzero terms.
octave_idx_type rows() const
octave_idx_type * xridx()
static void op_sm(std::size_t n, R *r, X x, const Y *y)
static void op_mm(std::size_t n, R *r, const X *x, const Y *y)
static void op_ms(std::size_t n, R *r, const X *x, Y y)
static void set_f(const F &f_in)
Vector representing the dimensions (size) of an Array.
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
F77_RET_T const F77_DBLE * x
Array< U > binmap(const T &x, const Array< R > &ya, F fcn)