00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_MArray_decl_h)
00024 #define octave_MArray_decl_h 1
00025
00026
00027 #define MARRAY_OP_ASSIGN_DECL(A_T, E_T, OP, PFX, API, LTGT, RHS_T) \
00028 PFX API A_T<E_T>& \
00029 operator OP LTGT (A_T<E_T>&, const RHS_T&)
00030
00031 #define MARRAY_OP_ASSIGN_DECLX(A_T, E_T, OP, PFX, API, LTGT, RHS_T) \
00032 PFX API A_T<E_T>& \
00033 OP LTGT (A_T<E_T>&, const RHS_T&)
00034
00035
00036 #define MARRAY_OP_ASSIGN_DECLS(A_T, E_T, PFX, API, LTGT, RHS_T) \
00037 MARRAY_OP_ASSIGN_DECL (A_T, E_T, +=, PFX, API, LTGT, RHS_T); \
00038 MARRAY_OP_ASSIGN_DECL (A_T, E_T, -=, PFX, API, LTGT, RHS_T); \
00039 MARRAY_OP_ASSIGN_DECLX (A_T, E_T, product_eq, PFX, API, LTGT, RHS_T); \
00040 MARRAY_OP_ASSIGN_DECLX (A_T, E_T, quotient_eq, PFX, API, LTGT, RHS_T);
00041
00042 #define MARRAY_OP_ASSIGN_DECLS1(A_T, E_T, PFX, API, LTGT, RHS_T) \
00043 MARRAY_OP_ASSIGN_DECL (A_T, E_T, +=, PFX, API, LTGT, RHS_T); \
00044 MARRAY_OP_ASSIGN_DECL (A_T, E_T, -=, PFX, API, LTGT, RHS_T); \
00045 MARRAY_OP_ASSIGN_DECL (A_T, E_T, *=, PFX, API, LTGT, RHS_T); \
00046 MARRAY_OP_ASSIGN_DECL (A_T, E_T, /=, PFX, API, LTGT, RHS_T);
00047
00048
00049 #define MARRAY_OP_ASSIGN_FWD_DECLS(A_T, RHS_T, API) \
00050 MARRAY_OP_ASSIGN_DECLS (A_T, T, template <typename T>, API, , RHS_T)
00051
00052 #define MARRAY_OP_ASSIGN_FWD_DECLS1(A_T, RHS_T, API) \
00053 MARRAY_OP_ASSIGN_DECLS1 (A_T, T, template <typename T>, API, , RHS_T)
00054
00055
00056 #define MARRAY_OP_ASSIGN_FRIENDS(A_T, RHS_T, API) \
00057 MARRAY_OP_ASSIGN_DECLS (A_T, T, friend, API, <>, RHS_T)
00058
00059 #define MARRAY_OP_ASSIGN_FRIENDS1(A_T, RHS_T, API) \
00060 MARRAY_OP_ASSIGN_DECLS1 (A_T, T, friend, API, <>, RHS_T)
00061
00062
00063
00064 #define MARRAY_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
00065 inline R \
00066 F (X_T& x, const Y_T& y) \
00067 { \
00068 return R (F (C_X (x), C_Y (y))); \
00069 }
00070
00071
00072 #define MARRAY_OP_ASSIGN_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
00073 MARRAY_OP_ASSIGN_FWD_FCN (R, operator +=, T, C_X, X_T, C_Y, Y_T) \
00074 MARRAY_OP_ASSIGN_FWD_FCN (R, operator -=, T, C_X, X_T, C_Y, Y_T) \
00075 MARRAY_OP_ASSIGN_FWD_FCN (R, product_eq, T, C_X, X_T, C_Y, Y_T) \
00076 MARRAY_OP_ASSIGN_FWD_FCN (R, quotient_eq, T, C_X, X_T, C_Y, Y_T)
00077
00078 #define MARRAY_OP_ASSIGN_FWD_DEFS1(R, T, C_X, X_T, C_Y, Y_T) \
00079 MARRAY_OP_ASSIGN_FWD_FCN (R, operator +=, T, C_X, X_T, C_Y, Y_T) \
00080 MARRAY_OP_ASSIGN_FWD_FCN (R, operator -=, T, C_X, X_T, C_Y, Y_T) \
00081 MARRAY_OP_ASSIGN_FWD_FCN (R, operator *=, T, C_X, X_T, C_Y, Y_T) \
00082 MARRAY_OP_ASSIGN_FWD_FCN (R, operator /=, T, C_X, X_T, C_Y, Y_T)
00083
00084
00085 #define MARRAY_UNOP(A_T, E_T, F, PFX, API, LTGT) \
00086 PFX API A_T<E_T> \
00087 F LTGT (const A_T<E_T>&)
00088
00089
00090 #define MARRAY_UNOP_DECLS(A_T, E_T, PFX, API, LTGT) \
00091 MARRAY_UNOP (A_T, E_T, operator +, PFX, API, LTGT); \
00092 MARRAY_UNOP (A_T, E_T, operator -, PFX, API, LTGT);
00093
00094
00095 #define MARRAY_UNOP_FWD_DECLS(A_T, API) \
00096 MARRAY_UNOP_DECLS (A_T, T, template <typename T>, API, )
00097
00098
00099 #define MARRAY_UNOP_FRIENDS(A_T, API) \
00100 MARRAY_UNOP_DECLS (A_T, T, friend, API, <>)
00101
00102
00103
00104 #define MARRAY_UNOP_FWD_FCN(R, F, T, C_X, X_T) \
00105 inline R \
00106 F (const X_T& x) \
00107 { \
00108 return R (F (C_X (x))); \
00109 }
00110
00111
00112 #define MARRAY_UNOP_FWD_DEFS(R, T, C_X, X_T) \
00113 MARRAY_UNOP_FWD_FCN (R, operator +, T, C_X, X_T) \
00114 MARRAY_UNOP_FWD_FCN (R, operator -, T, C_X, X_T)
00115
00116
00117 #define MARRAY_BINOP_DECL(A_T, E_T, F, PFX, API, LTGT, X_T, Y_T) \
00118 PFX API A_T<E_T> \
00119 F LTGT (const X_T&, const Y_T&)
00120
00121
00122
00123
00124 #define MARRAY_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \
00125 MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, X_T, Y_T); \
00126 MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, X_T, Y_T); \
00127 MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \
00128 MARRAY_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T);
00129
00130 #define MARRAY_AA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \
00131 MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
00132 MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
00133 MARRAY_BINOP_DECL (A_T, E_T, quotient, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
00134 MARRAY_BINOP_DECL (A_T, E_T, product, PFX, API, LTGT, A_T<E_T>, A_T<E_T>);
00135
00136 #define MDIAGARRAY2_DAS_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \
00137 MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \
00138 MARRAY_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T);
00139
00140 #define MDIAGARRAY2_SDA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT, X_T, Y_T) \
00141 MARRAY_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T);
00142
00143 #define MDIAGARRAY2_DADA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \
00144 MARRAY_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
00145 MARRAY_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
00146 MARRAY_BINOP_DECL (A_T, E_T, product, PFX, API, LTGT, A_T<E_T>, A_T<E_T>);
00147
00148
00149 #define MARRAY_BINOP_FWD_DECLS(A_T, API) \
00150 MARRAY_BINOP_DECLS (A_T, T, template <typename T>, API, , A_T<T>, T) \
00151 MARRAY_BINOP_DECLS (A_T, T, template <typename T>, API, , T, A_T<T>) \
00152 MARRAY_AA_BINOP_DECLS (A_T, T, template <typename T>, API, )
00153
00154 #define MDIAGARRAY2_BINOP_FWD_DECLS(A_T, API) \
00155 MDIAGARRAY2_DAS_BINOP_DECLS (A_T, T, template <typename T>, API, , A_T<T>, T) \
00156 MDIAGARRAY2_SDA_BINOP_DECLS (A_T, T, template <typename T>, API, , T, A_T<T>) \
00157 MDIAGARRAY2_DADA_BINOP_DECLS (A_T, T, template <typename T>, API, )
00158
00159
00160 #define MARRAY_BINOP_FRIENDS(A_T, API) \
00161 MARRAY_BINOP_DECLS (A_T, T, friend, API, <>, A_T<T>, T) \
00162 MARRAY_BINOP_DECLS (A_T, T, friend, API, <>, T, A_T<T>) \
00163 MARRAY_AA_BINOP_DECLS (A_T, T, friend, API, <>)
00164
00165 #define MDIAGARRAY2_BINOP_FRIENDS(A_T, API) \
00166 MDIAGARRAY2_DAS_BINOP_DECLS (A_T, T, friend, API, <>, A_T<T>, T) \
00167 MDIAGARRAY2_SDA_BINOP_DECLS (A_T, T, friend, API, <>, T, A_T<T>) \
00168 MDIAGARRAY2_DADA_BINOP_DECLS (A_T, T, friend, API, <>)
00169
00170
00171
00172 #define MARRAY_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
00173 inline R \
00174 F (const X_T& x, const Y_T& y) \
00175 { \
00176 return R (F (C_X (x), C_Y (y))); \
00177 }
00178
00179
00180
00181
00182 #define MARRAY_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
00183 MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \
00184 MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \
00185 MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) \
00186 MARRAY_BINOP_FWD_FCN (R, operator /, T, C_X, X_T, C_Y, Y_T)
00187
00188 #define MARRAY_AA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
00189 MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \
00190 MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \
00191 MARRAY_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T) \
00192 MARRAY_BINOP_FWD_FCN (R, quotient, T, C_X, X_T, C_Y, Y_T)
00193
00194 #define MDIAGARRAY2_DAS_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
00195 MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) \
00196 MARRAY_BINOP_FWD_FCN (R, operator /, T, C_X, X_T, C_Y, Y_T)
00197
00198 #define MDIAGARRAY2_SDA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
00199 MARRAY_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T)
00200
00201 #define MDIAGARRAY2_DADA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
00202 MARRAY_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \
00203 MARRAY_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \
00204 MARRAY_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T)
00205
00206
00207 #define MARRAY_OPS_FORWARD_DECLS(A_T, API) \
00208 template <class T> \
00209 class A_T; \
00210 \
00211 MARRAY_OP_ASSIGN_FWD_DECLS1 (A_T, T, API) \
00212 MARRAY_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>, API) \
00213 MARRAY_UNOP_FWD_DECLS (A_T, API) \
00214 MARRAY_BINOP_FWD_DECLS (A_T, API)
00215
00216 #define MDIAGARRAY2_OPS_FORWARD_DECLS(A_T, API) \
00217 template <class T> \
00218 class A_T; \
00219 \
00220 MARRAY_UNOP_FWD_DECLS (A_T, API) \
00221 MDIAGARRAY2_BINOP_FWD_DECLS (A_T, API)
00222
00223
00224 #define MARRAY_OPS_FRIEND_DECLS(A_T, API) \
00225 MARRAY_OP_ASSIGN_FRIENDS1 (A_T, T, API) \
00226 MARRAY_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \
00227 MARRAY_UNOP_FRIENDS (A_T, API) \
00228 MARRAY_BINOP_FRIENDS (A_T, API)
00229
00230 #define MDIAGARRAY2_OPS_FRIEND_DECLS(A_T, API) \
00231 MARRAY_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \
00232 MARRAY_UNOP_FRIENDS (A_T, API) \
00233 MDIAGARRAY2_BINOP_FRIENDS (A_T, API)
00234
00235
00236
00237 #define MARRAY_FORWARD_DEFS(B, R, T) \
00238 MARRAY_OP_ASSIGN_FWD_DEFS1 \
00239 (R, T, dynamic_cast<B<T>&>, R, , T) \
00240 \
00241 MARRAY_OP_ASSIGN_FWD_DEFS \
00242 (R, T, \
00243 dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \
00244 \
00245 MARRAY_UNOP_FWD_DEFS \
00246 (R, T, dynamic_cast<const B<T>&>, R) \
00247 \
00248 MARRAY_BINOP_FWD_DEFS \
00249 (R, T, dynamic_cast<const B<T>&>, R, , T) \
00250 \
00251 MARRAY_BINOP_FWD_DEFS \
00252 (R, T, , T, dynamic_cast<const B<T>&>, R) \
00253 \
00254 MARRAY_AA_BINOP_FWD_DEFS \
00255 (R, T, dynamic_cast<const B<T>&>, R, dynamic_cast<const B<T>&>, R)
00256
00257 #define MDIAGARRAY2_FORWARD_DEFS(B, R, T) \
00258 MARRAY_UNOP_FWD_DEFS \
00259 (R, T, dynamic_cast<const B<T>&>, R) \
00260 \
00261 MDIAGARRAY2_DAS_BINOP_FWD_DEFS \
00262 (R, T, dynamic_cast<const B<T>&>, R, , T) \
00263 \
00264 MDIAGARRAY2_SDA_BINOP_FWD_DEFS \
00265 (R, T, , T, dynamic_cast<const B<T>&>, R) \
00266 \
00267 MDIAGARRAY2_DADA_BINOP_FWD_DEFS \
00268 (R, T, dynamic_cast<const B<T>&>, R, dynamic_cast<const B<T>&>, R)
00269
00270 #endif