23 #if !defined (octave_oct_binmap_h)
24 #define octave_oct_binmap_h 1
63 template<
typename R,
typename X,
typename Y,
typename F>
77 op_mm (
size_t n, R* r,
const X*
x ,
const Y* y)
79 for (
size_t i = 0; i < n; i++)
80 r[i] =
f (x[i], y[i]);
84 op_sm (
size_t n, R* r, X
x,
const Y* y)
86 for (
size_t i = 0; i < n; i++)
91 op_ms (
size_t n , R* r,
const X*
x, Y y)
93 for (
size_t i = 0; i < n; i++)
99 template<
typename R,
typename X,
typename Y,
typename F>
104 template <
class U,
class T,
class R,
class F>
110 const R *y = ya.
data ();
116 for (i = 0; i < len - 3; i += 4)
120 p[i] = fcn (x, y[i]);
121 p[i+1] = fcn (x, y[i+1]);
122 p[i+2] = fcn (x, y[i+2]);
123 p[i+3] = fcn (x, y[i+3]);
129 p[i] = fcn (x, y[i]);
135 template <
class U,
class T,
class R,
class F>
141 const R *
x = xa.
data ();
147 for (i = 0; i < len - 3; i += 4)
151 p[i] = fcn (x[i], y);
152 p[i+1] = fcn (x[i+1], y);
153 p[i+2] = fcn (x[i+2], y);
154 p[i+3] = fcn (x[i+3], y);
160 p[i] = fcn (x[i], y);
166 template <
class U,
class T,
class R,
class F>
171 if (xa.
numel () == 1)
172 return binmap<U, T, R, F> (xa(0), ya, fcn);
173 else if (ya.
numel () == 1)
174 return binmap<U, T, R, F> (xa, ya(0), fcn);
191 const T *
x = xa.
data ();
192 const T *y = ya.
data ();
198 for (i = 0; i < len - 3; i += 4)
202 p[i] = fcn (x[i], y[i]);
203 p[i+1] = fcn (x[i+1], y[i+1]);
204 p[i+2] = fcn (x[i+2], y[i+2]);
205 p[i+3] = fcn (x[i+3], y[i+3]);
211 p[i] = fcn (x[i], y[i]);
217 template <
class U,
class T,
class R,
class F>
226 retval.xdata (i) = fcn (x, ys.
data (i));
230 retval.maybe_compress ();
235 template <
class U,
class T,
class R,
class F>
244 retval.xdata (i) = fcn (xs.
data (i), y);
248 retval.maybe_compress ();
253 template <
class U,
class T,
class R,
class F>
257 if (xs.
rows () == 1 && xs.
cols () == 1)
258 return binmap<U, T, R, F> (xs(0,0), ys, fcn);
259 else if (ys.
rows () == 1 && ys.
cols () == 1)
260 return binmap<U, T, R, F> (xs, ys(0,0), fcn);
267 U fz = fcn (xzero, yzero);
281 while (ix != ux || iy != uy)
289 retval.
xcidx (j+1) = nz;
302 while (ix != ux || iy != uy)
307 retval.
xridx (nz) = rx;
314 retval.
xridx (nz) = rx;
315 retval.
xdata (nz) = fcn (xs.
data (ix), yzero);
320 retval.
xridx (nz) = ry;
321 retval.
xdata (nz) = fcn (xzero, ys.
data (iy));
341 template <
class U,
class T,
class R>
345 {
return binmap<U, T, R, U (*) (T, R)> (xa, ya, fcn, name); }
347 template <
class U,
class T,
class R>
350 {
return binmap<U, T, R, U (*) (T, R)> (
x, ya, fcn); }
352 template <
class U,
class T,
class R>
355 {
return binmap<U, T, R, U (*) (T, R)> (xa, y, fcn); }
357 template <
class U,
class T,
class R>
361 {
return binmap<U, T, R, U (*) (T, R)> (xa, ya, fcn, name); }
363 template <
class U,
class T,
class R>
366 {
return binmap<U, T, R, U (*) (T, R)> (
x, ya, fcn); }
368 template <
class U,
class T,
class R>
371 {
return binmap<U, T, R, U (*) (T, R)> (xa, y, fcn); }
375 template <
class U,
class T,
class R>
379 {
return binmap<U, T, R, U (*) (const T&, const R&)> (xa, ya, fcn, name); }
381 template <
class U,
class T,
class R>
384 {
return binmap<U, T, R, U (*) (const T&, const R&)> (
x, ya, fcn); }
386 template <
class U,
class T,
class R>
389 {
return binmap<U, T, R, U (*) (const T&, const R&)> (xa, y, fcn); }
391 template <
class U,
class T,
class R>
395 {
return binmap<U, T, R, U (*) (const T&, const R&)> (xa, ya, fcn, name); }
397 template <
class U,
class T,
class R>
400 {
return binmap<U, T, R, U (*) (const T&, const R&)> (
x, ya, fcn); }
402 template <
class U,
class T,
class R>
405 {
return binmap<U, T, R, U (*) (const T&, const R&)> (xa, y, fcn); }
409 template <
class U,
class T,
class R>
413 {
return binmap<U, T, R, U (*) (const T&, R)> (xa, ya, fcn, name); }
415 template <
class U,
class T,
class R>
418 {
return binmap<U, T, R, U (*) (const T&, R)> (
x, ya, fcn); }
420 template <
class U,
class T,
class R>
423 {
return binmap<U, T, R, U (*) (const T&, R)> (xa, y, fcn); }
425 template <
class U,
class T,
class R>
429 {
return binmap<U, T, R, U (*) (const T&, R)> (xa, ya, fcn, name); }
431 template <
class U,
class T,
class R>
434 {
return binmap<U, T, R, U (*) (const T&, R)> (
x, ya, fcn); }
436 template <
class U,
class T,
class R>
439 {
return binmap<U, T, R, U (*) (const T&, R)> (xa, y, fcn); }
443 template <
class U,
class T,
class R>
447 {
return binmap<U, T, R, U (*) (T, const R&)> (xa, ya, fcn, name); }
449 template <
class U,
class T,
class R>
452 {
return binmap<U, T, R, U (*) (T, const R&)> (
x, ya, fcn); }
454 template <
class U,
class T,
class R>
457 {
return binmap<U, T, R, U (*) (T, const R&)> (xa, y, fcn); }
459 template <
class U,
class T,
class R>
463 {
return binmap<U, T, R, U (*) (T, const R&)> (xa, ya, fcn, name); }
465 template <
class U,
class T,
class R>
468 {
return binmap<U, T, R, U (*) (T, const R&)> (
x, ya, fcn); }
470 template <
class U,
class T,
class R>
473 {
return binmap<U, T, R, U (*) (T, const R&)> (xa, y, fcn); }