Shards_IndexList.hpp

00001 /*------------------------------------------------------------------------*/
00002 /*                  shards : Shared Discretization Tools                  */
00003 /*                Copyright (2008) Sandia Corporation                     */
00004 /*                                                                        */
00005 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00006 /*  license for use of this work by or on behalf of the U.S. Government.  */
00007 /*                                                                        */
00008 /*  This library is free software; you can redistribute it and/or modify  */
00009 /*  it under the terms of the GNU Lesser General Public License as        */
00010 /*  published by the Free Software Foundation; either version 2.1 of the  */
00011 /*  License, or (at your option) any later version.                       */
00012 /*                                                                        */
00013 /*  This library is distributed in the hope that it will be useful,       */
00014 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of        */
00015 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     */
00016 /*  Lesser General Public License for more details.                       */
00017 /*                                                                        */
00018 /*  You should have received a copy of the GNU Lesser General Public      */
00019 /*  License along with this library; if not, write to the Free Software   */
00020 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307   */
00021 /*  USA                                                                   */
00022 /*------------------------------------------------------------------------*/
00023 
00024 #ifndef Shards_IndexList_hpp
00025 #define Shards_IndexList_hpp
00026 
00027 namespace shards {
00028 
00041 template< int  I0 = -1 , int  I1 = -1 , int  I2 = -1 , int  I3 = -1 ,
00042           int  I4 = -1 , int  I5 = -1 , int  I6 = -1 , int  I7 = -1 ,
00043           int  I8 = -1 , int  I9 = -1 , int I10 = -1 , int I11 = -1 ,
00044           int I12 = -1 , int I13 = -1 , int I14 = -1 , int I15 = -1 ,
00045           int I16 = -1 , int I17 = -1 , int I18 = -1 , int I19 = -1 ,
00046           int I20 = -1 , int I21 = -1 , int I22 = -1 , int I23 = -1 ,
00047           int I24 = -1 , int I25 = -1 , int I26 = -1 , int I27 = -1 ,
00048           int I28 = -1 , int I29 = -1 , int I30 = -1 , int I31 = -1 >
00049 struct IndexList {};
00050 
00054 template< class List > struct IndexListLength {};
00055 
00059 template< class List , int J > struct IndexListAt {};
00060 
00064 template< class List , int J , bool OK = 0 <= J >
00065 struct IndexListFind ;
00066 
00070 template< class List > struct IndexListInverse {};
00071 
00072 #ifndef DOXYGEN_COMPILE
00073 
00074 //----------------------------------------------------------------------
00075 
00076 template<>
00077 struct IndexListLength< IndexList<> > { enum { value = 0 }; };
00078 
00079 template< int  I0 , int  I1 , int  I2 , int  I3 ,
00080           int  I4 , int  I5 , int  I6 , int  I7 ,
00081           int  I8 , int  I9 , int I10 , int I11 ,
00082           int I12 , int I13 , int I14 , int I15 ,
00083           int I16 , int I17 , int I18 , int I19 ,
00084           int I20 , int I21 , int I22 , int I23 ,
00085           int I24 , int I25 , int I26 , int I27 ,
00086           int I28 , int I29 , int I30 , int I31 >
00087 struct IndexListLength<
00088   IndexList<  I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 ,
00089               I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
00090              I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
00091              I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > >
00092 {
00093 private:
00094   typedef IndexList<        I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 ,
00095                       I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
00096                      I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
00097                      I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 , -1 >
00098     shift_type ;
00099 
00100 public:
00101   enum { value = 1 + IndexListLength< shift_type >::value };
00102 };
00103 
00104 //----------------------------------------------------------------------
00105 
00106 #define SHARDS_INDEX_LIST_AT_SPECIALIZATION( J , K )  \
00107   template< int  I0 , int  I1 , int  I2 , int  I3 , \
00108             int  I4 , int  I5 , int  I6 , int  I7 , \
00109             int  I8 , int  I9 , int I10 , int I11 , \
00110             int I12 , int I13 , int I14 , int I15 , \
00111             int I16 , int I17 , int I18 , int I19 , \
00112             int I20 , int I21 , int I22 , int I23 , \
00113             int I24 , int I25 , int I26 , int I27 , \
00114             int I28 , int I29 , int I30 , int I31 > \
00115 struct IndexListAt< \
00116   IndexList< I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 , \
00117              I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 , \
00118             I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \
00119             I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , J > \
00120 { enum { value = K }; };
00121 
00122 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  0 ,  I0 )
00123 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  1 ,  I1 )
00124 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  2 ,  I2 )
00125 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  3 ,  I3 )
00126 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  4 ,  I4 )
00127 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  5 ,  I5 )
00128 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  6 ,  I6 )
00129 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  7 ,  I7 )
00130 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  8 ,  I8 )
00131 SHARDS_INDEX_LIST_AT_SPECIALIZATION(  9 ,  I9 )
00132 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 10 , I10 )
00133 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 11 , I11 )
00134 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 12 , I12 )
00135 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 13 , I13 )
00136 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 14 , I14 )
00137 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 15 , I15 )
00138 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 16 , I16 )
00139 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 17 , I17 )
00140 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 18 , I18 )
00141 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 19 , I19 )
00142 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 20 , I20 )
00143 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 21 , I21 )
00144 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 22 , I22 )
00145 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 23 , I23 )
00146 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 24 , I24 )
00147 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 25 , I25 )
00148 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 26 , I26 )
00149 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 27 , I27 )
00150 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 28 , I28 )
00151 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 29 , I29 )
00152 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 30 , I30 )
00153 SHARDS_INDEX_LIST_AT_SPECIALIZATION( 31 , I31 )
00154 
00155 #undef SHARDS_INDEX_LIST_AT_SPECIALIZATION
00156 
00157 //----------------------------------------------------------------------
00158 
00159 template< class List , int J , bool OK >
00160 struct IndexListFind { enum { value = -1 }; };
00161 
00162 #define SHARDS_INDEX_LIST_FIND_SPECIALIZATION( J , K )  \
00163   template< int  I0 , int  I1 , int  I2 , int  I3 , \
00164             int  I4 , int  I5 , int  I6 , int  I7 , \
00165             int  I8 , int  I9 , int I10 , int I11 , \
00166             int I12 , int I13 , int I14 , int I15 , \
00167             int I16 , int I17 , int I18 , int I19 , \
00168             int I20 , int I21 , int I22 , int I23 , \
00169             int I24 , int I25 , int I26 , int I27 , \
00170             int I28 , int I29 , int I30 , int I31 > \
00171 struct IndexListFind< \
00172   IndexList< I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 , \
00173              I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 , \
00174             I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 , \
00175             I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > , K , true >  \
00176 { enum { value = J }; };
00177 
00178 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  0 ,  I0 )
00179 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  1 ,  I1 )
00180 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  2 ,  I2 )
00181 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  3 ,  I3 )
00182 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  4 ,  I4 )
00183 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  5 ,  I5 )
00184 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  6 ,  I6 )
00185 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  7 ,  I7 )
00186 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  8 ,  I8 )
00187 SHARDS_INDEX_LIST_FIND_SPECIALIZATION(  9 ,  I9 )
00188 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 10 , I10 )
00189 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 11 , I11 )
00190 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 12 , I12 )
00191 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 13 , I13 )
00192 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 14 , I14 )
00193 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 15 , I15 )
00194 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 16 , I16 )
00195 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 17 , I17 )
00196 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 18 , I18 )
00197 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 19 , I19 )
00198 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 20 , I20 )
00199 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 21 , I21 )
00200 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 22 , I22 )
00201 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 23 , I23 )
00202 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 24 , I24 )
00203 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 25 , I25 )
00204 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 26 , I26 )
00205 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 27 , I27 )
00206 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 28 , I28 )
00207 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 29 , I29 )
00208 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 30 , I30 )
00209 SHARDS_INDEX_LIST_FIND_SPECIALIZATION( 31 , I31 )
00210 
00211 #undef SHARDS_INDEX_LIST_FIND_SPECIALIZATION
00212 
00213 //----------------------------------------------------------------------
00214 
00215 template< int  I0 , int  I1 , int  I2 , int  I3 ,
00216           int  I4 , int  I5 , int  I6 , int  I7 ,
00217           int  I8 , int  I9 , int I10 , int I11 ,
00218           int I12 , int I13 , int I14 , int I15 ,
00219           int I16 , int I17 , int I18 , int I19 ,
00220           int I20 , int I21 , int I22 , int I23 ,
00221           int I24 , int I25 , int I26 , int I27 ,
00222           int I28 , int I29 , int I30 , int I31 >
00223 struct IndexListInverse<
00224   IndexList<  I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 ,
00225               I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
00226              I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
00227              I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > >
00228 {
00229 private:
00230   typedef IndexList<  I0 ,  I1 ,  I2 ,  I3 ,  I4 ,  I5 ,  I6 ,  I7 ,
00231                       I8 ,  I9 , I10 , I11 , I12 , I13 , I14 , I15 ,
00232                      I16 , I17 , I18 , I19 , I20 , I21 , I22 , I23 ,
00233                      I24 , I25 , I26 , I27 , I28 , I29 , I30 , I31 > list ;
00234 
00235   typedef IndexListInverse< list > SelfType ;
00236 
00237   enum { length = IndexListLength< list >::value };
00238 
00239   enum { J0  = IndexListFind< list ,  0 ,  0 < length >::value ,
00240          J1  = IndexListFind< list ,  1 ,  1 < length >::value ,
00241          J2  = IndexListFind< list ,  2 ,  2 < length >::value ,
00242          J3  = IndexListFind< list ,  3 ,  3 < length >::value ,
00243          J4  = IndexListFind< list ,  4 ,  4 < length >::value ,
00244          J5  = IndexListFind< list ,  5 ,  5 < length >::value ,
00245          J6  = IndexListFind< list ,  6 ,  6 < length >::value ,
00246          J7  = IndexListFind< list ,  7 ,  7 < length >::value ,
00247          J8  = IndexListFind< list ,  8 ,  8 < length >::value ,
00248          J9  = IndexListFind< list ,  9 ,  9 < length >::value ,
00249          J10 = IndexListFind< list , 10 , 10 < length >::value ,
00250          J11 = IndexListFind< list , 11 , 11 < length >::value ,
00251          J12 = IndexListFind< list , 12 , 12 < length >::value ,
00252          J13 = IndexListFind< list , 13 , 13 < length >::value ,
00253          J14 = IndexListFind< list , 14 , 14 < length >::value ,
00254          J15 = IndexListFind< list , 15 , 15 < length >::value ,
00255          J16 = IndexListFind< list , 16 , 16 < length >::value ,
00256          J17 = IndexListFind< list , 17 , 17 < length >::value ,
00257          J18 = IndexListFind< list , 18 , 18 < length >::value ,
00258          J19 = IndexListFind< list , 19 , 19 < length >::value ,
00259          J20 = IndexListFind< list , 20 , 20 < length >::value ,
00260          J21 = IndexListFind< list , 21 , 21 < length >::value ,
00261          J22 = IndexListFind< list , 22 , 22 < length >::value ,
00262          J23 = IndexListFind< list , 23 , 23 < length >::value ,
00263          J24 = IndexListFind< list , 24 , 24 < length >::value ,
00264          J25 = IndexListFind< list , 25 , 25 < length >::value ,
00265          J26 = IndexListFind< list , 26 , 26 < length >::value ,
00266          J27 = IndexListFind< list , 27 , 27 < length >::value ,
00267          J28 = IndexListFind< list , 28 , 28 < length >::value ,
00268          J29 = IndexListFind< list , 29 , 29 < length >::value ,
00269          J30 = IndexListFind< list , 30 , 30 < length >::value ,
00270          J31 = IndexListFind< list , 31 , 31 < length >::value };
00271 
00272 public:
00273 
00274   typedef IndexList< SelfType::J0 ,  SelfType::J1 ,
00275                      SelfType::J2 ,  SelfType::J3 , 
00276                      SelfType::J4 ,  SelfType::J5 , 
00277                      SelfType::J6 ,  SelfType::J7 , 
00278                      SelfType::J8 ,  SelfType::J9 , 
00279                      SelfType::J10 , SelfType::J11 ,
00280                      SelfType::J12 , SelfType::J13 ,
00281                      SelfType::J14 , SelfType::J15 ,
00282                      SelfType::J16 , SelfType::J17 ,
00283                      SelfType::J18 , SelfType::J19 ,
00284                      SelfType::J20 , SelfType::J21 ,
00285                      SelfType::J22 , SelfType::J23 ,
00286                      SelfType::J24 , SelfType::J25 ,
00287                      SelfType::J26 , SelfType::J27 ,
00288                      SelfType::J28 , SelfType::J29 ,
00289                      SelfType::J30 , SelfType::J31 > type ;
00290 };
00291 
00292 #endif /* DOXYGEN_COMPILE */
00293 
00296 } // namespace shards
00297 
00298 
00299 #endif // Shards_IndexList_hpp
00300 
Generated on Wed Mar 31 15:02:54 2010 for shards by  doxygen 1.6.3