• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

op_mult.hh

00001 // Copyright (C) 2006, 2007, 2008, 2009  EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef MLN_CORE_TRAIT_OP_MULT_HH
00027 # define MLN_CORE_TRAIT_OP_MULT_HH
00028 
00037 # define mln_op_mult(T, U) typename mln::trait::op_mult< T , U >::ret
00038 
00039 
00040 
00041 namespace mln
00042 {
00043 
00044   namespace algebra
00045   {
00046 
00047     template <unsigned n, typename T>
00048     class vec;
00049 
00050     template <unsigned n, unsigned m, typename T>
00051     class mat;
00052 
00053   } // end of namespace mln::metal
00054 
00055   namespace trait
00056   {
00057 
00058     template <typename T, typename U>
00059     struct op_mult;
00060 
00061 
00062     template <typename T>
00063     struct op_mult<T, T>
00064     {
00065       typedef T ret;
00066     };
00067 
00068     template <>
00069     struct op_mult<int, float>
00070     {
00071       typedef float ret;
00072     };
00073     template <>
00074     struct op_mult<float, int>
00075     {
00076       typedef float ret;
00077     };
00078 
00079     template <>
00080     struct op_mult<int, double>
00081     {
00082       typedef double ret;
00083     };
00084     template <>
00085     struct op_mult<double, int>
00086     {
00087       typedef double ret;
00088     };
00089 
00090     template <>
00091     struct op_mult<double, float>
00092     {
00093       typedef double ret;
00094     };
00095     template <>
00096     struct op_mult<float, double>
00097     {
00098       typedef double ret;
00099     };
00100 
00101     template <unsigned n, typename T, typename U>
00102     struct op_mult<algebra::vec<n, T>, U>
00103     {
00104       typedef algebra::vec<n, mln_op_mult(T, U)> ret;
00105     };
00106     template <typename U, unsigned n, typename T>
00107     struct op_mult<U, algebra::vec<n, T> >
00108     {
00109       typedef algebra::vec<n, mln_op_mult(T, U)> ret;
00110     };
00111 
00112     template <unsigned n, unsigned m, typename T, typename U>
00113     struct op_mult<algebra::mat<n, m, T>, U>
00114     {
00115       typedef algebra::mat<n, m, mln_op_mult(T, U)> ret;
00116     };
00117     template <typename U, unsigned n, unsigned m, typename T>
00118     struct op_mult<U, algebra::mat<n, m, T> >
00119     {
00120       typedef algebra::mat<n, m, mln_op_mult(T, U)> ret;
00121     };
00122 
00123     template <unsigned n, unsigned o, typename T, unsigned m, typename U>
00124     struct op_mult<algebra::mat<n, o, T>, algebra::mat<o, m, U> >
00125     {
00126       typedef algebra::mat<n, m, mln_op_mult(T, U)> ret;
00127     };
00128 
00129     template <unsigned m, unsigned n, typename T, typename U>
00130     struct op_mult<algebra::mat<m, n, T>, algebra::vec<n, U> >
00131     {
00132       typedef algebra::mat<m, 1, mln_op_mult(T, U)> ret;
00133     };
00134 
00135     template <unsigned n, typename U, unsigned m, typename T>
00136     struct op_mult< algebra::vec<n, U>, algebra::mat<n, m, T> >
00137     {
00138       typedef algebra::mat<1, m, mln_op_mult(T, U)> ret;
00139     };
00140 
00141 
00142   } // end of namespace mln::trait
00143 
00144 } // end of namespace mln
00145 
00146 #endif // ! MLN_CORE_TRAIT_OP_MULT_HH

Generated on Tue Oct 4 2011 15:24:07 for Milena (Olena) by  doxygen 1.7.1