00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if !defined (octave_MSparse_defs_h)
00025 #define octave_MSparse_defs_h 1
00026
00027
00028
00029
00030 #define SPARSE_OP_ASSIGN_DECL(A_T, E_T, OP, PFX, API, LTGT, RHS_T) \
00031 PFX API A_T<E_T>& \
00032 operator OP LTGT (A_T<E_T>&, const RHS_T&)
00033
00034
00035 #define SPARSE_OP_ASSIGN_DECLS(A_T, E_T, PFX, API, LTGT, RHS_T) \
00036 SPARSE_OP_ASSIGN_DECL (A_T, E_T, +=, PFX, API, LTGT, RHS_T); \
00037 SPARSE_OP_ASSIGN_DECL (A_T, E_T, -=, PFX, API, LTGT, RHS_T);
00038
00039
00040 #define SPARSE_OP_ASSIGN_FWD_DECLS(A_T, RHS_T, API) \
00041 SPARSE_OP_ASSIGN_DECLS (A_T, T, template <typename T>, API, , RHS_T)
00042
00043
00044 #define SPARSE_OP_ASSIGN_FRIENDS(A_T, RHS_T, API) \
00045 SPARSE_OP_ASSIGN_DECLS (A_T, T, friend, API, <>, RHS_T)
00046
00047
00048 #define SPARSE_OP_ASSIGN_DEFS(A_T, E_T, RHS_T, API) \
00049 SPARSE_OP_ASSIGN_DECLS (A_T, E_T, template, API, , RHS_T)
00050
00051
00052
00053 #define SPARSE_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
00054 inline R \
00055 F (X_T& x, const Y_T& y) \
00056 { \
00057 return R (F (C_X (x), C_Y (y))); \
00058 }
00059
00060
00061 #define SPARSE_OP_ASSIGN_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
00062 SPARSE_OP_ASSIGN_FWD_FCN (R, operator +=, T, C_X, X_T, C_Y, Y_T) \
00063 SPARSE_OP_ASSIGN_FWD_FCN (R, operator -=, T, C_X, X_T, C_Y, Y_T)
00064
00065
00066 #define SPARSE_UNOP(A_T, E_T, F, PFX, API, LTGT) \
00067 PFX API A_T<E_T> \
00068 F LTGT (const A_T<E_T>&)
00069
00070
00071 #define SPARSE_UNOP_DECLS(A_T, E_T, PFX, API, LTGT) \
00072 SPARSE_UNOP (A_T, E_T, operator +, PFX, API, LTGT); \
00073 SPARSE_UNOP (A_T, E_T, operator -, PFX, API, LTGT);
00074
00075
00076 #define SPARSE_UNOP_FWD_DECLS(A_T, API) \
00077 SPARSE_UNOP_DECLS (A_T, T, template <typename T>, API, )
00078
00079
00080 #define SPARSE_UNOP_FRIENDS(A_T, API) \
00081 SPARSE_UNOP_DECLS (A_T, T, friend, API, <>)
00082
00083
00084 #define SPARSE_UNOP_DEFS(A_T, E_T, API) \
00085 SPARSE_UNOP_DECLS (A_T, E_T, template, API, )
00086
00087
00088
00089 #define SPARSE_UNOP_FWD_FCN(R, F, T, C_X, X_T) \
00090 inline R \
00091 F (const X_T& x) \
00092 { \
00093 return R (F (C_X (x))); \
00094 }
00095
00096
00097 #define SPARSE_UNOP_FWD_DEFS(R, T, C_X, X_T) \
00098 SPARSE_UNOP_FWD_FCN (R, operator +, T, C_X, X_T) \
00099 SPARSE_UNOP_FWD_FCN (R, operator -, T, C_X, X_T)
00100
00101
00102 #define SPARSE_BINOP_DECL(A_T, E_T, F, PFX, API, LTGT, X_T, Y_T) \
00103 PFX API A_T<E_T> \
00104 F LTGT (const X_T&, const Y_T&)
00105
00106
00107
00108
00109 #define SPARSE_BINOP_DECLS(A_T, F_T, E_T, PFX, API, LTGT, X_T, Y_T) \
00110 SPARSE_BINOP_DECL (F_T, E_T, operator +, PFX, API, LTGT, X_T, Y_T); \
00111 SPARSE_BINOP_DECL (F_T, E_T, operator -, PFX, API, LTGT, X_T, Y_T); \
00112 SPARSE_BINOP_DECL (A_T, E_T, operator *, PFX, API, LTGT, X_T, Y_T); \
00113 SPARSE_BINOP_DECL (A_T, E_T, operator /, PFX, API, LTGT, X_T, Y_T);
00114
00115 #define SPARSE_AA_BINOP_DECLS(A_T, E_T, PFX, API, LTGT) \
00116 SPARSE_BINOP_DECL (A_T, E_T, operator +, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
00117 SPARSE_BINOP_DECL (A_T, E_T, operator -, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
00118 SPARSE_BINOP_DECL (A_T, E_T, quotient, PFX, API, LTGT, A_T<E_T>, A_T<E_T>); \
00119 SPARSE_BINOP_DECL (A_T, E_T, product, PFX, API, LTGT, A_T<E_T>, A_T<E_T>);
00120
00121
00122 #define SPARSE_BINOP_FWD_DECLS(A_T, F_T, API) \
00123 SPARSE_BINOP_DECLS (A_T, F_T, T, template <typename T>, API, , A_T<T>, T) \
00124 SPARSE_BINOP_DECLS (A_T, F_T, T, template <typename T>, API, , T, A_T<T>) \
00125 SPARSE_AA_BINOP_DECLS (A_T, T, template <typename T>, API, )
00126
00127
00128 #define SPARSE_BINOP_FRIENDS(A_T, F_T, API) \
00129 SPARSE_BINOP_DECLS (A_T, F_T, T, friend, API, <>, A_T<T>, T) \
00130 SPARSE_BINOP_DECLS (A_T, F_T, T, friend, API, <>, T, A_T<T>) \
00131 SPARSE_AA_BINOP_DECLS (A_T, T, friend, API, <>)
00132
00133
00134 #define SPARSE_BINOP_DEFS(A_T, F_T, E_T, API) \
00135 SPARSE_BINOP_DECLS (A_T, F_T, E_T, template, API, , A_T<E_T>, E_T) \
00136 SPARSE_BINOP_DECLS (A_T, F_T, E_T, template, API, , E_T, A_T<E_T>) \
00137 SPARSE_AA_BINOP_DECLS (A_T, E_T, template, API, )
00138
00139
00140
00141 #define SPARSE_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
00142 inline R \
00143 F (const X_T& x, const Y_T& y) \
00144 { \
00145 return R (F (C_X (x), C_Y (y))); \
00146 }
00147
00148
00149
00150
00151 #define SPARSE_BINOP_FWD_DEFS(R, F, T, C_X, X_T, C_Y, Y_T) \
00152 SPARSE_BINOP_FWD_FCN (F, operator +, T, C_X, X_T, C_Y, Y_T) \
00153 SPARSE_BINOP_FWD_FCN (F, operator -, T, C_X, X_T, C_Y, Y_T) \
00154 SPARSE_BINOP_FWD_FCN (R, operator *, T, C_X, X_T, C_Y, Y_T) \
00155 SPARSE_BINOP_FWD_FCN (R, operator /, T, C_X, X_T, C_Y, Y_T)
00156
00157 #define SPARSE_AA_BINOP_FWD_DEFS(R, T, C_X, X_T, C_Y, Y_T) \
00158 SPARSE_BINOP_FWD_FCN (R, operator +, T, C_X, X_T, C_Y, Y_T) \
00159 SPARSE_BINOP_FWD_FCN (R, operator -, T, C_X, X_T, C_Y, Y_T) \
00160 SPARSE_BINOP_FWD_FCN (R, product, T, C_X, X_T, C_Y, Y_T) \
00161 SPARSE_BINOP_FWD_FCN (R, quotient, T, C_X, X_T, C_Y, Y_T)
00162
00163
00164 #define SPARSE_OPS_FORWARD_DECLS(A_T, F_T, API) \
00165 template <class T> \
00166 class A_T; \
00167 \
00168 \
00169 SPARSE_OP_ASSIGN_FWD_DECLS (A_T, A_T<T>, API) \
00170 SPARSE_UNOP_FWD_DECLS (A_T, API) \
00171 SPARSE_BINOP_FWD_DECLS (A_T, F_T, API)
00172
00173
00174 #define SPARSE_OPS_FRIEND_DECLS(A_T, F_T, API) \
00175 \
00176 SPARSE_OP_ASSIGN_FRIENDS (A_T, A_T<T>, API) \
00177 SPARSE_UNOP_FRIENDS (A_T, API) \
00178 SPARSE_BINOP_FRIENDS (A_T, F_T, API)
00179
00180
00181
00182
00183 #define INSTANTIATE_SPARSE_FRIENDS(T, API) \
00184 \
00185 SPARSE_OP_ASSIGN_DEFS (MSparse, T, MSparse<T>, API) \
00186 SPARSE_UNOP_DEFS (MSparse, T, API) \
00187 SPARSE_BINOP_DEFS (MSparse, MArray2, T, API)
00188
00189
00190
00191 #define SPARSE_FORWARD_DEFS(B, R, F, T) \
00192 \
00193 \
00194 \
00195 SPARSE_OP_ASSIGN_FWD_DEFS \
00196 (R, T, \
00197 dynamic_cast<B<T>&>, R, dynamic_cast<const B<T>&>, R) \
00198 \
00199 SPARSE_UNOP_FWD_DEFS \
00200 (R, T, dynamic_cast<const B<T>&>, R) \
00201 \
00202 SPARSE_BINOP_FWD_DEFS \
00203 (R, F, T, dynamic_cast<const B<T>&>, R, , T) \
00204 \
00205 SPARSE_BINOP_FWD_DEFS \
00206 (R, F, T, , T, dynamic_cast<const B<T>&>, R) \
00207 \
00208 SPARSE_AA_BINOP_FWD_DEFS \
00209 (R, T, dynamic_cast<const B<T>&>, R, dynamic_cast<const B<T>&>, R)
00210
00211
00212
00213 #endif
00214
00215
00216
00217
00218
00219