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