Mercurial > hg > octave-nkf
comparison liboctave/MSparse-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 | 143b556ce725 |
children | 93c65f2a5668 |
comparison
equal
deleted
inserted
replaced
6707:b7e71f0fc805 | 6708:0ce71beb1cf3 |
---|---|
24 #define octave_MSparse_defs_h 1 | 24 #define octave_MSparse_defs_h 1 |
25 | 25 |
26 // Nothing like a little CPP abuse to brighten everyone's day. | 26 // Nothing like a little CPP abuse to brighten everyone's day. |
27 | 27 |
28 // A macro that can be used to declare and instantiate OP= operators. | 28 // A macro that can be used to declare and instantiate OP= operators. |
29 #define SPARSE_OP_ASSIGN_DECL(A_T, E_T, OP, PFX, LTGT, RHS_T) \ | 29 #define SPARSE_OP_ASSIGN_DECL(A_T, E_T, OP, PFX, API, LTGT, RHS_T) \ |
30 PFX A_T<E_T>& \ | 30 PFX API A_T<E_T>& \ |
31 operator OP LTGT (A_T<E_T>&, const RHS_T&) | 31 operator OP LTGT (A_T<E_T>&, const RHS_T&) |
32 | 32 |
33 // All the OP= operators that we care about. | 33 // All the OP= operators that we care about. |
34 #define SPARSE_OP_ASSIGN_DECLS(A_T, E_T, PFX, LTGT, RHS_T) \ | 34 #define SPARSE_OP_ASSIGN_DECLS(A_T, E_T, PFX, API, LTGT, RHS_T) \ |
35 SPARSE_OP_ASSIGN_DECL (A_T, E_T, +=, PFX, LTGT, RHS_T); \ | 35 SPARSE_OP_ASSIGN_DECL (A_T, E_T, +=, PFX, API, LTGT, RHS_T); \ |
36 SPARSE_OP_ASSIGN_DECL (A_T, E_T, -=, PFX, LTGT, RHS_T); | 36 SPARSE_OP_ASSIGN_DECL (A_T, E_T, -=, PFX, API, LTGT, RHS_T); |
37 | 37 |
38 // Generate forward declarations for OP= operators. | 38 // Generate forward declarations for OP= operators. |
39 #define SPARSE_OP_ASSIGN_FWD_DECLS(A_T, RHS_T) \ | 39 #define SPARSE_OP_ASSIGN_FWD_DECLS(A_T, RHS_T, API) \ |
40 SPARSE_OP_ASSIGN_DECLS (A_T, T, template <typename T>, , RHS_T) | 40 SPARSE_OP_ASSIGN_DECLS (A_T, T, template <typename T>, API, , RHS_T) |
41 | 41 |
42 // Generate friend declarations for the OP= operators. | 42 // Generate friend declarations for the OP= operators. |
43 #define SPARSE_OP_ASSIGN_FRIENDS(A_T, RHS_T) \ | 43 #define SPARSE_OP_ASSIGN_FRIENDS(A_T, RHS_T, API) \ |
44 SPARSE_OP_ASSIGN_DECLS (A_T, T, friend, <>, RHS_T) | 44 SPARSE_OP_ASSIGN_DECLS (A_T, T, friend, API, <>, RHS_T) |
45 | 45 |
46 // Instantiate the OP= operators. | 46 // Instantiate the OP= operators. |
47 #define SPARSE_OP_ASSIGN_DEFS(A_T, E_T, RHS_T) \ | 47 #define SPARSE_OP_ASSIGN_DEFS(A_T, E_T, RHS_T, API) \ |
48 SPARSE_OP_ASSIGN_DECLS (A_T, E_T, template OCTAVE_API, , RHS_T) | 48 SPARSE_OP_ASSIGN_DECLS (A_T, E_T, template, API, , RHS_T) |
49 | 49 |
50 // A function that can be used to forward OP= operations from derived | 50 // A function that can be used to forward OP= operations from derived |
51 // classes back to us. | 51 // classes back to us. |
52 #define SPARSE_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \ | 52 #define SPARSE_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \ |
53 inline R \ | 53 inline R \ |
60 #define SPARSE_OP_ASSIGN_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ | 60 #define SPARSE_OP_ASSIGN_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \ |
61 SPARSE_OP_ASSIGN_FWD_FCN (R, operator +=, T, C_X, X_T, C_Y, Y_T) \ | 61 SPARSE_OP_ASSIGN_FWD_FCN (R, operator +=, T, C_X, X_T, C_Y, Y_T) \ |
62 SPARSE_OP_ASSIGN_FWD_FCN (R, operator -=, T, C_X, X_T, C_Y, Y_T) | 62 SPARSE_OP_ASSIGN_FWD_FCN (R, operator -=, T, C_X, X_T, C_Y, Y_T) |
63 | 63 |
64 // A macro that can be used to declare and instantiate unary operators. | 64 // A macro that can be used to declare and instantiate unary operators. |
65 #define SPARSE_UNOP(A_T, E_T, F, PFX, LTGT) \ | 65 #define SPARSE_UNOP(A_T, E_T, F, PFX, API, LTGT) \ |
66 PFX A_T<E_T> \ | 66 PFX API A_T<E_T> \ |
67 F LTGT (const A_T<E_T>&) | 67 F LTGT (const A_T<E_T>&) |
68 | 68 |
69 // All the unary operators that we care about. | 69 // All the unary operators that we care about. |
70 #define SPARSE_UNOP_DECLS(A_T, E_T, PFX, LTGT) \ | 70 #define SPARSE_UNOP_DECLS(A_T, E_T, PFX, API, LTGT) \ |
71 SPARSE_UNOP (A_T, E_T, operator +, PFX, LTGT); \ | 71 SPARSE_UNOP (A_T, E_T, operator +, PFX, API, LTGT); \ |
72 SPARSE_UNOP (A_T, E_T, operator -, PFX, LTGT); | 72 SPARSE_UNOP (A_T, E_T, operator -, PFX, API, LTGT); |
73 | 73 |
74 // Generate forward declarations for unary operators. | 74 // Generate forward declarations for unary operators. |
75 #define SPARSE_UNOP_FWD_DECLS(A_T) \ | 75 #define SPARSE_UNOP_FWD_DECLS(A_T, API) \ |
76 SPARSE_UNOP_DECLS (A_T, T, template <typename T>, ) | 76 SPARSE_UNOP_DECLS (A_T, T, template <typename T>, API, ) |
77 | 77 |
78 // Generate friend declarations for the unary operators. | 78 // Generate friend declarations for the unary operators. |
79 #define SPARSE_UNOP_FRIENDS(A_T) \ | 79 #define SPARSE_UNOP_FRIENDS(A_T, API) \ |
80 SPARSE_UNOP_DECLS (A_T, T, friend, <>) | 80 SPARSE_UNOP_DECLS (A_T, T, friend, API, <>) |
81 | 81 |
82 // Instantiate the unary operators. | 82 // Instantiate the unary operators. |
83 #define SPARSE_UNOP_DEFS(A_T, E_T) \ | 83 #define SPARSE_UNOP_DEFS(A_T, E_T, API) \ |
84 SPARSE_UNOP_DECLS (A_T, E_T, template OCTAVE_API, ) | 84 SPARSE_UNOP_DECLS (A_T, E_T, template, API, ) |
85 | 85 |
86 // A function that can be used to forward unary operations from derived | 86 // A function that can be used to forward unary operations from derived |
87 // classes back to us. | 87 // classes back to us. |
88 #define SPARSE_UNOP_FWD_FCN(R, F, T, C_X, X_T) \ | 88 #define SPARSE_UNOP_FWD_FCN(R, F, T, C_X, X_T) \ |
89 inline R \ | 89 inline R \ |
96 #define SPARSE_UNOP_FWD_DEFS(R, T, C_X, X_T) \ | 96 #define SPARSE_UNOP_FWD_DEFS(R, T, C_X, X_T) \ |
97 SPARSE_UNOP_FWD_FCN (R, operator +, T, C_X, X_T) \ | 97 SPARSE_UNOP_FWD_FCN (R, operator +, T, C_X, X_T) \ |
98 SPARSE_UNOP_FWD_FCN (R, operator -, T, C_X, X_T) | 98 SPARSE_UNOP_FWD_FCN (R, operator -, T, C_X, X_T) |
99 | 99 |
100 // A macro that can be used to declare and instantiate binary operators. | 100 // A macro that can be used to declare and instantiate binary operators. |
101 #define SPARSE_BINOP_DECL(A_T, E_T, F, PFX, LTGT, X_T, Y_T) \ | 101 #define SPARSE_BINOP_DECL(A_T, E_T, F, PFX, API, LTGT, X_T, Y_T) \ |
102 PFX A_T<E_T> \ | 102 PFX API A_T<E_T> \ |
103 F LTGT (const X_T&, const Y_T&) | 103 F LTGT (const X_T&, const Y_T&) |
104 | 104 |
105 // All the binary operators that we care about. We have two | 105 // All the binary operators that we care about. We have two |
106 // sets of macros since the MArray OP MArray operations use functions | 106 // sets of macros since the MArray OP MArray operations use functions |
107 // (product and quotient) instead of operators (*, /). | 107 // (product and quotient) instead of operators (*, /). |
108 #define SPARSE_BINOP_DECLS(A_T, F_T, E_T, PFX, LTGT, X_T, Y_T) \ | 108 #define SPARSE_BINOP_DECLS(A_T, F_T, E_T, PFX, API, LTGT, X_T, Y_T) \ |
109 SPARSE_BINOP_DECL (F_T, E_T, operator +, PFX, LTGT, X_T, Y_T); \ | 109 SPARSE_BINOP_DECL (F_T, E_T, operator +, PFX, API, LTGT, X_T, Y_T); \ |
110 SPARSE_BINOP_DECL (F_T, E_T, operator -, PFX, LTGT, X_T, Y_T); \ | 110 SPARSE_BINOP_DECL (F_T, E_T, operator -, PFX, API, LTGT, X_T, Y_T); \ |
111 SPARSE_BINOP_DECL (A_T, E_T, operator *, PFX, LTGT, X_T, Y_T); \ | 111 SPARSE_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \ |
112 SPARSE_BINOP_DECL (A_T, E_T, operator /, PFX, LTGT, X_T, Y_T); | 112 SPARSE_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T); |
113 | 113 |
114 #define SPARSE_AA_BINOP_DECLS(A_T, E_T, PFX, LTGT) \ | 114 #define SPARSE_AA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \ |
115 SPARSE_BINOP_DECL (A_T, E_T, operator +, PFX, LTGT, A_T<E_T>, A_T<E_T>); \ | 115 SPARSE_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ |
116 SPARSE_BINOP_DECL (A_T, E_T, operator -, PFX, LTGT, A_T<E_T>, A_T<E_T>); \ | 116 SPARSE_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ |
117 SPARSE_BINOP_DECL (A_T, E_T, quotient, PFX, LTGT, A_T<E_T>, A_T<E_T>); \ | 117 SPARSE_BINOP_DECL (A_T, E_T, quotient, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \ |
118 SPARSE_BINOP_DECL (A_T, E_T, product, PFX, LTGT, A_T<E_T>, A_T<E_T>); | 118 SPARSE_BINOP_DECL (A_T, E_T, product, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); |
119 | 119 |
120 // Generate forward declarations for binary operators. | 120 // Generate forward declarations for binary operators. |
121 #define SPARSE_BINOP_FWD_DECLS(A_T, F_T) \ | 121 #define SPARSE_BINOP_FWD_DECLS(A_T, F_T, API) \ |
122 SPARSE_BINOP_DECLS (A_T, F_T, T, template <typename T>, , A_T<T>, T) \ | 122 SPARSE_BINOP_DECLS (A_T, F_T, T, template <typename T>, API, , A_T<T>, T) \ |
123 SPARSE_BINOP_DECLS (A_T, F_T, T, template <typename T>, , T, A_T<T>) \ | 123 SPARSE_BINOP_DECLS (A_T, F_T, T, template <typename T>, API, , T, A_T<T>) \ |
124 SPARSE_AA_BINOP_DECLS (A_T, T, template <typename T>, ) | 124 SPARSE_AA_BINOP_DECLS (A_T, T, template <typename T>, API, ) |
125 | 125 |
126 // Generate friend declarations for the binary operators. | 126 // Generate friend declarations for the binary operators. |
127 #define SPARSE_BINOP_FRIENDS(A_T, F_T) \ | 127 #define SPARSE_BINOP_FRIENDS(A_T, F_T, API) \ |
128 SPARSE_BINOP_DECLS (A_T, F_T, T, friend, <>, A_T<T>, T) \ | 128 SPARSE_BINOP_DECLS (A_T, F_T, T, friend, API, <>, A_T<T>, T) \ |
129 SPARSE_BINOP_DECLS (A_T, F_T, T, friend, <>, T, A_T<T>) \ | 129 SPARSE_BINOP_DECLS (A_T, F_T, T, friend, API, <>, T, A_T<T>) \ |
130 SPARSE_AA_BINOP_DECLS (A_T, T, friend, <>) | 130 SPARSE_AA_BINOP_DECLS (A_T, T, friend, API, <>) |
131 | 131 |
132 // Instantiate the binary operators. | 132 // Instantiate the binary operators. |
133 #define SPARSE_BINOP_DEFS(A_T, F_T, E_T) \ | 133 #define SPARSE_BINOP_DEFS(A_T, F_T, E_T, API) \ |
134 SPARSE_BINOP_DECLS (A_T, F_T, E_T, template OCTAVE_API, , A_T<E_T>, E_T) \ | 134 SPARSE_BINOP_DECLS (A_T, F_T, E_T, template, API, , A_T<E_T>, E_T) \ |
135 SPARSE_BINOP_DECLS (A_T, F_T, E_T, template OCTAVE_API, , E_T, A_T<E_T>) \ | 135 SPARSE_BINOP_DECLS (A_T, F_T, E_T, template, API, , E_T, A_T<E_T>) \ |
136 SPARSE_AA_BINOP_DECLS (A_T, E_T, template OCTAVE_API, ) | 136 SPARSE_AA_BINOP_DECLS (A_T, E_T, template, API, ) |
137 | 137 |
138 // A function that can be used to forward binary operations from derived | 138 // A function that can be used to forward binary operations from derived |
139 // classes back to us. | 139 // classes back to us. |
140 #define SPARSE_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \ | 140 #define SPARSE_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \ |
141 inline R \ | 141 inline R \ |
158 SPARSE_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \ | 158 SPARSE_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \ |
159 SPARSE_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T) \ | 159 SPARSE_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T) \ |
160 SPARSE_BINOP_FWD_FCN (R, quotient, T, C_X, X_T, C_Y, Y_T) | 160 SPARSE_BINOP_FWD_FCN (R, quotient, T, C_X, X_T, C_Y, Y_T) |
161 | 161 |
162 // Forward declarations for the MSparse operators. | 162 // Forward declarations for the MSparse operators. |
163 #define SPARSE_OPS_FORWARD_DECLS(A_T, F_T) \ | 163 #define SPARSE_OPS_FORWARD_DECLS(A_T, F_T, API) \ |
164 template <class T> \ | 164 template <class T> \ |
165 class A_T; \ | 165 class A_T; \ |
166 \ | 166 \ |
167 /* SPARSE_OP_ASSIGN_FWD_DECLS (A_T, T) */ \ | 167 /* SPARSE_OP_ASSIGN_FWD_DECLS (A_T, T) */ \ |
168 SPARSE_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>) \ | 168 SPARSE_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>, API) \ |
169 SPARSE_UNOP_FWD_DECLS (A_T) \ | 169 SPARSE_UNOP_FWD_DECLS (A_T, API) \ |
170 SPARSE_BINOP_FWD_DECLS (A_T, F_T) | 170 SPARSE_BINOP_FWD_DECLS (A_T, F_T, API) |
171 | 171 |
172 // Friend declarations for the MSparse operators. | 172 // Friend declarations for the MSparse operators. |
173 #define SPARSE_OPS_FRIEND_DECLS(A_T, F_T) \ | 173 #define SPARSE_OPS_FRIEND_DECLS(A_T, F_T, API) \ |
174 /* SPARSE_OP_ASSIGN_FRIENDS (A_T, T) */ \ | 174 /* SPARSE_OP_ASSIGN_FRIENDS (A_T, T) */ \ |
175 SPARSE_OP_ASSIGN_FRIENDS (A_T, A_T<T>) \ | 175 SPARSE_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \ |
176 SPARSE_UNOP_FRIENDS (A_T) \ | 176 SPARSE_UNOP_FRIENDS (A_T, API) \ |
177 SPARSE_BINOP_FRIENDS (A_T, F_T) | 177 SPARSE_BINOP_FRIENDS (A_T, F_T, API) |
178 | 178 |
179 // The following macros are for external use. | 179 // The following macros are for external use. |
180 | 180 |
181 // Instantiate all the MSparse friends for MSparse element type T. | 181 // Instantiate all the MSparse friends for MSparse element type T. |
182 #define INSTANTIATE_SPARSE_FRIENDS(T) \ | 182 #define INSTANTIATE_SPARSE_FRIENDS(T, API) \ |
183 /* SPARSE_OP_ASSIGN_DEFS (MSparse, T, T) */ \ | 183 /* SPARSE_OP_ASSIGN_DEFS (MSparse, T, T) */ \ |
184 SPARSE_OP_ASSIGN_DEFS (MSparse, T, MSparse<T>) \ | 184 SPARSE_OP_ASSIGN_DEFS (MSparse, T, MSparse<T>, API) \ |
185 SPARSE_UNOP_DEFS (MSparse, T) \ | 185 SPARSE_UNOP_DEFS (MSparse, T, API) \ |
186 SPARSE_BINOP_DEFS (MSparse, MArray2, T) | 186 SPARSE_BINOP_DEFS (MSparse, MArray2, T, API) |
187 | 187 |
188 // Define all the MSparse forwarding functions for return type R and | 188 // Define all the MSparse forwarding functions for return type R and |
189 // MSparse element type T | 189 // MSparse element type T |
190 #define SPARSE_FORWARD_DEFS(B, R, F, T) \ | 190 #define SPARSE_FORWARD_DEFS(B, R, F, T) \ |
191 /* SPARSE_OP_ASSIGN_FWD_DEFS */ \ | 191 /* SPARSE_OP_ASSIGN_FWD_DEFS */ \ |