comparison liboctave/Sparse-op-defs.h @ 6708:0ce71beb1cf3

[project @ 2007-06-13 06:40:48 by jwe]
author jwe
date Wed, 13 Jun 2007 06:40:49 +0000
parents 7e958a1532c6
children 93c65f2a5668
comparison
equal deleted inserted replaced
6707:b7e71f0fc805 6708:0ce71beb1cf3
24 #define octave_sparse_op_defs_h 1 24 #define octave_sparse_op_defs_h 1
25 25
26 #include "Array-util.h" 26 #include "Array-util.h"
27 #include "mx-ops.h" 27 #include "mx-ops.h"
28 28
29 #define SPARSE_BIN_OP_DECL(R, OP, X, Y) \ 29 #define SPARSE_BIN_OP_DECL(R, OP, X, Y, API) \
30 extern OCTAVE_API R OP (const X&, const Y&) 30 extern API R OP (const X&, const Y&)
31 31
32 #define SPARSE_CMP_OP_DECL(OP, X, Y) \ 32 #define SPARSE_CMP_OP_DECL(OP, X, Y, API) \
33 extern OCTAVE_API SparseBoolMatrix OP (const X&, const Y&) 33 extern API SparseBoolMatrix OP (const X&, const Y&)
34 34
35 #define SPARSE_BOOL_OP_DECL(OP, X, Y) \ 35 #define SPARSE_BOOL_OP_DECL(OP, X, Y, API) \
36 extern OCTAVE_API SparseBoolMatrix OP (const X&, const Y&) 36 extern API SparseBoolMatrix OP (const X&, const Y&)
37 37
38 // matrix by scalar operations. 38 // matrix by scalar operations.
39 39
40 #define SPARSE_SMS_BIN_OP_DECLS(R1, R2, M, S) \ 40 #define SPARSE_SMS_BIN_OP_DECLS(R1, R2, M, S, API) \
41 SPARSE_BIN_OP_DECL (R1, operator +, M, S); \ 41 SPARSE_BIN_OP_DECL (R1, operator +, M, S, API); \
42 SPARSE_BIN_OP_DECL (R1, operator -, M, S); \ 42 SPARSE_BIN_OP_DECL (R1, operator -, M, S, API); \
43 SPARSE_BIN_OP_DECL (R2, operator *, M, S); \ 43 SPARSE_BIN_OP_DECL (R2, operator *, M, S, API); \
44 SPARSE_BIN_OP_DECL (R2, operator /, M, S); 44 SPARSE_BIN_OP_DECL (R2, operator /, M, S, API);
45 45
46 #define SPARSE_SMS_BIN_OP_1(R, F, OP, M, S) \ 46 #define SPARSE_SMS_BIN_OP_1(R, F, OP, M, S) \
47 R \ 47 R \
48 F (const M& m, const S& s) \ 48 F (const M& m, const S& s) \
49 { \ 49 { \
84 SPARSE_SMS_BIN_OP_1 (R1, operator +, +, M, S) \ 84 SPARSE_SMS_BIN_OP_1 (R1, operator +, +, M, S) \
85 SPARSE_SMS_BIN_OP_1 (R1, operator -, -, M, S) \ 85 SPARSE_SMS_BIN_OP_1 (R1, operator -, -, M, S) \
86 SPARSE_SMS_BIN_OP_2 (R2, operator *, *, M, S) \ 86 SPARSE_SMS_BIN_OP_2 (R2, operator *, *, M, S) \
87 SPARSE_SMS_BIN_OP_2 (R2, operator /, /, M, S) 87 SPARSE_SMS_BIN_OP_2 (R2, operator /, /, M, S)
88 88
89 #define SPARSE_SMS_CMP_OP_DECLS(M, S) \ 89 #define SPARSE_SMS_CMP_OP_DECLS(M, S, API) \
90 SPARSE_CMP_OP_DECL (mx_el_lt, M, S); \ 90 SPARSE_CMP_OP_DECL (mx_el_lt, M, S, API); \
91 SPARSE_CMP_OP_DECL (mx_el_le, M, S); \ 91 SPARSE_CMP_OP_DECL (mx_el_le, M, S, API); \
92 SPARSE_CMP_OP_DECL (mx_el_ge, M, S); \ 92 SPARSE_CMP_OP_DECL (mx_el_ge, M, S, API); \
93 SPARSE_CMP_OP_DECL (mx_el_gt, M, S); \ 93 SPARSE_CMP_OP_DECL (mx_el_gt, M, S, API); \
94 SPARSE_CMP_OP_DECL (mx_el_eq, M, S); \ 94 SPARSE_CMP_OP_DECL (mx_el_eq, M, S, API); \
95 SPARSE_CMP_OP_DECL (mx_el_ne, M, S); 95 SPARSE_CMP_OP_DECL (mx_el_ne, M, S, API);
96 96
97 #define SPARSE_SMS_EQNE_OP_DECLS(M, S) \ 97 #define SPARSE_SMS_EQNE_OP_DECLS(M, S, API) \
98 SPARSE_CMP_OP_DECL (mx_el_eq, M, S); \ 98 SPARSE_CMP_OP_DECL (mx_el_eq, M, S, API); \
99 SPARSE_CMP_OP_DECL (mx_el_ne, M, S); 99 SPARSE_CMP_OP_DECL (mx_el_ne, M, S, API);
100 100
101 #define SPARSE_SMS_CMP_OP(F, OP, M, MZ, MC, S, SZ, SC) \ 101 #define SPARSE_SMS_CMP_OP(F, OP, M, MZ, MC, S, SZ, SC) \
102 SparseBoolMatrix \ 102 SparseBoolMatrix \
103 F (const M& m, const S& s) \ 103 F (const M& m, const S& s) \
104 { \ 104 { \
167 167
168 #define SPARSE_SMS_EQNE_OPS(M, MZ, CM, S, SZ, CS) \ 168 #define SPARSE_SMS_EQNE_OPS(M, MZ, CM, S, SZ, CS) \
169 SPARSE_SMS_CMP_OP (mx_el_eq, ==, M, MZ, , S, SZ, ) \ 169 SPARSE_SMS_CMP_OP (mx_el_eq, ==, M, MZ, , S, SZ, ) \
170 SPARSE_SMS_CMP_OP (mx_el_ne, !=, M, MZ, , S, SZ, ) 170 SPARSE_SMS_CMP_OP (mx_el_ne, !=, M, MZ, , S, SZ, )
171 171
172 #define SPARSE_SMS_BOOL_OP_DECLS(M, S) \ 172 #define SPARSE_SMS_BOOL_OP_DECLS(M, S, API) \
173 SPARSE_BOOL_OP_DECL (mx_el_and, M, S); \ 173 SPARSE_BOOL_OP_DECL (mx_el_and, M, S, API); \
174 SPARSE_BOOL_OP_DECL (mx_el_or, M, S); 174 SPARSE_BOOL_OP_DECL (mx_el_or, M, S, API);
175 175
176 #define SPARSE_SMS_BOOL_OP(F, OP, M, S, LHS_ZERO, RHS_ZERO) \ 176 #define SPARSE_SMS_BOOL_OP(F, OP, M, S, LHS_ZERO, RHS_ZERO) \
177 SparseBoolMatrix \ 177 SparseBoolMatrix \
178 F (const M& m, const S& s) \ 178 F (const M& m, const S& s) \
179 { \ 179 { \
237 SPARSE_SMS_BOOL_OP (mx_el_or, ||, M, S, LHS_ZERO, RHS_ZERO) 237 SPARSE_SMS_BOOL_OP (mx_el_or, ||, M, S, LHS_ZERO, RHS_ZERO)
238 238
239 #define SPARSE_SMS_BOOL_OPS(M, S, ZERO) \ 239 #define SPARSE_SMS_BOOL_OPS(M, S, ZERO) \
240 SPARSE_SMS_BOOL_OPS2(M, S, ZERO, ZERO) 240 SPARSE_SMS_BOOL_OPS2(M, S, ZERO, ZERO)
241 241
242 #define SPARSE_SMS_OP_DECLS(R1, R2, M, S) \ 242 #define SPARSE_SMS_OP_DECLS(R1, R2, M, S, API) \
243 SPARSE_SMS_BIN_OP_DECLS (R1, R2, M, S) \ 243 SPARSE_SMS_BIN_OP_DECLS (R1, R2, M, S, API) \
244 SPARSE_SMS_CMP_OP_DECLS (M, S) \ 244 SPARSE_SMS_CMP_OP_DECLS (M, S, API) \
245 SPARSE_SMS_BOOL_OP_DECLS (M, S) 245 SPARSE_SMS_BOOL_OP_DECLS (M, S, API)
246 246
247 // scalar by matrix operations. 247 // scalar by matrix operations.
248 248
249 #define SPARSE_SSM_BIN_OP_DECLS(R1, R2, S, M) \ 249 #define SPARSE_SSM_BIN_OP_DECLS(R1, R2, S, M, API) \
250 SPARSE_BIN_OP_DECL (R1, operator +, S, M); \ 250 SPARSE_BIN_OP_DECL (R1, operator +, S, M, API); \
251 SPARSE_BIN_OP_DECL (R1, operator -, S, M); \ 251 SPARSE_BIN_OP_DECL (R1, operator -, S, M, API); \
252 SPARSE_BIN_OP_DECL (R2, operator *, S, M); \ 252 SPARSE_BIN_OP_DECL (R2, operator *, S, M, API); \
253 SPARSE_BIN_OP_DECL (R2, operator /, S, M); 253 SPARSE_BIN_OP_DECL (R2, operator /, S, M, API);
254 254
255 #define SPARSE_SSM_BIN_OP_1(R, F, OP, S, M) \ 255 #define SPARSE_SSM_BIN_OP_1(R, F, OP, S, M) \
256 R \ 256 R \
257 F (const S& s, const M& m) \ 257 F (const S& s, const M& m) \
258 { \ 258 { \
294 SPARSE_SSM_BIN_OP_1 (R1, operator +, +, S, M) \ 294 SPARSE_SSM_BIN_OP_1 (R1, operator +, +, S, M) \
295 SPARSE_SSM_BIN_OP_1 (R1, operator -, -, S, M) \ 295 SPARSE_SSM_BIN_OP_1 (R1, operator -, -, S, M) \
296 SPARSE_SSM_BIN_OP_2 (R2, operator *, *, S, M) \ 296 SPARSE_SSM_BIN_OP_2 (R2, operator *, *, S, M) \
297 SPARSE_SSM_BIN_OP_2 (R2, operator /, /, S, M) 297 SPARSE_SSM_BIN_OP_2 (R2, operator /, /, S, M)
298 298
299 #define SPARSE_SSM_CMP_OP_DECLS(S, M) \ 299 #define SPARSE_SSM_CMP_OP_DECLS(S, M, API) \
300 SPARSE_CMP_OP_DECL (mx_el_lt, S, M); \ 300 SPARSE_CMP_OP_DECL (mx_el_lt, S, M, API); \
301 SPARSE_CMP_OP_DECL (mx_el_le, S, M); \ 301 SPARSE_CMP_OP_DECL (mx_el_le, S, M, API); \
302 SPARSE_CMP_OP_DECL (mx_el_ge, S, M); \ 302 SPARSE_CMP_OP_DECL (mx_el_ge, S, M, API); \
303 SPARSE_CMP_OP_DECL (mx_el_gt, S, M); \ 303 SPARSE_CMP_OP_DECL (mx_el_gt, S, M, API); \
304 SPARSE_CMP_OP_DECL (mx_el_eq, S, M); \ 304 SPARSE_CMP_OP_DECL (mx_el_eq, S, M, API); \
305 SPARSE_CMP_OP_DECL (mx_el_ne, S, M); 305 SPARSE_CMP_OP_DECL (mx_el_ne, S, M, API);
306 306
307 #define SPARSE_SSM_EQNE_OP_DECLS(S, M) \ 307 #define SPARSE_SSM_EQNE_OP_DECLS(S, M, API) \
308 SPARSE_CMP_OP_DECL (mx_el_eq, S, M); \ 308 SPARSE_CMP_OP_DECL (mx_el_eq, S, M, API); \
309 SPARSE_CMP_OP_DECL (mx_el_ne, S, M); 309 SPARSE_CMP_OP_DECL (mx_el_ne, S, M, API);
310 310
311 #define SPARSE_SSM_CMP_OP(F, OP, S, SZ, SC, M, MZ, MC) \ 311 #define SPARSE_SSM_CMP_OP(F, OP, S, SZ, SC, M, MZ, MC) \
312 SparseBoolMatrix \ 312 SparseBoolMatrix \
313 F (const S& s, const M& m) \ 313 F (const S& s, const M& m) \
314 { \ 314 { \
377 377
378 #define SPARSE_SSM_EQNE_OPS(S, SZ, SC, M, MZ, MC) \ 378 #define SPARSE_SSM_EQNE_OPS(S, SZ, SC, M, MZ, MC) \
379 SPARSE_SSM_CMP_OP (mx_el_eq, ==, S, SZ, , M, MZ, ) \ 379 SPARSE_SSM_CMP_OP (mx_el_eq, ==, S, SZ, , M, MZ, ) \
380 SPARSE_SSM_CMP_OP (mx_el_ne, !=, S, SZ, , M, MZ, ) 380 SPARSE_SSM_CMP_OP (mx_el_ne, !=, S, SZ, , M, MZ, )
381 381
382 #define SPARSE_SSM_BOOL_OP_DECLS(S, M) \ 382 #define SPARSE_SSM_BOOL_OP_DECLS(S, M, API) \
383 SPARSE_BOOL_OP_DECL (mx_el_and, S, M); \ 383 SPARSE_BOOL_OP_DECL (mx_el_and, S, M, API); \
384 SPARSE_BOOL_OP_DECL (mx_el_or, S, M); \ 384 SPARSE_BOOL_OP_DECL (mx_el_or, S, M, API); \
385 385
386 #define SPARSE_SSM_BOOL_OP(F, OP, S, M, LHS_ZERO, RHS_ZERO) \ 386 #define SPARSE_SSM_BOOL_OP(F, OP, S, M, LHS_ZERO, RHS_ZERO) \
387 SparseBoolMatrix \ 387 SparseBoolMatrix \
388 F (const S& s, const M& m) \ 388 F (const S& s, const M& m) \
389 { \ 389 { \
447 SPARSE_SSM_BOOL_OP (mx_el_or, ||, S, M, LHS_ZERO, RHS_ZERO) 447 SPARSE_SSM_BOOL_OP (mx_el_or, ||, S, M, LHS_ZERO, RHS_ZERO)
448 448
449 #define SPARSE_SSM_BOOL_OPS(S, M, ZERO) \ 449 #define SPARSE_SSM_BOOL_OPS(S, M, ZERO) \
450 SPARSE_SSM_BOOL_OPS2(S, M, ZERO, ZERO) 450 SPARSE_SSM_BOOL_OPS2(S, M, ZERO, ZERO)
451 451
452 #define SPARSE_SSM_OP_DECLS(R1, R2, S, M) \ 452 #define SPARSE_SSM_OP_DECLS(R1, R2, S, M, API) \
453 SPARSE_SSM_BIN_OP_DECLS (R1, R2, S, M) \ 453 SPARSE_SSM_BIN_OP_DECLS (R1, R2, S, M, API) \
454 SPARSE_SSM_CMP_OP_DECLS (S, M) \ 454 SPARSE_SSM_CMP_OP_DECLS (S, M, API) \
455 SPARSE_SSM_BOOL_OP_DECLS (S, M) \ 455 SPARSE_SSM_BOOL_OP_DECLS (S, M, API) \
456 456
457 // matrix by matrix operations. 457 // matrix by matrix operations.
458 458
459 #define SPARSE_SMSM_BIN_OP_DECLS(R1, R2, M1, M2) \ 459 #define SPARSE_SMSM_BIN_OP_DECLS(R1, R2, M1, M2, API) \
460 SPARSE_BIN_OP_DECL (R1, operator +, M1, M2); \ 460 SPARSE_BIN_OP_DECL (R1, operator +, M1, M2, API); \
461 SPARSE_BIN_OP_DECL (R1, operator -, M1, M2); \ 461 SPARSE_BIN_OP_DECL (R1, operator -, M1, M2, API); \
462 SPARSE_BIN_OP_DECL (R2, product, M1, M2); \ 462 SPARSE_BIN_OP_DECL (R2, product, M1, M2, API); \
463 SPARSE_BIN_OP_DECL (R2, quotient, M1, M2); 463 SPARSE_BIN_OP_DECL (R2, quotient, M1, M2, API);
464 464
465 #define SPARSE_SMSM_BIN_OP_1(R, F, OP, M1, M2) \ 465 #define SPARSE_SMSM_BIN_OP_1(R, F, OP, M1, M2) \
466 R \ 466 R \
467 F (const M1& m1, const M2& m2) \ 467 F (const M1& m1, const M2& m2) \
468 { \ 468 { \
801 SPARSE_SMSM_BIN_OP_1 (R1, operator +, +, M1, M2) \ 801 SPARSE_SMSM_BIN_OP_1 (R1, operator +, +, M1, M2) \
802 SPARSE_SMSM_BIN_OP_1 (R1, operator -, -, M1, M2) \ 802 SPARSE_SMSM_BIN_OP_1 (R1, operator -, -, M1, M2) \
803 SPARSE_SMSM_BIN_OP_2 (R2, product, *, M1, M2) \ 803 SPARSE_SMSM_BIN_OP_2 (R2, product, *, M1, M2) \
804 SPARSE_SMSM_BIN_OP_3 (R2, quotient, /, M1, M2) 804 SPARSE_SMSM_BIN_OP_3 (R2, quotient, /, M1, M2)
805 805
806 #define SPARSE_SMSM_CMP_OP_DECLS(M1, M2) \ 806 #define SPARSE_SMSM_CMP_OP_DECLS(M1, M2, API) \
807 SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2); \ 807 SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2, API); \
808 SPARSE_CMP_OP_DECL (mx_el_le, M1, M2); \ 808 SPARSE_CMP_OP_DECL (mx_el_le, M1, M2, API); \
809 SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2); \ 809 SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2, API); \
810 SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2); \ 810 SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2, API); \
811 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2); \ 811 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
812 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2); 812 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
813 813
814 #define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2) \ 814 #define SPARSE_SMSM_EQNE_OP_DECLS(M1, M2, API) \
815 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2); \ 815 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
816 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2); 816 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
817 817
818 #define SPARSE_SMSM_CMP_OP(F, OP, M1, C1, M2, C2) \ 818 #define SPARSE_SMSM_CMP_OP(F, OP, M1, C1, M2, C2) \
819 SparseBoolMatrix \ 819 SparseBoolMatrix \
820 F (const M1& m1, const M2& m2) \ 820 F (const M1& m1, const M2& m2) \
821 { \ 821 { \
887 887
888 #define SPARSE_SMSM_EQNE_OPS(M1, Z1, C1, M2, Z2, C2) \ 888 #define SPARSE_SMSM_EQNE_OPS(M1, Z1, C1, M2, Z2, C2) \
889 SPARSE_SMSM_CMP_OP (mx_el_eq, ==, M1, , M2, ) \ 889 SPARSE_SMSM_CMP_OP (mx_el_eq, ==, M1, , M2, ) \
890 SPARSE_SMSM_CMP_OP (mx_el_ne, !=, M1, , M2, ) 890 SPARSE_SMSM_CMP_OP (mx_el_ne, !=, M1, , M2, )
891 891
892 #define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2) \ 892 #define SPARSE_SMSM_BOOL_OP_DECLS(M1, M2, API) \
893 SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2); \ 893 SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \
894 SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2); 894 SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API);
895 895
896 #define SPARSE_SMSM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \ 896 #define SPARSE_SMSM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \
897 SparseBoolMatrix \ 897 SparseBoolMatrix \
898 F (const M1& m1, const M2& m2) \ 898 F (const M1& m1, const M2& m2) \
899 { \ 899 { \
962 SPARSE_SMSM_BOOL_OP (mx_el_or, ||, M1, M2, LHS_ZERO, RHS_ZERO) \ 962 SPARSE_SMSM_BOOL_OP (mx_el_or, ||, M1, M2, LHS_ZERO, RHS_ZERO) \
963 963
964 #define SPARSE_SMSM_BOOL_OPS(M1, M2, ZERO) \ 964 #define SPARSE_SMSM_BOOL_OPS(M1, M2, ZERO) \
965 SPARSE_SMSM_BOOL_OPS2(M1, M2, ZERO, ZERO) 965 SPARSE_SMSM_BOOL_OPS2(M1, M2, ZERO, ZERO)
966 966
967 #define SPARSE_SMSM_OP_DECLS(R1, R2, M1, M2) \ 967 #define SPARSE_SMSM_OP_DECLS(R1, R2, M1, M2, API) \
968 SPARSE_SMSM_BIN_OP_DECLS (R1, R2, M1, M2) \ 968 SPARSE_SMSM_BIN_OP_DECLS (R1, R2, M1, M2, API) \
969 SPARSE_SMSM_CMP_OP_DECLS (M1, M2) \ 969 SPARSE_SMSM_CMP_OP_DECLS (M1, M2, API) \
970 SPARSE_SMSM_BOOL_OP_DECLS (M1, M2) 970 SPARSE_SMSM_BOOL_OP_DECLS (M1, M2, API)
971 971
972 // matrix by matrix operations. 972 // matrix by matrix operations.
973 973
974 #define SPARSE_MSM_BIN_OP_DECLS(R1, R2, M1, M2) \ 974 #define SPARSE_MSM_BIN_OP_DECLS(R1, R2, M1, M2, API) \
975 SPARSE_BIN_OP_DECL (R1, operator +, M1, M2); \ 975 SPARSE_BIN_OP_DECL (R1, operator +, M1, M2, API); \
976 SPARSE_BIN_OP_DECL (R1, operator -, M1, M2); \ 976 SPARSE_BIN_OP_DECL (R1, operator -, M1, M2, API); \
977 SPARSE_BIN_OP_DECL (R2, product, M1, M2); \ 977 SPARSE_BIN_OP_DECL (R2, product, M1, M2, API); \
978 SPARSE_BIN_OP_DECL (R2, quotient, M1, M2); 978 SPARSE_BIN_OP_DECL (R2, quotient, M1, M2, API);
979 979
980 #define SPARSE_MSM_BIN_OP_1(R, F, OP, M1, M2) \ 980 #define SPARSE_MSM_BIN_OP_1(R, F, OP, M1, M2) \
981 R \ 981 R \
982 F (const M1& m1, const M2& m2) \ 982 F (const M1& m1, const M2& m2) \
983 { \ 983 { \
1055 SPARSE_MSM_BIN_OP_1 (R1, operator +, +, M1, M2) \ 1055 SPARSE_MSM_BIN_OP_1 (R1, operator +, +, M1, M2) \
1056 SPARSE_MSM_BIN_OP_1 (R1, operator -, -, M1, M2) \ 1056 SPARSE_MSM_BIN_OP_1 (R1, operator -, -, M1, M2) \
1057 SPARSE_MSM_BIN_OP_2 (R2, product, *, M1, M2, 0.0) \ 1057 SPARSE_MSM_BIN_OP_2 (R2, product, *, M1, M2, 0.0) \
1058 SPARSE_MSM_BIN_OP_2 (R2, quotient, /, M1, M2, 0.0) 1058 SPARSE_MSM_BIN_OP_2 (R2, quotient, /, M1, M2, 0.0)
1059 1059
1060 #define SPARSE_MSM_CMP_OP_DECLS(M1, M2) \ 1060 #define SPARSE_MSM_CMP_OP_DECLS(M1, M2, API) \
1061 SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2); \ 1061 SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2, API); \
1062 SPARSE_CMP_OP_DECL (mx_el_le, M1, M2); \ 1062 SPARSE_CMP_OP_DECL (mx_el_le, M1, M2, API); \
1063 SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2); \ 1063 SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2, API); \
1064 SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2); \ 1064 SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2, API); \
1065 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2); \ 1065 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
1066 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2); 1066 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
1067 1067
1068 #define SPARSE_MSM_EQNE_OP_DECLS(M1, M2) \ 1068 #define SPARSE_MSM_EQNE_OP_DECLS(M1, M2, API) \
1069 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2); \ 1069 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
1070 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2); 1070 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
1071 1071
1072 #define SPARSE_MSM_CMP_OP(F, OP, M1, C1, M2, C2) \ 1072 #define SPARSE_MSM_CMP_OP(F, OP, M1, C1, M2, C2) \
1073 SparseBoolMatrix \ 1073 SparseBoolMatrix \
1074 F (const M1& m1, const M2& m2) \ 1074 F (const M1& m1, const M2& m2) \
1075 { \ 1075 { \
1131 1131
1132 #define SPARSE_MSM_EQNE_OPS(M1, Z1, C1, M2, Z2, C2) \ 1132 #define SPARSE_MSM_EQNE_OPS(M1, Z1, C1, M2, Z2, C2) \
1133 SPARSE_MSM_CMP_OP (mx_el_eq, ==, M1, , M2, ) \ 1133 SPARSE_MSM_CMP_OP (mx_el_eq, ==, M1, , M2, ) \
1134 SPARSE_MSM_CMP_OP (mx_el_ne, !=, M1, , M2, ) 1134 SPARSE_MSM_CMP_OP (mx_el_ne, !=, M1, , M2, )
1135 1135
1136 #define SPARSE_MSM_BOOL_OP_DECLS(M1, M2) \ 1136 #define SPARSE_MSM_BOOL_OP_DECLS(M1, M2, API) \
1137 SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2); \ 1137 SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \
1138 SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2); 1138 SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API);
1139 1139
1140 #define SPARSE_MSM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \ 1140 #define SPARSE_MSM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \
1141 SparseBoolMatrix \ 1141 SparseBoolMatrix \
1142 F (const M1& m1, const M2& m2) \ 1142 F (const M1& m1, const M2& m2) \
1143 { \ 1143 { \
1196 SPARSE_MSM_BOOL_OP (mx_el_or, ||, M1, M2, LHS_ZERO, RHS_ZERO) \ 1196 SPARSE_MSM_BOOL_OP (mx_el_or, ||, M1, M2, LHS_ZERO, RHS_ZERO) \
1197 1197
1198 #define SPARSE_MSM_BOOL_OPS(M1, M2, ZERO) \ 1198 #define SPARSE_MSM_BOOL_OPS(M1, M2, ZERO) \
1199 SPARSE_MSM_BOOL_OPS2(M1, M2, ZERO, ZERO) 1199 SPARSE_MSM_BOOL_OPS2(M1, M2, ZERO, ZERO)
1200 1200
1201 #define SPARSE_MSM_OP_DECLS(R1, R2, M1, M2) \ 1201 #define SPARSE_MSM_OP_DECLS(R1, R2, M1, M2, API) \
1202 SPARSE_MSM_BIN_OP_DECLS (R1, R2, M1, M2) \ 1202 SPARSE_MSM_BIN_OP_DECLS (R1, R2, M1, M2, API) \
1203 SPARSE_MSM_CMP_OP_DECLS (M1, M2) \ 1203 SPARSE_MSM_CMP_OP_DECLS (M1, M2, API) \
1204 SPARSE_MSM_BOOL_OP_DECLS (M1, M2) 1204 SPARSE_MSM_BOOL_OP_DECLS (M1, M2, API)
1205 1205
1206 // matrix by matrix operations. 1206 // matrix by matrix operations.
1207 1207
1208 #define SPARSE_SMM_BIN_OP_DECLS(R1, R2, M1, M2) \ 1208 #define SPARSE_SMM_BIN_OP_DECLS(R1, R2, M1, M2, API) \
1209 SPARSE_BIN_OP_DECL (R1, operator +, M1, M2); \ 1209 SPARSE_BIN_OP_DECL (R1, operator +, M1, M2, API); \
1210 SPARSE_BIN_OP_DECL (R1, operator -, M1, M2); \ 1210 SPARSE_BIN_OP_DECL (R1, operator -, M1, M2, API); \
1211 SPARSE_BIN_OP_DECL (R2, product, M1, M2); \ 1211 SPARSE_BIN_OP_DECL (R2, product, M1, M2, API); \
1212 SPARSE_BIN_OP_DECL (R2, quotient, M1, M2); 1212 SPARSE_BIN_OP_DECL (R2, quotient, M1, M2, API);
1213 1213
1214 #define SPARSE_SMM_BIN_OP_1(R, F, OP, M1, M2) \ 1214 #define SPARSE_SMM_BIN_OP_1(R, F, OP, M1, M2) \
1215 R \ 1215 R \
1216 F (const M1& m1, const M2& m2) \ 1216 F (const M1& m1, const M2& m2) \
1217 { \ 1217 { \
1289 SPARSE_SMM_BIN_OP_1 (R1, operator +, +, M1, M2) \ 1289 SPARSE_SMM_BIN_OP_1 (R1, operator +, +, M1, M2) \
1290 SPARSE_SMM_BIN_OP_1 (R1, operator -, -, M1, M2) \ 1290 SPARSE_SMM_BIN_OP_1 (R1, operator -, -, M1, M2) \
1291 SPARSE_SMM_BIN_OP_2 (R2, product, *, M1, M2, 0.0) \ 1291 SPARSE_SMM_BIN_OP_2 (R2, product, *, M1, M2, 0.0) \
1292 SPARSE_SMM_BIN_OP_2 (R2, quotient, /, M1, M2, 0.0) 1292 SPARSE_SMM_BIN_OP_2 (R2, quotient, /, M1, M2, 0.0)
1293 1293
1294 #define SPARSE_SMM_CMP_OP_DECLS(M1, M2) \ 1294 #define SPARSE_SMM_CMP_OP_DECLS(M1, M2, API) \
1295 SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2); \ 1295 SPARSE_CMP_OP_DECL (mx_el_lt, M1, M2, API); \
1296 SPARSE_CMP_OP_DECL (mx_el_le, M1, M2); \ 1296 SPARSE_CMP_OP_DECL (mx_el_le, M1, M2, API); \
1297 SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2); \ 1297 SPARSE_CMP_OP_DECL (mx_el_ge, M1, M2, API); \
1298 SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2); \ 1298 SPARSE_CMP_OP_DECL (mx_el_gt, M1, M2, API); \
1299 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2); \ 1299 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
1300 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2); 1300 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
1301 1301
1302 #define SPARSE_SMM_EQNE_OP_DECLS(M1, M2) \ 1302 #define SPARSE_SMM_EQNE_OP_DECLS(M1, M2, API) \
1303 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2); \ 1303 SPARSE_CMP_OP_DECL (mx_el_eq, M1, M2, API); \
1304 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2); 1304 SPARSE_CMP_OP_DECL (mx_el_ne, M1, M2, API);
1305 1305
1306 #define SPARSE_SMM_CMP_OP(F, OP, M1, C1, M2, C2) \ 1306 #define SPARSE_SMM_CMP_OP(F, OP, M1, C1, M2, C2) \
1307 SparseBoolMatrix \ 1307 SparseBoolMatrix \
1308 F (const M1& m1, const M2& m2) \ 1308 F (const M1& m1, const M2& m2) \
1309 { \ 1309 { \
1365 1365
1366 #define SPARSE_SMM_EQNE_OPS(M1, Z1, C1, M2, Z2, C2) \ 1366 #define SPARSE_SMM_EQNE_OPS(M1, Z1, C1, M2, Z2, C2) \
1367 SPARSE_SMM_CMP_OP (mx_el_eq, ==, M1, , M2, ) \ 1367 SPARSE_SMM_CMP_OP (mx_el_eq, ==, M1, , M2, ) \
1368 SPARSE_SMM_CMP_OP (mx_el_ne, !=, M1, , M2, ) 1368 SPARSE_SMM_CMP_OP (mx_el_ne, !=, M1, , M2, )
1369 1369
1370 #define SPARSE_SMM_BOOL_OP_DECLS(M1, M2) \ 1370 #define SPARSE_SMM_BOOL_OP_DECLS(M1, M2, API) \
1371 SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2); \ 1371 SPARSE_BOOL_OP_DECL (mx_el_and, M1, M2, API); \
1372 SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2); 1372 SPARSE_BOOL_OP_DECL (mx_el_or, M1, M2, API);
1373 1373
1374 #define SPARSE_SMM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \ 1374 #define SPARSE_SMM_BOOL_OP(F, OP, M1, M2, LHS_ZERO, RHS_ZERO) \
1375 SparseBoolMatrix \ 1375 SparseBoolMatrix \
1376 F (const M1& m1, const M2& m2) \ 1376 F (const M1& m1, const M2& m2) \
1377 { \ 1377 { \
1430 SPARSE_SMM_BOOL_OP (mx_el_or, ||, M1, M2, LHS_ZERO, RHS_ZERO) \ 1430 SPARSE_SMM_BOOL_OP (mx_el_or, ||, M1, M2, LHS_ZERO, RHS_ZERO) \
1431 1431
1432 #define SPARSE_SMM_BOOL_OPS(M1, M2, ZERO) \ 1432 #define SPARSE_SMM_BOOL_OPS(M1, M2, ZERO) \
1433 SPARSE_SMM_BOOL_OPS2(M1, M2, ZERO, ZERO) 1433 SPARSE_SMM_BOOL_OPS2(M1, M2, ZERO, ZERO)
1434 1434
1435 #define SPARSE_SMM_OP_DECLS(R1, R2, M1, M2) \ 1435 #define SPARSE_SMM_OP_DECLS(R1, R2, M1, M2, API) \
1436 SPARSE_SMM_BIN_OP_DECLS (R1, R2, M1, M2) \ 1436 SPARSE_SMM_BIN_OP_DECLS (R1, R2, M1, M2, API) \
1437 SPARSE_SMM_CMP_OP_DECLS (M1, M2) \ 1437 SPARSE_SMM_CMP_OP_DECLS (M1, M2, API) \
1438 SPARSE_SMM_BOOL_OP_DECLS (M1, M2) 1438 SPARSE_SMM_BOOL_OP_DECLS (M1, M2, API)
1439 1439
1440 // Avoid some code duplication. Maybe we should use templates. 1440 // Avoid some code duplication. Maybe we should use templates.
1441 1441
1442 #define SPARSE_CUMSUM(RET_TYPE, ELT_TYPE, FCN) \ 1442 #define SPARSE_CUMSUM(RET_TYPE, ELT_TYPE, FCN) \
1443 \ 1443 \