GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
op-int.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #include "quit.h"
24 #include "bsxfun.h"
25 
26 #define DEFINTBINOP_OP(name, t1, t2, op, t3) \
27  BINOPDECL (name, a1, a2) \
28  { \
29  CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
30  octave_value retval = octave_value \
31  (v1.t1 ## _value () op v2.t2 ## _value ()); \
32  return retval; \
33  }
34 
35 #define DEFINTNDBINOP_OP(name, t1, t2, e1, e2, op, t3) \
36  BINOPDECL (name, a1, a2) \
37  { \
38  CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
39  octave_value retval = octave_value \
40  (v1.e1 ## _value () op v2.e2 ## _value ()); \
41  return retval; \
42  }
43 
44 #define DEFINTBINOP_FN(name, t1, t2, f, t3, op) \
45  BINOPDECL (name, a1, a2) \
46  { \
47  CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
48  octave_value retval = octave_value (f (v1.t1 ## _value (), v2.t2 ## _value ())); \
49  return retval; \
50  }
51 
52 #define DEFINTNDBINOP_FN(name, t1, t2, e1, e2, f, t3, op) \
53  BINOPDECL (name, a1, a2) \
54  { \
55  CAST_BINOP_ARGS (const octave_ ## t1&, const octave_ ## t2&); \
56  octave_value retval = octave_value (f (v1.e1 ## _value (), v2.e2 ## _value ())); \
57  return retval; \
58  }
59 
60 #define OCTAVE_CONCAT_FN2(T1, T2) \
61  DEFNDCATOP_FN2 (T1 ## _ ## T2 ## _s_s, T1 ## _scalar, T2 ## _scalar, , T1 ## NDArray, T1 ## _array, T2 ## _array, concat) \
62  DEFNDCATOP_FN2 (T1 ## _ ## T2 ## _s_m, T1 ## _scalar, T2 ## _matrix, , T1 ## NDArray, T1 ## _array, T2 ## _array, concat) \
63  DEFNDCATOP_FN2 (T1 ## _ ## T2 ## _m_s, T1 ## _matrix, T2 ## _scalar, , T1 ## NDArray, T1 ## _array, T2 ## _array, concat) \
64  DEFNDCATOP_FN2 (T1 ## _ ## T2 ## _m_m, T1 ## _matrix, T2 ## _matrix, , T1 ## NDArray, T1 ## _array, T2 ## _array, concat)
65 
66 #define OCTAVE_INSTALL_CONCAT_FN2(T1, T2) \
67  INSTALL_CATOP (octave_ ## T1 ## _scalar, octave_ ## T2 ## _scalar, T1 ## _ ## T2 ## _s_s) \
68  INSTALL_CATOP (octave_ ## T1 ## _scalar, octave_ ## T2 ## _matrix, T1 ## _ ## T2 ## _s_m) \
69  INSTALL_CATOP (octave_ ## T1 ## _matrix, octave_ ## T2 ## _scalar, T1 ## _ ## T2 ## _m_s) \
70  INSTALL_CATOP (octave_ ## T1 ## _matrix, octave_ ## T2 ## _matrix, T1 ## _ ## T2 ## _m_m)
71 
72 #define OCTAVE_DOUBLE_INT_CONCAT_FN(TYPE) \
73  DEFNDCATOP_FN2 (double ## _ ## TYPE ## _s_s, scalar, TYPE ## _scalar, TYPE ## NDArray, , array, TYPE ## _array, concat) \
74  DEFNDCATOP_FN2 (double ## _ ## TYPE ## _s_m, scalar, TYPE ## _matrix, TYPE ## NDArray, , array, TYPE ## _array, concat) \
75  DEFNDCATOP_FN2 (double ## _ ## TYPE ## _m_s, matrix, TYPE ## _scalar, TYPE ## NDArray, , array, TYPE ## _array, concat) \
76  DEFNDCATOP_FN2 (double ## _ ## TYPE ## _m_m, matrix, TYPE ## _matrix, TYPE ## NDArray, , array, TYPE ## _array, concat)
77 
78 #define OCTAVE_INSTALL_DOUBLE_INT_CONCAT_FN(TYPE) \
79  INSTALL_CATOP (octave_scalar, octave_ ## TYPE ## _scalar, double ## _ ## TYPE ## _s_s) \
80  INSTALL_CATOP (octave_scalar, octave_ ## TYPE ## _matrix, double ## _ ## TYPE ## _s_m) \
81  INSTALL_CATOP (octave_matrix, octave_ ## TYPE ## _scalar, double ## _ ## TYPE ## _m_s) \
82  INSTALL_CATOP (octave_matrix, octave_ ## TYPE ## _matrix, double ## _ ## TYPE ## _m_m)
83 
84 #define OCTAVE_INT_DOUBLE_CONCAT_FN(TYPE) \
85  DEFNDCATOP_FN2 (TYPE ## _ ## double ## _s_s, TYPE ## _scalar, scalar, , TYPE ## NDArray, TYPE ## _array, array, concat) \
86  DEFNDCATOP_FN2 (TYPE ## _ ## double ## _s_m, TYPE ## _scalar, matrix, , TYPE ## NDArray, TYPE ## _array, array, concat) \
87  DEFNDCATOP_FN2 (TYPE ## _ ## double ## _m_s, TYPE ## _matrix, scalar, , TYPE ## NDArray, TYPE ## _array, array, concat) \
88  DEFNDCATOP_FN2 (TYPE ## _ ## double ## _m_m, TYPE ## _matrix, matrix, , TYPE ## NDArray, TYPE ## _array, array, concat)
89 
90 #define OCTAVE_INSTALL_INT_DOUBLE_CONCAT_FN(TYPE) \
91  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_scalar, TYPE ## _ ## double ## _s_s) \
92  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_matrix, TYPE ## _ ## double ## _s_m) \
93  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_scalar, TYPE ## _ ## double ## _m_s) \
94  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_matrix, TYPE ## _ ## double ## _m_m)
95 
96 #define OCTAVE_FLOAT_INT_CONCAT_FN(TYPE) \
97  DEFNDCATOP_FN2 (float ## _ ## TYPE ## _s_s, float_scalar, TYPE ## _scalar, TYPE ## NDArray, , float_array, TYPE ## _array, concat) \
98  DEFNDCATOP_FN2 (float ## _ ## TYPE ## _s_m, float_scalar, TYPE ## _matrix, TYPE ## NDArray, , float_array, TYPE ## _array, concat) \
99  DEFNDCATOP_FN2 (float ## _ ## TYPE ## _m_s, float_matrix, TYPE ## _scalar, TYPE ## NDArray, , float_array, TYPE ## _array, concat) \
100  DEFNDCATOP_FN2 (float ## _ ## TYPE ## _m_m, float_matrix, TYPE ## _matrix, TYPE ## NDArray, , float_array, TYPE ## _array, concat)
101 
102 #define OCTAVE_INSTALL_FLOAT_INT_CONCAT_FN(TYPE) \
103  INSTALL_CATOP (octave_float_scalar, octave_ ## TYPE ## _scalar, float ## _ ## TYPE ## _s_s) \
104  INSTALL_CATOP (octave_float_scalar, octave_ ## TYPE ## _matrix, float ## _ ## TYPE ## _s_m) \
105  INSTALL_CATOP (octave_float_matrix, octave_ ## TYPE ## _scalar, float ## _ ## TYPE ## _m_s) \
106  INSTALL_CATOP (octave_float_matrix, octave_ ## TYPE ## _matrix, float ## _ ## TYPE ## _m_m)
107 
108 #define OCTAVE_INT_FLOAT_CONCAT_FN(TYPE) \
109  DEFNDCATOP_FN2 (TYPE ## _ ## float ## _s_s, TYPE ## _scalar, float_scalar, , TYPE ## NDArray, TYPE ## _array, float_array, concat) \
110  DEFNDCATOP_FN2 (TYPE ## _ ## float ## _s_m, TYPE ## _scalar, float_matrix, , TYPE ## NDArray, TYPE ## _array, float_array, concat) \
111  DEFNDCATOP_FN2 (TYPE ## _ ## float ## _m_s, TYPE ## _matrix, float_scalar, , TYPE ## NDArray, TYPE ## _array, float_array, concat) \
112  DEFNDCATOP_FN2 (TYPE ## _ ## float ## _m_m, TYPE ## _matrix, float_matrix, , TYPE ## NDArray, TYPE ## _array, float_array, concat)
113 
114 #define OCTAVE_INSTALL_INT_FLOAT_CONCAT_FN(TYPE) \
115  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_float_scalar, TYPE ## _ ## float ## _s_s) \
116  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_float_matrix, TYPE ## _ ## float ## _s_m) \
117  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_float_scalar, TYPE ## _ ## float ## _m_s) \
118  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_float_matrix, TYPE ## _ ## float ## _m_m)
119 
120 // For compatibility, concatenation with a character always returns a
121 // character.
122 
123 #define OCTAVE_CHAR_INT_CONCAT_FN(TYPE) \
124  DEFNDCHARCATOP_FN (char ## _ ## TYPE ## _m_s, char_matrix, TYPE ## _scalar, concat) \
125  DEFNDCHARCATOP_FN (char ## _ ## TYPE ## _m_m, char_matrix, TYPE ## _matrix, concat)
126 
127 #define OCTAVE_INSTALL_CHAR_INT_CONCAT_FN(TYPE) \
128  INSTALL_CATOP (octave_char_matrix_str, octave_ ## TYPE ## _scalar, char ## _ ## TYPE ## _m_s) \
129  INSTALL_CATOP (octave_char_matrix_str, octave_ ## TYPE ## _matrix, char ## _ ## TYPE ## _m_m) \
130  INSTALL_CATOP (octave_char_matrix_sq_str, octave_ ## TYPE ## _scalar, char ## _ ## TYPE ## _m_s) \
131  INSTALL_CATOP (octave_char_matrix_sq_str, octave_ ## TYPE ## _matrix, char ## _ ## TYPE ## _m_m)
132 
133 #define OCTAVE_INT_CHAR_CONCAT_FN(TYPE) \
134  DEFNDCHARCATOP_FN (TYPE ## _ ## char ## _s_m, TYPE ## _scalar, char_matrix, concat) \
135  DEFNDCHARCATOP_FN (TYPE ## _ ## char ## _m_m, TYPE ## _matrix, char_matrix, concat)
136 
137 #define OCTAVE_INSTALL_INT_CHAR_CONCAT_FN(TYPE) \
138  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_char_matrix_str, TYPE ## _ ## char ## _s_m) \
139  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_char_matrix_str, TYPE ## _ ## char ## _m_m) \
140  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_char_matrix_sq_str, TYPE ## _ ## char ## _s_m) \
141  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_char_matrix_sq_str, TYPE ## _ ## char ## _m_m)
142 
143 #define OCTAVE_CONCAT_FN(TYPE) \
144  DEFNDCATOP_FN (TYPE ## _s_s, TYPE ## _scalar, TYPE ## _scalar, TYPE ## _array, TYPE ## _array, concat) \
145  DEFNDCATOP_FN (TYPE ## _s_m, TYPE ## _scalar, TYPE ## _matrix, TYPE ## _array, TYPE ## _array, concat) \
146  DEFNDCATOP_FN (TYPE ## _m_s, TYPE ## _matrix, TYPE ## _scalar, TYPE ## _array, TYPE ## _array, concat) \
147  DEFNDCATOP_FN (TYPE ## _m_m, TYPE ## _matrix, TYPE ## _matrix, TYPE ## _array, TYPE ## _array, concat)
148 
149 #define OCTAVE_INSTALL_CONCAT_FN(TYPE) \
150  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_ ## TYPE ## _scalar, TYPE ## _s_s) \
151  INSTALL_CATOP (octave_ ## TYPE ## _scalar, octave_ ## TYPE ## _matrix, TYPE ## _s_m) \
152  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_ ## TYPE ## _scalar, TYPE ## _m_s) \
153  INSTALL_CATOP (octave_ ## TYPE ## _matrix, octave_ ## TYPE ## _matrix, TYPE ## _m_m)
154 
155 #define OCTAVE_S_INT_UNOPS(TYPE) \
156  /* scalar unary ops. */ \
157  \
158  DEFUNOP_OP (s_not, TYPE ## _scalar, !) \
159  DEFUNOP_OP (s_uplus, TYPE ## _scalar, /* no-op */) \
160  DEFUNOP (s_uminus, TYPE ## _scalar) \
161  { \
162  CAST_UNOP_ARG (const octave_ ## TYPE ## _scalar &); \
163  octave_value retval = octave_value (- v. TYPE ## _scalar_value ()); \
164  return retval; \
165  } \
166  DEFUNOP_OP (s_transpose, TYPE ## _scalar, /* no-op */) \
167  DEFUNOP_OP (s_hermitian, TYPE ## _scalar, /* no-op */) \
168  \
169  DEFNCUNOP_METHOD (s_incr, TYPE ## _scalar, increment) \
170  DEFNCUNOP_METHOD (s_decr, TYPE ## _scalar, decrement)
171 
172 #define OCTAVE_SS_INT_ARITH_OPS(PFX, T1, T2, T3) \
173  /* scalar by scalar ops. */ \
174  \
175  DEFINTBINOP_OP (PFX ## _add, T1 ## scalar, T2 ## scalar, +, T3) \
176  DEFINTBINOP_OP (PFX ## _sub, T1 ## scalar, T2 ## scalar, -, T3) \
177  DEFINTBINOP_OP (PFX ## _mul, T1 ## scalar, T2 ## scalar, *, T3) \
178  \
179  DEFBINOP (PFX ## _div, T1 ## scalar, T2 ## scalar) \
180  { \
181  CAST_BINOP_ARGS (const octave_ ## T1 ## scalar&, const octave_ ## T2 ## scalar&); \
182  \
183  if (! v2.T2 ## scalar_value ()) \
184  gripe_divide_by_zero (); \
185  \
186  octave_value retval = octave_value (v1.T1 ## scalar_value () / v2.T2 ## scalar_value ()); \
187  return retval; \
188  } \
189  \
190  DEFINTBINOP_FN (PFX ## _pow, T1 ## scalar, T2 ## scalar, xpow, T3, ^) \
191  \
192  DEFBINOP (PFX ## _ldiv, T1 ## scalar, T2 ## scalar) \
193  { \
194  CAST_BINOP_ARGS (const octave_ ## T1 ## scalar&, const octave_ ## T2 ## scalar&); \
195  \
196  if (! v1.T1 ## scalar_value ()) \
197  gripe_divide_by_zero (); \
198  \
199  octave_value retval = octave_value (v2.T2 ## scalar_value () / v1.T1 ## scalar_value ()); \
200  return retval; \
201  } \
202  \
203  DEFINTBINOP_OP (PFX ## _el_mul, T1 ## scalar, T2 ## scalar, *, T3) \
204  \
205  DEFBINOP (PFX ## _el_div, T1 ## scalar, T2 ## scalar) \
206  { \
207  CAST_BINOP_ARGS (const octave_ ## T1 ## scalar&, const octave_ ## T2 ## scalar&); \
208  \
209  if (! v2.T2 ## scalar_value ()) \
210  gripe_divide_by_zero (); \
211  \
212  octave_value retval = octave_value (v1.T1 ## scalar_value () / v2.T2 ## scalar_value ()); \
213  return retval; \
214  } \
215  \
216  DEFINTBINOP_FN (PFX ## _el_pow, T1 ## scalar, T2 ## scalar, xpow, T3, .^) \
217  \
218  DEFBINOP (PFX ## _el_ldiv, T1 ## scalar, T2 ## scalar) \
219  { \
220  CAST_BINOP_ARGS (const octave_ ## T1 ## scalar&, const octave_ ## T2 ## scalar&); \
221  \
222  if (! v1.T1 ## scalar_value ()) \
223  gripe_divide_by_zero (); \
224  \
225  octave_value retval = octave_value (v2.T2 ## scalar_value () / v1.T1 ## scalar_value ()); \
226  return retval; \
227  }
228 
229 #define OCTAVE_SS_INT_BOOL_OPS(PFX, T1, T2, Z1, Z2) \
230  DEFBINOP (PFX ## _el_and, T2, T2) \
231  { \
232  CAST_BINOP_ARGS (const octave_ ## T1 ## scalar&, const octave_ ## T2 ## scalar&); \
233  \
234  return v1.T1 ## scalar_value () != Z1 && v2.T2 ## scalar_value () != Z2; \
235  } \
236  \
237  DEFBINOP (PFX ## _el_or, T1, T2) \
238  { \
239  CAST_BINOP_ARGS (const octave_ ## T1 ## scalar&, const octave_ ## T2 ## scalar&); \
240  \
241  return v1.T1 ## scalar_value () != Z1 || v2.T2 ## scalar_value () != Z2; \
242  }
243 
244 #define OCTAVE_SS_INT_CMP_OPS(PFX, T1, T2) \
245  DEFBINOP_OP (PFX ## _lt, T1 ## scalar, T2 ## scalar, <) \
246  DEFBINOP_OP (PFX ## _le, T1 ## scalar, T2 ## scalar, <=) \
247  DEFBINOP_OP (PFX ## _eq, T1 ## scalar, T2 ## scalar, ==) \
248  DEFBINOP_OP (PFX ## _ge, T1 ## scalar, T2 ## scalar, >=) \
249  DEFBINOP_OP (PFX ## _gt, T1 ## scalar, T2 ## scalar, >) \
250  DEFBINOP_OP (PFX ## _ne, T1 ## scalar, T2 ## scalar, !=)
251 
252 #define OCTAVE_SS_POW_OPS(T1, T2) \
253  octave_value \
254  xpow (const octave_ ## T1& a, const octave_ ## T2& b) \
255  { \
256  return pow (a, b); \
257  } \
258  \
259  octave_value \
260  xpow (const octave_ ## T1& a, double b) \
261  { \
262  return pow (a, b); \
263  } \
264  \
265  octave_value \
266  xpow (double a, const octave_ ## T1& b) \
267  { \
268  return pow (a, b); \
269  } \
270  \
271  octave_value \
272  xpow (const octave_ ## T1& a, float b) \
273  { \
274  return powf (a, b); \
275  } \
276  \
277  octave_value \
278  xpow (float a, const octave_ ## T1& b) \
279  { \
280  return powf (a, b); \
281  }
282 
283 #define OCTAVE_SS_INT_OPS(TYPE) \
284  OCTAVE_S_INT_UNOPS (TYPE) \
285  OCTAVE_SS_POW_OPS (TYPE, TYPE) \
286  OCTAVE_SS_INT_ARITH_OPS (ss, TYPE ## _, TYPE ## _, TYPE) \
287  OCTAVE_SS_INT_ARITH_OPS (ssx, TYPE ## _, , TYPE) \
288  OCTAVE_SS_INT_ARITH_OPS (sxs, , TYPE ## _, TYPE) \
289  OCTAVE_SS_INT_ARITH_OPS (ssfx, TYPE ## _, float_, TYPE) \
290  OCTAVE_SS_INT_ARITH_OPS (sfxs, float_, TYPE ## _, TYPE) \
291  OCTAVE_SS_INT_CMP_OPS (ss, TYPE ## _, TYPE ## _) \
292  OCTAVE_SS_INT_CMP_OPS (sx, TYPE ## _, ) \
293  OCTAVE_SS_INT_CMP_OPS (xs, , TYPE ## _) \
294  OCTAVE_SS_INT_CMP_OPS (sfx, TYPE ## _, float_) \
295  OCTAVE_SS_INT_CMP_OPS (fxs, float_, TYPE ## _) \
296  OCTAVE_SS_INT_BOOL_OPS (ss, TYPE ## _, TYPE ## _, octave_ ## TYPE (0), octave_ ## TYPE (0)) \
297  OCTAVE_SS_INT_BOOL_OPS (sx, TYPE ## _, , octave_ ## TYPE (0), 0) \
298  OCTAVE_SS_INT_BOOL_OPS (xs, , TYPE ## _, 0, octave_ ## TYPE (0)) \
299  OCTAVE_SS_INT_BOOL_OPS (sfx, TYPE ## _, float_, octave_ ## TYPE (0), 0) \
300  OCTAVE_SS_INT_BOOL_OPS (fxs, float_, TYPE ## _, 0, octave_ ## TYPE (0))
301 
302 #define OCTAVE_SM_INT_ARITH_OPS(PFX, TS, TM, TI) \
303  /* scalar by matrix ops. */ \
304  \
305  DEFINTNDBINOP_OP (PFX ## _add, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, +, TI) \
306  DEFINTNDBINOP_OP (PFX ## _sub, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, -, TI) \
307  DEFINTNDBINOP_OP (PFX ## _mul, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, *, TI) \
308  \
309  /* DEFBINOP (PFX ## _div, TS ## scalar, TM ## matrix) */ \
310  /* { */ \
311  /* CAST_BINOP_ARGS (const octave_ ## TS ## scalar&, const octave_ ## TM ## matrix&); */ \
312  /* */ \
313  /* Matrix m1 = v1.TM ## matrix_value (); */ \
314  /* Matrix m2 = v2.TM ## matrix_value (); */ \
315  /* */ \
316  /* return octave_value (xdiv (m1, m2)); */ \
317  /* } */ \
318  \
319  /* DEFBINOP_FN (PFX ## _pow, TS ## scalar, TM ## matrix, xpow) */ \
320  \
321  DEFBINOP (PFX ## _ldiv, TS ## scalar, TM ## matrix) \
322  { \
323  CAST_BINOP_ARGS (const octave_ ## TS ## scalar&, const octave_ ## TM ## matrix&); \
324  \
325  if (! v1.TS ## scalar_value ()) \
326  gripe_divide_by_zero (); \
327  \
328  octave_value retval = octave_value (v2.TS ## scalar_value () / v1.TS ## scalar_value ()); \
329  return retval; \
330  } \
331  \
332  DEFINTNDBINOP_OP (PFX ## _el_mul, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, *, TI) \
333  DEFBINOP (PFX ## _el_div, TS ## scalar, TM ## matrix) \
334  { \
335  CAST_BINOP_ARGS (const octave_ ## TS ## scalar&, const octave_ ## TM ## matrix&); \
336  \
337  octave_value retval = octave_value (v1.TS ## scalar_value () / v2.TM ## array_value ()); \
338  return retval; \
339  } \
340  \
341  DEFINTNDBINOP_FN (PFX ## _el_pow, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, elem_xpow, TI, .^) \
342  \
343  DEFBINOP (PFX ## _el_ldiv, TS ## scalar, TM ## matrix) \
344  { \
345  CAST_BINOP_ARGS (const octave_ ## TS ## scalar&, const octave_ ## TM ## matrix&); \
346  \
347  if (! v1.TS ## scalar_value ()) \
348  gripe_divide_by_zero (); \
349  \
350  octave_value retval = octave_value (v2.TM ## array_value () / v1.TS ## scalar_value ()); \
351  return retval; \
352  }
353 
354 #define OCTAVE_SM_INT_CMP_OPS(PFX, TS, TM) \
355  DEFNDBINOP_FN (PFX ## _lt, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_lt) \
356  DEFNDBINOP_FN (PFX ## _le, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_le) \
357  DEFNDBINOP_FN (PFX ## _eq, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_eq) \
358  DEFNDBINOP_FN (PFX ## _ge, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_ge) \
359  DEFNDBINOP_FN (PFX ## _gt, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_gt) \
360  DEFNDBINOP_FN (PFX ## _ne, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_ne)
361 
362 #define OCTAVE_SM_INT_BOOL_OPS(PFX, TS, TM) \
363  DEFNDBINOP_FN (PFX ## _el_and, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_and) \
364  DEFNDBINOP_FN (PFX ## _el_or, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_or) \
365  DEFNDBINOP_FN (PFX ## _el_and_not, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_and_not) \
366  DEFNDBINOP_FN (PFX ## _el_or_not, TS ## scalar, TM ## matrix, TS ## scalar, TM ## array, mx_el_or_not)
367 
368 #define OCTAVE_SM_POW_OPS(T1, T2) \
369  octave_value \
370  elem_xpow (const octave_ ## T1& a, const T2 ## NDArray& b) \
371  { \
372  T2 ## NDArray result (b.dims ()); \
373  for (int i = 0; i < b.length (); i++) \
374  { \
375  OCTAVE_QUIT; \
376  result (i) = pow (a, b(i)); \
377  } \
378  return octave_value (result); \
379  } \
380 \
381  octave_value \
382  elem_xpow (const octave_ ## T1& a, const NDArray& b) \
383  { \
384  T1 ## NDArray result (b.dims ()); \
385  for (int i = 0; i < b.length (); i++) \
386  { \
387  OCTAVE_QUIT; \
388  result (i) = pow (a, b(i)); \
389  } \
390  return octave_value (result); \
391  } \
392  \
393  octave_value \
394  elem_xpow (double a, const T2 ## NDArray& b) \
395  { \
396  T2 ## NDArray result (b.dims ()); \
397  for (int i = 0; i < b.length (); i++) \
398  { \
399  OCTAVE_QUIT; \
400  result (i) = pow (a, b(i)); \
401  } \
402  return octave_value (result); \
403  } \
404 \
405  octave_value \
406  elem_xpow (const octave_ ## T1& a, const FloatNDArray& b) \
407  { \
408  T1 ## NDArray result (b.dims ()); \
409  for (int i = 0; i < b.length (); i++) \
410  { \
411  OCTAVE_QUIT; \
412  result (i) = powf (a, b(i)); \
413  } \
414  return octave_value (result); \
415  } \
416  \
417  octave_value \
418  elem_xpow (float a, const T2 ## NDArray& b) \
419  { \
420  T2 ## NDArray result (b.dims ()); \
421  for (int i = 0; i < b.length (); i++) \
422  { \
423  OCTAVE_QUIT; \
424  result (i) = powf (a, b(i)); \
425  } \
426  return octave_value (result); \
427  }
428 
429 
430 #define OCTAVE_SM_CONV(TS, TM) \
431  DEFCONV (TS ## s_ ## TM ## m_conv, TM ## scalar, TM ## matrix) \
432  { \
433  CAST_CONV_ARG (const octave_ ## TS ## scalar&); \
434  \
435  return new octave_ ## TM ## matrix (v.TM ## array_value ()); \
436  }
437 
438 #define OCTAVE_SM_INT_OPS(TYPE) \
439  OCTAVE_SM_POW_OPS (TYPE, TYPE) \
440  OCTAVE_SM_INT_ARITH_OPS (sm, TYPE ## _, TYPE ## _, TYPE) \
441  OCTAVE_SM_INT_ARITH_OPS (smx, TYPE ## _, , TYPE) \
442  OCTAVE_SM_INT_ARITH_OPS (sxm, , TYPE ## _, TYPE) \
443  OCTAVE_SM_INT_ARITH_OPS (smfx, TYPE ## _, float_, TYPE) \
444  OCTAVE_SM_INT_ARITH_OPS (sfxm, float_, TYPE ## _, TYPE) \
445  OCTAVE_SM_INT_CMP_OPS (sm, TYPE ## _, TYPE ## _) \
446  OCTAVE_SM_INT_CMP_OPS (xm, , TYPE ## _) \
447  OCTAVE_SM_INT_CMP_OPS (smx, TYPE ## _, ) \
448  OCTAVE_SM_INT_CMP_OPS (fxm, float_, TYPE ## _) \
449  OCTAVE_SM_INT_CMP_OPS (smfx, TYPE ## _, float_) \
450  OCTAVE_SM_INT_BOOL_OPS (sm, TYPE ## _, TYPE ## _) \
451  OCTAVE_SM_INT_BOOL_OPS (xm, , TYPE ## _) \
452  OCTAVE_SM_INT_BOOL_OPS (smx, TYPE ## _, ) \
453  OCTAVE_SM_INT_BOOL_OPS (fxm, float_, TYPE ## _) \
454  OCTAVE_SM_INT_BOOL_OPS (smfx, TYPE ## _, float_) \
455  OCTAVE_SM_CONV (TYPE ## _, TYPE ## _) \
456  OCTAVE_SM_CONV (TYPE ## _, complex_) \
457  OCTAVE_SM_CONV (TYPE ## _, float_complex_)
458 
459 #define OCTAVE_MS_INT_ARITH_OPS(PFX, TM, TS, TI) \
460  /* matrix by scalar ops. */ \
461  \
462  DEFINTNDBINOP_OP (PFX ## _add, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, +, TI) \
463  DEFINTNDBINOP_OP (PFX ## _sub, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, -, TI) \
464  DEFINTNDBINOP_OP (PFX ## _mul, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, *, TI) \
465  \
466  DEFBINOP (PFX ## _div, TM ## matrix, TS ## scalar) \
467  { \
468  CAST_BINOP_ARGS (const octave_ ## TM ## matrix&, const octave_ ## TS ## scalar&); \
469  \
470  if (! v2.TS ## scalar_value ()) \
471  gripe_divide_by_zero (); \
472  \
473  octave_value retval = octave_value (v1.TM ## array_value () / v2.TS ## scalar_value ()); \
474  return retval; \
475  } \
476  \
477  /* DEFBINOP_FN (PFX ## _pow, TM ## matrix, TS ## scalar, xpow) */ \
478  \
479  /* DEFBINOP (PFX ## _ldiv, TM ## matrix, TS ## scalar) */ \
480  /* { */ \
481  /* CAST_BINOP_ARGS (const octave_ ## TM ## matrix&, const octave_ ## TS ## scalar&); */ \
482  /* */ \
483  /* Matrix m1 = v1.TM ## matrix_value (); */ \
484  /* Matrix m2 = v2.TM ## matrix_value (); */ \
485  /* */ \
486  /* return octave_value (xleftdiv (m1, m2)); */ \
487  /* } */ \
488  \
489  DEFINTNDBINOP_OP (PFX ## _el_mul, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, *, TI) \
490  \
491  DEFBINOP (PFX ## _el_div, TM ## matrix, TS ## scalar) \
492  { \
493  CAST_BINOP_ARGS (const octave_ ## TM ## matrix&, const octave_ ## TS ## scalar&); \
494  \
495  if (! v2.TS ## scalar_value ()) \
496  gripe_divide_by_zero (); \
497  \
498  octave_value retval = octave_value (v1.TM ## array_value () / v2.TS ## scalar_value ()); \
499  return retval; \
500  } \
501  \
502  DEFINTNDBINOP_FN (PFX ## _el_pow, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, elem_xpow, TI, .^) \
503  \
504  DEFBINOP (PFX ## _el_ldiv, TM ## matrix, TS ## scalar) \
505  { \
506  CAST_BINOP_ARGS (const octave_ ## TM ## matrix&, const octave_ ## TS ## scalar&); \
507  \
508  octave_value retval = v2.TS ## scalar_value () / v1.TM ## array_value (); \
509  return retval; \
510  }
511 
512 #define OCTAVE_MS_INT_CMP_OPS(PFX, TM, TS) \
513  DEFNDBINOP_FN (PFX ## _lt, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_lt) \
514  DEFNDBINOP_FN (PFX ## _le, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_le) \
515  DEFNDBINOP_FN (PFX ## _eq, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_eq) \
516  DEFNDBINOP_FN (PFX ## _ge, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_ge) \
517  DEFNDBINOP_FN (PFX ## _gt, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_gt) \
518  DEFNDBINOP_FN (PFX ## _ne, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_ne)
519 
520 #define OCTAVE_MS_INT_BOOL_OPS(PFX, TM, TS) \
521  DEFNDBINOP_FN (PFX ## _el_and, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_and) \
522  DEFNDBINOP_FN (PFX ## _el_or, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_or) \
523  DEFNDBINOP_FN (PFX ## _el_not_and, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_not_and) \
524  DEFNDBINOP_FN (PFX ## _el_not_or, TM ## matrix, TS ## scalar, TM ## array, TS ## scalar, mx_el_not_or)
525 
526 #define OCTAVE_MS_INT_ASSIGN_OPS(PFX, TM, TS, TE) \
527  DEFNDASSIGNOP_FN (PFX ## _assign, TM ## matrix, TS ## scalar, TM ## scalar, assign)
528 
529 #define OCTAVE_MS_INT_ASSIGNEQ_OPS(PFX, TM) \
530  DEFNDASSIGNOP_OP (PFX ## _assign_add, TM ## matrix, TM ## scalar, TM ## scalar, +=) \
531  DEFNDASSIGNOP_OP (PFX ## _assign_sub, TM ## matrix, TM ## scalar, TM ## scalar, -=) \
532  DEFNDASSIGNOP_OP (PFX ## _assign_mul, TM ## matrix, TM ## scalar, TM ## scalar, *=) \
533  DEFNDASSIGNOP_OP (PFX ## _assign_div, TM ## matrix, TM ## scalar, TM ## scalar, /=)
534 
535 #define OCTAVE_MS_POW_OPS(T1, T2) \
536 octave_value elem_xpow (T1 ## NDArray a, octave_ ## T2 b) \
537 { \
538  T1 ## NDArray result (a.dims ()); \
539  for (int i = 0; i < a.length (); i++) \
540  { \
541  OCTAVE_QUIT; \
542  result (i) = pow (a(i), b); \
543  } \
544  return octave_value (result); \
545 } \
546 \
547 octave_value elem_xpow (T1 ## NDArray a, double b) \
548 { \
549  T1 ## NDArray result (a.dims ()); \
550  for (int i = 0; i < a.length (); i++) \
551  { \
552  OCTAVE_QUIT; \
553  result (i) = pow (a(i), b); \
554  } \
555  return octave_value (result); \
556 } \
557 \
558 octave_value elem_xpow (NDArray a, octave_ ## T2 b) \
559 { \
560  T2 ## NDArray result (a.dims ()); \
561  for (int i = 0; i < a.length (); i++) \
562  { \
563  OCTAVE_QUIT; \
564  result (i) = pow (a(i), b); \
565  } \
566  return octave_value (result); \
567 } \
568 \
569 octave_value elem_xpow (T1 ## NDArray a, float b) \
570 { \
571  T1 ## NDArray result (a.dims ()); \
572  for (int i = 0; i < a.length (); i++) \
573  { \
574  OCTAVE_QUIT; \
575  result (i) = powf (a(i), b); \
576  } \
577  return octave_value (result); \
578 } \
579 \
580 octave_value elem_xpow (FloatNDArray a, octave_ ## T2 b) \
581 { \
582  T2 ## NDArray result (a.dims ()); \
583  for (int i = 0; i < a.length (); i++) \
584  { \
585  OCTAVE_QUIT; \
586  result (i) = powf (a(i), b); \
587  } \
588  return octave_value (result); \
589 }
590 
591 
592 #define OCTAVE_MS_INT_OPS(TYPE) \
593  OCTAVE_MS_POW_OPS (TYPE, TYPE) \
594  OCTAVE_MS_INT_ARITH_OPS (ms, TYPE ## _, TYPE ## _, TYPE) \
595  OCTAVE_MS_INT_ARITH_OPS (msx, TYPE ## _, , TYPE) \
596  OCTAVE_MS_INT_ARITH_OPS (mxs, , TYPE ## _, TYPE) \
597  OCTAVE_MS_INT_ARITH_OPS (msfx, TYPE ## _, float_, TYPE) \
598  OCTAVE_MS_INT_ARITH_OPS (mfxs, float_, TYPE ## _, TYPE) \
599  OCTAVE_MS_INT_CMP_OPS (ms, TYPE ## _, TYPE ## _) \
600  OCTAVE_MS_INT_CMP_OPS (mx, TYPE ## _, ) \
601  OCTAVE_MS_INT_CMP_OPS (mxs, , TYPE ## _) \
602  OCTAVE_MS_INT_CMP_OPS (mfx, TYPE ## _, float_) \
603  OCTAVE_MS_INT_CMP_OPS (mfxs, float_, TYPE ## _) \
604  OCTAVE_MS_INT_BOOL_OPS (ms, TYPE ## _, TYPE ## _) \
605  OCTAVE_MS_INT_BOOL_OPS (mx, TYPE ## _, ) \
606  OCTAVE_MS_INT_BOOL_OPS (mxs, , TYPE ## _) \
607  OCTAVE_MS_INT_BOOL_OPS (mfx, TYPE ## _, float_) \
608  OCTAVE_MS_INT_BOOL_OPS (mfxs, float_, TYPE ## _) \
609  OCTAVE_MS_INT_ASSIGN_OPS (ms, TYPE ## _, TYPE ## _, TYPE ## _) \
610  OCTAVE_MS_INT_ASSIGNEQ_OPS (mse, TYPE ## _) \
611  OCTAVE_MS_INT_ASSIGN_OPS (mx, TYPE ## _, , ) \
612  OCTAVE_MS_INT_ASSIGN_OPS (mfx, TYPE ## _, float_, float_)
613 
614 #define OCTAVE_M_INT_UNOPS(TYPE) \
615  /* matrix unary ops. */ \
616  \
617  DEFNDUNOP_OP (m_not, TYPE ## _matrix, TYPE ## _array, !) \
618  DEFNDUNOP_OP (m_uplus, TYPE ## _matrix, TYPE ## _array, /* no-op */) \
619  DEFUNOP (m_uminus, TYPE ## _matrix) \
620  { \
621  CAST_UNOP_ARG (const octave_ ## TYPE ## _matrix &); \
622  octave_value retval = octave_value (- v. TYPE ## _array_value ()); \
623  return retval; \
624  } \
625  \
626  DEFUNOP (m_transpose, TYPE ## _matrix) \
627  { \
628  CAST_UNOP_ARG (const octave_ ## TYPE ## _matrix&); \
629  \
630  if (v.ndims () > 2) \
631  { \
632  error ("transpose not defined for N-d objects"); \
633  return octave_value (); \
634  } \
635  else \
636  return octave_value (v.TYPE ## _array_value ().transpose ()); \
637  } \
638  \
639  DEFNCUNOP_METHOD (m_incr, TYPE ## _matrix, increment) \
640  DEFNCUNOP_METHOD (m_decr, TYPE ## _matrix, decrement) \
641  DEFNCUNOP_METHOD (m_changesign, TYPE ## _matrix, changesign)
642 
643 #define OCTAVE_MM_INT_ARITH_OPS(PFX, T1, T2, T3) \
644  /* matrix by matrix ops. */ \
645  \
646  DEFINTNDBINOP_OP (PFX ## _add, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, +, T3) \
647  DEFINTNDBINOP_OP (PFX ## _sub, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, -, T3) \
648  \
649  /* DEFBINOP_OP (PFX ## _mul, T1 ## matrix, T2 ## matrix, *) */ \
650  /* DEFBINOP_FN (PFX ## _div, T1 ## matrix, T2 ## matrix, xdiv) */ \
651  \
652  DEFBINOPX (PFX ## _pow, T1 ## matrix, T2 ## matrix) \
653  { \
654  error ("can't do A ^ B for A and B both matrices"); \
655  return octave_value (); \
656  } \
657  \
658  /* DEFBINOP_FN (PFX ## _ldiv, T1 ## matrix, T2 ## matrix, xleftdiv) */ \
659  \
660  DEFINTNDBINOP_FN (PFX ## _el_mul, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, product, T3, .*) \
661  \
662  DEFINTNDBINOP_FN (PFX ## _el_div, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, quotient, T3, ./) \
663  \
664  DEFINTNDBINOP_FN (PFX ## _el_pow, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, elem_xpow, T3, .^) \
665  \
666  DEFBINOP (PFX ## _el_ldiv, T1 ## matrix, T2 ## matrix) \
667  { \
668  CAST_BINOP_ARGS (const octave_ ## T1 ## matrix&, const octave_ ## T2 ## matrix&); \
669  \
670  octave_value retval = octave_value (quotient (v2.T2 ## array_value (), v1.T1 ## array_value ())); \
671  return retval; \
672  }
673 
674 #define OCTAVE_MM_INT_CMP_OPS(PFX, T1, T2) \
675  DEFNDBINOP_FN (PFX ## _lt, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_lt) \
676  DEFNDBINOP_FN (PFX ## _le, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_le) \
677  DEFNDBINOP_FN (PFX ## _eq, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_eq) \
678  DEFNDBINOP_FN (PFX ## _ge, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_ge) \
679  DEFNDBINOP_FN (PFX ## _gt, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_gt) \
680  DEFNDBINOP_FN (PFX ## _ne, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_ne)
681 
682 #define OCTAVE_MM_INT_BOOL_OPS(PFX, T1, T2) \
683  DEFNDBINOP_FN (PFX ## _el_and, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_and) \
684  DEFNDBINOP_FN (PFX ## _el_or, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_or) \
685  DEFNDBINOP_FN (PFX ## _el_not_and, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_not_and) \
686  DEFNDBINOP_FN (PFX ## _el_not_or, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_not_or) \
687  DEFNDBINOP_FN (PFX ## _el_and_not, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_and_not) \
688  DEFNDBINOP_FN (PFX ## _el_or_not, T1 ## matrix, T2 ## matrix, T1 ## array, T2 ## array, mx_el_or_not)
689 
690 #define OCTAVE_MM_INT_ASSIGN_OPS(PFX, TLHS, TRHS, TE) \
691  DEFNDASSIGNOP_FN (PFX ## _assign, TLHS ## matrix, TRHS ## matrix, TLHS ## array, assign)
692 
693 #define OCTAVE_MM_INT_ASSIGNEQ_OPS(PFX, TM) \
694  DEFNDASSIGNOP_OP (PFX ## _assign_add, TM ## matrix, TM ## matrix, TM ## array, +=) \
695  DEFNDASSIGNOP_OP (PFX ## _assign_sub, TM ## matrix, TM ## matrix, TM ## array, -=) \
696  DEFNDASSIGNOP_FNOP (PFX ## _assign_el_mul, TM ## matrix, TM ## matrix, TM ## array, product_eq) \
697  DEFNDASSIGNOP_FNOP (PFX ## _assign_el_div, TM ## matrix, TM ## matrix, TM ## array, quotient_eq)
698 
699 #define OCTAVE_MM_POW_OPS(T1, T2) \
700  octave_value \
701  elem_xpow (const T1 ## NDArray& a, const T2 ## NDArray& b) \
702  { \
703  dim_vector a_dims = a.dims (); \
704  dim_vector b_dims = b.dims (); \
705  if (a_dims != b_dims) \
706  { \
707  if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \
708  { \
709  return bsxfun_pow (a, b); \
710  } \
711  else \
712  { \
713  gripe_nonconformant ("operator .^", a_dims, b_dims); \
714  return octave_value (); \
715  } \
716  } \
717  T1 ## NDArray result (a_dims); \
718  for (int i = 0; i < a.length (); i++) \
719  { \
720  OCTAVE_QUIT; \
721  result (i) = pow (a(i), b(i)); \
722  } \
723  return octave_value (result); \
724  } \
725 \
726  octave_value \
727  elem_xpow (const T1 ## NDArray& a, const NDArray& b) \
728  { \
729  dim_vector a_dims = a.dims (); \
730  dim_vector b_dims = b.dims (); \
731  if (a_dims != b_dims) \
732  { \
733  if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \
734  { \
735  return bsxfun_pow (a, b); \
736  } \
737  else \
738  { \
739  gripe_nonconformant ("operator .^", a_dims, b_dims); \
740  return octave_value (); \
741  } \
742  } \
743  T1 ## NDArray result (a_dims); \
744  for (int i = 0; i < a.length (); i++) \
745  { \
746  OCTAVE_QUIT; \
747  result (i) = pow (a(i), b(i)); \
748  } \
749  return octave_value (result); \
750  } \
751 \
752  octave_value \
753  elem_xpow (const NDArray& a, const T2 ## NDArray& b) \
754  { \
755  dim_vector a_dims = a.dims (); \
756  dim_vector b_dims = b.dims (); \
757  if (a_dims != b_dims) \
758  { \
759  if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \
760  { \
761  return bsxfun_pow (a, b); \
762  } \
763  else \
764  { \
765  gripe_nonconformant ("operator .^", a_dims, b_dims); \
766  return octave_value (); \
767  } \
768  } \
769  T2 ## NDArray result (a_dims); \
770  for (int i = 0; i < a.length (); i++) \
771  { \
772  OCTAVE_QUIT; \
773  result (i) = pow (a(i), b(i)); \
774  } \
775  return octave_value (result); \
776  } \
777 \
778  octave_value \
779  elem_xpow (const T1 ## NDArray& a, const FloatNDArray& b) \
780  { \
781  dim_vector a_dims = a.dims (); \
782  dim_vector b_dims = b.dims (); \
783  if (a_dims != b_dims) \
784  { \
785  if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \
786  { \
787  return bsxfun_pow (a, b); \
788  } \
789  else \
790  { \
791  gripe_nonconformant ("operator .^", a_dims, b_dims); \
792  return octave_value (); \
793  } \
794  } \
795  T1 ## NDArray result (a_dims); \
796  for (int i = 0; i < a.length (); i++) \
797  { \
798  OCTAVE_QUIT; \
799  result (i) = powf (a(i), b(i)); \
800  } \
801  return octave_value (result); \
802  } \
803 \
804  octave_value \
805  elem_xpow (const FloatNDArray& a, const T2 ## NDArray& b) \
806  { \
807  dim_vector a_dims = a.dims (); \
808  dim_vector b_dims = b.dims (); \
809  if (a_dims != b_dims) \
810  { \
811  if (is_valid_bsxfun ("operator .^", a_dims, b_dims)) \
812  { \
813  return bsxfun_pow (a, b); \
814  } \
815  else \
816  { \
817  gripe_nonconformant ("operator .^", a_dims, b_dims); \
818  return octave_value (); \
819  } \
820  } \
821  T2 ## NDArray result (a_dims); \
822  for (int i = 0; i < a.length (); i++) \
823  { \
824  OCTAVE_QUIT; \
825  result (i) = powf (a(i), b(i)); \
826  } \
827  return octave_value (result); \
828  }
829 
830 
831 #define OCTAVE_MM_CONV(T1, T2) \
832  DEFCONV (T1 ## m_ ## T2 ## m_conv, T1 ## matrix, T2 ## matrix) \
833  { \
834  CAST_CONV_ARG (const octave_ ## T1 ## matrix&); \
835  \
836  return new octave_ ## T2 ## matrix (v.T2 ## array_value ()); \
837  }
838 
839 #define OCTAVE_MM_INT_OPS(TYPE) \
840  OCTAVE_M_INT_UNOPS (TYPE) \
841  OCTAVE_MM_POW_OPS (TYPE, TYPE) \
842  OCTAVE_MM_INT_ARITH_OPS (mm, TYPE ## _, TYPE ## _, TYPE) \
843  OCTAVE_MM_INT_ARITH_OPS (mmx, TYPE ## _, , TYPE) \
844  OCTAVE_MM_INT_ARITH_OPS (mxm, , TYPE ## _, TYPE) \
845  OCTAVE_MM_INT_ARITH_OPS (mmfx, TYPE ## _, float_, TYPE) \
846  OCTAVE_MM_INT_ARITH_OPS (mfxm, float_, TYPE ## _, TYPE) \
847  OCTAVE_MM_INT_CMP_OPS (mm, TYPE ## _, TYPE ## _) \
848  OCTAVE_MM_INT_CMP_OPS (mmx, TYPE ## _, ) \
849  OCTAVE_MM_INT_CMP_OPS (mfxm, float_, TYPE ## _) \
850  OCTAVE_MM_INT_CMP_OPS (mmfx, TYPE ## _, float_) \
851  OCTAVE_MM_INT_CMP_OPS (mxm, , TYPE ## _) \
852  OCTAVE_MM_INT_BOOL_OPS (mm, TYPE ## _, TYPE ## _) \
853  OCTAVE_MM_INT_BOOL_OPS (mmx, TYPE ## _, ) \
854  OCTAVE_MM_INT_BOOL_OPS (mxm, , TYPE ## _) \
855  OCTAVE_MM_INT_BOOL_OPS (mmfx, TYPE ## _, float_) \
856  OCTAVE_MM_INT_BOOL_OPS (mfxm, float_, TYPE ## _) \
857  OCTAVE_MM_INT_ASSIGN_OPS (mm, TYPE ## _, TYPE ## _, TYPE ## _) \
858  OCTAVE_MM_INT_ASSIGNEQ_OPS (mme, TYPE ## _) \
859  OCTAVE_MM_INT_ASSIGN_OPS (mmx, TYPE ## _, , ) \
860  OCTAVE_MM_INT_ASSIGN_OPS (mmfx, TYPE ## _, float_, float_) \
861  OCTAVE_MM_CONV(TYPE ## _, complex_) \
862  OCTAVE_MM_CONV(TYPE ## _, float_complex_)
863 
864 #define OCTAVE_RE_INT_ASSIGN_OPS(TYPE) \
865  DEFNDASSIGNOP_FN (TYPE ## ms_assign, matrix, TYPE ## _scalar, array, assign) \
866  DEFNDASSIGNOP_FN (TYPE ## mm_assign, matrix, TYPE ## _matrix, array, assign)
867 
868 #define OCTAVE_FLT_RE_INT_ASSIGN_OPS(TYPE) \
869  DEFNDASSIGNOP_FN (TYPE ## fms_assign, float_matrix, TYPE ## _scalar, float_array, assign) \
870  DEFNDASSIGNOP_FN (TYPE ## fmm_assign, float_matrix, TYPE ## _matrix, float_array, assign)
871 
872 #define OCTAVE_CX_INT_ASSIGN_OPS(TYPE) \
873  DEFNDASSIGNOP_FN (TYPE ## cms_assign, complex_matrix, TYPE ## _scalar, complex_array, assign) \
874  DEFNDASSIGNOP_FN (TYPE ## cmm_assign, complex_matrix, TYPE ## _matrix, complex_array, assign)
875 
876 #define OCTAVE_FLT_CX_INT_ASSIGN_OPS(TYPE) \
877  DEFNDASSIGNOP_FN (TYPE ## fcms_assign, float_complex_matrix, TYPE ## _scalar, float_complex_array, assign) \
878  DEFNDASSIGNOP_FN (TYPE ## fcmm_assign, float_complex_matrix, TYPE ## _matrix, float_complex_array, assign)
879 
880 #define OCTAVE_INT_NULL_ASSIGN_OPS(TYPE) \
881  DEFNULLASSIGNOP_FN (TYPE ## null_assign, TYPE ## _matrix, delete_elements)
882 
883 #define OCTAVE_INT_OPS(TYPE) \
884  OCTAVE_SS_INT_OPS (TYPE) \
885  OCTAVE_SM_INT_OPS (TYPE) \
886  OCTAVE_MS_INT_OPS (TYPE) \
887  OCTAVE_MM_INT_OPS (TYPE) \
888  OCTAVE_CONCAT_FN (TYPE) \
889  OCTAVE_RE_INT_ASSIGN_OPS (TYPE) \
890  OCTAVE_FLT_RE_INT_ASSIGN_OPS (TYPE) \
891  OCTAVE_CX_INT_ASSIGN_OPS (TYPE) \
892  OCTAVE_FLT_CX_INT_ASSIGN_OPS (TYPE) \
893  OCTAVE_INT_NULL_ASSIGN_OPS(TYPE)
894 
895 #define OCTAVE_INSTALL_S_INT_UNOPS(TYPE) \
896  INSTALL_UNOP (op_not, octave_ ## TYPE ## _scalar, s_not); \
897  INSTALL_UNOP (op_uplus, octave_ ## TYPE ## _scalar, s_uplus); \
898  INSTALL_UNOP (op_uminus, octave_ ## TYPE ## _scalar, s_uminus); \
899  INSTALL_UNOP (op_transpose, octave_ ## TYPE ## _scalar, s_transpose); \
900  INSTALL_UNOP (op_hermitian, octave_ ## TYPE ## _scalar, s_hermitian); \
901  \
902  INSTALL_NCUNOP (op_incr, octave_ ## TYPE ## _scalar, s_incr); \
903  INSTALL_NCUNOP (op_decr, octave_ ## TYPE ## _scalar, s_decr);
904 
905 #define OCTAVE_INSTALL_SS_INT_ARITH_OPS(PFX, T1, T2) \
906  INSTALL_BINOP (op_add, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _add); \
907  INSTALL_BINOP (op_sub, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _sub); \
908  INSTALL_BINOP (op_mul, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _mul); \
909  INSTALL_BINOP (op_div, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _div); \
910  INSTALL_BINOP (op_pow, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _pow); \
911  INSTALL_BINOP (op_ldiv, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _ldiv); \
912  INSTALL_BINOP (op_el_mul, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _el_mul); \
913  INSTALL_BINOP (op_el_div, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _el_div); \
914  INSTALL_BINOP (op_el_pow, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _el_pow); \
915  INSTALL_BINOP (op_el_ldiv, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _el_ldiv);
916 
917 #define OCTAVE_INSTALL_SS_INT_CMP_OPS(PFX, T1, T2) \
918  INSTALL_BINOP (op_lt, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _lt); \
919  INSTALL_BINOP (op_le, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _le); \
920  INSTALL_BINOP (op_eq, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _eq); \
921  INSTALL_BINOP (op_ge, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _ge); \
922  INSTALL_BINOP (op_gt, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _gt); \
923  INSTALL_BINOP (op_ne, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _ne);
924 
925 #define OCTAVE_INSTALL_SS_INT_BOOL_OPS(PFX, T1, T2) \
926  INSTALL_BINOP (op_el_and, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _el_and); \
927  INSTALL_BINOP (op_el_or, octave_ ## T1 ## scalar, octave_ ## T2 ## scalar, PFX ## _el_or);
928 
929 #define OCTAVE_INSTALL_SS_INT_OPS(TYPE) \
930  OCTAVE_INSTALL_S_INT_UNOPS (TYPE) \
931  OCTAVE_INSTALL_SS_INT_ARITH_OPS (ss, TYPE ## _, TYPE ## _) \
932  OCTAVE_INSTALL_SS_INT_ARITH_OPS (ssx, TYPE ## _, ) \
933  OCTAVE_INSTALL_SS_INT_ARITH_OPS (sxs, , TYPE ## _) \
934  OCTAVE_INSTALL_SS_INT_ARITH_OPS (ssfx, TYPE ## _, float_) \
935  OCTAVE_INSTALL_SS_INT_ARITH_OPS (sfxs, float_, TYPE ## _) \
936  OCTAVE_INSTALL_SS_INT_CMP_OPS (ss, TYPE ## _, TYPE ## _) \
937  OCTAVE_INSTALL_SS_INT_CMP_OPS (sx, TYPE ## _, ) \
938  OCTAVE_INSTALL_SS_INT_CMP_OPS (xs, , TYPE ## _) \
939  OCTAVE_INSTALL_SS_INT_CMP_OPS (sfx, TYPE ## _, float_) \
940  OCTAVE_INSTALL_SS_INT_CMP_OPS (fxs, float_, TYPE ## _) \
941  OCTAVE_INSTALL_SS_INT_BOOL_OPS (ss, TYPE ## _, TYPE ## _) \
942  OCTAVE_INSTALL_SS_INT_BOOL_OPS (sx, TYPE ## _, ) \
943  OCTAVE_INSTALL_SS_INT_BOOL_OPS (xs, , TYPE ## _) \
944  OCTAVE_INSTALL_SS_INT_BOOL_OPS (sfx, TYPE ## _, float_) \
945  OCTAVE_INSTALL_SS_INT_BOOL_OPS (fxs, float_, TYPE ## _) \
946  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_ ## TYPE ## _scalar, octave_ ## TYPE ## _matrix) \
947  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_scalar, octave_ ## TYPE ## _matrix) \
948  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_float_scalar, octave_ ## TYPE ## _matrix) \
949  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_complex_scalar, octave_complex_matrix) \
950  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_float_complex_scalar, octave_float_complex_matrix)
951 
952 #define OCTAVE_INSTALL_SM_INT_ARITH_OPS(PFX, T1, T2) \
953  INSTALL_BINOP (op_add, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _add); \
954  INSTALL_BINOP (op_sub, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _sub); \
955  INSTALL_BINOP (op_mul, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _mul); \
956  /* INSTALL_BINOP (op_div, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _div); */ \
957  /* INSTALL_BINOP (op_pow, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _pow); */ \
958  INSTALL_BINOP (op_ldiv, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _ldiv); \
959  INSTALL_BINOP (op_el_mul, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _el_mul); \
960  INSTALL_BINOP (op_el_div, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _el_div); \
961  INSTALL_BINOP (op_el_pow, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _el_pow); \
962  INSTALL_BINOP (op_el_ldiv, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _el_ldiv);
963 
964 #define OCTAVE_INSTALL_SM_INT_CMP_OPS(PFX, T1, T2) \
965  INSTALL_BINOP (op_lt, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _lt); \
966  INSTALL_BINOP (op_le, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _le); \
967  INSTALL_BINOP (op_eq, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _eq); \
968  INSTALL_BINOP (op_ge, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _ge); \
969  INSTALL_BINOP (op_gt, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _gt); \
970  INSTALL_BINOP (op_ne, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _ne);
971 
972 #define OCTAVE_INSTALL_SM_INT_BOOL_OPS(PFX, T1, T2) \
973  INSTALL_BINOP (op_el_and, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _el_and); \
974  INSTALL_BINOP (op_el_or, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _el_or); \
975  INSTALL_BINOP (op_el_and_not, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _el_and_not); \
976  INSTALL_BINOP (op_el_or_not, octave_ ## T1 ## scalar, octave_ ## T2 ## matrix, PFX ## _el_or_not);
977 
978 #define OCTAVE_INSTALL_SM_INT_OPS(TYPE) \
979  OCTAVE_INSTALL_SM_INT_ARITH_OPS (sm, TYPE ## _, TYPE ## _) \
980  OCTAVE_INSTALL_SM_INT_ARITH_OPS (smx, TYPE ## _, ) \
981  OCTAVE_INSTALL_SM_INT_ARITH_OPS (sxm, , TYPE ## _) \
982  OCTAVE_INSTALL_SM_INT_ARITH_OPS (smfx, TYPE ## _, float_) \
983  OCTAVE_INSTALL_SM_INT_ARITH_OPS (sfxm, float_, TYPE ## _) \
984  OCTAVE_INSTALL_SM_INT_CMP_OPS (sm, TYPE ## _, TYPE ## _) \
985  OCTAVE_INSTALL_SM_INT_CMP_OPS (xm, , TYPE ## _) \
986  OCTAVE_INSTALL_SM_INT_CMP_OPS (smx, TYPE ## _, ) \
987  OCTAVE_INSTALL_SM_INT_CMP_OPS (fxm, float_, TYPE ## _) \
988  OCTAVE_INSTALL_SM_INT_CMP_OPS (smfx, TYPE ## _, float_) \
989  OCTAVE_INSTALL_SM_INT_BOOL_OPS (sm, TYPE ## _, TYPE ## _) \
990  OCTAVE_INSTALL_SM_INT_BOOL_OPS (xm, , TYPE ## _) \
991  OCTAVE_INSTALL_SM_INT_BOOL_OPS (smx, TYPE ## _, ) \
992  OCTAVE_INSTALL_SM_INT_BOOL_OPS (fxm, float_, TYPE ## _) \
993  OCTAVE_INSTALL_SM_INT_BOOL_OPS (smfx, TYPE ## _, float_) \
994  INSTALL_WIDENOP (octave_ ## TYPE ## _scalar, octave_ ## TYPE ## _matrix, TYPE ## _s_ ## TYPE ## _m_conv) \
995  INSTALL_WIDENOP (octave_ ## TYPE ## _scalar, octave_complex_matrix, TYPE ## _s_complex_m_conv) \
996  INSTALL_WIDENOP (octave_ ## TYPE ## _scalar, octave_float_complex_matrix, TYPE ## _s_float_complex_m_conv) \
997  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_ ## TYPE ## _matrix, octave_ ## TYPE ## _matrix) \
998  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_matrix, octave_ ## TYPE ## _matrix) \
999  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_float_matrix, octave_ ## TYPE ## _matrix) \
1000  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_complex_matrix, octave_complex_matrix) \
1001  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_float_complex_matrix, octave_float_complex_matrix)
1002 
1003 #define OCTAVE_INSTALL_MS_INT_ARITH_OPS(PFX, T1, T2) \
1004  INSTALL_BINOP (op_add, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _add); \
1005  INSTALL_BINOP (op_sub, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _sub); \
1006  INSTALL_BINOP (op_mul, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _mul); \
1007  INSTALL_BINOP (op_div, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _div); \
1008  /* INSTALL_BINOP (op_pow, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _pow); */ \
1009  /* INSTALL_BINOP (op_ldiv, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _ldiv); */ \
1010  \
1011  INSTALL_BINOP (op_el_mul, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _el_mul); \
1012  INSTALL_BINOP (op_el_div, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _el_div); \
1013  INSTALL_BINOP (op_el_pow, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _el_pow); \
1014  INSTALL_BINOP (op_el_ldiv, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _el_ldiv);
1015 
1016 #define OCTAVE_INSTALL_MS_INT_CMP_OPS(PFX, T1, T2) \
1017  INSTALL_BINOP (op_lt, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _lt); \
1018  INSTALL_BINOP (op_le, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _le); \
1019  INSTALL_BINOP (op_eq, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _eq); \
1020  INSTALL_BINOP (op_ge, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _ge); \
1021  INSTALL_BINOP (op_gt, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _gt); \
1022  INSTALL_BINOP (op_ne, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _ne);
1023 
1024 #define OCTAVE_INSTALL_MS_INT_BOOL_OPS(PFX, T1, T2) \
1025  INSTALL_BINOP (op_el_and, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _el_and); \
1026  INSTALL_BINOP (op_el_or, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _el_or); \
1027  INSTALL_BINOP (op_el_not_and, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _el_not_and); \
1028  INSTALL_BINOP (op_el_not_or, octave_ ## T1 ## matrix, octave_ ## T2 ## scalar, PFX ## _el_not_or);
1029 
1030 #define OCTAVE_INSTALL_MS_INT_ASSIGN_OPS(PFX, TLHS, TRHS) \
1031  INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## scalar, PFX ## _assign)
1032 
1033 #define OCTAVE_INSTALL_MS_INT_ASSIGNEQ_OPS(PFX, TLHS, TRHS) \
1034  INSTALL_ASSIGNOP (op_add_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## scalar, PFX ## _assign_add) \
1035  INSTALL_ASSIGNOP (op_sub_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## scalar, PFX ## _assign_sub) \
1036  INSTALL_ASSIGNOP (op_mul_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## scalar, PFX ## _assign_mul) \
1037  INSTALL_ASSIGNOP (op_div_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## scalar, PFX ## _assign_div)
1038 
1039 #define OCTAVE_INSTALL_MS_INT_OPS(TYPE) \
1040  OCTAVE_INSTALL_MS_INT_ARITH_OPS (ms, TYPE ## _, TYPE ## _) \
1041  OCTAVE_INSTALL_MS_INT_ARITH_OPS (msx, TYPE ## _, ) \
1042  OCTAVE_INSTALL_MS_INT_ARITH_OPS (mxs, , TYPE ## _) \
1043  OCTAVE_INSTALL_MS_INT_ARITH_OPS (msfx, TYPE ## _, float_) \
1044  OCTAVE_INSTALL_MS_INT_ARITH_OPS (mfxs, float_, TYPE ## _) \
1045  OCTAVE_INSTALL_MS_INT_CMP_OPS (ms, TYPE ## _, TYPE ## _) \
1046  OCTAVE_INSTALL_MS_INT_CMP_OPS (mx, TYPE ## _, ) \
1047  OCTAVE_INSTALL_MS_INT_CMP_OPS (mxs, , TYPE ## _) \
1048  OCTAVE_INSTALL_MS_INT_CMP_OPS (mfx, TYPE ## _, float_) \
1049  OCTAVE_INSTALL_MS_INT_CMP_OPS (mfxs, float_, TYPE ## _) \
1050  OCTAVE_INSTALL_MS_INT_BOOL_OPS (ms, TYPE ## _, TYPE ## _) \
1051  OCTAVE_INSTALL_MS_INT_BOOL_OPS (mx, TYPE ## _, ) \
1052  OCTAVE_INSTALL_MS_INT_BOOL_OPS (mxs, , TYPE ## _) \
1053  OCTAVE_INSTALL_MS_INT_BOOL_OPS (mfx, TYPE ## _, float_) \
1054  OCTAVE_INSTALL_MS_INT_BOOL_OPS (mfxs, float_, TYPE ## _) \
1055  OCTAVE_INSTALL_MS_INT_ASSIGN_OPS (ms, TYPE ## _, TYPE ## _) \
1056  OCTAVE_INSTALL_MS_INT_ASSIGNEQ_OPS (mse, TYPE ## _, TYPE ## _) \
1057  OCTAVE_INSTALL_MS_INT_ASSIGN_OPS (mx, TYPE ## _, ) \
1058  OCTAVE_INSTALL_MS_INT_ASSIGN_OPS (mfx, TYPE ## _, float_) \
1059  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _matrix, octave_complex_scalar, octave_complex_matrix) \
1060  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _matrix, octave_float_complex_scalar, octave_float_complex_matrix)
1061 
1062 #define OCTAVE_INSTALL_M_INT_UNOPS(TYPE) \
1063  INSTALL_UNOP (op_not, octave_ ## TYPE ## _matrix, m_not); \
1064  INSTALL_UNOP (op_uplus, octave_ ## TYPE ## _matrix, m_uplus); \
1065  INSTALL_UNOP (op_uminus, octave_ ## TYPE ## _matrix, m_uminus); \
1066  INSTALL_UNOP (op_transpose, octave_ ## TYPE ## _matrix, m_transpose); \
1067  INSTALL_UNOP (op_hermitian, octave_ ## TYPE ## _matrix, m_transpose); \
1068  \
1069  INSTALL_NCUNOP (op_incr, octave_ ## TYPE ## _matrix, m_incr); \
1070  INSTALL_NCUNOP (op_decr, octave_ ## TYPE ## _matrix, m_decr); \
1071  INSTALL_NCUNOP (op_uminus, octave_ ## TYPE ## _matrix, m_changesign);
1072 
1073 #define OCTAVE_INSTALL_MM_INT_ARITH_OPS(PFX, T1, T2) \
1074  INSTALL_BINOP (op_add, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _add); \
1075  INSTALL_BINOP (op_sub, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _sub); \
1076  /* INSTALL_BINOP (op_mul, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _mul); */ \
1077  /* INSTALL_BINOP (op_div, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _div); */ \
1078  INSTALL_BINOP (op_pow, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _pow); \
1079  /* INSTALL_BINOP (op_ldiv, octave_ ## T1 ## _matrix, octave_ ## T2 ## _matrix, mm_ldiv); */ \
1080  INSTALL_BINOP (op_el_mul, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_mul); \
1081  INSTALL_BINOP (op_el_div, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_div); \
1082  INSTALL_BINOP (op_el_pow, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_pow); \
1083  INSTALL_BINOP (op_el_ldiv, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_ldiv);
1084 
1085 #define OCTAVE_INSTALL_MM_INT_CMP_OPS(PFX, T1, T2) \
1086  INSTALL_BINOP (op_lt, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _lt); \
1087  INSTALL_BINOP (op_le, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _le); \
1088  INSTALL_BINOP (op_eq, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _eq); \
1089  INSTALL_BINOP (op_ge, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _ge); \
1090  INSTALL_BINOP (op_gt, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _gt); \
1091  INSTALL_BINOP (op_ne, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _ne);
1092 
1093 #define OCTAVE_INSTALL_MM_INT_BOOL_OPS(PFX, T1, T2) \
1094  INSTALL_BINOP (op_el_and, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_and); \
1095  INSTALL_BINOP (op_el_or, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_or); \
1096  INSTALL_BINOP (op_el_not_and, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_not_and); \
1097  INSTALL_BINOP (op_el_not_or, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_not_or); \
1098  INSTALL_BINOP (op_el_and_not, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_and_not); \
1099  INSTALL_BINOP (op_el_or_not, octave_ ## T1 ## matrix, octave_ ## T2 ## matrix, PFX ## _el_or_not);
1100 
1101 #define OCTAVE_INSTALL_MM_INT_ASSIGN_OPS(PFX, TLHS, TRHS) \
1102  INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## matrix, PFX ## _assign)
1103 
1104 #define OCTAVE_INSTALL_MM_INT_ASSIGNEQ_OPS(PFX, TLHS, TRHS) \
1105  INSTALL_ASSIGNOP (op_add_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## matrix, PFX ## _assign_add) \
1106  INSTALL_ASSIGNOP (op_sub_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## matrix, PFX ## _assign_sub) \
1107  INSTALL_ASSIGNOP (op_el_mul_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## matrix, PFX ## _assign_el_mul) \
1108  INSTALL_ASSIGNOP (op_el_div_eq, octave_ ## TLHS ## matrix, octave_ ## TRHS ## matrix, PFX ## _assign_el_div)
1109 
1110 #define OCTAVE_INSTALL_MM_INT_OPS(TYPE) \
1111  OCTAVE_INSTALL_M_INT_UNOPS (TYPE) \
1112  OCTAVE_INSTALL_MM_INT_ARITH_OPS (mm, TYPE ##_, TYPE ## _) \
1113  OCTAVE_INSTALL_MM_INT_ARITH_OPS (mmx, TYPE ##_, ) \
1114  OCTAVE_INSTALL_MM_INT_ARITH_OPS (mxm, , TYPE ##_) \
1115  OCTAVE_INSTALL_MM_INT_ARITH_OPS (mmfx, TYPE ##_, float_) \
1116  OCTAVE_INSTALL_MM_INT_ARITH_OPS (mfxm, float_, TYPE ##_) \
1117  OCTAVE_INSTALL_MM_INT_CMP_OPS (mm, TYPE ## _, TYPE ## _) \
1118  OCTAVE_INSTALL_MM_INT_CMP_OPS (mmx, TYPE ## _, ) \
1119  OCTAVE_INSTALL_MM_INT_CMP_OPS (mxm, , TYPE ## _) \
1120  OCTAVE_INSTALL_MM_INT_CMP_OPS (mmfx, TYPE ## _, float_) \
1121  OCTAVE_INSTALL_MM_INT_CMP_OPS (mfxm, float_, TYPE ## _) \
1122  OCTAVE_INSTALL_MM_INT_BOOL_OPS (mm, TYPE ## _, TYPE ## _) \
1123  OCTAVE_INSTALL_MM_INT_BOOL_OPS (mmx, TYPE ## _, ) \
1124  OCTAVE_INSTALL_MM_INT_BOOL_OPS (mxm, , TYPE ## _) \
1125  OCTAVE_INSTALL_MM_INT_BOOL_OPS (mmfx, TYPE ## _, float_) \
1126  OCTAVE_INSTALL_MM_INT_BOOL_OPS (mfxm, float_, TYPE ## _) \
1127  OCTAVE_INSTALL_MM_INT_ASSIGN_OPS (mm, TYPE ## _, TYPE ## _) \
1128  OCTAVE_INSTALL_MM_INT_ASSIGNEQ_OPS (mme, TYPE ## _, TYPE ## _) \
1129  OCTAVE_INSTALL_MM_INT_ASSIGN_OPS (mmx, TYPE ## _, ) \
1130  OCTAVE_INSTALL_MM_INT_ASSIGN_OPS (mmfx, TYPE ## _, float_) \
1131  INSTALL_WIDENOP (octave_ ## TYPE ## _matrix, octave_complex_matrix, TYPE ## _m_complex_m_conv) \
1132  INSTALL_WIDENOP (octave_ ## TYPE ## _matrix, octave_float_complex_matrix, TYPE ## _m_float_complex_m_conv) \
1133  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _matrix, octave_complex_matrix, octave_complex_matrix) \
1134  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _matrix, octave_float_complex_matrix, octave_float_complex_matrix)
1135 
1136 #define OCTAVE_INSTALL_RE_INT_ASSIGN_OPS(TYPE) \
1137  INSTALL_ASSIGNOP (op_asn_eq, octave_matrix, octave_ ## TYPE ## _scalar, TYPE ## ms_assign) \
1138  INSTALL_ASSIGNOP (op_asn_eq, octave_matrix, octave_ ## TYPE ## _matrix, TYPE ## mm_assign) \
1139  INSTALL_ASSIGNCONV (octave_scalar, octave_ ## TYPE ## _scalar, octave_matrix) \
1140  INSTALL_ASSIGNCONV (octave_matrix, octave_ ## TYPE ## _matrix, octave_matrix)
1141 
1142 #define OCTAVE_INSTALL_FLT_RE_INT_ASSIGN_OPS(TYPE) \
1143  INSTALL_ASSIGNOP (op_asn_eq, octave_float_matrix, octave_ ## TYPE ## _scalar, TYPE ## fms_assign) \
1144  INSTALL_ASSIGNOP (op_asn_eq, octave_float_matrix, octave_ ## TYPE ## _matrix, TYPE ## fmm_assign) \
1145  INSTALL_ASSIGNCONV (octave_float_scalar, octave_ ## TYPE ## _scalar, octave_float_matrix) \
1146  INSTALL_ASSIGNCONV (octave_float_matrix, octave_ ## TYPE ## _matrix, octave_float_matrix)
1147 
1148 #define OCTAVE_INSTALL_CX_INT_ASSIGN_OPS(TYPE) \
1149  INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_ ## TYPE ## _scalar, TYPE ## cms_assign) \
1150  INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_ ## TYPE ## _matrix, TYPE ## cmm_assign) \
1151  INSTALL_ASSIGNCONV (octave_complex_scalar, octave_ ## TYPE ## _scalar, octave_complex_matrix) \
1152  INSTALL_ASSIGNCONV (octave_complex_matrix, octave_ ## TYPE ## _matrix, octave_complex_matrix)
1153 
1154 #define OCTAVE_INSTALL_FLT_CX_INT_ASSIGN_OPS(TYPE) \
1155  INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix, octave_ ## TYPE ## _scalar, TYPE ## fcms_assign) \
1156  INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix, octave_ ## TYPE ## _matrix, TYPE ## fcmm_assign) \
1157  INSTALL_ASSIGNCONV (octave_float_complex_scalar, octave_ ## TYPE ## _scalar, octave_complex_matrix) \
1158  INSTALL_ASSIGNCONV (octave_float_complex_matrix, octave_ ## TYPE ## _matrix, octave_complex_matrix)
1159 
1160 #define OCTAVE_INSTALL_INT_NULL_ASSIGN_OPS(TYPE) \
1161  INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TYPE ## _matrix, octave_null_matrix, TYPE ## null_assign) \
1162  INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TYPE ## _matrix, octave_null_str, TYPE ## null_assign) \
1163  INSTALL_ASSIGNOP (op_asn_eq, octave_ ## TYPE ## _matrix, octave_null_sq_str, TYPE ## null_assign) \
1164  INSTALL_ASSIGNCONV (octave_ ## TYPE ## _scalar, octave_null_matrix, octave_ ## TYPE ## _matrix) \
1165  INSTALL_ASSIGNCONV (octave_## TYPE ## _scalar, octave_null_str, octave_ ## TYPE ## _matrix) \
1166  INSTALL_ASSIGNCONV (octave_## TYPE ## _scalar, octave_null_sq_str, octave_ ## TYPE ## _matrix)
1167 
1168 #define OCTAVE_INSTALL_INT_OPS(TYPE) \
1169  OCTAVE_INSTALL_SS_INT_OPS (TYPE) \
1170  OCTAVE_INSTALL_SM_INT_OPS (TYPE) \
1171  OCTAVE_INSTALL_MS_INT_OPS (TYPE) \
1172  OCTAVE_INSTALL_MM_INT_OPS (TYPE) \
1173  OCTAVE_INSTALL_CONCAT_FN (TYPE) \
1174  OCTAVE_INSTALL_RE_INT_ASSIGN_OPS (TYPE) \
1175  OCTAVE_INSTALL_FLT_RE_INT_ASSIGN_OPS (TYPE) \
1176  OCTAVE_INSTALL_CX_INT_ASSIGN_OPS (TYPE) \
1177  OCTAVE_INSTALL_FLT_CX_INT_ASSIGN_OPS (TYPE) \
1178  OCTAVE_INSTALL_INT_NULL_ASSIGN_OPS(TYPE)
1179 
1180 #define OCTAVE_INSTALL_SM_INT_ASSIGNCONV(TLHS, TRHS) \
1181  INSTALL_ASSIGNCONV (octave_ ## TLHS ## _scalar, octave_ ## TRHS ## _scalar, octave_ ## TLHS ## _matrix) \
1182  INSTALL_ASSIGNCONV (octave_ ## TLHS ## _scalar, octave_ ## TRHS ## _matrix, octave_ ## TLHS ## _matrix)
1183 
1184 #define OCTAVE_MIXED_INT_CMP_OPS(T1, T2) \
1185  OCTAVE_SS_INT_CMP_OPS (T1 ## _ ## T2 ## _ss, T1 ## _, T2 ## _) \
1186  OCTAVE_SM_INT_CMP_OPS (T1 ## _ ## T2 ## _sm, T1 ## _, T2 ## _) \
1187  OCTAVE_MS_INT_CMP_OPS (T1 ## _ ## T2 ## _ms, T1 ## _, T2 ## _) \
1188  OCTAVE_MM_INT_CMP_OPS (T1 ## _ ## T2 ## _mm, T1 ## _, T2 ## _)
1189 
1190 #define OCTAVE_INSTALL_MIXED_INT_CMP_OPS(T1, T2) \
1191  OCTAVE_INSTALL_SS_INT_CMP_OPS (T1 ## _ ## T2 ## _ss, T1 ## _, T2 ## _) \
1192  OCTAVE_INSTALL_SM_INT_CMP_OPS (T1 ## _ ## T2 ## _sm, T1 ## _, T2 ## _) \
1193  OCTAVE_INSTALL_MS_INT_CMP_OPS (T1 ## _ ## T2 ## _ms, T1 ## _, T2 ## _) \
1194  OCTAVE_INSTALL_MM_INT_CMP_OPS (T1 ## _ ## T2 ## _mm, T1 ## _, T2 ## _)