annotate liboctave/bsxfun-defs.cc @ 10142:829e69ec3110

make OCTAVE_QUIT a function
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 20 Jan 2010 10:38:00 +0100
parents 36ea14c8992d
children b47ab50a6aa8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9747
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
1 /*
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
2
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
3 Copyright (C) 2009 Jaroslav Hajek
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
4 Copyright (C) 2009 VZLU Prague
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
5
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
6 This file is part of Octave.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
7
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
11 option) any later version.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
12
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
16 for more details.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
17
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
19 along with Octave; see the file COPYING. If not, see
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20 <http://www.gnu.org/licenses/>.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
21
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
22 */
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
23
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
24 #if !defined (octave_bsxfun_defs_h)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25 #define octave_bsxfun_defs_h 1
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
26
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
27 #include <algorithm>
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28 #include <iostream>
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
29
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
30 #include "dim-vector.h"
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
31 #include "oct-locbuf.h"
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32 #include "lo-error.h"
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34 #include "mx-inlines.cc"
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
36 template <class RNDA, class XNDA, class YNDA>
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
37 RNDA
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38 do_bsxfun_op (const XNDA& x, const YNDA& y,
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39 void (*op_vv) (size_t, typename RNDA::element_type *,
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
40 const typename XNDA::element_type *,
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
41 const typename YNDA::element_type *),
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
42 void (*op_sv) (size_t, typename RNDA::element_type *,
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
43 typename XNDA::element_type,
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44 const typename YNDA::element_type *),
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45 void (*op_vs) (size_t, typename RNDA::element_type *,
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
46 const typename XNDA::element_type *,
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47 typename YNDA::element_type))
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
48 {
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
49 int nd = std::max (x.ndims (), y.ndims ());
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50 dim_vector dvx = x.dims ().redim (nd), dvy = y.dims ().redim (nd);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
51
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 // Construct the result dimensions.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
53 dim_vector dvr;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 dvr.resize (nd);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55 for (int i = 0; i < nd; i++)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56 {
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57 octave_idx_type xk = dvx(i), yk = dvy(i);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
58 if (xk == 1)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
59 dvr(i) = yk;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
60 else if (yk == 1 || xk == yk)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
61 dvr(i) = xk;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
62 else
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
63 {
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
64 (*current_liboctave_error_handler)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
65 ("bsxfun: nonconformant dimensions: %s and %s",
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
66 x.dims ().str ().c_str (), y.dims ().str ().c_str ());
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
67 break;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
68 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
69 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
70
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
71 RNDA retval (dvr);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
72
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
73 const typename XNDA::element_type *xvec = x.fortran_vec ();
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
74 const typename YNDA::element_type *yvec = y.fortran_vec ();
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
75 typename RNDA::element_type *rvec = retval.fortran_vec ();
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
76
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
77 // Fold the common leading dimensions.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
78 int start;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
79 octave_idx_type ldr = 1;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
80 for (start = 0; start < nd; start++)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
81 {
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
82 if (dvx(start) != dvy(start))
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
83 break;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
84 ldr *= dvr(start);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
85 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
86
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
87 if (retval.is_empty ())
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
88 ; // do nothing
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
89 else if (start == nd)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
90 op_vv (retval.numel (), rvec, xvec, yvec);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
91 else
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
92 {
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
93 // Determine the type of the low-level loop.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
94 bool xsing = false, ysing = false;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
95 if (ldr == 1)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
96 {
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
97 xsing = dvx(start) == 1;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
98 ysing = dvy(start) == 1;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
99 if (xsing || ysing)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
100 {
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
101 ldr *= dvx(start) * dvy(start);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
102 start++;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
103 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
104 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
105 dim_vector cdvx = dvx.cumulative (), cdvy = dvy.cumulative ();
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
106 // Nullify singleton dims to achieve a spread effect.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
107 for (int i = std::max (start, 1); i < nd; i++)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
108 {
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
109 if (dvx(i) == 1)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
110 cdvx(i-1) = 0;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
111 if (dvy(i) == 1)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
112 cdvy(i-1) = 0;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
113 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
114
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
115 octave_idx_type niter = dvr.numel (start);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
116 // The index array.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
117 OCTAVE_LOCAL_BUFFER_INIT (octave_idx_type, idx, nd, 0);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
118 for (octave_idx_type iter = 0; iter < niter; iter++)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
119 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 10140
diff changeset
120 octave_quit ();
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9747
diff changeset
121
9747
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
122 // Compute indices.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
123 // FIXME: performance impact noticeable?
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
124 octave_idx_type xidx = cdvx.cum_compute_index (idx);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
125 octave_idx_type yidx = cdvy.cum_compute_index (idx);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
126 octave_idx_type ridx = dvr.compute_index (idx);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
127
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
128 // Apply the low-level loop.
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
129 if (xsing)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
130 op_sv (ldr, rvec + ridx, xvec[xidx], yvec + yidx);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
131 else if (ysing)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
132 op_vs (ldr, rvec + ridx, xvec + xidx, yvec[yidx]);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
133 else
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
134 op_vv (ldr, rvec + ridx, xvec + xidx, yvec + yidx);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
135
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
136 dvr.increment_index (idx + start, start);
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
137 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
138 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
139
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
140 return retval;
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
141 }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
142
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
143 #define BSXFUN_OP_DEF(OP, ARRAY) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
144 ARRAY bsxfun_ ## OP (const ARRAY& x, const ARRAY& y)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
145
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9747
diff changeset
146 #define BSXFUN_OP2_DEF(OP, ARRAY, ARRAY1, ARRAY2) \
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9747
diff changeset
147 ARRAY bsxfun_ ## OP (const ARRAY1& x, const ARRAY2& y)
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9747
diff changeset
148
9747
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
149 #define BSXFUN_REL_DEF(OP, ARRAY) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
150 boolNDArray bsxfun_ ## OP (const ARRAY& x, const ARRAY& y)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
151
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
152 #define BSXFUN_OP_DEF_MXLOOP(OP, ARRAY, LOOP) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
153 BSXFUN_OP_DEF(OP, ARRAY) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
154 { return do_bsxfun_op<ARRAY, ARRAY, ARRAY> (x, y, LOOP, LOOP, LOOP); }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
155
9827
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9747
diff changeset
156 #define BSXFUN_OP2_DEF_MXLOOP(OP, ARRAY, ARRAY1, ARRAY2, LOOP) \
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9747
diff changeset
157 BSXFUN_OP2_DEF(OP, ARRAY, ARRAY1, ARRAY2) \
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9747
diff changeset
158 { return do_bsxfun_op<ARRAY, ARRAY1, ARRAY2> (x, y, LOOP, LOOP, LOOP); }
c15a5ed0da58 optimize bsxfun (@power, ...)
Jaroslav Hajek <highegg@gmail.com>
parents: 9747
diff changeset
159
9747
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
160 #define BSXFUN_REL_DEF_MXLOOP(OP, ARRAY, LOOP) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
161 BSXFUN_REL_DEF(OP, ARRAY) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
162 { return do_bsxfun_op<boolNDArray, ARRAY, ARRAY> (x, y, LOOP, LOOP, LOOP); }
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
163
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
164 #define BSXFUN_STDOP_DEFS_MXLOOP(ARRAY) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
165 BSXFUN_OP_DEF_MXLOOP (add, ARRAY, mx_inline_add) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
166 BSXFUN_OP_DEF_MXLOOP (sub, ARRAY, mx_inline_sub) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
167 BSXFUN_OP_DEF_MXLOOP (mul, ARRAY, mx_inline_mul) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
168 BSXFUN_OP_DEF_MXLOOP (div, ARRAY, mx_inline_div) \
10140
36ea14c8992d fix reversed min/max in bsxfun
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
169 BSXFUN_OP_DEF_MXLOOP (min, ARRAY, mx_inline_xmin) \
36ea14c8992d fix reversed min/max in bsxfun
Jaroslav Hajek <highegg@gmail.com>
parents: 9827
diff changeset
170 BSXFUN_OP_DEF_MXLOOP (max, ARRAY, mx_inline_xmax) \
9747
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
171
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
172 #define BSXFUN_STDREL_DEFS_MXLOOP(ARRAY) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
173 BSXFUN_REL_DEF_MXLOOP (eq, ARRAY, mx_inline_eq) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
174 BSXFUN_REL_DEF_MXLOOP (ne, ARRAY, mx_inline_ne) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
175 BSXFUN_REL_DEF_MXLOOP (lt, ARRAY, mx_inline_lt) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
176 BSXFUN_REL_DEF_MXLOOP (le, ARRAY, mx_inline_le) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
177 BSXFUN_REL_DEF_MXLOOP (gt, ARRAY, mx_inline_gt) \
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
178 BSXFUN_REL_DEF_MXLOOP (ge, ARRAY, mx_inline_ge)
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
179
7bda650b691a add omitted files from 26abff55f6fe
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
180 #endif