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
mx-op-decl.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 John W. Eaton
4 Copyright (C) 2008-2009 Jaroslav Hajek
5 Copyright (C) 2009 VZLU Prague, a.s.
6 
7 This file is part of Octave.
8 
9 Octave is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 3 of the License, or (at your
12 option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Octave; see the file COPYING. If not, see
21 <http://www.gnu.org/licenses/>.
22 
23 */
24 
25 #if !defined (octave_mx_op_decl_h)
26 #define octave_mx_op_decl_h 1
27 
28 #define BIN_OP_DECL(R, OP, X, Y, API) \
29  extern API R OP (const X&, const Y&)
30 
31 class boolMatrix;
32 class boolNDArray;
33 
34 #define CMP_OP_DECL(OP, X, Y, API) \
35  extern API boolMatrix OP (const X&, const Y&)
36 
37 #define NDCMP_OP_DECL(OP, X, Y, API) \
38  extern API boolNDArray OP (const X&, const Y&)
39 
40 #define BOOL_OP_DECL(OP, X, Y, API) \
41  extern API boolMatrix OP (const X&, const Y&)
42 
43 #define NDBOOL_OP_DECL(OP, X, Y, API) \
44  extern API boolNDArray OP (const X&, const Y&)
45 
46 // vector by scalar operations.
47 
48 #define VS_BIN_OP_DECLS(R, V, S, API) \
49  BIN_OP_DECL (R, operator +, V, S, API); \
50  BIN_OP_DECL (R, operator -, V, S, API); \
51  BIN_OP_DECL (R, operator *, V, S, API); \
52  BIN_OP_DECL (R, operator /, V, S, API);
53 
54 #define VS_OP_DECLS(R, V, S, API) \
55  VS_BIN_OP_DECLS(R, V, S, API)
56 
57 // scalar by vector by operations.
58 
59 #define SV_BIN_OP_DECLS(R, S, V, API) \
60  BIN_OP_DECL (R, operator +, S, V, API); \
61  BIN_OP_DECL (R, operator -, S, V, API); \
62  BIN_OP_DECL (R, operator *, S, V, API); \
63  BIN_OP_DECL (R, operator /, S, V, API);
64 
65 #define SV_OP_DECLS(R, S, V, API) \
66  SV_BIN_OP_DECLS(R, S, V, API)
67 
68 // vector by vector operations.
69 
70 #define VV_BIN_OP_DECLS(R, V1, V2, API) \
71  BIN_OP_DECL (R, operator +, V1, V2, API); \
72  BIN_OP_DECL (R, operator -, V1, V2, API); \
73  BIN_OP_DECL (R, product, V1, V2, API); \
74  BIN_OP_DECL (R, quotient, V1, V2, API);
75 
76 #define VV_OP_DECLS(R, V1, V2, API) \
77  VV_BIN_OP_DECLS(R, V1, V2, API)
78 
79 // matrix by scalar operations.
80 
81 #define MS_BIN_OP_DECLS(R, M, S, API) \
82  BIN_OP_DECL (R, operator +, M, S, API); \
83  BIN_OP_DECL (R, operator -, M, S, API); \
84  BIN_OP_DECL (R, operator *, M, S, API); \
85  BIN_OP_DECL (R, operator /, M, S, API);
86 
87 #define MS_CMP_OP_DECLS(M, S, API) \
88  CMP_OP_DECL (mx_el_lt, M, S, API); \
89  CMP_OP_DECL (mx_el_le, M, S, API); \
90  CMP_OP_DECL (mx_el_ge, M, S, API); \
91  CMP_OP_DECL (mx_el_gt, M, S, API); \
92  CMP_OP_DECL (mx_el_eq, M, S, API); \
93  CMP_OP_DECL (mx_el_ne, M, S, API);
94 
95 #define MS_BOOL_OP_DECLS(M, S, API) \
96  BOOL_OP_DECL (mx_el_and, M, S, API); \
97  BOOL_OP_DECL (mx_el_or, M, S, API); \
98 
99 #define MS_OP_DECLS(R, M, S, API) \
100  MS_BIN_OP_DECLS (R, M, S, API) \
101  MS_CMP_OP_DECLS (M, S, API) \
102  MS_BOOL_OP_DECLS (M, S, API) \
103 
104 // scalar by matrix operations.
105 
106 #define SM_BIN_OP_DECLS(R, S, M, API) \
107  BIN_OP_DECL (R, operator +, S, M, API); \
108  BIN_OP_DECL (R, operator -, S, M, API); \
109  BIN_OP_DECL (R, operator *, S, M, API); \
110  BIN_OP_DECL (R, operator /, S, M, API);
111 
112 #define SM_CMP_OP_DECLS(S, M, API) \
113  CMP_OP_DECL (mx_el_lt, S, M, API); \
114  CMP_OP_DECL (mx_el_le, S, M, API); \
115  CMP_OP_DECL (mx_el_ge, S, M, API); \
116  CMP_OP_DECL (mx_el_gt, S, M, API); \
117  CMP_OP_DECL (mx_el_eq, S, M, API); \
118  CMP_OP_DECL (mx_el_ne, S, M, API);
119 
120 #define SM_BOOL_OP_DECLS(S, M, API) \
121  BOOL_OP_DECL (mx_el_and, S, M, API); \
122  BOOL_OP_DECL (mx_el_or, S, M, API); \
123 
124 #define SM_OP_DECLS(R, S, M, API) \
125  SM_BIN_OP_DECLS (R, S, M, API) \
126  SM_CMP_OP_DECLS (S, M, API) \
127  SM_BOOL_OP_DECLS (S, M, API) \
128 
129 // matrix by matrix operations.
130 
131 #define MM_BIN_OP_DECLS(R, M1, M2, API) \
132  BIN_OP_DECL (R, operator +, M1, M2, API); \
133  BIN_OP_DECL (R, operator -, M1, M2, API); \
134  BIN_OP_DECL (R, product, M1, M2, API); \
135  BIN_OP_DECL (R, quotient, M1, M2, API);
136 
137 #define MM_CMP_OP_DECLS(M1, M2, API) \
138  CMP_OP_DECL (mx_el_lt, M1, M2, API); \
139  CMP_OP_DECL (mx_el_le, M1, M2, API); \
140  CMP_OP_DECL (mx_el_ge, M1, M2, API); \
141  CMP_OP_DECL (mx_el_gt, M1, M2, API); \
142  CMP_OP_DECL (mx_el_eq, M1, M2, API); \
143  CMP_OP_DECL (mx_el_ne, M1, M2, API);
144 
145 #define MM_BOOL_OP_DECLS(M1, M2, API) \
146  BOOL_OP_DECL (mx_el_and, M1, M2, API); \
147  BOOL_OP_DECL (mx_el_or, M1, M2, API);
148 
149 #define MM_OP_DECLS(R, M1, M2, API) \
150  MM_BIN_OP_DECLS (R, M1, M2, API) \
151  MM_CMP_OP_DECLS (M1, M2, API) \
152  MM_BOOL_OP_DECLS (M1, M2, API)
153 
154 // N-d matrix by scalar operations.
155 
156 #define NDS_BIN_OP_DECLS(R, ND, S, API) \
157  BIN_OP_DECL (R, operator +, ND, S, API); \
158  BIN_OP_DECL (R, operator -, ND, S, API); \
159  BIN_OP_DECL (R, operator *, ND, S, API); \
160  BIN_OP_DECL (R, operator /, ND, S, API);
161 
162 #define NDS_CMP_OP_DECLS(ND, S, API) \
163  NDCMP_OP_DECL (mx_el_lt, ND, S, API); \
164  NDCMP_OP_DECL (mx_el_le, ND, S, API); \
165  NDCMP_OP_DECL (mx_el_ge, ND, S, API); \
166  NDCMP_OP_DECL (mx_el_gt, ND, S, API); \
167  NDCMP_OP_DECL (mx_el_eq, ND, S, API); \
168  NDCMP_OP_DECL (mx_el_ne, ND, S, API);
169 
170 #define NDS_BOOL_OP_DECLS(ND, S, API) \
171  NDBOOL_OP_DECL (mx_el_and, ND, S, API); \
172  NDBOOL_OP_DECL (mx_el_or, ND, S, API); \
173  NDBOOL_OP_DECL (mx_el_not_and, ND, S, API); \
174  NDBOOL_OP_DECL (mx_el_not_or, ND, S, API);
175 
176 #define NDS_OP_DECLS(R, ND, S, API) \
177  NDS_BIN_OP_DECLS (R, ND, S, API) \
178  NDS_CMP_OP_DECLS (ND, S, API) \
179  NDS_BOOL_OP_DECLS (ND, S, API)
180 
181 // scalar by N-d matrix operations.
182 
183 #define SND_BIN_OP_DECLS(R, S, ND, API) \
184  BIN_OP_DECL (R, operator +, S, ND, API); \
185  BIN_OP_DECL (R, operator -, S, ND, API); \
186  BIN_OP_DECL (R, operator *, S, ND, API); \
187  BIN_OP_DECL (R, operator /, S, ND, API);
188 
189 #define SND_CMP_OP_DECLS(S, ND, API) \
190  NDCMP_OP_DECL (mx_el_lt, S, ND, API); \
191  NDCMP_OP_DECL (mx_el_le, S, ND, API); \
192  NDCMP_OP_DECL (mx_el_ge, S, ND, API); \
193  NDCMP_OP_DECL (mx_el_gt, S, ND, API); \
194  NDCMP_OP_DECL (mx_el_eq, S, ND, API); \
195  NDCMP_OP_DECL (mx_el_ne, S, ND, API);
196 
197 #define SND_BOOL_OP_DECLS(S, ND, API) \
198  NDBOOL_OP_DECL (mx_el_and, S, ND, API); \
199  NDBOOL_OP_DECL (mx_el_or, S, ND, API); \
200  NDBOOL_OP_DECL (mx_el_and_not, S, ND, API); \
201  NDBOOL_OP_DECL (mx_el_or_not, S, ND, API);
202 
203 #define SND_OP_DECLS(R, S, ND, API) \
204  SND_BIN_OP_DECLS (R, S, ND, API) \
205  SND_CMP_OP_DECLS (S, ND, API) \
206  SND_BOOL_OP_DECLS (S, ND, API)
207 
208 // N-d matrix by N-d matrix operations.
209 
210 #define NDND_BIN_OP_DECLS(R, ND1, ND2, API) \
211  BIN_OP_DECL (R, operator +, ND1, ND2, API); \
212  BIN_OP_DECL (R, operator -, ND1, ND2, API); \
213  BIN_OP_DECL (R, product, ND1, ND2, API); \
214  BIN_OP_DECL (R, quotient, ND1, ND2, API);
215 
216 #define NDND_CMP_OP_DECLS(ND1, ND2, API) \
217  NDCMP_OP_DECL (mx_el_lt, ND1, ND2, API); \
218  NDCMP_OP_DECL (mx_el_le, ND1, ND2, API); \
219  NDCMP_OP_DECL (mx_el_ge, ND1, ND2, API); \
220  NDCMP_OP_DECL (mx_el_gt, ND1, ND2, API); \
221  NDCMP_OP_DECL (mx_el_eq, ND1, ND2, API); \
222  NDCMP_OP_DECL (mx_el_ne, ND1, ND2, API);
223 
224 #define NDND_BOOL_OP_DECLS(ND1, ND2, API) \
225  NDBOOL_OP_DECL (mx_el_and, ND1, ND2, API); \
226  NDBOOL_OP_DECL (mx_el_or, ND1, ND2, API); \
227  NDBOOL_OP_DECL (mx_el_and_not, ND1, ND2, API); \
228  NDBOOL_OP_DECL (mx_el_or_not, ND1, ND2, API); \
229  NDBOOL_OP_DECL (mx_el_not_and, ND1, ND2, API); \
230  NDBOOL_OP_DECL (mx_el_not_or, ND1, ND2, API);
231 
232 #define NDND_OP_DECLS(R, ND1, ND2, API) \
233  NDND_BIN_OP_DECLS (R, ND1, ND2, API) \
234  NDND_CMP_OP_DECLS (ND1, ND2, API) \
235  NDND_BOOL_OP_DECLS (ND1, ND2, API)
236 
237 // scalar by diagonal matrix operations.
238 
239 #define SDM_BIN_OP_DECLS(R, S, DM, API) \
240  BIN_OP_DECL (R, operator *, S, DM, API); \
241 
242 #define SDM_OP_DECLS(R, S, DM, API) \
243  SDM_BIN_OP_DECLS(R, S, DM, API)
244 
245 // diagonal matrix by scalar operations.
246 
247 #define DMS_BIN_OP_DECLS(R, DM, S, API) \
248  BIN_OP_DECL (R, operator *, DM, S, API); \
249  BIN_OP_DECL (R, operator /, DM, S, API);
250 
251 #define DMS_OP_DECLS(R, DM, S, API) \
252  DMS_BIN_OP_DECLS(R, DM, S, API)
253 
254 // matrix by diagonal matrix operations.
255 
256 #define MDM_BIN_OP_DECLS(R, M, DM, API) \
257  BIN_OP_DECL (R, operator +, M, DM, API); \
258  BIN_OP_DECL (R, operator -, M, DM, API); \
259  BIN_OP_DECL (R, operator *, M, DM, API);
260 
261 #define MDM_OP_DECLS(R, M, DM, API) \
262  MDM_BIN_OP_DECLS(R, M, DM, API)
263 
264 // diagonal matrix by matrix operations.
265 
266 #define DMM_BIN_OP_DECLS(R, DM, M, API) \
267  BIN_OP_DECL (R, operator +, DM, M, API); \
268  BIN_OP_DECL (R, operator -, DM, M, API); \
269  BIN_OP_DECL (R, operator *, DM, M, API);
270 
271 #define DMM_OP_DECLS(R, DM, M, API) \
272  DMM_BIN_OP_DECLS(R, DM, M, API)
273 
274 // diagonal matrix by diagonal matrix operations.
275 
276 #define DMDM_BIN_OP_DECLS(R, DM1, DM2, API) \
277  BIN_OP_DECL (R, operator +, DM1, DM2, API); \
278  BIN_OP_DECL (R, operator -, DM1, DM2, API); \
279  BIN_OP_DECL (R, product, DM1, DM2, API);
280 
281 #define DMDM_OP_DECLS(R, DM1, DM2, API) \
282  DMDM_BIN_OP_DECLS (R, DM1, DM2, API)
283 
284 // scalar by N-d array min/max ops
285 
286 #define MINMAX_DECLS(T, S, API) \
287  extern API T min (S d, const T& m); \
288  extern API T min (const T& m, S d); \
289  extern API T min (const T& a, const T& b); \
290  extern API T max (S d, const T& m); \
291  extern API T max (const T& m, S d); \
292  extern API T max (const T& a, const T& b);
293 
294 // permutation matrix by matrix ops and vice versa
295 
296 #define PMM_BIN_OP_DECLS(R, PM, M, API) \
297  BIN_OP_DECL (R, operator *, PM, M, API);
298 
299 #define MPM_BIN_OP_DECLS(R, M, PM, API) \
300  BIN_OP_DECL (R, operator *, M, PM, API);
301 
302 #endif
303