GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Sparse-op-decls.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-2018 David Bateman
4 Copyright (C) 1998-2004 Andy Adler
5 Copyright (C) 2008 Jaroslav Hajek
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
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Octave is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License 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 <https://www.gnu.org/licenses/>.
22 
23 */
24 
25 #if ! defined (octave_Sparse_op_decls_h)
26 #define octave_Sparse_op_decls_h 1
27 
28 #include "octave-config.h"
29 
30 class SparseBoolMatrix;
31 
32 #define SPARSE_BIN_OP_DECL(R, OP, X, Y, API) \
33  extern API R OP (const X&, const Y&)
34 
35 #define SPARSE_CMP_OP_DECL(OP, X, Y, API) \
36  extern API SparseBoolMatrix OP (const X&, const Y&)
37 
38 #define SPARSE_BOOL_OP_DECL(OP, X, Y, API) \
39  extern API SparseBoolMatrix OP (const X&, const Y&)
40 
41 // sparse matrix by scalar operations.
42 
43 #define SPARSE_SMS_BIN_OP_DECLS(R1, R2, M, S, API) \
44  SPARSE_BIN_OP_DECL (R1, operator +, M, S, API); \
45  SPARSE_BIN_OP_DECL (R1, operator -, M, S, API); \
46  SPARSE_BIN_OP_DECL (R2, operator *, M, S, API); \
47  SPARSE_BIN_OP_DECL (R2, operator /, M, S, API);
48 
49 #define SPARSE_SMS_CMP_OP_DECLS(M, S, API) \
50  SPARSE_CMP_OP_DECL (mx_el_lt, M, S, API); \
51  SPARSE_CMP_OP_DECL (mx_el_le, M, S, API); \
52  SPARSE_CMP_OP_DECL (mx_el_ge, M, S, API); \
53  SPARSE_CMP_OP_DECL (mx_el_gt, M, S, API); \
54  SPARSE_CMP_OP_DECL (mx_el_eq, M, S, API); \
55  SPARSE_CMP_OP_DECL (mx_el_ne, M, S, API);
56 
57 #define SPARSE_SMS_EQNE_OP_DECLS(M, S, API) \
58  SPARSE_CMP_OP_DECL (mx_el_eq, M, S, API); \
59  SPARSE_CMP_OP_DECL (mx_el_ne, M, S, API);
60 
61 #define SPARSE_SMS_BOOL_OP_DECLS(M, S, API) \
62  SPARSE_BOOL_OP_DECL (mx_el_and, M, S, API); \
63  SPARSE_BOOL_OP_DECL (mx_el_or, M, S, API);
64 
65 #define SPARSE_SMS_OP_DECLS(R1, R2, M, S, API) \
66  SPARSE_SMS_BIN_OP_DECLS (R1, R2, M, S, API) \
67  SPARSE_SMS_CMP_OP_DECLS (M, S, API) \
68  SPARSE_SMS_BOOL_OP_DECLS (M, S, API)
69 
70 // scalar by sparse matrix operations.
71 
72 #define SPARSE_SSM_BIN_OP_DECLS(R1, R2, S, M, API) \
73  SPARSE_BIN_OP_DECL (R1, operator +, S, M, API); \
74  SPARSE_BIN_OP_DECL (R1, operator -, S, M, API); \
75  SPARSE_BIN_OP_DECL (R2, operator *, S, M, API); \
76  SPARSE_BIN_OP_DECL (R2, operator /, S, M, API);
77 
78 #define SPARSE_SSM_CMP_OP_DECLS(S, M, API) \
79  SPARSE_CMP_OP_DECL (mx_el_lt, S, M, API); \
80  SPARSE_CMP_OP_DECL (mx_el_le, S, M, API); \
81  SPARSE_CMP_OP_DECL (mx_el_ge, S, M, API); \
82  SPARSE_CMP_OP_DECL (mx_el_gt, S, M, API); \
83  SPARSE_CMP_OP_DECL (mx_el_eq, S, M, API); \
84  SPARSE_CMP_OP_DECL (mx_el_ne, S, M, API);
85 
86 #define SPARSE_SSM_EQNE_OP_DECLS(S, M, API) \
87  SPARSE_CMP_OP_DECL (mx_el_eq, S, M, API); \
88  SPARSE_CMP_OP_DECL (mx_el_ne, S, M, API);
89 
90 #define SPARSE_SSM_BOOL_OP_DECLS(S, M, API) \
91  SPARSE_BOOL_OP_DECL (mx_el_and, S, M, API); \
92  SPARSE_BOOL_OP_DECL (mx_el_or, S, M, API); \
93 
94 #define SPARSE_SSM_OP_DECLS(R1, R2, S, M, API) \
95  SPARSE_SSM_BIN_OP_DECLS (R1, R2, S, M, API) \
96  SPARSE_SSM_CMP_OP_DECLS (S, M, API) \
97  SPARSE_SSM_BOOL_OP_DECLS (S, M, API) \
98 
99 // sparse matrix by sparse matrix operations.
100 
101 #define SPARSE_SMSM_BIN_OP_DECLS(R1, R2, M1, M2, API) \
102  SPARSE_BIN_OP_DECL (R1, operator +, M1, M2, API); \
103  SPARSE_BIN_OP_DECL (R1, operator -, M1, M2, API); \
104  SPARSE_BIN_OP_DECL (R2, product, M1, M2, API); \
105  SPARSE_BIN_OP_DECL (R2, quotient, M1, M2, API);
106 
107 #define SPARSE_SMSM_CMP_OP_DECLS(M1, M2, API) \
108  SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2, API); \
109  SPARSE_CMP_OP_DECL (mx_el_le, M1, M2, API); \
110  SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2, API); \
111  SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2, API); \
112  SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
113  SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
114 
115 #define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2, API) \
116  SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
117  SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
118 
119 #define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2, API) \
120  SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \
121  SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API);
122 
123 #define SPARSE_SMSM_OP_DECLS(R1, R2, M1, M2, API) \
124  SPARSE_SMSM_BIN_OP_DECLS (R1, R2, M1, M2, API) \
125  SPARSE_SMSM_CMP_OP_DECLS (M1, M2, API) \
126  SPARSE_SMSM_BOOL_OP_DECLS (M1, M2, API)
127 
128 // matrix by sparse matrix operations.
129 
130 #define SPARSE_MSM_BIN_OP_DECLS(R1, R2, M1, M2, API) \
131  SPARSE_BIN_OP_DECL (R1, operator +, M1, M2, API); \
132  SPARSE_BIN_OP_DECL (R1, operator -, M1, M2, API); \
133  SPARSE_BIN_OP_DECL (R2, product, M1, M2, API); \
134  SPARSE_BIN_OP_DECL (R2, quotient, M1, M2, API);
135 
136 #define SPARSE_MSM_CMP_OP_DECLS(M1, M2, API) \
137  SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2, API); \
138  SPARSE_CMP_OP_DECL (mx_el_le, M1, M2, API); \
139  SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2, API); \
140  SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2, API); \
141  SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
142  SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
143 
144 #define SPARSE_MSM_EQNE_OP_DECLS(M1, M2, API) \
145  SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
146  SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
147 
148 #define SPARSE_MSM_BOOL_OP_DECLS(M1, M2, API) \
149  SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \
150  SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API);
151 
152 #define SPARSE_MSM_OP_DECLS(R1, R2, M1, M2, API) \
153  SPARSE_MSM_BIN_OP_DECLS (R1, R2, M1, M2, API) \
154  SPARSE_MSM_CMP_OP_DECLS (M1, M2, API) \
155  SPARSE_MSM_BOOL_OP_DECLS (M1, M2, API)
156 
157 // sparse matrix by matrix operations.
158 
159 #define SPARSE_SMM_BIN_OP_DECLS(R1, R2, M1, M2, API) \
160  SPARSE_BIN_OP_DECL (R1, operator +, M1, M2, API); \
161  SPARSE_BIN_OP_DECL (R1, operator -, M1, M2, API); \
162  SPARSE_BIN_OP_DECL (R2, product, M1, M2, API); \
163  SPARSE_BIN_OP_DECL (R2, quotient, M1, M2, API);
164 
165 #define SPARSE_SMM_CMP_OP_DECLS(M1, M2, API) \
166  SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2, API); \
167  SPARSE_CMP_OP_DECL (mx_el_le, M1, M2, API); \
168  SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2, API); \
169  SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2, API); \
170  SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
171  SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
172 
173 #define SPARSE_SMM_EQNE_OP_DECLS(M1, M2, API) \
174  SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
175  SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
176 
177 #define SPARSE_SMM_BOOL_OP_DECLS(M1, M2, API) \
178  SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \
179  SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API);
180 
181 #define SPARSE_SMM_OP_DECLS(R1, R2, M1, M2, API) \
182  SPARSE_SMM_BIN_OP_DECLS (R1, R2, M1, M2, API) \
183  SPARSE_SMM_CMP_OP_DECLS (M1, M2, API) \
184  SPARSE_SMM_BOOL_OP_DECLS (M1, M2, API)
185 
186 #endif