• Main Page
  • Namespaces
  • Data Structures
  • Files
  • File List

/export/development/ViennaMath/viennamath/compiletime/ct_equation.hpp

Go to the documentation of this file.
00001 #ifndef VIENNAMATH_COMPILETIME_CT_EQUATION_HPP
00002 #define VIENNAMATH_COMPILETIME_CT_EQUATION_HPP
00003 
00004 /* =======================================================================
00005    Copyright (c) 2012, Institute for Microelectronics,
00006                        Institute for Analysis and Scientific Computing,
00007                        TU Wien.
00008                              -----------------
00009                ViennaMath - Symbolic and Numerical Math in C++
00010                              -----------------
00011 
00012    Author:     Karl Rupp                          rupp@iue.tuwien.ac.at
00013 
00014    License:    MIT (X11), see file LICENSE in the ViennaMath base directory
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_equation
00036   {};
00037   
00039   template <typename LHS, typename RHS>
00040   std::ostream& operator<<(std::ostream & stream, ct_equation<LHS, RHS> const & u)
00041   {
00042     stream << "ct_equation(" << LHS() << " = " << RHS() << ")";
00043     return stream;
00044   }
00045   
00046   
00047   //
00048   // compile time 
00049   // [binary expression, unary expression, constant, function symbol, variable] for each argument -> 25 overloads
00050   // Note that the following can be reduced to one function using enable_if<> in a suitable way
00051   //
00052   
00053   //
00054   //first argument: binary expression
00056   template <typename LHS1, typename OP1, typename RHS1,
00057             typename LHS2, typename OP2, typename RHS2>
00058   ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00059               ct_binary_expr<LHS2, OP2, RHS2> > 
00060   make_equation(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00061                 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00062   {
00063     return ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00064                        ct_binary_expr<LHS2, OP2, RHS2> >(); 
00065   }
00066   
00068   template <typename LHS1, typename OP1, typename RHS1,
00069             typename LHS2, typename OP2>
00070   ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00071               ct_unary_expr<LHS2, OP2> > 
00072   make_equation(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00073                 ct_unary_expr<LHS2, OP2> const & rhs)
00074   {
00075     return ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00076                        ct_unary_expr<LHS2, OP2> >(); 
00077   }
00078   
00080   template <typename LHS1, typename OP1, typename RHS1,
00081             long value>
00082   ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00083               ct_constant<value> > 
00084   make_equation(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00085                 ct_constant<value> const & rhs)
00086   {
00087     return ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00088                        ct_constant<value> >(); 
00089   }
00090 
00092   template <typename LHS1, typename OP1, typename RHS1,
00093             typename TAG>
00094   ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00095               ct_function_symbol<TAG> > 
00096   make_equation(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00097                 ct_function_symbol<TAG> const & rhs)
00098   {
00099     return ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00100                        ct_function_symbol<TAG> >(); 
00101   }
00102 
00104   template <typename LHS1, typename OP1, typename RHS1,
00105             id_type id>
00106   ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00107               ct_variable<id> > 
00108   make_equation(ct_binary_expr<LHS1, OP1, RHS1> const & lhs,
00109                 ct_variable<id> const & rhs)
00110   {
00111     return ct_equation<ct_binary_expr<LHS1, OP1, RHS1>,
00112                        ct_variable<id> >(); 
00113   }
00114 
00115 
00116   //
00117   //first argument: unary expression
00119   template <typename LHS1, typename OP1,
00120             typename LHS2, typename OP2, typename RHS2>
00121   ct_equation<ct_unary_expr<LHS1, OP1>,
00122               ct_binary_expr<LHS2, OP2, RHS2> > 
00123   make_equation(ct_unary_expr<LHS1, OP1> const & lhs,
00124                 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00125   {
00126     return ct_equation<ct_unary_expr<LHS1, OP1>,
00127                        ct_binary_expr<LHS2, OP2, RHS2> >(); 
00128   }
00129 
00131   template <typename LHS1, typename OP1,
00132             typename LHS2, typename OP2>
00133   ct_equation<ct_unary_expr<LHS1, OP1>,
00134               ct_unary_expr<LHS2, OP2> > 
00135   make_equation(ct_unary_expr<LHS1, OP1> const & lhs,
00136                 ct_unary_expr<LHS2, OP2> const & rhs)
00137   {
00138     return ct_equation<ct_unary_expr<LHS1, OP1>,
00139                        ct_unary_expr<LHS2, OP2> >(); 
00140   }
00141 
00143   template <typename LHS1, typename OP1,
00144             long value>
00145   ct_equation<ct_unary_expr<LHS1, OP1>,
00146               ct_constant<value> > 
00147   make_equation(ct_unary_expr<LHS1, OP1> const & lhs,
00148                 ct_constant<value> const & rhs)
00149   {
00150     return ct_equation<ct_unary_expr<LHS1, OP1>,
00151                        ct_constant<value> >(); 
00152   }
00153 
00155   template <typename LHS1, typename OP1,
00156             typename TAG>
00157   ct_equation<ct_unary_expr<LHS1, OP1>,
00158               ct_function_symbol<TAG> >
00159   make_equation(ct_unary_expr<LHS1, OP1> const & lhs,
00160                 ct_function_symbol<TAG> const & rhs)
00161   {
00162     return ct_equation<ct_unary_expr<LHS1, OP1>,
00163                        ct_function_symbol<TAG> >(); 
00164   }
00165 
00167   template <typename LHS1, typename OP1,
00168             id_type id>
00169   ct_equation<ct_unary_expr<LHS1, OP1>,
00170               ct_variable<id> > 
00171   make_equation(ct_unary_expr<LHS1, OP1> const & lhs,
00172                 ct_variable<id> const & rhs)
00173   {
00174     return ct_equation<ct_unary_expr<LHS1, OP1>,
00175                        ct_variable<id> >(); 
00176   }
00177 
00178 
00179   //
00180   //first argument: ct_constant
00182   template <long value1,
00183             typename LHS2, typename OP2, typename RHS2>
00184   ct_equation<ct_constant<value1>,
00185               ct_binary_expr<LHS2, OP2, RHS2> > 
00186   make_equation(ct_constant<value1> const & lhs,
00187                 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00188   {
00189     return ct_equation<ct_constant<value1>,
00190                        ct_binary_expr<LHS2, OP2, RHS2> >(); 
00191   }
00192 
00194   template <long value1,
00195             typename LHS2, typename OP2>
00196   ct_equation<ct_constant<value1>,
00197               ct_unary_expr<LHS2, OP2> > 
00198   make_equation(ct_constant<value1> const & lhs,
00199                 ct_unary_expr<LHS2, OP2> const & rhs)
00200   {
00201     return ct_equation<ct_constant<value1>,
00202                        ct_unary_expr<LHS2, OP2> >(); 
00203   }
00204   
00206   template <long value1,
00207             long value2>
00208   ct_equation<ct_constant<value1>,
00209               ct_constant<value2> > 
00210   make_equation(ct_constant<value1> const & lhs,
00211                 ct_constant<value2> const & rhs)
00212   {
00213     return ct_equation<ct_constant<value1>,
00214                        ct_constant<value2> >(); 
00215   }
00216 
00218   template <long value1,
00219             typename TAG>
00220   ct_equation<ct_constant<value1>,
00221               ct_function_symbol<TAG> > 
00222   make_equation(ct_constant<value1> const & lhs,
00223                 ct_function_symbol<TAG> const & rhs)
00224   {
00225     return ct_equation<ct_constant<value1>,
00226                        ct_function_symbol<TAG> >(); 
00227   }
00228 
00229 
00231   template <long value1,
00232             id_type id>
00233   ct_equation<ct_constant<value1>,
00234               ct_variable<id> > 
00235   make_equation(ct_constant<value1> const & lhs,
00236                 ct_variable<id> const & rhs)
00237   {
00238     return ct_equation<ct_constant<value1>,
00239                        ct_variable<id> >(); 
00240   }
00241 
00242 
00243   //
00244   //first argument: function symbol
00246   template <typename TAG,
00247             typename LHS2, typename OP2, typename RHS2>
00248   ct_equation<ct_function_symbol<TAG>,
00249               ct_binary_expr<LHS2, OP2, RHS2> > 
00250   make_equation(ct_function_symbol<TAG> const & lhs,
00251                 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00252   {
00253     return ct_equation<ct_function_symbol<TAG>,
00254                        ct_binary_expr<LHS2, OP2, RHS2> >(); 
00255   }
00256 
00258   template <typename TAG,
00259             typename LHS2, typename OP2>
00260   ct_equation<ct_function_symbol<TAG>,
00261               ct_unary_expr<LHS2, OP2> > 
00262   make_equation(ct_function_symbol<TAG> const & lhs,
00263                 ct_unary_expr<LHS2, OP2> const & rhs)
00264   {
00265     return ct_equation<ct_function_symbol<TAG>,
00266                        ct_unary_expr<LHS2, OP2> >(); 
00267   }
00268 
00270   template <typename TAG,
00271             long value>
00272   ct_equation<ct_function_symbol<TAG>,
00273               ct_constant<value> > 
00274   make_equation(ct_function_symbol<TAG> const & lhs,
00275                 ct_constant<value> const & rhs)
00276   {
00277     return ct_equation<ct_function_symbol<TAG>,
00278                        ct_constant<value> >(); 
00279   }
00280 
00282   template <typename TAG1,
00283             typename TAG2>
00284   ct_equation<ct_function_symbol<TAG1>,
00285               ct_function_symbol<TAG2> >
00286   make_equation(ct_function_symbol<TAG1> const & lhs,
00287                 ct_function_symbol<TAG2> const & rhs)
00288   {
00289     return ct_equation<ct_function_symbol<TAG1>,
00290                        ct_function_symbol<TAG2> >(); 
00291   }
00292 
00294   template <typename TAG,
00295             id_type id>
00296   ct_equation<ct_function_symbol<TAG>,
00297               ct_variable<id> > 
00298   make_equation(ct_function_symbol<TAG> const & lhs,
00299                 ct_variable<id> const & rhs)
00300   {
00301     return ct_equation<ct_function_symbol<TAG>,
00302                        ct_variable<id> >(); 
00303   }
00304 
00305 
00306   //
00307   //first argument: variable
00309   template <id_type id1,
00310             typename LHS2, typename OP2, typename RHS2>
00311   ct_equation<ct_variable<id1>,
00312               ct_binary_expr<LHS2, OP2, RHS2> > 
00313   make_equation(ct_variable<id1> const & lhs,
00314                 ct_binary_expr<LHS2, OP2, RHS2> const & rhs)
00315   {
00316     return ct_equation<ct_variable<id1>,
00317                        ct_binary_expr<LHS2, OP2, RHS2> >(); 
00318   }
00319   
00321   template <id_type id1,
00322             typename LHS2, typename OP2>
00323   ct_equation<ct_variable<id1>,
00324               ct_unary_expr<LHS2, OP2> > 
00325   make_equation(ct_variable<id1> const & lhs,
00326                 ct_unary_expr<LHS2, OP2> const & rhs)
00327   {
00328     return ct_equation<ct_variable<id1>,
00329                        ct_unary_expr<LHS2, OP2> >(); 
00330   }
00331   
00333   template <id_type id1,
00334             long value2>
00335   ct_equation<ct_variable<id1>,
00336               ct_constant<value2> > 
00337   make_equation(ct_variable<id1> const & lhs,
00338                 ct_constant<value2> const & rhs)
00339   {
00340     return ct_equation<ct_variable<id1>,
00341                        ct_constant<value2> >(); 
00342   }
00343 
00345   template <id_type id1,
00346             typename TAG>
00347   ct_equation<ct_variable<id1>,
00348               ct_function_symbol<TAG> > 
00349   make_equation(ct_variable<id1> const & lhs,
00350                 ct_function_symbol<TAG> const & rhs)
00351   {
00352     return ct_equation<ct_variable<id1>,
00353                        ct_function_symbol<TAG> >(); 
00354   }
00355 
00356 
00358   template <id_type id1,
00359             id_type id2>
00360   ct_equation<ct_variable<id1>,
00361               ct_variable<id2> > 
00362   make_equation(ct_variable<id1> const & lhs,
00363                 ct_variable<id2> const & rhs)
00364   {
00365     return ct_equation<ct_variable<id1>,
00366                        ct_variable<id2> >(); 
00367   }
00368   
00369 }
00370 
00371 #endif

Generated on Wed Feb 29 2012 21:50:43 for ViennaMath by  doxygen 1.7.1