• Main Page
  • Namespaces
  • Classes
  • Files
  • File List

libalgebra-demo/libalgebra/ConstLog2.h

00001 /* *************************************************************
00002 
00003 Copyright 2010 Terry Lyons, Stephen Buckley, Djalil Chafai, 
00004 Greg Gyurkó and Arend Janssen. 
00005 
00006 Distributed under the terms of the GNU General Public License, 
00007 Version 3. (See accompanying file License.txt)
00008 
00009 ************************************************************* */
00010 
00011 
00012 
00013 
00014 #pragma once
00015 #ifndef ConstLog2_h__
00016 #define ConstLog2_h__
00017 
00019 
00022 
00023 template <unsigned exp>
00024 struct ConstLog2
00025 {
00026         static  enum
00027         {
00028                 ans = ConstLog2 < exp /2 >::ans+1
00029         };
00030 };
00031 
00032 template <>
00033 struct ConstLog2<1>
00034 {
00035         static  enum
00036         {
00037                 ans = 0
00038         };
00039 };
00040 
00041 template <>
00042 struct ConstLog2<0>
00043 {
00044         static  enum
00045         {
00046                 ans = 0
00047         };
00048 };
00050 template <unsigned RANGE>
00051 struct TestConstLog2
00052 {
00053         static enum
00054         {
00055                 ans = ((RANGE >> ConstLog2<RANGE>::ans) == 1) && TestConstLog2< RANGE - 1 >::ans
00056         };
00057 };
00058 
00059 template <>
00060 struct TestConstLog2<1>
00061 {
00062         static enum
00063         {
00064                 ans = ((1 >> ConstLog2<1>::ans) == 1) && (ConstLog2<0>::ans == 0)
00065         };
00066 };
00067 
00068 
00069 #endif // ConstLog2_h__

Generated on Fri Jan 14 2011 17:50:32 for Rough Differential Equation Solver by  doxygen 1.7.1