Meta.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2011 Benoit Jacob <jacob.benoit.1@gmail.com>
00005 //
00006 // This Source Code Form is subject to the terms of the Mozilla
00007 // Public License v. 2.0. If a copy of the MPL was not distributed
00008 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00009 
00010 #ifndef EIGEN2_META_H
00011 #define EIGEN2_META_H
00012 
00013 namespace Eigen { 
00014 
00015 template<typename T>
00016 struct ei_traits : internal::traits<T>
00017 {};
00018 
00019 struct ei_meta_true {  enum { ret = 1 }; };
00020 struct ei_meta_false { enum { ret = 0 }; };
00021 
00022 template<bool Condition, typename Then, typename Else>
00023 struct ei_meta_if { typedef Then ret; };
00024 
00025 template<typename Then, typename Else>
00026 struct ei_meta_if <false, Then, Else> { typedef Else ret; };
00027 
00028 template<typename T, typename U> struct ei_is_same_type { enum { ret = 0 }; };
00029 template<typename T> struct ei_is_same_type<T,T> { enum { ret = 1 }; };
00030 
00031 template<typename T> struct ei_unref { typedef T type; };
00032 template<typename T> struct ei_unref<T&> { typedef T type; };
00033 
00034 template<typename T> struct ei_unpointer { typedef T type; };
00035 template<typename T> struct ei_unpointer<T*> { typedef T type; };
00036 template<typename T> struct ei_unpointer<T*const> { typedef T type; };
00037 
00038 template<typename T> struct ei_unconst { typedef T type; };
00039 template<typename T> struct ei_unconst<const T> { typedef T type; };
00040 template<typename T> struct ei_unconst<T const &> { typedef T & type; };
00041 template<typename T> struct ei_unconst<T const *> { typedef T * type; };
00042 
00043 template<typename T> struct ei_cleantype { typedef T type; };
00044 template<typename T> struct ei_cleantype<const T>   { typedef typename ei_cleantype<T>::type type; };
00045 template<typename T> struct ei_cleantype<const T&>  { typedef typename ei_cleantype<T>::type type; };
00046 template<typename T> struct ei_cleantype<T&>        { typedef typename ei_cleantype<T>::type type; };
00047 template<typename T> struct ei_cleantype<const T*>  { typedef typename ei_cleantype<T>::type type; };
00048 template<typename T> struct ei_cleantype<T*>        { typedef typename ei_cleantype<T>::type type; };
00049 
00053 template<int Y,
00054          int InfX = 0,
00055          int SupX = ((Y==1) ? 1 : Y/2),
00056          bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
00057                                 // use ?: instead of || just to shut up a stupid gcc 4.3 warning
00058 class ei_meta_sqrt
00059 {
00060     enum {
00061       MidX = (InfX+SupX)/2,
00062       TakeInf = MidX*MidX > Y ? 1 : 0,
00063       NewInf = int(TakeInf) ? InfX : int(MidX),
00064       NewSup = int(TakeInf) ? int(MidX) : SupX
00065     };
00066   public:
00067     enum { ret = ei_meta_sqrt<Y,NewInf,NewSup>::ret };
00068 };
00069 
00070 template<int Y, int InfX, int SupX>
00071 class ei_meta_sqrt<Y, InfX, SupX, true> { public:  enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
00072 
00073 } // end namespace Eigen
00074 
00075 #endif // EIGEN2_META_H


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Sat Jun 8 2019 19:38:12