00001 #ifndef VIENNAMATH_COMPILETIME_CT_INTERVAL_HPP
00002 #define VIENNAMATH_COMPILETIME_CT_INTERVAL_HPP
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <ostream>
00021 #include "viennamath/forwards.h"
00022
00027 namespace viennamath
00028 {
00034 template <typename LHS, typename RHS>
00035 class ct_interval {};
00036
00038 template <typename LHS, typename RHS>
00039 std::ostream& operator<<(std::ostream & stream, ct_interval<LHS, RHS> const & u)
00040 {
00041 stream << "ct_interval(" << LHS() << ", " << RHS() << ")";
00042 return stream;
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00055 template <typename LHS1, typename OP1, typename RHS1,
00056 typename LHS2, typename OP2, typename RHS2>
00057 ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00058 ct_binary_expr<LHS2, OP2, RHS2> >
00059 make_interval(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00060 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00061 {
00062 return ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00063 ct_binary_expr<LHS2, OP2, RHS2> >();
00064 }
00065
00067 template <typename LHS1, typename OP1, typename RHS1,
00068 typename LHS2, typename OP2>
00069 ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00070 ct_unary_expr<LHS2, OP2> >
00071 make_interval(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00072 ct_unary_expr<LHS2, OP2> const & rhs)
00073 {
00074 return ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00075 ct_unary_expr<LHS2, OP2> >();
00076 }
00077
00079 template <typename LHS1, typename OP1, typename RHS1,
00080 long value>
00081 ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00082 ct_constant<value> >
00083 make_interval(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00084 ct_constant<value> const & rhs)
00085 {
00086 return ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00087 ct_constant<value> >();
00088 }
00089
00091 template <typename LHS1, typename OP1, typename RHS1,
00092 typename TAG>
00093 ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00094 ct_function_symbol<TAG> >
00095 make_interval(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00096 ct_function_symbol<TAG> const & rhs)
00097 {
00098 return ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00099 ct_function_symbol<TAG> >();
00100 }
00101
00103 template <typename LHS1, typename OP1, typename RHS1,
00104 id_type id>
00105 ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00106 ct_variable<id> >
00107 make_interval(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00108 ct_variable<id> const & rhs)
00109 {
00110 return ct_interval<ct_binary_expr<LHS1, OP1, RHS1>,
00111 ct_variable<id> >();
00112 }
00113
00114
00115
00116
00118 template <typename LHS1, typename OP1,
00119 typename LHS2, typename OP2, typename RHS2>
00120 ct_interval<ct_unary_expr<LHS1, OP1>,
00121 ct_binary_expr<LHS2, OP2, RHS2> >
00122 make_interval(ct_unary_expr<LHS1, OP1> const & lhs,
00123 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00124 {
00125 return ct_interval<ct_unary_expr<LHS1, OP1>,
00126 ct_binary_expr<LHS2, OP2, RHS2> >();
00127 }
00128
00130 template <typename LHS1, typename OP1,
00131 typename LHS2, typename OP2>
00132 ct_interval<ct_unary_expr<LHS1, OP1>,
00133 ct_unary_expr<LHS2, OP2> >
00134 make_interval(ct_unary_expr<LHS1, OP1> const & lhs,
00135 ct_unary_expr<LHS2, OP2> const & rhs)
00136 {
00137 return ct_interval<ct_unary_expr<LHS1, OP1>,
00138 ct_unary_expr<LHS2, OP2> >();
00139 }
00140
00142 template <typename LHS1, typename OP1,
00143 long value>
00144 ct_interval<ct_unary_expr<LHS1, OP1>,
00145 ct_constant<value> >
00146 make_interval(ct_unary_expr<LHS1, OP1> const & lhs,
00147 ct_constant<value> const & rhs)
00148 {
00149 return ct_interval<ct_unary_expr<LHS1, OP1>,
00150 ct_constant<value> >();
00151 }
00152
00154 template <typename LHS1, typename OP1,
00155 typename TAG>
00156 ct_interval<ct_unary_expr<LHS1, OP1>,
00157 ct_function_symbol<TAG> >
00158 make_interval(ct_unary_expr<LHS1, OP1> const & lhs,
00159 ct_function_symbol<TAG> const & rhs)
00160 {
00161 return ct_interval<ct_unary_expr<LHS1, OP1>,
00162 ct_function_symbol<TAG> >();
00163 }
00164
00166 template <typename LHS1, typename OP1,
00167 id_type id>
00168 ct_interval<ct_unary_expr<LHS1, OP1>,
00169 ct_variable<id> >
00170 make_interval(ct_unary_expr<LHS1, OP1> const & lhs,
00171 ct_variable<id> const & rhs)
00172 {
00173 return ct_interval<ct_unary_expr<LHS1, OP1>,
00174 ct_variable<id> >();
00175 }
00176
00177
00178
00179
00181 template <long value1,
00182 typename LHS2, typename OP2, typename RHS2>
00183 ct_interval<ct_constant<value1>,
00184 ct_binary_expr<LHS2, OP2, RHS2> >
00185 make_interval(ct_constant<value1> const & lhs,
00186 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00187 {
00188 return ct_interval<ct_constant<value1>,
00189 ct_binary_expr<LHS2, OP2, RHS2> >();
00190 }
00191
00193 template <long value1,
00194 typename LHS2, typename OP2>
00195 ct_interval<ct_constant<value1>,
00196 ct_unary_expr<LHS2, OP2> >
00197 make_interval(ct_constant<value1> const & lhs,
00198 ct_unary_expr<LHS2, OP2> const & rhs)
00199 {
00200 return ct_interval<ct_constant<value1>,
00201 ct_unary_expr<LHS2, OP2> >();
00202 }
00203
00205 template <long value1,
00206 long value2>
00207 ct_interval<ct_constant<value1>,
00208 ct_constant<value2> >
00209 make_interval(ct_constant<value1> const & lhs,
00210 ct_constant<value2> const & rhs)
00211 {
00212 return ct_interval<ct_constant<value1>,
00213 ct_constant<value2> >();
00214 }
00215
00217 template <long value1,
00218 typename TAG>
00219 ct_interval<ct_constant<value1>,
00220 ct_function_symbol<TAG> >
00221 make_interval(ct_constant<value1> const & lhs,
00222 ct_function_symbol<TAG> const & rhs)
00223 {
00224 return ct_interval<ct_constant<value1>,
00225 ct_function_symbol<TAG> >();
00226 }
00227
00228
00230 template <long value1,
00231 id_type id>
00232 ct_interval<ct_constant<value1>,
00233 ct_variable<id> >
00234 make_interval(ct_constant<value1> const & lhs,
00235 ct_variable<id> const & rhs)
00236 {
00237 return ct_interval<ct_constant<value1>,
00238 ct_variable<id> >();
00239 }
00240
00241
00242
00243
00245 template <typename TAG,
00246 typename LHS2, typename OP2, typename RHS2>
00247 ct_interval<ct_function_symbol<TAG>,
00248 ct_binary_expr<LHS2, OP2, RHS2> >
00249 make_interval(ct_function_symbol<TAG> const & lhs,
00250 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00251 {
00252 return ct_interval<ct_function_symbol<TAG>,
00253 ct_binary_expr<LHS2, OP2, RHS2> >();
00254 }
00255
00257 template <typename TAG,
00258 typename LHS2, typename OP2>
00259 ct_interval<ct_function_symbol<TAG>,
00260 ct_unary_expr<LHS2, OP2> >
00261 make_interval(ct_function_symbol<TAG> const & lhs,
00262 ct_unary_expr<LHS2, OP2> const & rhs)
00263 {
00264 return ct_interval<ct_function_symbol<TAG>,
00265 ct_unary_expr<LHS2, OP2> >();
00266 }
00267
00269 template <typename TAG,
00270 long value>
00271 ct_interval<ct_function_symbol<TAG>,
00272 ct_constant<value> >
00273 make_interval(ct_function_symbol<TAG> const & lhs,
00274 ct_constant<value> const & rhs)
00275 {
00276 return ct_interval<ct_function_symbol<TAG>,
00277 ct_constant<value> >();
00278 }
00279
00281 template <typename TAG1,
00282 typename TAG2>
00283 ct_interval<ct_function_symbol<TAG1>,
00284 ct_function_symbol<TAG2> >
00285 make_interval(ct_function_symbol<TAG1> const & lhs,
00286 ct_function_symbol<TAG2> const & rhs)
00287 {
00288 return ct_interval<ct_function_symbol<TAG1>,
00289 ct_function_symbol<TAG2> >();
00290 }
00291
00293 template <typename TAG,
00294 id_type id>
00295 ct_interval<ct_function_symbol<TAG>,
00296 ct_variable<id> >
00297 make_interval(ct_function_symbol<TAG> const & lhs,
00298 ct_variable<id> const & rhs)
00299 {
00300 return ct_interval<ct_function_symbol<TAG>,
00301 ct_variable<id> >();
00302 }
00303
00304
00305
00306
00308 template <id_type id1,
00309 typename LHS2, typename OP2, typename RHS2>
00310 ct_interval<ct_variable<id1>,
00311 ct_binary_expr<LHS2, OP2, RHS2> >
00312 make_interval(ct_variable<id1> const & lhs,
00313 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00314 {
00315 return ct_interval<ct_variable<id1>,
00316 ct_binary_expr<LHS2, OP2, RHS2> >();
00317 }
00318
00320 template <id_type id1,
00321 typename LHS2, typename OP2>
00322 ct_interval<ct_variable<id1>,
00323 ct_unary_expr<LHS2, OP2> >
00324 make_interval(ct_variable<id1> const & lhs,
00325 ct_unary_expr<LHS2, OP2> const & rhs)
00326 {
00327 return ct_interval<ct_variable<id1>,
00328 ct_unary_expr<LHS2, OP2> >();
00329 }
00330
00332 template <id_type id1,
00333 long value2>
00334 ct_interval<ct_variable<id1>,
00335 ct_constant<value2> >
00336 make_interval(ct_variable<id1> const & lhs,
00337 ct_constant<value2> const & rhs)
00338 {
00339 return ct_interval<ct_variable<id1>,
00340 ct_constant<value2> >();
00341 }
00342
00344 template <id_type id1,
00345 typename TAG>
00346 ct_interval<ct_variable<id1>,
00347 ct_function_symbol<TAG> >
00348 make_interval(ct_variable<id1> const & lhs,
00349 ct_function_symbol<TAG> const & rhs)
00350 {
00351 return ct_interval<ct_variable<id1>,
00352 ct_function_symbol<TAG> >();
00353 }
00354
00355
00357 template <id_type id1,
00358 id_type id2>
00359 ct_interval<ct_variable<id1>,
00360 ct_variable<id2> >
00361 make_interval(ct_variable<id1> const & lhs,
00362 ct_variable<id2> const & rhs)
00363 {
00364 return ct_interval<ct_variable<id1>,
00365 ct_variable<id2> >();
00366 }
00367
00368 }
00369
00370 #endif