CompileFunctions.h

Go to the documentation of this file.
00001 #ifndef COMPILE_FUNCTIONS
00002 #define COMPILE_FUNCTIONS
00003 
00004 #include <stdio.h>
00005 
00006 #include <string.h>
00007 #include <string>
00008 
00019 //--------------------- Compile-Hilfsfunktionen --------------------
00020 
00021 // Vorbelegung von Operationstabellen(z.B: Additionstabellen)  für std::endliche Körper:
00022 // Auch wenn die Template-Berechnungen zur Compilezeit etwas bringen:
00023 // die Definition eines statischen const array mit BOOST erwies sich als zu schwierig,
00024 // (wegen der Syntax mussten Praeprozessorwiederholungen eingesetzt werden,
00025 // diese sind aber meistens auf 256 wiederholungen beschraekt;// siehe TemplateExperiments.h)
00026 // Daher sollten die const Definitionen fuer die Operationsstabellen mit einem Hilfsprogramm erstellt werden
00027 
00028 
00040 template <int NN>
00041 struct pow2             
00042 {
00043         enum    {value          = 2*pow2<NN - 1>::value    };
00044         enum    {valueMinusOne  = 2*pow2<NN - 1>::value -1};
00045 };
00046 
00047 
00055 template <>
00056 struct pow2<0>  
00057 {
00058 
00059         enum    {       value=1 };
00060 };
00061 
00062 
00070 template <int NUM>
00071 struct needbits 
00072 {
00073         enum    {       value           = needbits<NUM/2>::value +1             };
00074         enum    {       valueplusone    = needbits<NUM/2>::valueplusone +1      };
00075         enum    {       doubledvalue    = needbits<NUM/2>::doubledvalue +2      };
00076    
00077 };
00078 
00079 
00086 template <>
00087 struct needbits<1>
00088 { 
00089         enum    {       value =1        };
00090         enum    {       valueplusone = 2        };
00091         enum    {       doubledvalue = 2        };
00092         
00093 };
00094 
00095 template <>
00096 struct needbits<0>
00097 { 
00098         enum    {       value =1        };
00099         enum    {       valueplusone = 2        };
00100         enum    {       doubledvalue = 2        };
00101         
00102 };
00103 
00112 template <int CHAR>
00113 struct nextpow2num
00114 {
00115         enum {value = pow2<  needbits<CHAR>::value  >::value };
00116 };
00117 
00118 
00119 
00120 // ----------Ende Compile-Hilfsfunktionen --------------------
00121 
00122 
00123 #endif
Generated on Tue Nov 23 13:10:51 2010 for centerfocus by  doxygen 1.6.3